]>
git.saurik.com Git - wxWidgets.git/blob - include/wx/palmos/window.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/palmos/window.h
3 // Purpose: wxWindow class
4 // Author: William Osborne
8 // Copyright: (c) William Osborne
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
15 // ---------------------------------------------------------------------------
17 // ---------------------------------------------------------------------------
19 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
20 #pragma interface "window.h"
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
27 // a better solution should be found later...
28 #define wxUSE_MOUSEEVENT_HACK 0
30 // ---------------------------------------------------------------------------
31 // wxWindow declaration for Palm
32 // ---------------------------------------------------------------------------
34 class WXDLLEXPORT wxWindowPalm
: public wxWindowBase
37 wxWindowPalm() { Init(); }
39 wxWindowPalm(wxWindow
*parent
,
41 const wxPoint
& pos
= wxDefaultPosition
,
42 const wxSize
& size
= wxDefaultSize
,
44 const wxString
& name
= wxPanelNameStr
)
47 Create(parent
, id
, pos
, size
, style
, name
);
50 virtual ~wxWindowPalm();
52 bool Create(wxWindow
*parent
,
54 const wxPoint
& pos
= wxDefaultPosition
,
55 const wxSize
& size
= wxDefaultSize
,
57 const wxString
& name
= wxPanelNameStr
);
59 // implement base class pure virtuals
60 virtual void SetTitle( const wxString
& title
);
61 virtual wxString
GetTitle() const;
66 virtual bool Show( bool show
= true );
67 virtual bool Enable( bool enable
= true );
69 virtual void SetFocus();
70 virtual void SetFocusFromKbd();
72 virtual bool Reparent(wxWindowBase
*newParent
);
74 virtual void WarpPointer(int x
, int y
);
76 virtual void Refresh( bool eraseBackground
= true,
77 const wxRect
*rect
= (const wxRect
*) NULL
);
78 virtual void Update();
79 virtual void Freeze();
82 virtual void SetWindowStyleFlag( long style
);
83 virtual bool SetCursor( const wxCursor
&cursor
);
84 virtual bool SetFont( const wxFont
&font
);
86 virtual int GetCharHeight() const;
87 virtual int GetCharWidth() const;
88 virtual void GetTextExtent(const wxString
& string
,
90 int *descent
= (int *) NULL
,
91 int *externalLeading
= (int *) NULL
,
92 const wxFont
*theFont
= (const wxFont
*) NULL
)
95 #if wxUSE_MENUS_NATIVE
96 virtual bool DoPopupMenu( wxMenu
*menu
, int x
, int y
);
97 #endif // wxUSE_MENUS_NATIVE
99 virtual void SetScrollbar( int orient
, int pos
, int thumbVisible
,
100 int range
, bool refresh
= true );
101 virtual void SetScrollPos( int orient
, int pos
, bool refresh
= true );
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
);
108 virtual bool ScrollLines(int lines
);
109 virtual bool ScrollPages(int pages
);
111 #if wxUSE_DRAG_AND_DROP
112 virtual void SetDropTarget( wxDropTarget
*dropTarget
);
113 #endif // wxUSE_DRAG_AND_DROP
115 // Accept files for dragging
116 virtual void DragAcceptFiles(bool accept
);
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__
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
133 // implementation from now on
134 // --------------------------
139 WXHWND
GetHWND() const { return m_hWnd
; }
140 void SetHWND(WXHWND hWnd
) { m_hWnd
= hWnd
; }
141 virtual WXWidget
GetHandle() const { return GetHWND(); }
146 void OnEraseBackground(wxEraseEvent
& event
);
147 void OnPaint(wxPaintEvent
& event
);
150 // For implementation purposes - sometimes decorations make the client area
152 virtual wxPoint
GetClientAreaOrigin() const;
154 // Windows subclassing
155 void SubclassWin(WXHWND hWnd
);
156 void UnsubclassWin();
158 WXFARPROC
PalmGetOldWndProc() const { return m_oldWndProc
; }
159 void PalmSetOldWndProc(WXFARPROC proc
) { m_oldWndProc
= proc
; }
161 // return true if the window is of a standard (i.e. not wxWidgets') class
163 // to understand why does it work, look at SubclassWin() code and comments
164 bool IsOfStandardClass() const { return m_oldWndProc
!= NULL
; }
166 wxWindow
*FindItem(long id
) const;
167 wxWindow
*FindItemByHWND(WXHWND hWnd
, bool controlOnly
= false) const;
169 // Palm only: true if this control is part of the main control
170 virtual bool ContainsHWND(WXHWND
WXUNUSED(hWnd
)) const { return false; };
172 // translate wxWidgets style flags for this control into the Windows style
173 // and optional extended style for the corresponding native control
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 ;
179 // get the Palm window flags corresponding to wxWidgets ones
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
); }
186 // translate wxWidgets coords into Windows ones suitable to be passed to
189 // returns true if non default coords are returned, false otherwise
190 bool PalmGetCreateWindowCoords(const wxPoint
& pos
,
193 int& w
, int& h
) const;
195 // get the HWND to be used as parent of this window with CreateWindow()
196 virtual WXHWND
PalmGetParent() const;
198 // creates the window of specified Windows class with given style, extended
199 // style, title and geometry (default values
201 // returns true if the window has been created, false if creation failed
202 bool PalmCreate(const wxChar
*wclass
,
203 const wxChar
*title
= NULL
,
204 const wxPoint
& pos
= wxDefaultPosition
,
205 const wxSize
& size
= wxDefaultSize
,
207 WXDWORD exendedStyle
= 0);
209 virtual bool PalmCommand(WXUINT param
, WXWORD id
);
211 #ifndef __WXUNIVERSAL__
212 // Create an appropriate wxWindow from a HWND
213 virtual wxWindow
* CreateWindowFromHWND(wxWindow
* parent
, WXHWND hWnd
);
215 // Make sure the window style reflects the HWND style (roughly)
216 virtual void AdoptAttributesFromHWND();
217 #endif // __WXUNIVERSAL__
219 // Setup background and foreground colours correctly
220 virtual void SetupColours();
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 // ------------------------------------------------------------------------
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
);
239 // ------------------------------------------------------------------------
240 // internal handlers for Palm messages: all handlers return a boolean value:
241 // true means that the handler processed the event and false that it didn't
242 // ------------------------------------------------------------------------
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.
251 // scroll event (both horizontal and vertical)
252 virtual bool PalmOnScroll(int orientation
, WXWORD nSBCode
,
253 WXWORD pos
, WXHWND control
);
255 // child control notifications
257 virtual bool PalmOnNotify(int idCtrl
, WXLPARAM lParam
, WXLPARAM
*result
);
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
);
264 // the rest are not virtual
265 bool HandleCreate(WXLPCREATESTRUCT cs
, bool *mayCreate
);
266 bool HandleInitDialog(WXHWND hWndFocus
);
267 bool HandleDestroy();
270 bool HandleEraseBkgnd(WXHDC pDC
);
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
);
278 bool HandleShow(bool show
, int status
);
279 bool HandleActivate(int flag
, bool minimized
, WXHWND activate
);
281 bool HandleCommand(WXWORD id
, WXWORD cmd
, WXHWND control
);
283 bool HandleCtlColor(WXHBRUSH
*hBrush
,
291 bool HandlePaletteChanged(WXHWND hWndPalChange
);
292 bool HandleQueryNewPalette();
293 bool HandleSysColorChange();
294 bool HandleDisplayChange();
295 bool HandleCaptureChanged(WXHWND gainedCapture
);
297 bool HandleQueryEndSession(long logOff
, bool *mayEnd
);
298 bool HandleEndSession(bool endSession
, long logOff
);
300 bool HandleSetFocus(WXHWND wnd
);
301 bool HandleKillFocus(WXHWND wnd
);
303 bool HandleDropFiles(WXWPARAM wParam
);
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
);
309 bool HandleChar(WXWPARAM wParam
, WXLPARAM lParam
, bool isASCII
= false);
310 bool HandleKeyDown(WXWPARAM wParam
, WXLPARAM lParam
);
311 bool HandleKeyUp(WXWPARAM wParam
, WXLPARAM lParam
);
313 bool HandleHotKey(WXWPARAM wParam
, WXLPARAM lParam
);
316 bool HandleQueryDragIcon(WXHICON
*hIcon
);
318 bool HandleSetCursor(WXHWND hWnd
, short nHitTest
, int mouseMsg
);
321 virtual WXLRESULT
PalmWindowProc(WXUINT nMsg
, WXWPARAM wParam
, WXLPARAM lParam
);
323 // Calls an appropriate default window procedure
324 virtual WXLRESULT
PalmDefWindowProc(WXUINT nMsg
, WXWPARAM wParam
, WXLPARAM lParam
);
326 // message processing helpers
328 // return false if the message shouldn't be translated/preprocessed but
329 // dispatched normally
330 virtual bool PalmShouldPreProcessMessage(WXMSG
* pMsg
);
332 // return true if the message was preprocessed and shouldn't be dispatched
333 virtual bool PalmProcessMessage(WXMSG
* pMsg
);
335 // return true if the message was translated and shouldn't be dispatched
336 virtual bool PalmTranslateMessage(WXMSG
* pMsg
);
338 // called when the window is about to be destroyed
339 virtual void PalmDestroyWindow();
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
,
350 // Responds to colour changes: passes event on to children.
351 void OnSysColourChanged(wxSysColourChangedEvent
& event
);
353 // initialize various fields of wxMouseEvent (common part of PalmOnMouseXXX)
354 void InitMouseEvent(wxMouseEvent
& event
, int x
, int y
, WXUINT flags
);
356 // check if mouse is in the window
357 bool IsMouseInWindow() const;
359 // virtual function for implementing internal idle
361 virtual void OnInternalIdle() ;
368 FormType
*GetFormPtr();
369 void SetFormPtr(FormType
*FormPtr
);
371 // the old window proc (we subclass all windows)
372 WXFARPROC m_oldWndProc
;
374 // additional (Palm specific) flags
375 bool m_mouseInWindow
:1;
376 bool m_lastKeydownProcessed
:1;
378 // the size of one page for scrolling
382 #if wxUSE_MOUSEEVENT_HACK
383 // the coordinates of the last mouse event and the type of it
386 int m_lastMouseEvent
;
387 #endif // wxUSE_MOUSEEVENT_HACK
389 WXHMENU m_hMenu
; // Menu, if any
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
);
402 virtual void DoCaptureMouse();
403 virtual void DoReleaseMouse();
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
);
412 virtual void DoSetToolTip( wxToolTip
*tip
);
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
,
418 const wxString
& ttip
);
419 #endif // wxUSE_TOOLTIPS
421 // the helper functions used by HandleChar/KeyXXX methods
422 wxKeyEvent
CreateKeyEvent(wxEventType evType
, int id
,
423 WXLPARAM lParam
= 0, WXWPARAM wParam
= 0) const;
426 // common part of all ctors
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
);
435 bool HandleNotify(int idCtrl
, WXLPARAM lParam
, WXLPARAM
*result
);
438 // list of disabled children before last call to our Disable()
439 wxWindowList
*m_childrenDisabled
;
441 // number of calls to Freeze() minus number of calls to Thaw()
442 unsigned int m_frozenness
;
444 DECLARE_DYNAMIC_CLASS(wxWindowPalm
)
445 DECLARE_NO_COPY_CLASS(wxWindowPalm
)
446 DECLARE_EVENT_TABLE()
449 // ---------------------------------------------------------------------------
451 // ---------------------------------------------------------------------------
453 // kbd code translation
454 WXDLLEXPORT
int wxCharCodePalmToWX(int keySym
, WXLPARAM lParam
= 0);
455 WXDLLEXPORT
int wxCharCodeWXToPalm(int id
, bool *IsVirtual
);
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
460 class wxWindowCreationHook
463 wxWindowCreationHook(wxWindowPalm
*winBeingCreated
);
464 ~wxWindowCreationHook();
467 // ----------------------------------------------------------------------------
469 // ----------------------------------------------------------------------------
471 // notice that this hash must be defined after wxWindow declaration as it
472 // needs to "see" its dtor and not just forward declaration
475 // pseudo-template HWND <-> wxWindow hash table
476 WX_DECLARE_HASH(wxWindowPalm
, wxWindowList
, wxWinHashTable
);
478 extern wxWinHashTable
*wxWinHandleHash
;