1 //////////////////////////////////////////////////////////////////////////
2 //
3 // pgAdmin III - PostgreSQL Tools
4 //
5 // Copyright (C) 2002 - 2016, The pgAdmin Development Team
6 // This software is released under the PostgreSQL Licence
7 //
8 // ddColumnKindIcon.h - Figure container for kind of Column Images
9 //
10 //////////////////////////////////////////////////////////////////////////
11 
12 #ifndef DDCOLUMNKINDICON_H
13 #define DDCOLUMNKINDICON_H
14 
15 #include "hotdraw/figures/hdAbstractMenuFigure.h"
16 
17 class ddColumnFigure;
18 
19 enum ddColumnType
20 {
21 	pk = 321,
22 	uk,
23 	none,
24 	noaction  //no action kind means column type don't have right now a useful value
25 };
26 
27 enum
28 {
29 	MNU_DDCTPKEY = 321,
30 	MNU_DDCTUKEY
31 };
32 
33 class ddColumnKindIcon : public hdAbstractMenuFigure
34 {
35 public:
36 	ddColumnKindIcon(ddColumnFigure *owner);
37 	~ddColumnKindIcon();
38 	virtual void OnGenericPopupClick(wxCommandEvent &event, hdDrawingView *view = NULL);
39 	virtual void createMenu(wxMenu &mnu);
40 	virtual void basicDraw(wxBufferedDC &context, hdDrawingView *view);
41 	virtual void basicDrawSelected(wxBufferedDC &context, hdDrawingView *view);
42 	virtual void toggleColumnKind(ddColumnType type, hdDrawingView *view = NULL, bool interaction = true);
43 	virtual int getWidth();
44 	virtual int getHeight();
45 	bool isNone();
46 	bool isPrimaryKey();
47 	bool isForeignKey();
48 	void disableUniqueKey();
49 	void disablePrimaryKey();
50 	void enablePrimaryKey();
51 	ddColumnFigure *getOwnerColumn();
52 	bool isUniqueKey();
53 	bool isUniqueKey(int uniqueIndex);
54 	int getUniqueConstraintIndex();
55 	void setUniqueConstraintIndex(int i);
56 	void setRightIconForColumn();
57 	void setPrimaryKey(bool value);
58 	void setUkIndex(int ukIdx);
59 protected:
60 
61 private:
62 	ddColumnFigure *ownerColumn;
63 	wxBitmap *iconToDraw;
64 	wxBitmap icon;
65 	int ukIndex;
66 	bool isPk;
67 
68 	//multiple Uk management at table
69 	void syncUkIndexes();
70 	bool uniqueConstraintManager(bool ukCol, hdDrawingView *view = NULL, bool interaction = true);
71 };
72 #endif
73