aboutsummaryrefslogtreecommitdiff
path: root/Src/Wasabi/api/wnd/wndclass/wndholder.h
blob: 580b8ba2784e477ce0ca2d4dcba9c27a4c9698a3 (plain) (blame)
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
#ifndef __WINDOWHOLDER_H
#define __WINDOWHOLDER_H

#include <api/wnd/wndclass/guiobjwnd.h>
#include <bfc/ptrlist.h>
#include <api/syscb/callbacks/wndcb.h>
#include <api/timer/timerclient.h>

class svc_windowCreate;

#define WINDOWHOLDER_PARENT GuiObjectWnd 


/**
  Class 

  @short 
  @author Nullsoft
  @ver 1.0
  @see 
*/
class WindowHolder : public Dispatchable 
{
  public:
    ifc_window *onInsertWindow(GUID g, const wchar_t *groupid);
    void onRemoveWindow(int deferred=0);
    int wantGuid(GUID g);
    int wantGroup(const wchar_t *groupid);
    GUID getCurGuid();
    const wchar_t *getCurGroupId();
    ifc_window *getCurRootWnd();
    const wchar_t *getCurId();
    ifc_window *getRootWndPtr();
    int acceptsGenericGuid();
    int acceptsGenericGroup();
    int wndholder_getPreferences(int what);
    void wndholder_onNeedReloadGroup(const wchar_t *id);
    void cancelDeferredRemove();
    int wndholder_wantAutoFocus();
    int wndholder_isAutoAvailable();

  enum {
    WNDHOLDER_ONINSERTWINDOW=50,
    WNDHOLDER_ONREMOVEWINDOW=100,
    WNDHOLDER_WANTGUID=150,
    WNDHOLDER_WANTGROUP=200,
    WNDHOLDER_GETROOTWNDPTR=250,
    WNDHOLDER_GETCURGUID=300,
    WNDHOLDER_GETCURGROUPID=350,
    WNDHOLDER_GETCURROOTWND=400,
    WNDHOLDER_GETCURID=450,
    WNDHOLDER_ISGENERICGUID=500,
    WNDHOLDER_ISGENERICGROUP=550,
    WNDHOLDER_GETPREFERENCES=600,
    WNDHOLDER_ONNEEDRELOADGRP=650,
    WNDHOLDER_CANCELDEFERREDREMOVE=660,
    WNDHOLDER_WANTAUTOFOCUS=670,
    WNDHOLDER_ISAUTOAVAILABLE=680,
  };
};

inline ifc_window *WindowHolder::onInsertWindow(GUID g, const wchar_t *groupid) {  
  return _call(WNDHOLDER_ONINSERTWINDOW, (ifc_window *)NULL, g, groupid);
}

inline void WindowHolder::onRemoveWindow(int def) {  
  _voidcall(WNDHOLDER_ONREMOVEWINDOW, def);
}

inline int WindowHolder::wantGuid(GUID g) {  
  return _call(WNDHOLDER_WANTGUID, 0, g);
}

inline int WindowHolder::wantGroup(const wchar_t *groupid) {  
  return _call(WNDHOLDER_WANTGROUP, 0, groupid);
}                                             

inline ifc_window *WindowHolder::getRootWndPtr() {
  return _call(WNDHOLDER_GETROOTWNDPTR, (ifc_window *)NULL);
}

inline GUID WindowHolder::getCurGuid() {
  return _call(WNDHOLDER_GETCURGUID, INVALID_GUID);
}

inline const wchar_t *WindowHolder::getCurGroupId() {
  return _call(WNDHOLDER_GETCURGROUPID, (const wchar_t *)NULL);
}

inline ifc_window *WindowHolder::getCurRootWnd() {
  return _call(WNDHOLDER_GETCURROOTWND, (ifc_window *)NULL);
}

inline const wchar_t *WindowHolder::getCurId() {
  return _call(WNDHOLDER_GETCURID, (const wchar_t *)NULL);
}

inline int WindowHolder::acceptsGenericGuid() {
  return _call(WNDHOLDER_ISGENERICGUID, 0);
}

inline int WindowHolder::acceptsGenericGroup() {
  return _call(WNDHOLDER_ISGENERICGROUP, 0);
}

inline int WindowHolder::wndholder_getPreferences(int what) {
  return _call(WNDHOLDER_GETPREFERENCES, 0, what);
}

inline void WindowHolder::wndholder_onNeedReloadGroup(const wchar_t *id) {
  _voidcall(WNDHOLDER_ONNEEDRELOADGRP, id);
}

inline void WindowHolder::cancelDeferredRemove() {
  _voidcall(WNDHOLDER_CANCELDEFERREDREMOVE);
}

inline int WindowHolder::wndholder_wantAutoFocus() {
  return _call(WNDHOLDER_WANTAUTOFOCUS, 1);
}

