This repository has been archived by the owner on Oct 6, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ui_actions.h
436 lines (334 loc) · 14.1 KB
/
ui_actions.h
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
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
/*
Konnekt UI
Nag³ówek ui_actions.cpp
*/
#include "include\Richhtml.h"
void HTMLInfoStyleCB(const CStdString & token , const CStdString & styleClass , cRichEditFormat::cSetStyle & ss);
UIEXTERN ToolTipX tooltip;
class cUIAction {
public:
int type; // typ przypisanej kontrolki
unsigned int index;
unsigned int parent; // identyfikator rodzica
unsigned int id; // identyfikator
unsigned int cnt;
class cUIGroup * pparent; // wskaznik do rodzica
string txt; // text
// string tip; // tip
string params; // dodatkowe parametry...
int status; // flagi statusu
int exstyle; // dodatkowe flagi
void * handle; // uchwyt
int owner; // identyfikator wtyczki , ktora dodala akcje
int userParam; // parametr uzytkownika
int p1,p2; // p1 - parametr typu grupy (np. konfiguracji)
// w menu - ikonka , w cfg - kolumna do automatycznego zapisywania
// p2 - parametr kontrolki
short w,h;
#ifdef __DEBUG
HTREEITEM dbg;
#endif
class cUIGroup * getRoot();
class cUIGroup & getGroup();
sUIActionNotify notify(unsigned int code , int notify1,int notify2);
int call(unsigned int code , int notify1 ,int notify2,int cnt=AC_CURRENT);
int call(sUIActionNotify_base * an);
virtual void getInfo(sUIActionInfo * ai);
virtual void setInfo(sUIActionInfo & ai, bool update=true);
void setType(int t) {type&=~ACT_MASK; type|=t & ACT_MASK;}
int getType() {return type & ACT_MASK;}
inline int statusType() {return status & ACTM_TYPE;}
virtual bool setCnt(unsigned int _cnt , bool recursive=false);
sUIAction act() {return sUIAction(parent , id , cnt);}
sUIACTION act(int _cnt) {return sUIAction(parent , id , _cnt);}
ToolTipX::iTip * getTipObject(bool useText=false);
bool hasTipObject(bool useText=false);
CStdString getParam(const string & name) {return GetActParam(this->params, name);}
void setParam(const string & name, const string & value) {this->params = SetActParam(this->params, name, value);}
bool paramExists(const string & name) {return ActParamExists(this->params, name);}
void addParams(const string & add);
cUIAction();
virtual ~cUIAction() {};
};
class cUIAction_cfg: public cUIAction {
public:
short x,y;
cUIAction_cfg() {x=y=0;}
virtual void getInfo(sUIActionInfo * ai);
virtual void setInfo(sUIActionInfo & ai, bool update=true);
void setComboItems(const char * txt);
void setComboValue(const char * txt);
void getComboValue(char * txt , size_t size);
void setRadio(const char * txt, bool update=false);
void setRadioValue(const char * txt);
void getRadioValue(char * txt , size_t size);
void setSlider(const char * txt, bool update=false);
void setSliderValue(const char * txt);
void getSliderValue(char * txt , size_t size);
void setSpinner(const char * txt, bool update=false);
void setButton(const char * txt, bool update=false);
void setTimeValue(const char * txt);
void getTimeValue(char * txt , size_t size);
void setImage(const char * txt, bool update=false);
};
class cUIGroup : public cUIAction {
public:
int count;
typedef deque <cUIAction*> tAct;
tAct Act;
typedef deque <cUIAction*>::iterator t_Act_it;
typedef t_Act_it Act_it_t ;
cUIGroup ():cUIAction() {count=0;handle=ghandle=0;owner=0;}
~cUIGroup();
cUIAction & operator [](int pos);
cUIAction & operator ()(int id);
int size() {return Act.size();}
cUIAction * insert (int id , int pos=-1 , const char * txt="", int status=0,int p1=0 , short w = 0 , short h = 0 , int p2=0, int param=0 , int exstyle=0 , int owner = 0);
cUIAction * cfginsert (int id , int pos=-1 , const char * txt="", int status=0,int p1=0 , short x=0 , short y=0 , short w = 0 , short h = 0 , int p2=0, int param=0 , int exstyle=0 , int owner = 0);
cUIAction * insert (sUIActionInfo * ai , int owner);
void move(int old_pos , int pos); // Przenosi akcje na nowa pozycje
int remove (int pos);
bool setCnt(unsigned int _cnt , bool recursive=false);
HANDLE ghandle;
void setInfo(sUIActionInfo & ai, bool update=true);
int find (int id); // Znajduje podakcje i podaje jej pozycje
cUIAction * findAction (int id); // Znajduje podakcje szukajac wglab
int findIndex (int index); // Znajduje podakcje i podaje jej pozycje
int findHandle (void * handle);
bool exists(int id) {return find(id)!=-1;} // Sprawdza czy posiada taka akcje
cUIAction * getIndex (int index); // Pobiera poprzez indeks
// zwraca domyslna akcje (ACTN_DEFAULT)
cUIAction * getDefaultAction(void);
};
// -------------------------------------------
// Tablica modyfikacji
#define AMOD_ACTION 0 // 64
#define AMOD_MASK 1
#define AMOD_STATUS_AND 2
#define AMOD_STATUS_OR 3
#define AMOD_STYLE_AND 4
#define AMOD_STYLE_OR 5
#define AMOD_POS 6
#define AMOD_TITLE 7
#define AMOD_P1 8
#define AMOD_XY 9
#define AMOD_WH 10
// Maski nalozonych modyfikacji
#define MODM_STATUS 1
#define MODM_STYLE 2
#define MODM_POS 4
#define MODM_TITLE 8
#define MODM_P1 0x10
#define MODM_XY 0x20
#define MODM_WH 0x40
class cUIActMod {
public:
cUIActMod();/*:loaded(false)*/
void load(); // Laduje ustawienia do pamieci
void save(); // Zapisuje ust. do pliku
class CdTable * DT; // Tablica z danymi
int createEntry(cUIAction & act);
int getEntry(cUIAction & act);
void changeStatus(cUIAction & act , int mask , int value);
/* TODO: Przy okazji zamykania akcji w klasy, to tez MUSI byc zmienione! */
// Zapamietywanie pozycji...
void loadWindow(cUIGroup & grp); // ustawia okno
void saveWindow(cUIGroup & grp); // zapamietuje okno
void loadAction(cUIAction & act);
void loadBar(cUIGroup & grp); // ustawia caly toolbar
void saveBar(cUIGroup & grp); // zapisuje caly toolbar
private:
//bool loaded;
};
typedef map <int , cUIGroup*>::iterator t_Grp_it;
class cUIActions {
public:
map <int , cUIGroup*> Grp;
cUIActMod Mod; // Zmiany wprowadzone przez uzytkownika
// zwraca wskaznik do grupy
unsigned int lastIndex;
cUIActions();
~cUIActions();
cUIGroup & operator [](int n);
cUIAction & operator ()(sUIAction & uia);
cUIAction & operator ()(int id);
cUIAction & operator ()(int parent , int id) {return (*this)[parent](id);}
cUIAction * getIndex (int index);
cUIAction * findId (int id);
cUIGroup * getRoot() {return Grp[0];}
bool exists(int parent_id) {return Grp.find(parent_id)!=Grp.end();}
bool exists(int parent , int id) {return exists(parent) && Grp[parent]->find(id)>=0;}
bool exists(sUIAction & act) {return exists(act.parent) && Grp[act.parent]->find(act.id)>=0;}
cUIAction * insert (sUIActionInfo * ai , int owner) {
if (!exists(ai->act.parent)) return 0;
return Grp[ai->act.parent]->insert(ai , owner);
}
/* cUIAction * set (sUIActionInfo * ai , int owner) {
Grp[ai->act.parent].insert(ai , owner);
}
*/
int size() {return Grp.size();}
// ustawia / dodaje grupe
// set(int n,cUIGroup & v) {return Grp[n]=v;}
// zwraca/ustawia akcje
// bool get(int g , int id , cUIAction & val); // id grupy , id akcji , referencja
// bool set(int g , int id , cUIAction & val); // id grupy , id akcji , referencja
// bool addGroup(int g , int id , string txt);
// bool addAction(int g , int id, string txt , int pos=-1,bool after=0);
};
// ----------------------------------------
class sUIIcon {
//ImageList_Add
public:
HBITMAP bmp;
HICON ico , ico_;
int index [4];
HIMAGELIST * iml;
bool isIcon;
sUIIcon();
~sUIIcon();
int draw(HDC hDC , int x , int y , int style=0 , int state=0 , int rop=0 , int frame=0 , COLORREF effect=0);
int draw(IML_enum what , HDC hDC , int x , int y , int style=0 , int state=0 , int rop=0 , int frame=0 , COLORREF effect=0);
int measure(int * w , int * h);
int measure(IML_enum what , int * w , int * h);
IML_enum getType();
HICON getIcon();
};
typedef map <int , sUIIcon>::iterator Ico_it_t;
class cUIIcons {
public:
map <int , sUIIcon> Ico;
// pair <int , cUIIcon> Ico_pair;
cUIIcons();
~cUIIcons();
sUIIcon & operator [] (int);
bool find (int);
int count (int id);
bool isAnim(int id) {return this->find(id | 1);}
int erase (int id);
int iconRes(int id , int res , HINSTANCE inst=0 , IML_enum target=IML_16 , sUIIconRegister::tIconParams * ip=0);
int iconRes(int id , const char * res=0 , HINSTANCE inst=0 , IML_enum target=IML_16 , sUIIconRegister::tIconParams * ip=0);
int bmpRes(int id , int res=0 , HINSTANCE inst=0 ,IML_enum target=IML_16);
bool iconAdd(IML_enum target , string URL);
bool iconRegister(sUIIconRegister * ir , HINSTANCE hDll=0);
bool iconRegisterList(sUIIconRegisterList * irl);
bool iconExists(int ID , IML_enum target);
bool iconUnregister(int ID , IML_enum target);
HANDLE iconGet(int ID , IML_enum target);
int getIconIndex(int ID , IML_enum target);
HIMAGELIST getImageList(IML_enum target);
void addHandleToList(sUIIcon & _ico , int type , int imlIndex , HANDLE handle , HBITMAP mask);
static HANDLE getImageFromURL(string URL , int & imageType , HINSTANCE dll=0 , sUIIconRegister::tIconParams * ip=0);
HIMAGELIST iml [4];
// HBITMAP getBmp();
// doneBmp();
};
class TargetAction: public ToolTipX::Target {
public:
TargetAction():Target() {_act = 0; _useText = false;}
ToolTipX::TipPtr getTip(ToolTipX * ttx);
bool operator==(const iTarget & b) const {return false;}
const char *getClass() const {return "TargetAction";}
protected:
cUIAction * _act;
bool _useText;
};
class TargetActionRebar: public TargetAction {
public:
bool mouseAtTarget(ToolTipX * ttx, HWND window, POINT screen, POINT local);
};
class TargetActionTipButton: public ToolTipX::TargetFixed {
public:
TargetActionTipButton(ToolTipX::TipPtr tip, HWND button):ToolTipX::TargetFixed(tip) {
this->_button = button;
}
// ToolTipX::enPositioning getPositioning() {return (ToolTipX::enPositioning)(ToolTipX::positionFixed | ToolTipX::positionRefresh);}
void attach(ToolTipX * ttx);
void detach(ToolTipX * ttx);
const char * getClass() {return "TargetActionTipButton";}
bool operator==(const iTarget & b) const {return iTarget::operator==(b) && static_cast<const TargetActionTipButton&>(b)._button == _button;}
protected:
HWND _button;
};
class TipAction: public ToolTipX::iTipCallBack {
public:
TipAction(cUIAction & act):_act(&act){}
void fillCache();
private:
cUIAction * _act;
};
class TipActionTaskBar: public ToolTipX::iTipCallBack {
public:
TipActionTaskBar(int id):_id(id){}
void fillCache();
private:
int _id;
};
class TargetActionTaskbar: public ToolTipX::Target {
public:
TargetActionTaskbar(int id):Target(ToolTipX::TipPtr(new TipActionTaskBar(id))), _id(id){ }
bool mouseAtTarget(ToolTipX * ttx, HWND window, POINT screen, POINT local);
void onHide(ToolTipX * ttx);
void onShow(ToolTipX * ttx);
ToolTipX::enPositioning getPositioning() {return ToolTipX::positionFixed;}
int getDelay(ToolTipX * ttx) {return ttx->enterWait * 2;}
private:
int _id;
POINT _screen;
};
//---------------------------------------------
// Zmienne globalne
UIEXTERN cUIActions Act;
UIEXTERN cUIIcons Ico;
//---------------------------------------------
// F-CJE
int CALLBACK PropClassProc(HWND, UINT, WPARAM, LPARAM);
void resizeProp(HWND hwndParent);
void clipPropSize(HWND hwndParent, int edge, RECT & rc, int minW, int minH, int maxW=0x7FFF, int maxH=0x7FFF);
void clipPropSize(cUIGroup & g, int edge, RECT & rc, int minW, int minH, int maxW=0x7FFF, int maxH=0x7FFF);
void openCfgAction(cUIGroup & g);
HWND makeToolBar(HWND hwndOwner , cUIGroup & g);
void saveCfg(cUIAction * a = 0);
HMENU makeActionsMenu(cUIGroup & , int startFrom=0 , bool create=true);
void makeCfgTree(cUIGroup & g);
const char * checkCfgValue(cUIAction & a,char * v);
void setCfgValue(cUIAction & a , char * v , size_t size);
const char * getCfgValue(cUIAction & a , char * buff = 0 , int size = 0);
const char * getActionValue(cUIAction & act , char * buff = 0, size_t size = 0 , bool convert = false , size_t * newSize = 0);
const char * setActionValue(cUIAction & act , const char * buff , bool convert = false);
int ActionStatus(sUIAction & a , int status=-1 , char * text=0 , int ico=-1);
#ifdef __DEBUG
void DbgActionsSet(cUIAction * act , bool showup);
#endif
int fillProfiles(int where);
HMENU makeActionsMenu(cUIGroup & g , int startFrom , bool create);
void destroyActionsMenu(cUIGroup & g);
void makeCfgTree(cUIGroup & g , HWND tree);
const char * getCfgValue(cUIAction & a , char * buff , int size);
void setCfgValue(cUIAction & a , char * v);
const char * checkCfgValue(cUIAction & a,char * v);
HWND getCfgHandle(cUIAction & act);
HWND makeCfgProp(cUIGroup & g );
void openCfgAction(cUIGroup & g);
void destroyCfgTree(cUIGroup * g = 0);
void destroyActionsTree(cUIGroup & g);
void saveCfg(cUIAction * a);
void SetCfgTip(HWND hwnd , const char * tip , void * handle);
HWND makeToolBar(HWND hwndOwner , cUIGroup & g);
HWND makeBar(HWND hwndOwner , cUIGroup & g);
int ActionSet(sUIActionInfo & ai);
int ActionStatus(sUIAction & act , int status, char * text , int ico);
void makeActions();
void makeCfg();
void destroyActions();
INT_PTR CALLBACK ConfigProc(HWND hwndDlg,UINT message,WPARAM wParam,LPARAM lParam);
int CALLBACK PropClassProc(HWND hWnd,UINT message,WPARAM wParam,LPARAM lParam);
cUIAction * UIPopupMenu(cUIGroup & act , UINT uFlags, int x, int y, int nReserved, HWND hWnd, CONST RECT *prcRect , int start = 0);
int UIMessageProc(int curCnt , HWND hWnd , UINT message , WPARAM wParam , LPARAM lParam);
int CALLBACK ReBarControlProc(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam);
void DbgActionsRefresh(cUIGroup * start);
INT_PTR CALLBACK DbgActionsProc(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam);
void registerActions();
void registerActionsAfter();
void unregisterActions();
HICON makeIconFromBitmap(HBITMAP bmp);