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