1
0

basewnd.h 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944
  1. //NONPORTABLE
  2. #ifndef _BASEWND_H
  3. #define _BASEWND_H
  4. #include <api/wnd/api_wnd.h>
  5. #include <api/timer/api_timer.h>
  6. #include <bfc/wasabi_std.h>
  7. #include <bfc/common.h>
  8. #include <api/wnd/api_window.h>
  9. #include <api/wnd/drag.h>
  10. #include <bfc/ptrlist.h>
  11. #include <bfc/tlist.h>
  12. #include <bfc/named.h>
  13. #include <api/timer/timerclient.h>
  14. #include <api/wnd/findobjectcb.h>
  15. #include <bfc/stack.h>
  16. #include <api/wnd/rootwnd.h>
  17. class BaseWnd;
  18. #include <tataki/canvas/bltcanvas.h>
  19. class FilenamePS;
  20. class Canvas;
  21. class ifc_canvas;
  22. class RegionI;
  23. class DragSet;
  24. class VirtualWnd;
  25. class Tooltip;
  26. class svc_toolTipsRenderer;
  27. class Accessible;
  28. // for triggerEvent()
  29. #define TRIGGER_ONRESIZE 1000
  30. #define TRIGGER_INVALIDATE 2000
  31. // it is safe to use anything higher than this for your own funky messages
  32. #define BASEWND_NOTIFY_USER NUM_NOTIFY_MESSAGES
  33. #define BASEWND_CURSOR_USERSET -1// window will do own setting
  34. #define BASEWND_CURSOR_POINTER 1
  35. #define BASEWND_CURSOR_NORTHSOUTH 2
  36. #define BASEWND_CURSOR_EASTWEST 3
  37. #define BASEWND_CURSOR_NORTHWEST_SOUTHEAST 4
  38. #define BASEWND_CURSOR_NORTHEAST_SOUTHWEST 5
  39. #define BASEWND_CURSOR_4WAY 6
  40. #define BASEWND_CURSOR_EDIT 7
  41. // Our own defined window messages
  42. #define WM_WA_CONTAINER_TOGGLED WM_USER+0x1338
  43. #define WM_WA_COMPONENT_TOGGLED WM_USER+0x1339
  44. #define WM_WA_RELOAD WM_USER+0x133A
  45. #define WM_WA_GETFBSIZE WM_USER+0x133B
  46. #define DEFERREDCB_FLUSHPAINT 0x200
  47. #define SYSRGN 4
  48. #define REGIONOP_NONE 0
  49. #define REGIONOP_OR 1
  50. #define REGIONOP_AND 2
  51. #define REGIONOP_SUB -1
  52. #define REGIONOP_SUB2 -2
  53. #define TABORDER_K 0.0001f
  54. class ReparentWndEntry {
  55. public:
  56. ReparentWndEntry(OSWINDOWHANDLE wnd, OSWINDOWHANDLE parentwnd);
  57. virtual ~ReparentWndEntry() {}
  58. void unparent();
  59. void reparent(OSWINDOWHANDLE newparent);
  60. private:
  61. RECT rect;
  62. OSWINDOWHANDLE wnd;
  63. };
  64. class virtualChildTimer {
  65. public:
  66. virtualChildTimer(int _id, ifc_window *_child) : id(_id), child(_child) { }
  67. virtual ~virtualChildTimer() {}
  68. int id;
  69. ifc_window *child;
  70. };
  71. class RootWndFinder : public FindObjectCallbackI {
  72. public:
  73. RootWndFinder() { findobject_guid = INVALID_GUID; }
  74. virtual ~RootWndFinder() { }
  75. void reset() { findobject_id = L""; findobject_guid = INVALID_GUID; }
  76. void setFindId(const wchar_t *id) { findobject_id = id; }
  77. void setFindGuid(GUID guid) { findobject_guid = guid; }
  78. virtual int findobjectcb_matchObject(ifc_window *w) {
  79. if (!findobject_id.isempty()) {
  80. if (w != NULL) {
  81. const wchar_t *id = w->getId();
  82. return WCSCASEEQLSAFE(id, findobject_id);
  83. }
  84. } else if (findobject_guid != INVALID_GUID) {
  85. return (w->getInterface(findobject_guid) != NULL);
  86. }
  87. return 0;
  88. }
  89. private:
  90. StringW findobject_id;
  91. GUID findobject_guid;
  92. };
  93. #ifdef _WIN32
  94. typedef struct {
  95. HWND owner;
  96. HWND hthis;
  97. PtrList<ifc_window> *hlist;
  98. } enumownedstruct;
  99. #endif
  100. class WndWatcher: public DependentViewerI {
  101. public:
  102. WndWatcher(BaseWnd *b) : watched(NULL), dep(NULL), watcher(b) { ASSERT(watcher != NULL); }
  103. WndWatcher() : watched(NULL), dep(NULL), watcher(NULL) { }
  104. virtual ~WndWatcher() {}
  105. virtual void setWatcher(BaseWnd *w) {
  106. if (watcher != NULL)
  107. watchWindow(NULL);
  108. watcher = w;
  109. }
  110. virtual void watchWindow(ifc_window *w) {
  111. ASSERT(watcher != NULL);
  112. if (dep != NULL) {
  113. viewer_delViewItem(dep);
  114. dep = NULL;
  115. watched = NULL;
  116. }
  117. if (w != NULL) {
  118. watched = w;
  119. dep = w->getDependencyPtr();
  120. viewer_addViewItem(dep);
  121. }
  122. }
  123. virtual int viewer_onItemDeleted(ifc_dependent *item);
  124. private:
  125. ifc_window *watched;
  126. ifc_dependent *dep;
  127. BaseWnd *watcher;
  128. };
  129. #ifdef _WIN32
  130. BOOL CALLBACK EnumOwnedTopMostWindows(HWND hwnd, LPARAM lParam);
  131. #endif
  132. class TabOrderEntry {
  133. public:
  134. ifc_window *wnd;
  135. float order; // yes, float. if a wnd tries to set order n and n is already set for another wnd, that other wnd will be pushed to n+k
  136. // with k = 0.0001 . recursively, if n+k is taken, it'll push that wnd to n+2k, which if taken has its wnd pushed to n+3k, etc
  137. // if n+xk >= n+1 (when x = 10000), the 10000th entry is discarded (if you manage to make a dialog with 10000 keyboard fields inside
  138. // a single group, you're nuts anyway, and you should die a painful death)
  139. };
  140. class TabOrderSort {
  141. public:
  142. static int compareItem(TabOrderEntry *p1, TabOrderEntry *p2) {
  143. if (p1->order < p2->order) return -1;
  144. if (p1->order > p2->order) return 1;
  145. return 0;
  146. }
  147. };
  148. // base class
  149. #define BASEWND_PARENT RootWndI
  150. class NOVTABLE BaseWnd :
  151. public RootWndI,
  152. public DragInterface,
  153. public NamedW,
  154. public DependentI,
  155. public TimerClientI
  156. {
  157. friend class VirtualWnd;
  158. protected:
  159. // override constructor to init your data, but don't create anything yet
  160. BaseWnd();
  161. public:
  162. virtual ~BaseWnd();
  163. //INITIALIZATION
  164. // these actually create the window
  165. // try REALLY hard to not have to override these, and if you do,
  166. // override the second one
  167. virtual int init(ifc_window *parent, int nochild=FALSE);
  168. virtual int init(OSMODULEHANDLE hInstance, OSWINDOWHANDLE parent, int nochild=FALSE);
  169. virtual int isInited(); // are we post init() ?
  170. virtual int isPostOnInit() { return postoninit; }
  171. virtual int setVirtual(int i) { return 0; }
  172. // if at all possible put your init stuff in this one, and call up the
  173. // heirarchy BEFORE your code
  174. virtual int onInit();
  175. virtual int onPostOnInit(); // this one is called after onInit so you get a chance to do something after your inheritor override
  176. // use this to return the cursor type to show
  177. virtual int getCursorType(int x, int y);
  178. // WINDOW SIZING/MOVEMENT/CONTROL
  179. virtual int getFontSize() { return 0; }
  180. virtual int setFontSize(int size) { return -1; }
  181. // if you override it, be sure to call up the heirarchy
  182. virtual void resize(int x, int y, int w, int h, int wantcb=1); // resize yourself
  183. void resize(RECT *r, int wantcb=1);
  184. void resizeToRect(RECT *r) { resize(r); }//helper
  185. // called after resize happens, return TRUE if you override
  186. virtual int onResize();
  187. virtual int onAfterResize() { return 1; }
  188. void resizeToClient(BaseWnd *wnd); // resize a window to match you
  189. virtual int onPostedMove(); // whenever WM_WINDOWPOSCHANGED happens, use mainly to record positions when moved by the window tracker, avoid using for another prupose, not portable
  190. // move only, no resize
  191. virtual void move(int x, int y);
  192. virtual void notifyDeferredMove(int x, int y);
  193. // puts window on top of its siblings
  194. virtual void bringToFront();
  195. // puts window behind its siblings
  196. virtual void bringToBack();
  197. // fired when a sibbling invalidates a region. you can change the region before returning, use with care, can fuck up everything if not used well
  198. virtual int onSiblingInvalidateRgn(api_region *r, ifc_window *who, int who_idx, int my_idx) { return 0; }
  199. // set window's visibility
  200. virtual void setVisible(int show);
  201. virtual void setCloaked(int cloak);
  202. virtual void onSetVisible(int show); // override this one
  203. virtual void onChildInvalidate(api_region *r, ifc_window *w) {}
  204. // enable/disable window for input
  205. virtual void setEnabled(int en);
  206. // grab the keyboard focus
  207. virtual void setFocus();
  208. virtual void setFocusOnClick(int f);
  209. virtual int getFocusOnClick() { return focus_on_click; }
  210. virtual int pointInWnd(POINT *p);
  211. // repaint yourself
  212. virtual void invalidate(); // mark entire window for repainting
  213. virtual void invalidateRect(RECT *r);// mark specific rect for repainting
  214. virtual void invalidateRgn(api_region *r);// mark specific rgn for repainting
  215. virtual void invalidateFrom(ifc_window *who); // mark entire window for repainting
  216. virtual void invalidateRectFrom(RECT *r, ifc_window *who);// mark specific rect for repainting
  217. virtual void invalidateRgnFrom(api_region *r, ifc_window *who);// mark specific rgn for repainting
  218. virtual void validate(); // unmark the entire window from repainting
  219. virtual void validateRect(RECT *r); // unmark specific rect from repainting
  220. virtual void validateRgn(api_region *reg); // unmark specific region from repainting
  221. // no virtual on these please
  222. void deferedInvalidateRgn(api_region *h);
  223. void deferedInvalidateRect(RECT *r);
  224. void deferedInvalidate();
  225. void deferedValidateRgn(api_region *h);
  226. void deferedValidateRect(RECT *r);
  227. void deferedValidate();
  228. api_region *getDeferedInvalidRgn();
  229. int hasVirtualChildren();
  230. virtual void setVirtualChildFocus(ifc_window *w);
  231. virtual ifc_window *getNextVirtualFocus(ifc_window *w);
  232. void setVirtualTabOrder(ifc_window *w, int a);
  233. int getVirtualTabOrder(ifc_window *w);
  234. virtual void setTabOrder(int a);
  235. virtual int getTabOrder();
  236. virtual void setAutoTabOrder();
  237. virtual void setVirtualAutoTabOrder(ifc_window *w);
  238. virtual void focusNext();
  239. virtual void focusPrevious();
  240. virtual ifc_window *getCurVirtualChildFocus() { return curVirtualChildFocus; }
  241. virtual ifc_window *getTab(int what=TAB_GETNEXT);
  242. private:
  243. //virtual int focusVirtualChild(api_window *child);
  244. virtual void physicalInvalidateRgn(api_region *r);
  245. void autoFocus(ifc_window *w);
  246. protected:
  247. virtual int ensureVirtualCanvasOk();
  248. virtual void setVirtualCanvas(Canvas *c);
  249. virtual void setRSize(int x, int y, int w, int h);
  250. public:
  251. virtual void repaint(); // repaint right now!
  252. // override this to add decorations
  253. virtual void getClientRect(RECT *);
  254. RECT clientRect(); // helper
  255. virtual void getNonClientRect(RECT *);
  256. RECT nonClientRect(); // helper
  257. virtual void getWindowRect(RECT *); // windows coords in screen system
  258. RECT windowRect(); // helper
  259. virtual void getPosition(POINT *pt); // window coord relative to os window (instead of rootparent)
  260. virtual void *getInterface(GUID interface_guid) { return NULL; }
  261. virtual void *dependent_getInterface(const GUID *classguid);
  262. virtual void clientToScreen(int *x, int *y); // convenience fn
  263. virtual void screenToClient(int *x, int *y); // convenience fn
  264. virtual void clientToScreen(POINT *pt); // convenience fn
  265. virtual void screenToClient(POINT *pt); // convenience fn
  266. virtual void clientToScreen(RECT *r); // convenience fn
  267. virtual void screenToClient(RECT *r); // convenience fn
  268. void setIcon(OSICONHANDLE icon, int _small);
  269. virtual void setSkinId(int id);
  270. virtual int getPreferences(int what);
  271. virtual void setPreferences(int what, int v);
  272. virtual void setStartHidden(int wtf);
  273. virtual void setDefaultCursor(Cursor *c);
  274. virtual Canvas *getFrameBuffer();
  275. void setWindowTitle(const wchar_t *title);
  276. // from api_window
  277. protected:
  278. virtual DragInterface *getDragInterface();
  279. virtual ifc_window *rootWndFromPoint(POINT *pt);
  280. virtual int rootwnd_paintTree(ifc_canvas *canvas, api_region *r);
  281. void assignRootFocus(ifc_window *w);
  282. public:
  283. // override for custom processing (NONPORTABLE!)
  284. #ifdef _WIN32
  285. virtual LRESULT wndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
  286. #elif defined(__APPLE__)
  287. virtual OSStatus eventHandler(EventHandlerCallRef inHandlerCallRef, EventRef inEvent, void *inUserData);
  288. #endif
  289. virtual void performBatchProcesses(); // this is called after wndProc is called (under win32) to recompute batch operations such as calculating window regions, cascaderepainting, etc. this prevents N children from independently calling repaintTree for the whole gui on overlaping zones of the framebuffer. under OSes other than win32, this should be called after you've executed all your window events for this poll, try not to use it, or use a dirty bit to cut down on your job
  290. virtual const wchar_t *getRootWndName();
  291. virtual const wchar_t *getId();
  292. // end from api_window
  293. // or override these, they're more portable
  294. virtual int onContextMenu(int x, int y); // always return 1 if accept msg
  295. virtual int onChildContextMenu(int x, int y); // always return 1 if accept msg
  296. // called on WM_PAINT by onPaint(Canvas, api_region *), if the canvas is null, create your own, if not, it will have update regions clipped for you
  297. virtual int onPaint(Canvas *canvas);
  298. void setTransparency(int amount); // 0..255
  299. int getTransparency();
  300. // override those two
  301. virtual void timerCallback(int id);
  302. virtual int onDeferredCallback(intptr_t p1, intptr_t p2);
  303. int setTimer(int id, int ms);
  304. int killTimer(int id);
  305. void postDeferredCallback(intptr_t p1, intptr_t p2=0, int mindelay=0);
  306. // from timerclient
  307. virtual int timerclient_onDeferredCallback(intptr_t p1, intptr_t p2);
  308. virtual void timerclient_timerCallback(int id);
  309. virtual TimerClient *timerclient_getMasterClient();
  310. virtual void timerclient_onMasterClientMultiplex();
  311. virtual TimerClient *getTimerClient();
  312. virtual const wchar_t *timerclient_getName();
  313. private:
  314. virtual int onPaint(Canvas *canvas, api_region *r);
  315. public:
  316. // click-drag. FYI, the drag-drop handling overrides these
  317. virtual int onLeftButtonDown(int x, int y);
  318. virtual int onRightButtonDown(int x, int y) { return 0; }
  319. virtual int onMouseMove(int x, int y); // only called when mouse captured
  320. virtual int onLeftButtonUp(int x, int y);
  321. virtual int onRightButtonUp(int x, int y) { return 0; }
  322. virtual int onMouseWheelUp(int click, int lines);
  323. virtual int onMouseWheelDown(int click, int lines);
  324. virtual int beginCapture();
  325. virtual int endCapture();
  326. virtual int getCapture(); // returns 1 if this window has mouse/keyb captured
  327. virtual void onCancelCapture(); // called when someone steals the capture from you
  328. virtual void cancelCapture();
  329. // these will not be called in the middle of a drag operation
  330. virtual int onLeftButtonDblClk(int x, int y);
  331. virtual int onRightButtonDblClk(int x, int y);
  332. virtual int onGetFocus(); // you have the keyboard focus
  333. virtual int onKillFocus(); // you lost the keyboard focus
  334. virtual int gotFocus();
  335. virtual int isActive();
  336. virtual int onActivate();
  337. virtual void activate();
  338. virtual int onDeactivate();
  339. virtual int onEnable(int en);
  340. virtual int isEnabled(int within=0);
  341. virtual void registerAcceleratorSection(const wchar_t *name, int global=0);
  342. virtual int onAcceleratorEvent(const wchar_t *name);
  343. virtual int onChar(unsigned int c);
  344. virtual int onKeyDown(int keyCode) { return 0; }
  345. virtual int onKeyUp(int keyCode) { return 0; }
  346. virtual int onSysKeyDown(int keyCode, int keyData) { return 0; }
  347. virtual int onSysKeyUp(int keyCode, int keyData) { return 0; }
  348. virtual int onEraseBkgnd(HDC dc);// override and return 0 to authorize bkg painting, 1 to avoid it (default to 1)
  349. virtual int onUserMessage(int msg, int w, int l, int *r);
  350. //CHILD->PARENT MESSAGES
  351. // feel free to override for your own messages, but be sure to call up the
  352. // chain for unhandled msgs
  353. // children should not call this directly if they don't have to; use
  354. // notifyParent on yourself instead
  355. // message ids should be put in notifmsg.h to avoid conflicts
  356. virtual int childNotify(ifc_window *child, int msg,
  357. int param1=0, int param2=0);
  358. // don't try to override these
  359. void setParent(ifc_window *newparent);
  360. ifc_window *getParent();
  361. virtual ifc_window *getRootParent();
  362. virtual ifc_window *getDesktopParent();
  363. // avoid overriding this one if you can
  364. virtual int reparent(ifc_window *newparent);
  365. // override this one
  366. virtual void onSetParent(ifc_window *newparent) {}
  367. virtual api_region *getRegion(); // override to return your client region
  368. virtual void setRegionOp(int op); // 0 = none, 1 == or, 2=and, 3=xor, -1 = sub, -2 = sub thru groups
  369. virtual void setRectRgn(int i); // set to 1 if you don't want your region to clip your clicks
  370. virtual void invalidateWindowRegion(); // call this when your region has changed
  371. api_region *getComposedRegion(); // returns the result of and/or/subing your children regions with your region
  372. api_region *getSubtractorRegion(); // returns the composed subtracting region, that region is automatically subtracted from the desktop root parent's region
  373. int ptInRegion(int x, int y); // handled automatically if you override getRegion and isRectRgn, but you can still override it if you need
  374. virtual int getRegionOp(); //
  375. virtual int isRectRgn();
  376. // call this to notify your parent via its childNotify method
  377. virtual int notifyParent(int msg, int param1=0, int param2=0);
  378. // call this when you have received a childNotify and wish to
  379. // defer the notification to your own notify object.
  380. virtual int passNotifyUp(ifc_window *child, int msg,
  381. int param1=0, int param2=0);
  382. // This allows you to set a custom integer ID for any object you control,
  383. // such that you can use its ID in a switch statement by calling getNotifyId()
  384. // which is dispatched through api_window.
  385. void setNotifyId(int id);
  386. virtual int getNotifyId();
  387. // from class Named
  388. virtual void onSetName();
  389. // non-virtuals only: sets the exported name of the OS window WITHOUT changing the Named member (getRootWndName() will not return this string)
  390. virtual void setOSWndName(const wchar_t *name);
  391. // non-virtuals only: retreive the exported name of the OS window. This is NOT the same as getRootWndName().
  392. virtual const wchar_t *getOSWndName();
  393. virtual const wchar_t *getTip();
  394. virtual void setTip(const wchar_t *tooltip);
  395. virtual int getStartHidden();
  396. virtual void abortTip();
  397. virtual int isVisible(int within=0);
  398. // Virtual windows functions
  399. virtual Canvas *createFrameBuffer(int w, int h);
  400. virtual void prepareFrameBuffer(Canvas *canvas, int w, int h);
  401. virtual void deleteFrameBuffer(Canvas *canvas);
  402. virtual void registerRootWndChild(ifc_window *child);
  403. virtual void unregisterRootWndChild(ifc_window *child);
  404. virtual ifc_window *findRootWndChild(int x, int y, int only_virtuals=0);
  405. virtual ifc_window *enumRootWndChildren(int _enum);
  406. virtual int getNumRootWndChildren();
  407. virtual int isVirtual();
  408. virtual ifc_window *enumVirtualChild(int _enum);
  409. virtual int getNumVirtuals();
  410. virtual int handleVirtualChildMsg(UINT uMsg,int x, int y, void *p=NULL, void *d=NULL);
  411. virtual void setVirtualChildCapture(ifc_window *child);
  412. virtual ifc_window *getVirtualChildCapture();
  413. virtual int cascadeRepaintFrom(ifc_window *who, int pack=1);
  414. virtual int cascadeRepaintRgnFrom(api_region *reg, ifc_window *who, int pack=1);
  415. virtual int cascadeRepaintRectFrom(RECT *r, ifc_window *who, int pack=1);
  416. virtual int cascadeRepaint(int pack=1);
  417. virtual int cascadeRepaintRgn(api_region *reg, int pack=1);
  418. virtual int cascadeRepaintRect(RECT *r, int pack=1);
  419. virtual void flushPaint();
  420. virtual void onMinimize();
  421. virtual void onRestore();
  422. virtual int isMinimized();
  423. virtual int isMaximized() { return maximized; }
  424. virtual void onMaximize() { }
  425. virtual void freeResources();
  426. virtual void reloadResources();
  427. virtual int getDesktopAlpha();
  428. virtual int handleDesktopAlpha() { return isVirtual(); }
  429. virtual int getPaintingAlpha(); // this one is a hint for painting, it returns either activealpha or inactivealpha
  430. virtual void setAlpha(int activealpha, int inactivealpha=-1); // -1 means same as activealpha
  431. virtual void getAlpha(int *activealpha=NULL, int *inactivealpha=NULL);
  432. virtual int getFlag(int flag);
  433. virtual int triggerEvent(int event, intptr_t p1, intptr_t p2);
  434. void commitFrameBuffer(Canvas *canvas, RECT *r, double ratio);
  435. virtual int paint(Canvas *canvas, api_region *r);
  436. protected:
  437. void do_flushPaint();
  438. virtual int paintTree(Canvas *canvas, api_region *r);
  439. virtual int virtualBeforePaint(api_region *r);
  440. virtual int virtualAfterPaint(api_region *r);
  441. int virtualOnPaint();
  442. virtual void setDesktopAlpha(int do_alpha);
  443. virtual void onSetDesktopAlpha(int a);
  444. public:
  445. virtual OSWINDOWHANDLE getOsWindowHandle();
  446. virtual OSMODULEHANDLE getOsModuleHandle();
  447. public:
  448. bool getNoCopyBits(void);
  449. void setNoCopyBits(bool ncb);
  450. BltCanvas *scalecanvas;
  451. protected:
  452. virtual int checkDoubleClick(int button, int x, int y);
  453. //MISC
  454. public:
  455. virtual int isDestroying(); // in the middle of dying
  456. //DRAGGING AND DROPPING -- (derived from DragInterface)
  457. // derived windows should call this if they detect a drag beginning
  458. // call once per datum per type of data being exposed. order is maintained
  459. int addDragItem(const wchar_t *droptype, void *item);
  460. // returns TRUE if drop was accepted
  461. int handleDrag();
  462. int resetDragSet(); // you don't need to call this
  463. // (called on dest) when dragged item enters the winder
  464. virtual int dragEnter(ifc_window *sourceWnd);
  465. // (called on dest) during the winder
  466. // FG> x/y are in screen corrdinates because target is a rootwnd
  467. virtual int dragOver(int x, int y, ifc_window *sourceWnd) { return 0; }
  468. // (called on src)
  469. virtual int dragSetSticky(ifc_window *wnd, int left, int right, int up, int down);
  470. // (called on dest) when dragged item leaves the winder
  471. virtual int dragLeave(ifc_window *sourceWnd) { return 0; }
  472. // when it finally is dropped:
  473. // called on destination window
  474. // FG> x/y are in screen corrdinates because target is a rootwnd
  475. virtual int dragDrop(ifc_window *sourceWnd, int x, int y) { return 0; }
  476. // called on source window
  477. virtual int dragComplete(int success) { return 0; }
  478. // in that order
  479. // must be called right before handleDrag(); (sender)
  480. void setSuggestedDropTitle(const wchar_t *title);
  481. // must be called from dragDrop(); (receiver)
  482. virtual const wchar_t *dragGetSuggestedDropTitle(void);
  483. virtual int dragCheckData(const wchar_t *type, int *nitems=NULL);
  484. virtual void *dragGetData(int slot, int itemnum);
  485. virtual int dragCheckOption(int option) { return 0; }
  486. // return TRUE if you support any of the datatypes this window is exposing
  487. virtual int checkDragTypes(ifc_window *sourceWnd) { return 0; }
  488. // external drops
  489. // override this and return 1 to receive drops from the OS
  490. virtual int acceptExternalDrops() { return 0; }
  491. virtual void onExternalDropBegin() {}
  492. virtual void onExternalDropDirScan(const wchar_t *dirname) {}
  493. virtual void onExternalDropEnd() {}
  494. virtual int bypassModal();
  495. virtual ifc_window *findWindow(const wchar_t *id);
  496. virtual ifc_window *findWindowByInterface(GUID interface_guid);
  497. virtual ifc_window *findWindowByCallback(FindObjectCallback *cb);
  498. virtual ifc_window *findWindowChain(FindObjectCallback *cb, ifc_window *wcaller=NULL);
  499. private:
  500. void addDroppedFile(const wchar_t *filename, PtrList<FilenamePS> *plist); // recursive
  501. void setLayeredWindow(int i);
  502. Accessible *createNewAccObj();
  503. public:
  504. //FG> alternate notify window
  505. virtual void setNotifyWindow(ifc_window *newnotify);
  506. virtual ifc_window *getNotifyWindow();
  507. virtual double getRenderRatio();
  508. virtual void setRenderRatio(double r);
  509. virtual void onRatioChanged() {}
  510. virtual void setRatioLinked(int l);
  511. virtual int handleRatio();
  512. int renderRatioActive();
  513. void multRatio(int *x, int *y=NULL);
  514. void multRatio(RECT *r);
  515. void divRatio(int *x, int *y=NULL);
  516. void divRatio(RECT *r);
  517. virtual int isClickThrough();
  518. virtual void setClickThrough(int ct);
  519. virtual ifc_window *getForwardWnd() { return this; }
  520. virtual void setNoLeftClicks(int no);
  521. virtual void setNoRightClicks(int no);
  522. virtual void setNoDoubleClicks(int no);
  523. virtual void setNoMouseMoves(int no);
  524. virtual void setNoContextMenus(int no);
  525. // these functions are override that can be changed via XML. They are not intended to describe how your wnd should receive its messages, they are here rather
  526. // to allow a skinner to disable part of the functionality of an object (ie: removing the context menu via nocontextmenu="1").
  527. virtual int wantDoubleClicks() { return !nodoubleclick; }
  528. virtual int wantLeftClicks() { return !noleftclick; }
  529. virtual int wantRightClicks() { return !norightclick; }
  530. virtual int wantMouseMoves() { return !nomousemove; }
  531. virtual int wantContextMenus() { return !nocontextmnu; }
  532. // DERIVED WINDOW BEHAVIORAL PREFERENCES
  533. protected:
  534. // return 1 to get onMouseOver even if mouse isn't captured
  535. virtual int wantSiblingInvalidations();
  536. virtual int wantFocus();
  537. virtual int wantAutoContextMenu(); // return 1 if you want to auto popup the main app context menu
  538. protected:
  539. void onTipMouseMove();
  540. void renderBaseTexture(ifc_canvas *c, const RECT &r, int alpha=255);
  541. void rootwnd_renderBaseTexture(ifc_canvas *c, const RECT *r, int alpha=255) { renderBaseTexture(c, *r, alpha); }
  542. int getTabOrderEntry(ifc_window *w);
  543. void delTabOrderEntry(int i);
  544. int getTabOrderEntry(float order);
  545. void delTabOrderEntry(ifc_window *w);
  546. virtual OSCURSORHANDLE getCustomCursor(int x, int y);
  547. public:
  548. virtual ifc_window *getBaseTextureWindow();
  549. void setBaseTextureWindow(ifc_window *w);
  550. virtual int isMouseOver(int x, int y);
  551. virtual void bringVirtualToFront(ifc_window *w);
  552. virtual void bringVirtualToBack(ifc_window *w);
  553. virtual void bringVirtualAbove(ifc_window *w, ifc_window *b);
  554. virtual void bringVirtualBelow(ifc_window *w, ifc_window *b);
  555. void changeChildZorder(ifc_window *w, int newpos);
  556. //CUT static int isDesktopAlphaAvailable();
  557. //CUT static int isTransparencyAvailable();
  558. virtual int handleTransparency(); // return 0 if you use overlay mode to render your stuff
  559. virtual int runModal();
  560. virtual int exec() { return runModal(); }
  561. virtual void endModal(int ret);
  562. ifc_dependent *rootwnd_getDependencyPtr();
  563. ifc_dependent *timerclient_getDependencyPtr();
  564. virtual void signalMinMaxEnforcerChanged(void);
  565. virtual void onMinMaxEnforcerChanged(void) {}
  566. virtual void addMinMaxEnforcer(ifc_window *w);
  567. virtual void removeMinMaxEnforcer(ifc_window *w);
  568. virtual ifc_window *enumMinMaxEnforcer(int n);
  569. virtual int getNumMinMaxEnforcers();
  570. virtual int onAction(const wchar_t *action, const wchar_t *param=NULL, int x=-1, int y=-1, intptr_t p1=0, intptr_t p2=0, void *data=NULL, size_t datalen=0, ifc_window *source=NULL);
  571. virtual int sendAction(ifc_window *target, const wchar_t *action, const wchar_t *param=NULL, int x=0, int y=0, intptr_t p1=0, intptr_t p2=0, void *data=NULL, size_t datalen=0);
  572. virtual void setRenderBaseTexture(int r);
  573. virtual int getRenderBaseTexture();
  574. virtual GuiObject *getGuiObject();
  575. void setAutoResizeAfterInit(int tf) { want_autoresize_after_init = tf; }
  576. virtual void setAllowDeactivation(int allow) { allow_deactivate = allow; }
  577. virtual int allowDeactivation();
  578. int getNumTabs();
  579. ifc_window *enumTab(int i);
  580. virtual void onSetRootFocus(ifc_window *w);
  581. virtual int wantActivation() { return 1; } // return 0 if you don't want activation upon click
  582. virtual Accessible *getAccessibleObject(int createifnotexists=1);
  583. virtual int accessibility_getState();
  584. #ifdef EXPERIMENTAL_INDEPENDENT_AOT
  585. virtual void setAlwaysOnTop(int i);
  586. virtual int getAlwaysOnTop();
  587. #endif
  588. virtual void wndwatcher_onDeleteWindow(ifc_window *w);
  589. virtual void setOSModuleHandle(OSMODULEHANDLE module) { hinstance = module; }
  590. #ifndef WA3COMPATIBILITY
  591. virtual void setDropTarget(void *dt);
  592. virtual void *getDropTarget();
  593. #endif
  594. virtual void pushWindowRect();
  595. virtual int popWindowRect(RECT *rc=NULL, int applyhow=PWR_DIMENTIONS|PWR_POSITION);
  596. virtual void maximize(int axis=MAXIMIZE_WIDTH|MAXIMIZE_HEIGHT);
  597. virtual void restore(int what=RESTORE_X|RESTORE_Y|RESTORE_WIDTH|RESTORE_HEIGHT);
  598. virtual int getRestoredRect(RECT *r);
  599. virtual void setRestoredRect(RECT *r); // turns maximized state on automatically
  600. virtual int forcedOnResize();
  601. virtual void forcedOnResizeChain(ifc_window *w);
  602. protected:
  603. void setForeignWnd(int i); // set to 1 if this basewnd was wrapped around an OSWINDOWHANDLE
  604. // this means mainly that the destructor will not destroy the window handle.
  605. protected:
  606. // ATTENTION: note the capitalization on these -- so as not to mix up with
  607. // wndProc()'s hWnd
  608. OSMODULEHANDLE hinstance;
  609. OSWINDOWHANDLE hwnd;
  610. private:
  611. ifc_window *parentWnd;
  612. int inputCaptured;
  613. void onTab();
  614. //CUT HWND createWindow(int x, int y, int w, int h, int nochild, HWND parent, HINSTANCE hinstance);
  615. void recursive_setVirtualTabOrder(ifc_window *w, float a, float lambda=TABORDER_K);
  616. void recursive_buildTabList(ifc_window *from, PtrList<ifc_window> *list);
  617. RECT restore_rect;
  618. int maximized;
  619. protected:
  620. void dropVirtualCanvas();
  621. int bufferizeLockedUIMsg(int uMsg, int wParam, int lParam);
  622. void clearBufferizedUI() { bufferedmsgs.removeAll(); }
  623. void checkLockedUI();
  624. int checkModal();
  625. void hintDestroying() { destroying=TRUE; } // call that in your destructor if you'd otherwise generate virtual calls after your destructor
  626. virtual int forceTransparencyFlag();
  627. int dragging;
  628. Canvas *virtualCanvas;
  629. void updateWindowRegion();
  630. int isWindowRegionValid() { return !wndregioninvalid; }
  631. virtual int wantRedrawOnResize() { return 1; }
  632. int ensureWindowRegionValid();
  633. int disable_tooltip_til_recapture;
  634. virtual int reinit(); // calls reinit(api_window *parWnd, int nochild);
  635. virtual int reinit(ifc_window *parWnd, int nochild); // calls reinit(OSMODULEHANDLE moduleHandle, OSWINDOWHANDLE parent, int nochild);
  636. virtual int reinit(OSMODULEHANDLE moduleHandle, OSWINDOWHANDLE parent, int nochild);
  637. int inonresize;
  638. virtual void onBeforeReinit() {}
  639. virtual void onAfterReinit() {}
  640. StringW tip;
  641. private:
  642. void reparentHWNDChildren();
  643. void redrawHWNDChildren();
  644. void unparentHWNDChildren();
  645. #ifdef EXPERIMENTAL_INDEPENDENT_AOT
  646. void saveTopMosts();
  647. void restoreTopMosts();
  648. #endif
  649. void _cascadeRepaintRgn(api_region *rg);
  650. void packCascadeRepaintRgn(api_region *rg);
  651. int createTip();
  652. void destroyTip(); // called in destructor, do not override
  653. PtrList<DragSet> dragsets;
  654. ifc_window *prevtarg;
  655. StringW suggestedTitle;
  656. typedef struct {
  657. int msg;
  658. int wparam;
  659. int lparam;
  660. } bufferedMsgStruct;
  661. TList<bufferedMsgStruct> bufferedmsgs;
  662. int uiwaslocked;
  663. void onTip();
  664. //FG
  665. int start_hidden;
  666. svc_toolTipsRenderer *tipsvc;
  667. int tipid;
  668. bool tip_done;
  669. bool tipawaytimer;
  670. bool tipshowtimer;
  671. bool tipbeenchecked;
  672. bool tipdestroytimer;
  673. //FG
  674. bool ncb;
  675. uint32_t lastClick[2];
  676. POINT lastClickP[2];
  677. //FG
  678. ifc_window *btexture;
  679. //FG
  680. ifc_window *notifyWindow;
  681. bool destroying;
  682. //CT:Virtual children
  683. PtrList<ifc_window> virtualChildren;
  684. PtrList<ifc_window> rootwndchildren; //FG
  685. int virtualCanvasHandled;
  686. int virtualCanvasH,virtualCanvasW;
  687. int rwidth, rheight, rx, ry;
  688. ifc_window *curVirtualChildCaptured;
  689. //FG>
  690. RegionI *deferedInvalidRgn;
  691. OSWINDOWHANDLE oldCapture;
  692. int hasfocus;
  693. ifc_window *curVirtualChildFocus;
  694. double ratio;
  695. int skin_id;
  696. int wndalpha;
  697. int w2k_alpha;
  698. int curframerate;
  699. int notifyid;
  700. int activealpha;
  701. int inactivealpha;
  702. int clickthrough;
  703. int triedtipsvc;
  704. int mustquit;
  705. int returnvalue;
  706. int postoninit;
  707. int inited;
  708. int skipnextfocus;
  709. RegionI *subtractorrgn, *composedrgn;
  710. void setWindowRegion(api_region *r);
  711. void computeComposedRegion();
  712. void assignWindowRegion(api_region *wr);
  713. int wndregioninvalid;
  714. int rectrgn, regionop;
  715. RegionI *deferedCascadeRepaintRgn;
  716. int need_flush_cascaderepaint;
  717. Tooltip *tooltip;
  718. PtrList<ifc_window> minmaxEnforcers;
  719. int this_visible;
  720. int renderbasetexture;
  721. GuiObject *my_guiobject;
  722. int want_autoresize_after_init;
  723. int resizecount;
  724. double lastratio;
  725. int suggested_w, suggested_h;
  726. int maximum_w, maximum_h;
  727. int minimum_w, minimum_h;
  728. int allow_deactivate;
  729. int minimized;
  730. int deleting;
  731. int preventcancelcapture;
  732. StringW tcname;
  733. int focus_on_click;
  734. PtrListQuickSorted<TabOrderEntry, TabOrderSort> childtabs;
  735. ifc_window *rootfocus;
  736. int ratiolinked;
  737. int nodoubleclick, noleftclick, norightclick, nomousemove, nocontextmnu;
  738. Cursor *customdefaultcursor;
  739. Accessible *accessible;
  740. StringW osname;
  741. int focusEventsEnabled;
  742. PtrList<ifc_window> ontoplist;
  743. int alwaysontop;
  744. WndWatcher rootfocuswatcher;
  745. int cloaked;
  746. int m_takenOver;
  747. int this_enabled;
  748. int has_alpha_flag;
  749. RECT *commitfb_rect;
  750. PtrList<ReparentWndEntry> reparentwnds;
  751. #ifndef WA3COMPATIBILITY
  752. void *m_target;
  753. #endif
  754. int lastnullregion;
  755. Stack<RECT> windowrectstack;
  756. TList<OSWINDOWHANDLE> ghosthwnd;
  757. int ghostbust;
  758. OSWINDOWHANDLE lastActiveWnd;
  759. };
  760. #ifdef WIN32
  761. __inline HINSTANCE HINSTANCEfromHWND(HWND wnd) {
  762. if (wnd == NULL) return NULL;
  763. return (HINSTANCE)(LONG_PTR)GetWindowLongPtrW(wnd, GWLP_HINSTANCE);
  764. }
  765. #endif
  766. #endif