1
//////////////////////////////////////////////////////////////////////////
3
// pgAdmin III - PostgreSQL Tools
4
// RCS-ID: $Id: factory.h 6930 2008-01-02 00:10:01Z dpage $
5
// Copyright (C) 2002 - 2008, The pgAdmin Development Team
6
// This software is released under the Artistic Licence
8
// factory.h - Object classes factory
10
//////////////////////////////////////////////////////////////////////////
22
#pragma warning(disable:4183)
32
class pgaCollectionFactory;
38
virtual dlgProperty *CreateDialog(frmMain *frame, pgObject *node, pgObject *parent)=0;
39
virtual pgObject *CreateObjects(pgCollection *obj, ctlTree *browser, const wxString &restr=wxEmptyString) { return 0; }
40
virtual pgCollection *CreateCollection(pgObject *obj) =0;
41
virtual bool IsCollection() { return false; }
42
virtual void AppendMenu(wxMenu *menu);
43
bool IsCollectionFor(pgaFactory &f) { return f.GetCollectionFactory() == (pgaCollectionFactory*)this; }
46
static pgaFactory *GetFactory(int id);
47
static pgaFactory *GetFactory(const wxString &name);
48
static pgaFactory *GetFactoryByMetaType(const int type);
49
int GetId() { return id; }
51
wxChar *GetTypeName() { return typeName; }
52
wxChar *GetNewString() { return newString; }
53
wxChar *GetNewLongString() { return newLongString; }
54
pgaCollectionFactory *GetCollectionFactory() { return collectionFactory; }
57
static void RegisterMenu(wxWindow *w, wxObjectEventFunction func);
58
static void RealizeImages();
59
char **GetImage() const { return image; }
62
pgaFactory(const wxChar *tn=0, const wxChar *ns=0, const wxChar *nls=0, char **img=0, char **smImg=0);
64
int addIcon(char **img);
68
wxChar *newString, *newLongString;
69
int iconId, smallIconId;
72
pgaCollectionFactory *collectionFactory;
73
friend class pgaCollectionFactory;
77
class pgaCollectionFactory : public pgaFactory
80
pgaCollectionFactory(pgaFactory *f, wxChar *tn=0, char **img=0, char **imgSm=0);
81
wxChar *GetItemTypeName() { return itemFactory->GetTypeName(); }
82
pgaFactory *GetItemFactory() { return itemFactory; }
83
pgObject *CreateObjects(pgCollection *obj, ctlTree *browser, const wxString &restr=wxEmptyString);
86
virtual bool IsCollection() { return true; }
87
dlgProperty *CreateDialog(frmMain *frame, pgObject *node, pgObject *parent);
88
virtual pgCollection *CreateCollection(pgObject *obj) { return 0; };
90
pgaFactory *itemFactory;
96
class menuFactoryList : public wxArrayPtrVoid
101
void CheckMenu(pgObject *obj, wxMenuBar *menubar, wxToolBar *toolbar);
102
void AppendEnabledMenus(wxMenuBar *menuBar, wxMenu *treeContextMenu);
103
actionFactory *GetFactory(int id, bool actionOnly=true);
104
void RegisterMenu(wxWindow *w, wxObjectEventFunction func);
105
void EnableSubmenu(wxMenuBar *menubar, int id);
108
void Add(menuFactory *f) { wxArrayPtrVoid::Add(f); }
109
friend class menuFactory;
116
virtual bool IsAction() { return false; }
117
virtual bool IsSubmenu() { return false; }
120
menuFactory(menuFactoryList *list);
124
class actionFactory : public menuFactory
127
virtual bool IsAction() { return true; }
128
virtual wxWindow *StartDialog(frmMain *form, pgObject *obj)=0;
129
virtual bool CheckEnable(pgObject *obj) { return true; }
130
virtual bool CheckChecked(pgObject *obj) { return true; }
131
bool GetContext() { return context; }
132
int GetId() { return id; }
135
actionFactory(menuFactoryList *list);
140
friend class menuFactoryList;
144
class contextActionFactory : public actionFactory
147
contextActionFactory(menuFactoryList *list) : actionFactory(list) { context=true; }
150
class submenuFactory : public contextActionFactory
153
submenuFactory(menuFactoryList *list) : contextActionFactory(list) {};
154
wxWindow *StartDialog(frmMain *form, pgObject *obj) { return 0; };
155
virtual bool IsSubmenu() { return true; }
158
class separatorFactory : public menuFactory
161
separatorFactory(menuFactoryList *list) : menuFactory(list) {}
1
//////////////////////////////////////////////////////////////////////////
3
// pgAdmin III - PostgreSQL Tools
4
// RCS-ID: $Id: factory.h 7758 2009-03-26 20:49:59Z dpage $
5
// Copyright (C) 2002 - 2009, The pgAdmin Development Team
6
// This software is released under the BSD Licence
8
// factory.h - Object classes factory
10
//////////////////////////////////////////////////////////////////////////
22
#pragma warning(disable:4183)
32
class pgaCollectionFactory;
38
virtual dlgProperty *CreateDialog(frmMain *frame, pgObject *node, pgObject *parent)=0;
39
virtual pgObject *CreateObjects(pgCollection *obj, ctlTree *browser, const wxString &restr=wxEmptyString) { return 0; }
40
virtual pgCollection *CreateCollection(pgObject *obj) =0;
41
virtual bool IsCollection() { return false; }
42
virtual void AppendMenu(wxMenu *menu);
43
bool IsCollectionFor(pgaFactory &f) { return f.GetCollectionFactory() == (pgaCollectionFactory*)this; }
46
static pgaFactory *GetFactory(int id);
47
static pgaFactory *GetFactory(const wxString &name);
48
static pgaFactory *GetFactoryByMetaType(const int type);
49
int GetId() { return id; }
51
wxChar *GetTypeName() { return typeName; }
52
wxChar *GetNewString() { return newString; }
53
wxChar *GetNewLongString() { return newLongString; }
54
pgaCollectionFactory *GetCollectionFactory() { return collectionFactory; }
57
static void RegisterMenu(wxWindow *w, wxObjectEventFunction func);
58
static void RealizeImages();
59
const char **GetImage() const { return image; }
62
pgaFactory(const wxChar *tn=0, const wxChar *ns=0, const wxChar *nls=0, const char **img=0, const char **smImg=0);
64
int addIcon(const char **img);
68
wxChar *newString, *newLongString;
69
int iconId, smallIconId;
72
pgaCollectionFactory *collectionFactory;
73
friend class pgaCollectionFactory;
77
class pgaCollectionFactory : public pgaFactory
80
pgaCollectionFactory(pgaFactory *f, const wxChar *tn=0, const char **img=0, const char **imgSm=0);
81
wxChar *GetItemTypeName() { return itemFactory->GetTypeName(); }
82
pgaFactory *GetItemFactory() { return itemFactory; }
83
pgObject *CreateObjects(pgCollection *obj, ctlTree *browser, const wxString &restr=wxEmptyString);
86
virtual bool IsCollection() { return true; }
87
dlgProperty *CreateDialog(frmMain *frame, pgObject *node, pgObject *parent);
88
virtual pgCollection *CreateCollection(pgObject *obj) { return 0; };
90
pgaFactory *itemFactory;
96
class menuFactoryList : public wxArrayPtrVoid
101
void CheckMenu(pgObject *obj, wxMenuBar *menubar, ctlMenuToolbar *toolbar);
102
void AppendEnabledMenus(wxMenuBar *menuBar, wxMenu *treeContextMenu);
103
actionFactory *GetFactory(int id, bool actionOnly=true);
104
void RegisterMenu(wxWindow *w, wxObjectEventFunction func);
105
void EnableSubmenu(wxMenuBar *menubar, int id);
108
void Add(menuFactory *f) { wxArrayPtrVoid::Add(f); }
109
friend class menuFactory;
116
virtual bool IsAction() { return false; }
117
virtual bool IsSubmenu() { return false; }
120
menuFactory(menuFactoryList *list);
124
class actionFactory : public menuFactory
127
virtual bool IsAction() { return true; }
128
virtual wxWindow *StartDialog(frmMain *form, pgObject *obj)=0;
129
virtual bool CheckEnable(pgObject *obj) { return true; }
130
virtual bool CheckChecked(pgObject *obj) { return true; }
131
bool GetContext() { return context; }
132
int GetId() { return id; }
135
actionFactory(menuFactoryList *list);
140
friend class menuFactoryList;
144
class contextActionFactory : public actionFactory
147
contextActionFactory(menuFactoryList *list) : actionFactory(list) { context=true; }
150
class submenuFactory : public contextActionFactory
153
submenuFactory(menuFactoryList *list) : contextActionFactory(list) {};
154
wxWindow *StartDialog(frmMain *form, pgObject *obj) { return 0; };
155
virtual bool IsSubmenu() { return true; }
158
class separatorFactory : public menuFactory
161
separatorFactory(menuFactoryList *list) : menuFactory(list) {}