]>
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 /////////////////////////////////////////////////////////////////////////////
20 // ---------------------------------------------------------------------------
22 // ---------------------------------------------------------------------------
24 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
25 #pragma interface "window.h"
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
32 // a better solution should be found later...
33 #define wxUSE_MOUSEEVENT_HACK 0
35 // ---------------------------------------------------------------------------
37 // ---------------------------------------------------------------------------
39 #if WXWIN_COMPATIBILITY_2_4
40 // they're unused by wxWidgets...
48 // ---------------------------------------------------------------------------
49 // wxWindow declaration for Palm
50 // ---------------------------------------------------------------------------
52 class WXDLLEXPORT wxWindowPalm
: public wxWindowBase
55 wxWindowPalm() { Init(); }
57 wxWindowPalm(wxWindow
*parent
,
59 const wxPoint
& pos
= wxDefaultPosition
,
60 const wxSize
& size
= wxDefaultSize
,
62 const wxString
& name
= wxPanelNameStr
)
65 Create(parent
, id
, pos
, size
, style
, name
);
68 virtual ~wxWindowPalm();
70 bool Create(wxWindow
*parent
,
72 const wxPoint
& pos
= wxDefaultPosition
,
73 const wxSize
& size
= wxDefaultSize
,
75 const wxString
& name
= wxPanelNameStr
);
77 // implement base class pure virtuals
78 virtual void SetTitle( const wxString
& title
);
79 virtual wxString
GetTitle() const;
84 virtual bool Show( bool show
= true );
85 virtual bool Enable( bool enable
= true );
87 virtual void SetFocus();
88 virtual void SetFocusFromKbd();
90 virtual bool Reparent(wxWindowBase
*newParent
);
92 virtual void WarpPointer(int x
, int y
);
94 virtual void Refresh( bool eraseBackground
= true,
95 const wxRect
*rect
= (const wxRect
*) NULL
);
96 virtual void Update();
97 virtual void Freeze();
100 virtual void SetWindowStyleFlag( long style
);
101 virtual bool SetCursor( const wxCursor
&cursor
);
102 virtual bool SetFont( const wxFont
&font
);
104 virtual int GetCharHeight() const;
105 virtual int GetCharWidth() const;
106 virtual void GetTextExtent(const wxString
& string
,
108 int *descent
= (int *) NULL
,
109 int *externalLeading
= (int *) NULL
,
110 const wxFont
*theFont
= (const wxFont
*) NULL
)
113 #if wxUSE_MENUS_NATIVE
114 virtual bool DoPopupMenu( wxMenu
*menu
, int x
, int y
);
115 #endif // wxUSE_MENUS_NATIVE
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
);
126 virtual bool ScrollLines(int lines
);
127 virtual bool ScrollPages(int pages
);
129 #if wxUSE_DRAG_AND_DROP
130 virtual void SetDropTarget( wxDropTarget
*dropTarget
);
131 #endif // wxUSE_DRAG_AND_DROP
133 // Accept files for dragging
134 virtual void DragAcceptFiles(bool accept
);
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
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__
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
157 // implementation from now on
158 // --------------------------
163 WXHWND
GetHWND() const { return m_hWnd
; }
164 void SetHWND(WXHWND hWnd
) { m_hWnd
= hWnd
; }
165 virtual WXWidget
GetHandle() const { return GetHWND(); }
170 void OnEraseBackground(wxEraseEvent
& event
);
171 void OnPaint(wxPaintEvent
& event
);
174 // For implementation purposes - sometimes decorations make the client area
176 virtual wxPoint
GetClientAreaOrigin() const;
178 // Windows subclassing
179 void SubclassWin(WXHWND hWnd
);
180 void UnsubclassWin();
182 WXFARPROC
PalmGetOldWndProc() const { return m_oldWndProc
; }
183 void PalmSetOldWndProc(WXFARPROC proc
) { m_oldWndProc
= proc
; }
185 // return true if the window is of a standard (i.e. not wxWidgets') class
187 // to understand why does it work, look at SubclassWin() code and comments
188 bool IsOfStandardClass() const { return m_oldWndProc
!= NULL
; }
190 wxWindow
*FindItem(long id
) const;
191 wxWindow
*FindItemByHWND(WXHWND hWnd
, bool controlOnly
= false) const;
193 // Palm only: true if this control is part of the main control
194 virtual bool ContainsHWND(WXHWND
WXUNUSED(hWnd
)) const { return false; };
196 // translate wxWidgets style flags for this control into the Windows style
197 // and optional extended style for the corresponding native control
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 ;
203 // get the Palm window flags corresponding to wxWidgets ones
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
); }
210 // translate wxWidgets coords into Windows ones suitable to be passed to
213 // returns true if non default coords are returned, false otherwise
214 bool PalmGetCreateWindowCoords(const wxPoint
& pos
,
217 int& w
, int& h
) const;
219 // get the HWND to be used as parent of this window with CreateWindow()
220 virtual WXHWND
PalmGetParent() const;
222 // creates the window of specified Windows class with given style, extended
223 // style, title and geometry (default values
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
,
231 WXDWORD exendedStyle
= 0);
233 virtual bool PalmCommand(WXUINT param
, WXWORD id
);
235 #ifndef __WXUNIVERSAL__
236 // Create an appropriate wxWindow from a HWND
237 virtual wxWindow
* CreateWindowFromHWND(wxWindow
* parent
, WXHWND hWnd
);
239 // Make sure the window style reflects the HWND style (roughly)
240 virtual void AdoptAttributesFromHWND();
241 #endif // __WXUNIVERSAL__
243 // Setup background and foreground colours correctly
244 virtual void SetupColours();
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 // ------------------------------------------------------------------------
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
);
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 // ------------------------------------------------------------------------
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.
275 // scroll event (both horizontal and vertical)
276 virtual bool PalmOnScroll(int orientation
, WXWORD nSBCode
,
277 WXWORD pos
, WXHWND control
);
279 // child control notifications
281 virtual bool PalmOnNotify(int idCtrl
, WXLPARAM lParam
, WXLPARAM
*result
);
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
);
288 // the rest are not virtual
289 bool HandleCreate(WXLPCREATESTRUCT cs
, bool *mayCreate
);
290 bool HandleInitDialog(WXHWND hWndFocus
);
291 bool HandleDestroy();
294 bool HandleEraseBkgnd(WXHDC pDC
);
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
);
302 bool HandleShow(bool show
, int status
);
303 bool HandleActivate(int flag
, bool minimized
, WXHWND activate
);
305 bool HandleCommand(WXWORD id
, WXWORD cmd
, WXHWND control
);
307 bool HandleCtlColor(WXHBRUSH
*hBrush
,
315 bool HandlePaletteChanged(WXHWND hWndPalChange
);
316 bool HandleQueryNewPalette();
317 bool HandleSysColorChange();
318 bool HandleDisplayChange();
319 bool HandleCaptureChanged(WXHWND gainedCapture
);
321 bool HandleQueryEndSession(long logOff
, bool *mayEnd
);
322 bool HandleEndSession(bool endSession
, long logOff
);
324 bool HandleSetFocus(WXHWND wnd
);
325 bool HandleKillFocus(WXHWND wnd
);
327 bool HandleDropFiles(WXWPARAM wParam
);
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
);
333 bool HandleChar(WXWPARAM wParam
, WXLPARAM lParam
, bool isASCII
= false);
334 bool HandleKeyDown(WXWPARAM wParam
, WXLPARAM lParam
);
335 bool HandleKeyUp(WXWPARAM wParam
, WXLPARAM lParam
);
337 bool HandleHotKey(WXWPARAM wParam
, WXLPARAM lParam
);
340 int HandleMenuChar(int chAccel
, WXLPARAM lParam
);
343 bool HandleQueryDragIcon(WXHICON
*hIcon
);
345 bool HandleSetCursor(WXHWND hWnd
, short nHitTest
, int mouseMsg
);
348 virtual WXLRESULT
PalmWindowProc(WXUINT nMsg
, WXWPARAM wParam
, WXLPARAM lParam
);
350 // Calls an appropriate default window procedure
351 virtual WXLRESULT
PalmDefWindowProc(WXUINT nMsg
, WXWPARAM wParam
, WXLPARAM lParam
);
353 // message processing helpers
355 // return false if the message shouldn't be translated/preprocessed but
356 // dispatched normally
357 virtual bool PalmShouldPreProcessMessage(WXMSG
* pMsg
);
359 // return true if the message was preprocessed and shouldn't be dispatched
360 virtual bool PalmProcessMessage(WXMSG
* pMsg
);
362 // return true if the message was translated and shouldn't be dispatched
363 virtual bool PalmTranslateMessage(WXMSG
* pMsg
);
365 // called when the window is about to be destroyed
366 virtual void PalmDestroyWindow();
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
,
377 // Responds to colour changes: passes event on to children.
378 void OnSysColourChanged(wxSysColourChangedEvent
& event
);
380 // initialize various fields of wxMouseEvent (common part of PalmOnMouseXXX)
381 void InitMouseEvent(wxMouseEvent
& event
, int x
, int y
, WXUINT flags
);
383 // check if mouse is in the window
384 bool IsMouseInWindow() const;
386 // virtual function for implementing internal idle
388 virtual void OnInternalIdle() ;
395 FormType
*GetFormPtr();
396 void SetFormPtr(FormType
*FormPtr
);
398 // the old window proc (we subclass all windows)
399 WXFARPROC m_oldWndProc
;
401 // additional (Palm specific) flags
402 bool m_mouseInWindow
:1;
403 bool m_lastKeydownProcessed
:1;
405 // the size of one page for scrolling
409 #if wxUSE_MOUSEEVENT_HACK
410 // the coordinates of the last mouse event and the type of it
413 int m_lastMouseEvent
;
414 #endif // wxUSE_MOUSEEVENT_HACK
416 WXHMENU m_hMenu
; // Menu, if any
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
);
429 virtual void DoCaptureMouse();
430 virtual void DoReleaseMouse();
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
);
439 virtual void DoSetToolTip( wxToolTip
*tip
);
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
,
445 const wxString
& ttip
);
446 #endif // wxUSE_TOOLTIPS
448 // the helper functions used by HandleChar/KeyXXX methods
449 wxKeyEvent
CreateKeyEvent(wxEventType evType
, int id
,
450 WXLPARAM lParam
= 0, WXWPARAM wParam
= 0) const;
453 // common part of all ctors
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
);
462 bool HandleNotify(int idCtrl
, WXLPARAM lParam
, WXLPARAM
*result
);
465 // list of disabled children before last call to our Disable()
466 wxWindowList
*m_childrenDisabled
;
468 // number of calls to Freeze() minus number of calls to Thaw()
469 unsigned int m_frozenness
;
471 DECLARE_DYNAMIC_CLASS(wxWindowPalm
)
472 DECLARE_NO_COPY_CLASS(wxWindowPalm
)
473 DECLARE_EVENT_TABLE()
476 // ----------------------------------------------------------------------------
478 // ----------------------------------------------------------------------------
480 #if WXWIN_COMPATIBILITY_2_4
482 inline bool wxWindowPalm::GetUseCtl3D() const { return false; }
483 inline bool wxWindowPalm::GetTransparentBackground() const { return false; }
484 inline void wxWindowPalm::SetTransparent(bool WXUNUSED(t
)) { }
486 #endif // WXWIN_COMPATIBILITY_2_4
488 // ---------------------------------------------------------------------------
490 // ---------------------------------------------------------------------------
492 // kbd code translation
493 WXDLLEXPORT
int wxCharCodePalmToWX(int keySym
, WXLPARAM lParam
= 0);
494 WXDLLEXPORT
int wxCharCodeWXToPalm(int id
, bool *IsVirtual
);
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
502 wxWindowCreationHook(wxWindowPalm
*winBeingCreated
);
503 ~wxWindowCreationHook();
506 // ----------------------------------------------------------------------------
508 // ----------------------------------------------------------------------------
510 // notice that this hash must be defined after wxWindow declaration as it
511 // needs to "see" its dtor and not just forward declaration
514 // pseudo-template HWND <-> wxWindow hash table
515 #if WXWIN_COMPATIBILITY_2_4
516 WX_DECLARE_HASH(wxWindow
, wxWindowList
, wxWinHashTable
);
518 WX_DECLARE_HASH(wxWindowPalm
, wxWindowList
, wxWinHashTable
);
521 extern wxWinHashTable
*wxWinHandleHash
;