~ubuntu-branches/debian/sid/pgadmin3/sid

« back to all changes in this revision

Viewing changes to pgadmin/include/utils/factory.h

  • Committer: Bazaar Package Importer
  • Author(s): Gerfried Fuchs
  • Date: 2009-07-30 12:27:16 UTC
  • mfrom: (1.1.6 upstream)
  • Revision ID: james.westby@ubuntu.com-20090730122716-fddbh42on721bbs2
Tags: 1.10.0-1
* New upstream release.
* Adjusted watch file to match release candidates.
* Updated to Standards-Version 3.8.2:
  - Moved to Section: database.
  - Add DEB_BUILD_OPTIONS support for parallel building.
  - Move from findstring to filter suggestion for DEB_BUILD_OPTIONS parsing.
* pgagent got split into its own separate source package by upstream.
* Exclude Docs.vcproj from installation.
* Move doc-base.enus from pgadmin3 to pgadmin3-data package, the files are
  in there too.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
//////////////////////////////////////////////////////////////////////////
2
 
//
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
7
 
//
8
 
// factory.h - Object classes factory
9
 
//
10
 
//////////////////////////////////////////////////////////////////////////
11
 
 
12
 
#ifndef FACTORY_H
13
 
#define FACTORY_H
14
 
 
15
 
// wxWindows headers
16
 
#include <wx/wx.h>
17
 
 
18
 
#include "frm/menu.h"
19
 
 
20
 
#ifdef WIN32
21
 
#ifndef __GNUC__
22
 
#pragma warning(disable:4183)
23
 
#endif
24
 
#endif
25
 
 
26
 
class pgObject;
27
 
class frmMain;
28
 
class dlgProperty;
29
 
class ctlTree;
30
 
class pgCollection;
31
 
class pgSchema;
32
 
class pgaCollectionFactory;
33
 
 
34
 
 
35
 
class pgaFactory
36
 
{
37
 
public:
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; }
44
 
    bool WantSmallIcon();
45
 
 
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; }
50
 
    int GetMetaType();
51
 
    wxChar *GetTypeName() { return typeName; }
52
 
    wxChar *GetNewString() { return newString; }
53
 
    wxChar *GetNewLongString() { return newLongString; }
54
 
    pgaCollectionFactory *GetCollectionFactory() { return collectionFactory; }
55
 
 
56
 
    int GetIconId();
57
 
    static void RegisterMenu(wxWindow *w, wxObjectEventFunction func);
58
 
    static void RealizeImages();
59
 
    char **GetImage() const { return image; }
60
 
 
61
 
protected:
62
 
    pgaFactory(const wxChar *tn=0, const wxChar *ns=0, const wxChar *nls=0, char **img=0, char **smImg=0);
63
 
 
64
 
    int addIcon(char **img);
65
 
 
66
 
    int id, metaType;
67
 
    wxChar *typeName;
68
 
    wxChar *newString, *newLongString;
69
 
    int iconId, smallIconId;
70
 
    char **image;
71
 
 
72
 
    pgaCollectionFactory *collectionFactory;
73
 
    friend class pgaCollectionFactory;
74
 
};
75
 
 
76
 
 
77
 
class pgaCollectionFactory : public pgaFactory
78
 
{
79
 
public:
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);
84
 
    
85
 
protected:
86
 
    virtual bool IsCollection() { return true; }
87
 
    dlgProperty *CreateDialog(frmMain *frame, pgObject *node, pgObject *parent);
88
 
    virtual pgCollection *CreateCollection(pgObject *obj) { return 0; };
89
 
 
90
 
    pgaFactory *itemFactory;
91
 
};
92
 
 
93
 
 
94
 
class actionFactory;
95
 
class menuFactory;
96
 
class menuFactoryList : public wxArrayPtrVoid
97
 
{
98
 
public:
99
 
    ~menuFactoryList();
100
 
 
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);
106
 
 
107
 
private:
108
 
    void Add(menuFactory *f) { wxArrayPtrVoid::Add(f); }
109
 
    friend class menuFactory;
110
 
};
111
 
 
112
 
 
113
 
class menuFactory
114
 
{
115
 
public:
116
 
    virtual bool IsAction() { return false; }
117
 
    virtual bool IsSubmenu() { return false; }
118
 
 
119
 
protected:
120
 
    menuFactory(menuFactoryList *list);
121
 
};
122
 
 
123
 
 
124
 
class actionFactory : public menuFactory
125
 
{
126
 
public:
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; }
133
 
 
134
 
protected:
135
 
    actionFactory(menuFactoryList *list);
136
 
 
137
 
    int id;
138
 
    bool context;
139
 
 
140
 
    friend class menuFactoryList;
141
 
};
142
 
 
143
 
 
144
 
class contextActionFactory : public actionFactory
145
 
{
146
 
protected:
147
 
    contextActionFactory(menuFactoryList *list) : actionFactory(list) { context=true; }
148
 
};
149
 
 
150
 
class submenuFactory : public contextActionFactory
151
 
