My favorites | Sign in
Project Home Downloads Source
Checkout   Browse   Changes    
 
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
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
#ifndef _XMLMenuEditor_h_
#define _XMLMenuEditor_h_

#include <CtrlLib/CtrlLib.h>

#include "XMLMenuInterface.h"

NAMESPACE_UPP

#define LAYOUTFILE <XMLMenu/XMLMenuEditor.lay>
#include <CtrlCore/lay.h>

////////////////////////////////////////////////////////////////////////////////
// bar editor class -- allow editing of a single menu/toolbar
class XMLBarEditor : public ParentCtrl
{
friend class XMLBarsEditor;
private:
// toolbar being edited
XMLToolBar *bar;

// current icon, if any
Image curIcon;

// size of item editor
Size itemSize;

// item editor pane
WithItemEditorLayout<ParentCtrl> itemPane;

// tree ctrl containing bar structure
TreeCtrl barTree;

// vertical splitter dividing tree from item editor
Splitter vertSplitter;

// layouts control
void Layout(void);

// builds bar tree
void buildTree(int root, XMLToolBar const *bar);

// drag and drop support

// dragging element
void dragCb(void);

// dropping between elements (inserts between)
void dropInsertCb(int parent, int ii, PasteClip& d);

// item selection callback
void itemSelCb(void);

// fields modified callback
void fieldsModCb(void);

// image selection callback
void imageSelCb(void);

// refresh current bar
void RefreshBar(int treeRoot = 0, XMLToolBar *subBar = NULL);

protected:

public:
typedef XMLBarEditor CLASSNAME;

// constructor
XMLBarEditor();

// gets minimum size of bar editor
Size GetMinSize(void);

// sets bar being edited
void SetBar(XMLToolBar *bar);

// sets command id into currently selected item
void SetCommandId(String const &cmdId) { itemPane.cmdId = cmdId; fieldsModCb(); }

// barTree context menu
void treeContextCb(Bar &bar);
void treeContextAddCb(int mode);
void treeContextRemoveCb(void);
};

////////////////////////////////////////////////////////////////////////////////
class XMLBarAdd : public WithBarAddLayout<TopWindow>
{
private :
XMLToolBars &bars;

protected :
void okCb(void)
{
if(~barName == "")
{
Exclamation(t_("Invalid empty bar name"));
return;
}
if(bars.Find(barName) >= 0)
{
Exclamation(Format(t_("Bar '%s' already present"), ~barName));
return;
}
Break(IDOK);
}
void cancelCb(void) { Break(IDCANCEL);}

public :
typedef XMLBarAdd CLASSNAME;

XMLBarAdd(XMLToolBars &t) : bars(t)
{
CtrlLayout(*this);
okBtn.Ok() << THISBACK(okCb);
cancelBtn.Cancel() << THISBACK(cancelCb);
}
};

////////////////////////////////////////////////////////////////////////////////
class XMLBarsEditor : public ParentCtrl
{
private:

// local copy of toolbars being edited
XMLToolBars toolBars;

// MenuBars and ToolBars lists
WithBarListLayout<ParentCtrl> barListPane;

// horizontal splitter
Splitter horzSplitter;

// the bar editor
XMLBarEditor barEditor;

// size of selector
Size selectorSize;

// bar selection callback
void barSelCb(void);

// bar list context menu
void barContextCb(Bar &bar);
void barContextAddCb(void);
void barContextRemoveCb(void);

protected:

public:

typedef XMLBarsEditor CLASSNAME;

// constructor
XMLBarsEditor();

// gets minimum size of bar editor
Size GetMinSize(void);

// adjust layout on win changes
void Layout(void);

// set title
void SetTitle(const char *s);

// sets the local copy of toolbars
void SetToolBars(XMLToolBars const &tb);

// gets the local copy of toolbars
XMLToolBars &GetToolBars(void);

// query if a command is in use by a toolbar
bool IsUsingCommand(String const &cmdId) const;

// sets command id into currently selected item of currently selected toolbar
void SetCommandId(String const &cmdId) { barEditor.SetCommandId(cmdId); }
};

////////////////////////////////////////////////////////////////////////////////
class XMLCmdEdit : public WithCmdEditLayout<TopWindow>
{
private :
XMLCommands &cmds;
bool adding;

protected :
void okCb(void)
{
if(~cmdId == "")
{
Exclamation(t_("Invalid empty command Id"));
return;
}
if(adding && cmds.Has(cmdId))
{
Exclamation(Format(t_("Command '%s' already present"), ~cmdId));
return;
}
Break(IDOK);
}
void cancelCb(void) { Break(IDCANCEL);}

public :
typedef XMLCmdEdit CLASSNAME;

XMLCmdEdit(XMLCommands &c, bool add) : cmds(c)
{
CtrlLayout(*this);
okBtn.Ok() << THISBACK(okCb);
cancelBtn.Cancel() << THISBACK(cancelCb);
adding = add;
cmdId.SetEditable(adding);
}
};

////////////////////////////////////////////////////////////////////////////////
class XMLMenuEditor : public WithMenuEditorLayout<TopWindow>
{
private :
// interface to access menu system data
XMLMenuInterface *iFace;

// left pane
WithCmdBoxLayout<ParentCtrl> cmdPane;

// the menus and bars editors
XMLBarsEditor menusEditor, barsEditor;

// local copy of commands
XMLCommands commands;

// right pane - contains tab ctrl
TabCtrl tabCtrl;

// vertical size of button area
int buttonVertSize;

// original sizes of cmd area and item editor area
Size cmdSize, editorSize, tabCtrlSize;

// minimum window width and height
int minWidth, minHeight;

// fills (or updates) command list
void FillCmdList(void);

// check wether a command is used in a menu
bool cmdInUse(String const &cmdId) const;

// commandlist context menu
void cmdContextCb(Bar &bar);
void cmdContextAddCb(void);
void cmdContextEditCb(void);
void cmdContextRemoveCb(void);

// commandlist double-click handler
void cmdDblClickCb(void);

protected :

void cancelCb(void);
void okCb(void);

// adjust layout on win changes
void Layout(void);

public :

typedef XMLMenuEditor CLASSNAME;

XMLMenuEditor(XMLMenuInterface *iFace);

~XMLMenuEditor();

};

END_UPP_NAMESPACE

#endif

Change log

r4242 by micio on Dec 4, 2011   Diff
Bazaar/XMLMenu : allow custom command
string on custom commands
Fixed a couple of bugs in editor
Go to: 
Project members, sign in to write a code review

Older revisions

r4070 by micio on Oct 20, 2011   Diff
sandbox/XMLMenu moved to bazaar
r4050 by micio on Oct 18, 2011   Diff
sandbox/XMLMenu : completed menu
editor
r4047 by micio on Oct 18, 2011   Diff
sandbox/XMLMenu : added context menu
for bar lists - still bug on deleting
last bar
All revisions of this file

File info

Size: 6180 bytes, 279 lines
Powered by Google Project Hosting