1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237
|
//////////////////////////////////////////////////////////////////////////
//
// pgAdmin III - PostgreSQL Tools
//
// Copyright (C) 2002 - 2014, The pgAdmin Development Team
// This software is released under the PostgreSQL Licence
//
// factory.h - Object classes factory
//
//////////////////////////////////////////////////////////////////////////
#ifndef FACTORY_H
#define FACTORY_H
// wxWindows headers
#include <wx/wx.h>
#include "frm/menu.h"
#ifdef WIN32
#ifndef __GNUC__
#pragma warning(disable:4183)
#endif
#endif
class pgObject;
class frmMain;
class dlgProperty;
class ctlTree;
class pgCollection;
class pgSchema;
class pgaCollectionFactory;
class pgaFactory
{
public:
virtual dlgProperty *CreateDialog(frmMain *frame, pgObject *node, pgObject *parent) = 0;
virtual pgObject *CreateObjects(pgCollection *obj, ctlTree *browser, const wxString &restr = wxEmptyString)
{
return 0;
}
virtual pgCollection *CreateCollection(pgObject *obj) = 0;
virtual bool IsCollection()
{
return false;
}
virtual void AppendMenu(wxMenu *menu);
bool IsCollectionFor(pgaFactory &f)
{
return f.GetCollectionFactory() == (pgaCollectionFactory *)this;
}
bool WantSmallIcon();
static pgaFactory *GetFactory(int id);
static pgaFactory *GetFactory(const wxString &name);
static pgaFactory *GetFactoryByMetaType(const int type);
int GetId()
{
return id;
}
int GetMetaType();
wxChar *GetTypeName()
{
return typeName;
}
wxChar *GetNewString()
{
return newString;
}
wxChar *GetNewLongString()
{
return newLongString;
}
pgaCollectionFactory *GetCollectionFactory()
{
return collectionFactory;
}
int GetIconId();
static void RegisterMenu(wxWindow *w, wxObjectEventFunction func);
const wxImage &GetImage() const
{
return image;
}
static void RealizeImages();
protected:
pgaFactory(const wxChar *tn = 0, const wxChar *ns = 0, const wxChar *nls = 0, wxImage *img = 0, wxImage *imgSm = 0);
int addIcon(wxImage *img);
int id, metaType;
wxChar *typeName;
wxChar *newString, *newLongString;
int iconId, smallIconId;
wxImage image;
pgaCollectionFactory *collectionFactory;
friend class pgaCollectionFactory;
};
class pgaCollectionFactory : public pgaFactory
{
public:
pgaCollectionFactory(pgaFactory *f, const wxChar *tn = 0, wxImage *img = 0, wxImage *imgSm = 0);
wxChar *GetItemTypeName()
{
return itemFactory->GetTypeName();
}
pgaFactory *GetItemFactory()
{
return itemFactory;
}
pgObject *CreateObjects(pgCollection *obj, ctlTree *browser, const wxString &restr = wxEmptyString);
protected:
virtual bool IsCollection()
{
return true;
}
dlgProperty *CreateDialog(frmMain *frame, pgObject *node, pgObject *parent);
virtual pgCollection *CreateCollection(pgObject *obj)
{
return 0;
};
pgaFactory *itemFactory;
};
class actionFactory;
class menuFactory;
class menuFactoryList : public wxArrayPtrVoid
{
public:
~menuFactoryList();
void CheckMenu(pgObject *obj, wxMenuBar *menubar, ctlMenuToolbar *toolbar);
void AppendEnabledMenus(wxMenuBar *menuBar, wxMenu *treeContextMenu);
actionFactory *GetFactory(int id, bool actionOnly = true);
void RegisterMenu(wxWindow *w, wxObjectEventFunction func);
void EnableSubmenu(wxMenuBar *menubar, int id);
private:
void Add(menuFactory *f)
{
wxArrayPtrVoid::Add(f);
}
friend class menuFactory;
};
class menuFactory
{
public:
virtual ~menuFactory();
virtual bool IsAction()
{
return false;
}
virtual bool IsSubmenu()
{
return false;
}
protected:
menuFactory(menuFactoryList *list);
};
class actionFactory : public menuFactory
{
public:
virtual bool IsAction()
{
return true;
}
virtual wxWindow *StartDialog(frmMain *form, pgObject *obj) = 0;
virtual bool CheckEnable(pgObject *obj)
{
return true;
}
virtual bool CheckChecked(pgObject *obj)
{
return true;
}
bool GetContext()
{
return context;
}
int GetId()
{
return id;
}
protected:
actionFactory(menuFactoryList *list);
int id;
bool context;
friend class menuFactoryList;
};
class contextActionFactory : public actionFactory
{
protected:
contextActionFactory(menuFactoryList *list) : actionFactory(list)
{
context = true;
}
};
class submenuFactory : public contextActionFactory
{
public:
submenuFactory(menuFactoryList *list) : contextActionFactory(list) {};
wxWindow *StartDialog(frmMain *form, pgObject *obj)
{
return 0;
};
virtual bool IsSubmenu()
{
return true;
}
};
class separatorFactory : public menuFactory
{
public:
separatorFactory(menuFactoryList *list) : menuFactory(list) {}
};
#endif
|