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