]> git.saurik.com Git - wxWidgets.git/blob - include/wx/palmos/window.h
Added wxEXEC_NODISABLE flag
[wxWidgets.git] / include / wx / palmos / window.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/palmos/window.h
3 // Purpose: wxWindow class
4 // Author: William Osborne
5 // Modified by:
6 // Created: 10/13/04
7 // RCS-ID: $Id:
8 // Copyright: (c) William Osborne
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_WINDOW_H_
13 #define _WX_WINDOW_H_
14
15 // ---------------------------------------------------------------------------
16 // headers
17 // ---------------------------------------------------------------------------
18
19 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
20 #pragma interface "window.h"
21 #endif
22
23 // [at least] some version of Windows send extra mouse move messages after
24 // a mouse click or a key press - to temporarily fix this problem, set the
25 // define below to 1
26 //
27 // a better solution should be found later...
28 #define wxUSE_MOUSEEVENT_HACK 0
29
30 // ---------------------------------------------------------------------------
31 // constants
32 // ---------------------------------------------------------------------------
33
34 #if WXWIN_COMPATIBILITY_2_4
35 // they're unused by wxWidgets...
36 enum
37 {
38 wxKEY_SHIFT = 1,
39 wxKEY_CTRL = 2
40 };
41 #endif
42
43 // ---------------------------------------------------------------------------
44 // wxWindow declaration for Palm
45 // ---------------------------------------------------------------------------
46
47 class WXDLLEXPORT wxWindowPalm : public wxWindowBase
48 {
49 public:
50 wxWindowPalm() { Init(); }
51
52 wxWindowPalm(wxWindow *parent,
53 wxWindowID id,
54 const wxPoint& pos = wxDefaultPosition,
55 const wxSize& size = wxDefaultSize,
56 long style = 0,
57 const wxString& name = wxPanelNameStr)
58 {
59 Init();
60 Create(parent, id, pos, size, style, name);
61 }
62
63 virtual ~wxWindowPalm();
64
65 bool Create(wxWindow *parent,
66 wxWindowID id,
67 const wxPoint& pos = wxDefaultPosition,
68 const wxSize& size = wxDefaultSize,
69 long style = 0,
70 const wxString& name = wxPanelNameStr);
71
72 // implement base class pure virtuals
73 virtual void SetTitle( const wxString& title);
74 virtual wxString GetTitle() const;
75
76 virtual void Raise();
77 virtual void Lower();
78
79 virtual bool Show( bool show = true );
80 virtual bool Enable( bool enable = true );
81
82 virtual void SetFocus();
83 virtual void SetFocusFromKbd();
84
85 virtual bool Reparent(wxWindowBase *newParent);
86
87 virtual void WarpPointer(int x, int y);
88
89 virtual void Refresh( bool eraseBackground = true,
90 const wxRect *rect = (const wxRect *) NULL );
91 virtual void Update();
92 virtual void Freeze();
93 virtual void Thaw();
94
95 virtual void SetWindowStyleFlag( long style );
96 virtual bool SetCursor( const wxCursor &cursor );
97 virtual bool SetFont( const wxFont &font );
98
99 virtual int GetCharHeight() const;
100 virtual int GetCharWidth() const;
101 virtual void GetTextExtent(const wxString& string,
102 int *x, int *y,
103 int *descent = (int *) NULL,
104 int *externalLeading = (int *) NULL,
105 const wxFont *theFont = (const wxFont *) NULL)
106 const;
107
108 #if wxUSE_MENUS_NATIVE
109 virtual bool DoPopupMenu( wxMenu *menu, int x, int y );
110 #endif // wxUSE_MENUS_NATIVE
111
112 virtual void SetScrollbar( int orient, int pos, int thumbVisible,
113 int range, bool refresh = true );
114 virtual void SetScrollPos( int orient, int pos, bool refresh = true );
115 virtual int GetScrollPos( int orient ) const;
116 virtual int GetScrollThumb( int orient ) const;
117 virtual int GetScrollRange( int orient ) const;
118 virtual void ScrollWindow( int dx, int dy,
119 const wxRect* rect = (wxRect *) NULL );
120
121 virtual bool ScrollLines(int lines);
122 virtual bool ScrollPages(int pages);
123
124 #if wxUSE_DRAG_AND_DROP
125 virtual void SetDropTarget( wxDropTarget *dropTarget );
126 #endif // wxUSE_DRAG_AND_DROP
127
128 // Accept files for dragging
129 virtual void DragAcceptFiles(bool accept);
130
131 #if WXWIN_COMPATIBILITY_2_4
132 wxDEPRECATED( bool GetUseCtl3D() const );
133 wxDEPRECATED( bool GetTransparentBackground() const );
134 wxDEPRECATED( void SetTransparent(bool t = true) );
135 #endif // WXWIN_COMPATIBILITY_2_4
136
137 #ifndef __WXUNIVERSAL__
138 // Native resource loading (implemented in src/Palm/nativdlg.cpp)
139 // FIXME: should they really be all virtual?
140 virtual bool LoadNativeDialog(wxWindow* parent, wxWindowID& id);
141 virtual bool LoadNativeDialog(wxWindow* parent, const wxString& name);
142 wxWindow* GetWindowChild1(wxWindowID id);
143 wxWindow* GetWindowChild(wxWindowID id);
144 #endif // __WXUNIVERSAL__
145
146 #if wxUSE_HOTKEY
147 // install and deinstall a system wide hotkey
148 virtual bool RegisterHotKey(int hotkeyId, int modifiers, int keycode);
149 virtual bool UnregisterHotKey(int hotkeyId);
150 #endif // wxUSE_HOTKEY
151
152 // implementation from now on
153 // --------------------------
154
155 // simple accessors
156 // ----------------
157
158 WXHWND GetHWND() const { return m_hWnd; }
159 void SetHWND(WXHWND hWnd) { m_hWnd = hWnd; }
160 virtual WXWidget GetHandle() const { return GetHWND(); }
161
162 // event handlers
163 // --------------
164
165 void OnEraseBackground(wxEraseEvent& event);
166 void OnPaint(wxPaintEvent& event);
167
168 public:
169 // For implementation purposes - sometimes decorations make the client area
170 // smaller
171 virtual wxPoint GetClientAreaOrigin() const;
172
173 // Windows subclassing
174 void SubclassWin(WXHWND hWnd);
175 void UnsubclassWin();
176
177 WXFARPROC PalmGetOldWndProc() const { return m_oldWndProc; }
178 void PalmSetOldWndProc(WXFARPROC proc) { m_oldWndProc = proc; }
179
180 // return true if the window is of a standard (i.e. not wxWidgets') class
181 //
182 // to understand why does it work, look at SubclassWin() code and comments
183 bool IsOfStandardClass() const { return m_oldWndProc != NULL; }
184
185 wxWindow *FindItem(long id) const;
186 wxWindow *FindItemByHWND(WXHWND hWnd, bool controlOnly = false) const;
187
188 // Palm only: true if this control is part of the main control
189 virtual bool ContainsHWND(WXHWND WXUNUSED(hWnd)) const { return false; };
190
191 // translate wxWidgets style flags for this control into the Windows style
192 // and optional extended style for the corresponding native control
193 //
194 // this is the function that should be overridden in the derived classes,
195 // but you will mostly use PalmGetCreateWindowFlags() below
196 virtual WXDWORD PalmGetStyle(long flags, WXDWORD *exstyle = NULL) const ;
197
198 // get the Palm window flags corresponding to wxWidgets ones
199 //
200 // the functions returns the flags (WS_XXX) directly and puts the ext
201 // (WS_EX_XXX) flags into the provided pointer if not NULL
202 WXDWORD PalmGetCreateWindowFlags(WXDWORD *exflags = NULL) const
203 { return PalmGetStyle(GetWindowStyle(), exflags); }
204
205 // translate wxWidgets coords into Windows ones suitable to be passed to
206 // ::CreateWindow()
207 //
208 // returns true if non default coords are returned, false otherwise
209 bool PalmGetCreateWindowCoords(const wxPoint& pos,
210 const wxSize& size,
211 int& x, int& y,
212 int& w, int& h) const;
213
214 // get the HWND to be used as parent of this window with CreateWindow()
215 virtual WXHWND PalmGetParent() const;
216
217 // creates the window of specified Windows class with given style, extended
218 // style, title and geometry (default values
219 //
220 // returns true if the window has been created, false if creation failed
221 bool PalmCreate(const wxChar *wclass,
222 const wxChar *title = NULL,
223 const wxPoint& pos = wxDefaultPosition,
224 const wxSize& size = wxDefaultSize,
225 WXDWORD style = 0,
226 WXDWORD exendedStyle = 0);
227
228 virtual bool PalmCommand(WXUINT param, WXWORD id);
229
230 #ifndef __WXUNIVERSAL__
231 // Create an appropriate wxWindow from a HWND
232 virtual wxWindow* CreateWindowFromHWND(wxWindow* parent, WXHWND hWnd);
233
234 // Make sure the window style reflects the HWND style (roughly)
235 virtual void AdoptAttributesFromHWND();
236 #endif // __WXUNIVERSAL__
237
238 // Setup background and foreground colours correctly
239 virtual void SetupColours();
240
241 // ------------------------------------------------------------------------
242 // helpers for message handlers: these perform the same function as the
243 // message crackers from <windowsx.h> - they unpack WPARAM and LPARAM into
244 // the correct parameters
245 // ------------------------------------------------------------------------
246
247 void UnpackCommand(WXWPARAM wParam, WXLPARAM lParam,
248 WXWORD *id, WXHWND *hwnd, WXWORD *cmd);
249 void UnpackActivate(WXWPARAM wParam, WXLPARAM lParam,
250 WXWORD *state, WXWORD *minimized, WXHWND *hwnd);
251 void UnpackScroll(WXWPARAM wParam, WXLPARAM lParam,
252 WXWORD *code, WXWORD *pos, WXHWND *hwnd);
253 void UnpackCtlColor(WXWPARAM wParam, WXLPARAM lParam,
254 WXWORD *nCtlColor, WXHDC *hdc, WXHWND *hwnd);
255 void UnpackMenuSelect(WXWPARAM wParam, WXLPARAM lParam,
256 WXWORD *item, WXWORD *flags, WXHMENU *hmenu);
257
258 // ------------------------------------------------------------------------
259 // internal handlers for Palm messages: all handlers return a boolean value:
260 // true means that the handler processed the event and false that it didn't
261 // ------------------------------------------------------------------------
262
263 // there are several cases where we have virtual functions for Windows
264 // message processing: this is because these messages often require to be
265 // processed in a different manner in the derived classes. For all other
266 // messages, however, we do *not* have corresponding PalmOnXXX() function
267 // and if the derived class wants to process them, it should override
268 // PalmWindowProc() directly.
269
270 // scroll event (both horizontal and vertical)
271 virtual bool PalmOnScroll(int orientation, WXWORD nSBCode,
272 WXWORD pos, WXHWND control);
273
274 // child control notifications
275 #ifdef __WIN95__
276 virtual bool PalmOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result);
277 #endif // __WIN95__
278
279 // owner-drawn controls need to process these messages
280 virtual bool PalmOnDrawItem(int id, WXDRAWITEMSTRUCT *item);
281 virtual bool PalmOnMeasureItem(int id, WXMEASUREITEMSTRUCT *item);
282
283 // the rest are not virtual
284 bool HandleCreate(WXLPCREATESTRUCT cs, bool *mayCreate);
285 bool HandleInitDialog(WXHWND hWndFocus);
286 bool HandleDestroy();
287
288 bool HandlePaint();
289 bool HandleEraseBkgnd(WXHDC pDC);
290
291 bool HandleMinimize();
292 bool HandleMaximize();
293 bool HandleSize(int x, int y, WXUINT flag);
294 bool HandleSizing(wxRect& rect);
295 bool HandleGetMinMaxInfo(void *mmInfo);
296
297 bool HandleShow(bool show, int status);
298 bool HandleActivate(int flag, bool minimized, WXHWND activate);
299
300 bool HandleCommand(WXWORD id, WXWORD cmd, WXHWND control);
301
302 bool HandleCtlColor(WXHBRUSH *hBrush,
303 WXHDC hdc,
304 WXHWND hWnd,
305 WXUINT nCtlColor,
306 WXUINT message,
307 WXWPARAM wParam,
308 WXLPARAM lParam);
309
310 bool HandlePaletteChanged(WXHWND hWndPalChange);
311 bool HandleQueryNewPalette();
312 bool HandleSysColorChange();
313 bool HandleDisplayChange();
314 bool HandleCaptureChanged(WXHWND gainedCapture);
315
316 bool HandleQueryEndSession(long logOff, bool *mayEnd);
317 bool HandleEndSession(bool endSession, long logOff);
318
319 bool HandleSetFocus(WXHWND wnd);
320 bool HandleKillFocus(WXHWND wnd);
321
322 bool HandleDropFiles(WXWPARAM wParam);
323
324 bool HandleMouseEvent(WXUINT msg, int x, int y, WXUINT flags);
325 bool HandleMouseMove(int x, int y, WXUINT flags);
326 bool HandleMouseWheel(WXWPARAM wParam, WXLPARAM lParam);
327
328 bool HandleChar(WXWPARAM wParam, WXLPARAM lParam, bool isASCII = false);
329 bool HandleKeyDown(WXWPARAM wParam, WXLPARAM lParam);
330 bool HandleKeyUp(WXWPARAM wParam, WXLPARAM lParam);
331 #if wxUSE_ACCEL
332 bool HandleHotKey(WXWPARAM wParam, WXLPARAM lParam);
333 #endif
334
335 bool HandleQueryDragIcon(WXHICON *hIcon);
336
337 bool HandleSetCursor(WXHWND hWnd, short nHitTest, int mouseMsg);
338
339 // Window procedure
340 virtual WXLRESULT PalmWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam);
341
342 // Calls an appropriate default window procedure
343 virtual WXLRESULT PalmDefWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam);
344
345 // message processing helpers
346
347 // return false if the message shouldn't be translated/preprocessed but
348 // dispatched normally
349 virtual bool PalmShouldPreProcessMessage(WXMSG* pMsg);
350
351 // return true if the message was preprocessed and shouldn't be dispatched
352 virtual bool PalmProcessMessage(WXMSG* pMsg);
353
354 // return true if the message was translated and shouldn't be dispatched
355 virtual bool PalmTranslateMessage(WXMSG* pMsg);
356
357 // called when the window is about to be destroyed
358 virtual void PalmDestroyWindow();
359
360 // this function should return the brush to paint the window background
361 // with or 0 for the default brush
362 virtual WXHBRUSH OnCtlColor(WXHDC hDC,
363 WXHWND hWnd,
364 WXUINT nCtlColor,
365 WXUINT message,
366 WXWPARAM wParam,
367 WXLPARAM lParam);
368
369 // Responds to colour changes: passes event on to children.
370 void OnSysColourChanged(wxSysColourChangedEvent& event);
371
372 // initialize various fields of wxMouseEvent (common part of PalmOnMouseXXX)
373 void InitMouseEvent(wxMouseEvent& event, int x, int y, WXUINT flags);
374
375 // check if mouse is in the window
376 bool IsMouseInWindow() const;
377
378 // virtual function for implementing internal idle
379 // behaviour
380 virtual void OnInternalIdle() ;
381
382 protected:
383 // the window handle
384 WXHWND m_hWnd;
385 FormType *FrameForm;
386
387 FormType *GetFormPtr();
388 void SetFormPtr(FormType *FormPtr);
389
390 // the old window proc (we subclass all windows)
391 WXFARPROC m_oldWndProc;
392
393 // additional (Palm specific) flags
394 bool m_mouseInWindow:1;
395 bool m_lastKeydownProcessed:1;
396
397 // the size of one page for scrolling
398 int m_xThumbSize;
399 int m_yThumbSize;
400
401 #if wxUSE_MOUSEEVENT_HACK
402 // the coordinates of the last mouse event and the type of it
403 long m_lastMouseX,
404 m_lastMouseY;
405 int m_lastMouseEvent;
406 #endif // wxUSE_MOUSEEVENT_HACK
407
408 WXHMENU m_hMenu; // Menu, if any
409
410 // implement the base class pure virtuals
411 virtual void DoClientToScreen( int *x, int *y ) const;
412 virtual void DoScreenToClient( int *x, int *y ) const;
413 virtual void DoGetPosition( int *x, int *y ) const;
414 virtual void DoGetSize( int *width, int *height ) const;
415 virtual void DoGetClientSize( int *width, int *height ) const;
416 virtual void DoSetSize(int x, int y,
417 int width, int height,
418 int sizeFlags = wxSIZE_AUTO);
419 virtual void DoSetClientSize(int width, int height);
420
421 virtual void DoCaptureMouse();
422 virtual void DoReleaseMouse();
423
424 // move the window to the specified location and resize it: this is called
425 // from both DoSetSize() and DoSetClientSize() and would usually just call
426 // ::MoveWindow() except for composite controls which will want to arrange
427 // themselves inside the given rectangle
428 virtual void DoMoveWindow(int x, int y, int width, int height);
429
430 #if wxUSE_TOOLTIPS
431 virtual void DoSetToolTip( wxToolTip *tip );
432
433 // process TTN_NEEDTEXT message properly (i.e. fixing the bugs in
434 // comctl32.dll in our code -- see the function body for more info)
435 bool HandleTooltipNotify(WXUINT code,
436 WXLPARAM lParam,
437 const wxString& ttip);
438 #endif // wxUSE_TOOLTIPS
439
440 // the helper functions used by HandleChar/KeyXXX methods
441 wxKeyEvent CreateKeyEvent(wxEventType evType, int id,
442 WXLPARAM lParam = 0, WXWPARAM wParam = 0) const;
443
444 private:
445 // common part of all ctors
446 void Init();
447
448 // the (non-virtual) handlers for the events
449 bool HandleMove(int x, int y);
450 bool HandleMoving(wxRect& rect);
451 bool HandleJoystickEvent(WXUINT msg, int x, int y, WXUINT flags);
452
453 #ifdef __WIN95__
454 bool HandleNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result);
455 #endif // __WIN95__
456
457 // list of disabled children before last call to our Disable()
458 wxWindowList *m_childrenDisabled;
459
460 // number of calls to Freeze() minus number of calls to Thaw()
461 unsigned int m_frozenness;
462
463 DECLARE_DYNAMIC_CLASS(wxWindowPalm)
464 DECLARE_NO_COPY_CLASS(wxWindowPalm)
465 DECLARE_EVENT_TABLE()
466 };
467
468 // ----------------------------------------------------------------------------
469 // inline functions
470 // ----------------------------------------------------------------------------
471
472 #if WXWIN_COMPATIBILITY_2_4
473
474 inline bool wxWindowPalm::GetUseCtl3D() const { return false; }
475 inline bool wxWindowPalm::GetTransparentBackground() const { return false; }
476 inline void wxWindowPalm::SetTransparent(bool WXUNUSED(t)) { }
477
478 #endif // WXWIN_COMPATIBILITY_2_4
479
480 // ---------------------------------------------------------------------------
481 // global functions
482 // ---------------------------------------------------------------------------
483
484 // kbd code translation
485 WXDLLEXPORT int wxCharCodePalmToWX(int keySym, WXLPARAM lParam = 0);
486 WXDLLEXPORT int wxCharCodeWXToPalm(int id, bool *IsVirtual);
487
488 // window creation helper class: before creating a new HWND, instantiate an
489 // object of this class on stack - this allows to process the messages sent to
490 // the window even before CreateWindow() returns
491 class wxWindowCreationHook
492 {
493 public:
494 wxWindowCreationHook(wxWindowPalm *winBeingCreated);
495 ~wxWindowCreationHook();
496 };
497
498 // ----------------------------------------------------------------------------
499 // global objects
500 // ----------------------------------------------------------------------------
501
502 // notice that this hash must be defined after wxWindow declaration as it
503 // needs to "see" its dtor and not just forward declaration
504 #include "wx/hash.h"
505
506 // pseudo-template HWND <-> wxWindow hash table
507 #if WXWIN_COMPATIBILITY_2_4
508 WX_DECLARE_HASH(wxWindow, wxWindowList, wxWinHashTable);
509 #else
510 WX_DECLARE_HASH(wxWindowPalm, wxWindowList, wxWinHashTable);
511 #endif
512
513 extern wxWinHashTable *wxWinHandleHash;
514
515 #endif
516 // _WX_WINDOW_H_