inline int WindowHolder::wndholder_isAutoAvailable() {
  return _call(WNDHOLDER_ISAUTOAVAILABLE, 1);
}

class DeferredRemove;

/**
  Class 

  @short 
  @author Nullsoft
  @ver 1.0
  @see 
*/
class WindowHolderI : public WindowHolder {
  public:

    WindowHolderI();
    virtual ~WindowHolderI();

    virtual ifc_window *onInsertWindow(GUID g, const wchar_t *groupid);
    

    virtual void onRemoveWindow(int deferred);

 
    void addAcceptGuid(GUID g);
    void addAcceptGroup(const wchar_t *groupid);
    void setAcceptAllGuids(int tf);
    

    void setAcceptAllGroups(int tf);

    virtual int acceptsGenericGroup() { return generic_group; }

    virtual int acceptsGenericGuid() { return generic_guid; }

    virtual int wantGuid(GUID g);
    virtual int wantGroup(const wchar_t *groupid);

    virtual void onInsert(ifc_window *w, const wchar_t *id) {};
    
    virtual void onRemove(ifc_window *w, const wchar_t *id) {};

    virtual ifc_window *getRootWndPtr()=0; 
    virtual GUID getCurGuid() { return cur_guid; }
    virtual const wchar_t *getCurGroupId() { return cur_groupid; }

    virtual ifc_window *getCurRootWnd() { return wnd; }

    virtual GUID *getFirstAcceptedGuid();
    virtual const wchar_t *getFirstAcceptedGroup();
    virtual const wchar_t *getCurId() { return cur_id; }

    virtual void cancelDeferredRemove();
    virtual int wndholder_isAutoAvailable() { return 1; }
    
    GUID getDeferedGuid() { return defered_guid; }

    virtual int wndholder_getPreferences(int what)=0;
 
    virtual void wndholder_onNeedReloadGroup(const wchar_t *id);

  private:

  
    ifc_window *createWindow(const GUID *g, const wchar_t *groupid);
    virtual int wndholder_wantAutoFocus();
    

    void destroyWindow();

    ifc_window *wnd;
    GUID cur_guid;
    StringW cur_groupid;
    StringW cur_id;
    PtrList<GUID> accepted_guids;
    PtrList<StringW> accepted_groups;
    int generic_guid;
    int generic_group;

    svc_windowCreate *wc_svc;
    GUID defered_guid;

    DeferredRemove *dr;

  protected:

    RECVS_DISPATCH;
};


/**
  Class 

  @short 
  @author Nullsoft
  @ver 1.0
  @see 
*/
class WindowHolderWnd : public WINDOWHOLDER_PARENT, public WindowHolderI 
{

  public:

    WindowHolderWnd();
    virtual ~WindowHolderWnd();
    virtual int onInit();

    virtual ifc_window *getRootWndPtr() { return this; }
    virtual void onInsert(ifc_window *w, const wchar_t *id);
    virtual void onRemove(ifc_window *w, const wchar_t *id);
    virtual int onResize();
    virtual int handleRatio();
    virtual int handleDesktopAlpha();
    virtual int handleTransparency();
    virtual int wndholder_getPreferences(int what) { return getPreferences(what); }
    virtual int getPreferences(int what);
    void setAutoOpen(int tf) { autoopen = tf; }
    void setAutoClose(int tf) { autoclose = tf; }
    void setNoCmdBar(int tf) { nocmdbar = tf; if (isInited()) invalidate(); }
    void setNoAnim(int tf) { noanim = tf; }
    virtual int onGroupChange(const wchar_t *grpid);
    virtual int wndholder_wantAutoFocus();
    void setAutoFocus(int autof) { autofocus = autof; }
    void setAutoAvailable(int autoa) { autoavail = autoa; }
    virtual int wndholder_isAutoAvailable() { return autoavail; }

  private:
    void notifyOnRemove(); // no virtual please
    void notifyOnInsert(); // no virtual please
    virtual void onSetVisible(int show);
    virtual int onDeferredCallback(intptr_t p1, intptr_t p2);

    int autoopen;
    int autoclose;
    int nocmdbar;
    int noanim;
    int has_wnd;
    int autofocus;
    int autoavail;
};

class DeferredRemove : public TimerClientDI 
{
  public:
    DeferredRemove(WindowHolderI *parent) : whi(parent) {}
    virtual ~DeferredRemove() {}

    void post() {
      timerclient_postDeferredCallback(1, 0);
    }

    virtual int timerclient_onDeferredCallback(intptr_t p1, intptr_t p2) {
      if (p1 == 1 && whi != NULL) whi->onRemoveWindow(0);
      else return TimerClientDI::timerclient_onDeferredCallback(p1, p2);
      return 0;
    }

  private:
    WindowHolderI *whi;
};

#endif