]>
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 - minimal working wxPalmOS port
5 // Modified by: Wlodzimierz ABX Skiba - more than minimal functionality
8 // Copyright: (c) William Osborne, Wlodzimierz Skiba
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 // owner-drawn controls need to process these messages
256 virtual bool PalmOnDrawItem(int id
, WXDRAWITEMSTRUCT
*item
);
257 virtual bool PalmOnMeasureItem(int id
, WXMEASUREITEMSTRUCT
*item
);
259 // the rest are not virtual
260 bool HandleCreate(WXLPCREATESTRUCT cs
, bool *mayCreate
);
261 bool HandleInitDialog(WXHWND hWndFocus
);
262 bool HandleDestroy();
265 bool HandleEraseBkgnd(WXHDC pDC
);
267 bool HandleMinimize();
268 bool HandleMaximize();
269 bool HandleSize(int x
, int y
, WXUINT flag
);
270 bool HandleSizing(wxRect
& rect
);
271 bool HandleGetMinMaxInfo(void *mmInfo
);
273 bool HandleShow(bool show
, int status
);
274 bool HandleActivate(int flag
, bool minimized
, WXHWND activate
);
276 bool HandleCommand(WXWORD id
, WXWORD cmd
, WXHWND control
);
278 bool HandleCtlColor(WXHBRUSH
*hBrush
,
286 bool HandlePaletteChanged(WXHWND hWndPalChange
);
287 bool HandleQueryNewPalette();
288 bool HandleSysColorChange();
289 bool HandleDisplayChange();
290 bool HandleCaptureChanged(WXHWND gainedCapture
);
292 bool HandleQueryEndSession(long logOff
, bool *mayEnd
);
293 bool HandleEndSession(bool endSession
, long logOff
);
295 bool HandleSetFocus(WXHWND wnd
);
296 bool HandleKillFocus(WXHWND wnd
);
298 bool HandleDropFiles(WXWPARAM wParam
);
300 bool HandleMouseEvent(WXUINT msg
, int x
, int y
, WXUINT flags
);
301 bool HandleMouseMove(int x
, int y
, WXUINT flags
);
302 bool HandleMouseWheel(WXWPARAM wParam
, WXLPARAM lParam
);
304 bool HandleChar(WXWPARAM wParam
, WXLPARAM lParam
, bool isASCII
= false);
305 bool HandleKeyDown(WXWPARAM wParam
, WXLPARAM lParam
);
306 bool HandleKeyUp(WXWPARAM wParam
, WXLPARAM lParam
);
308 bool HandleHotKey(WXWPARAM wParam
, WXLPARAM lParam
);
311 bool HandleQueryDragIcon(WXHICON
*hIcon
);
313 bool HandleSetCursor(WXHWND hWnd
, short nHitTest
, int mouseMsg
);
316 virtual WXLRESULT
PalmWindowProc(WXUINT nMsg
, WXWPARAM wParam
, WXLPARAM lParam
);
318 // Calls an appropriate default window procedure
319 virtual WXLRESULT
PalmDefWindowProc(WXUINT nMsg
, WXWPARAM wParam
, WXLPARAM lParam
);
321 // message processing helpers
323 // return false if the message shouldn't be translated/preprocessed but
324 // dispatched normally
325 virtual bool PalmShouldPreProcessMessage(WXMSG
* pMsg
);
327 // return true if the message was preprocessed and shouldn't be dispatched
328 virtual bool PalmProcessMessage(WXMSG
* pMsg
);
330 // return true if the message was translated and shouldn't be dispatched
331 virtual bool PalmTranslateMessage(WXMSG
* pMsg
);
333 // called when the window is about to be destroyed
334 virtual void PalmDestroyWindow();
336 // this function should return the brush to paint the window background
337 // with or 0 for the default brush
338 virtual WXHBRUSH
OnCtlColor(WXHDC hDC
,
345 // Responds to colour changes: passes event on to children.
346 void OnSysColourChanged(wxSysColourChangedEvent
& event
);
348 // initialize various fields of wxMouseEvent (common part of PalmOnMouseXXX)
349 void InitMouseEvent(wxMouseEvent
& event
, int x
, int y
, WXUINT flags
);
351 // check if mouse is in the window
352 bool IsMouseInWindow() const;
354 // virtual function for implementing internal idle
356 virtual void OnInternalIdle() ;
363 FormType
*GetFormPtr();
364 void SetFormPtr(FormType
*FormPtr
);
366 // the old window proc (we subclass all windows)
367 WXFARPROC m_oldWndProc
;
369 // additional (Palm specific) flags
370 bool m_mouseInWindow
:1;
371 bool m_lastKeydownProcessed
:1;
373 // the size of one page for scrolling
377 #if wxUSE_MOUSEEVENT_HACK
378 // the coordinates of the last mouse event and the type of it
381 int m_lastMouseEvent
;
382 #endif // wxUSE_MOUSEEVENT_HACK
384 WXHMENU m_hMenu
; // Menu, if any
386 // implement the base class pure virtuals
387 virtual void DoClientToScreen( int *x
, int *y
) const;
388 virtual void DoScreenToClient( int *x
, int *y
) const;
389 virtual void DoGetPosition( int *x
, int *y
) const;
390 virtual void DoGetSize( int *width
, int *height
) const;
391 virtual void DoGetClientSize( int *width
, int *height
) const;
392 virtual void DoSetSize(int x
, int y
,
393 int width
, int height
,
394 int sizeFlags
= wxSIZE_AUTO
);
395 virtual void DoSetClientSize(int width
, int height
);
397 virtual void DoCaptureMouse();
398 virtual void DoReleaseMouse();
400 // move the window to the specified location and resize it: this is called
401 // from both DoSetSize() and DoSetClientSize() and would usually just call
402 // ::MoveWindow() except for composite controls which will want to arrange
403 // themselves inside the given rectangle
404 virtual void DoMoveWindow(int x
, int y
, int width
, int height
);
407 virtual void DoSetToolTip( wxToolTip
*tip
);
409 // process TTN_NEEDTEXT message properly (i.e. fixing the bugs in
410 // comctl32.dll in our code -- see the function body for more info)
411 bool HandleTooltipNotify(WXUINT code
,
413 const wxString
& ttip
);
414 #endif // wxUSE_TOOLTIPS
416 // the helper functions used by HandleChar/KeyXXX methods
417 wxKeyEvent
CreateKeyEvent(wxEventType evType
, int id
,
418 WXLPARAM lParam
= 0, WXWPARAM wParam
= 0) const;
421 // common part of all ctors
424 // the (non-virtual) handlers for the events
425 bool HandleMove(int x
, int y
);
426 bool HandleMoving(wxRect
& rect
);
427 bool HandleJoystickEvent(WXUINT msg
, int x
, int y
, WXUINT flags
);
429 // list of disabled children before last call to our Disable()
430 wxWindowList
*m_childrenDisabled
;
432 // number of calls to Freeze() minus number of calls to Thaw()
433 unsigned int m_frozenness
;
435 DECLARE_DYNAMIC_CLASS(wxWindowPalm
)
436 DECLARE_NO_COPY_CLASS(wxWindowPalm
)
437 DECLARE_EVENT_TABLE()
440 // ---------------------------------------------------------------------------
442 // ---------------------------------------------------------------------------
444 // kbd code translation
445 WXDLLEXPORT
int wxCharCodePalmToWX(int keySym
, WXLPARAM lParam
= 0);
446 WXDLLEXPORT
int wxCharCodeWXToPalm(int id
, bool *IsVirtual
);
448 // window creation helper class: before creating a new HWND, instantiate an
449 // object of this class on stack - this allows to process the messages sent to
450 // the window even before CreateWindow() returns
451 class wxWindowCreationHook
454 wxWindowCreationHook(wxWindowPalm
*winBeingCreated
);
455 ~wxWindowCreationHook();
458 // ----------------------------------------------------------------------------
460 // ----------------------------------------------------------------------------
462 // notice that this hash must be defined after wxWindow declaration as it
463 // needs to "see" its dtor and not just forward declaration
466 // pseudo-template HWND <-> wxWindow hash table
467 WX_DECLARE_HASH(wxWindowPalm
, wxWindowList
, wxWinHashTable
);
469 extern wxWinHashTable
*wxWinHandleHash
;