{
152
 
public:
153
 
    submenuFactory(menuFactoryList *list) : contextActionFactory(list) {};
154
 
    wxWindow *StartDialog(frmMain *form, pgObject *obj) { return 0; };
155
 
    virtual bool IsSubmenu() { return true; }
156
 
};
157
 
 
158
 
class separatorFactory : public menuFactory
159
 
{
160
 
public:
161
 
    separatorFactory(menuFactoryList *list) : menuFactory(list) {}
162
 
};
163
 
#endif
 
1
//////////////////////////////////////////////////////////////////////////
 
2
//
 
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
 
7
//
 
8
// factory.h - Object classes factory
 
9
//
 
10
//////////////////////////////////////////////////////////////////////////
 
11
 
 
12
#ifndef FACTORY_H
 
13
#define FACTORY_H
 
14
 
 
15
// wxWindows headers
 
16
#include <wx/wx.h>
 
17
 
 
18
#include "frm/menu.h"
 
19
 
 
20
#ifdef WIN32
 
21
#ifndef __GNUC__
 
22
#pragma warning(disable:4183)
 
23
#endif
 
24
#endif
 
25
 
 
26
class pgObject;
 
27
class frmMain;
 
28
class dlgProperty;
 
29
class ctlTree;
 
30
class pgCollection;
 
31
class pgSchema;
 
32
class pgaCollectionFactory;
 
33
 
 
34
 
 
35
class pgaFactory
 
36
{
 
37
public:
 
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; }
 
44
    bool WantSmallIcon();
 
45
 
 
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; }
 
50
    int GetMetaType();
 
51
    wxChar *GetTypeName() { return typeName; }
 
52
    wxChar *GetNewString() { return newString; }
 
53
    wxChar *GetNewLongString() { return newLongString; }
 
54
    pgaCollectionFactory *GetCollectionFactory() { return collectionFactory; }
 
55
 
 
56
    int GetIconId();
 
57
    static void RegisterMenu(wxWindow *w, wxObjectEventFunction func);
 
58
    static void RealizeImages();
 
59
    const char **GetImage() const { return image; }
 
60
 
 
61
protected:
 
62
    pgaFactory(const wxChar *tn=0, const wxChar *ns=0, const wxChar *nls=0, const char **img=0, const char **smImg=0);
 
63
 
 
64
    int addIcon(const char **img);
 
65
 
 
66
    int id, metaType;
 
67
    wxChar *typeName;
 
68
    wxChar *newString, *newLongString;
 
69
    int iconId, smallIconId;
 
70
    const char **image;
 
71
 
 
72
    pgaCollectionFactory *collectionFactory;
 
73
    friend class pgaCollectionFactory;
 
74
};
 
75
 
 
76
 
 
77
class pgaCollectionFactory : public pgaFactory
 
78
{
 
79
public:
 
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);
 
84
    
 
85
protected:
 
86
    virtual bool IsCollection() { return true; }
 
87
    dlgProperty *CreateDialog(frmMain *frame, pgObject *node, pgObject *parent);
 
88
    virtual pgCollection *CreateCollection(pgObject *obj) { return 0; };
 
89
 
 
90
    pgaFactory *itemFactory;
 
91
};
 
92
 
 
93
 
 
94
class actionFactory;
 
95
class menuFactory;
 
96
class menuFactoryList : public wxArrayPtrVoid
 
97
{
 
98
public:
 
99
    ~menuFactoryList();
 
100
 
 
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);
 
106
 
 
107
private:
 
108
    void Add(menuFactory *f) { wxArrayPtrVoid::Add(f); }
 
109
    friend class menuFactory;
 
110
};
 
111
 
 
112
 
 
113
class menuFactory
 
114
{
 
115
public:
 
116
    virtual bool IsAction() { return false; }
 
117
    virtual bool IsSubmenu() { return false; }
 
118
 
 
119
protected:
 
120
    menuFactory(menuFactoryList *list);
 
121
};
 
122
 
 
123
 
 
124
class actionFactory : public menuFactory
 
125
{
 
126
public:
 
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; }
 
133
 
 
134
protected:
 
135
    actionFactory(menuFactoryList *list);
 
136
 
 
137
    int id;
 
138
    bool context;
 
139
 
 
140
    friend class menuFactoryList;
 
141
};
 
142
 
 
143
 
 
144
class contextActionFactory : public actionFactory
 
145
{
 
146
protected:
 
147
    contextActionFactory(menuFactoryList *list) : actionFactory(list) { context=true; }
 
148
};
 
149
 
 
150
class submenuFactory : public contextActionFactory
 
151
{
 
152
public:
 
153
    submenuFactory(menuFactoryList *list) : contextActionFactory(list) {};
 
154
    wxWindow *StartDialog(frmMain *form, pgObject *obj) { return 0; };
 
155
    virtual bool IsSubmenu() { return true; }
 
156
};
 
157
 
 
158
class separatorFactory : public menuFactory
 
159
{
 
160
public:
 
161
    separatorFactory(menuFactoryList *list) : menuFactory(list) {}
 
162
};
 
163
#endif