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 // [at least] some version of Windows send extra mouse move messages after
20 // a mouse click or a key press - to temporarily fix this problem, set the
23 // a better solution should be found later...
24 #define wxUSE_MOUSEEVENT_HACK 0
26 // ---------------------------------------------------------------------------
27 // wxWindow declaration for Palm
28 // ---------------------------------------------------------------------------
30 class WXDLLIMPEXP_CORE wxWindowPalm
: public wxWindowBase
33 wxWindowPalm() { Init(); }
35 wxWindowPalm(wxWindow
*parent
,
37 const wxPoint
& pos
= wxDefaultPosition
,
38 const wxSize
& size
= wxDefaultSize
,
40 const wxString
& name
= wxPanelNameStr
)
43 Create(parent
, id
, pos
, size
, style
, name
);
46 virtual ~wxWindowPalm();
48 bool Create(wxWindow
*parent
,
50 const wxPoint
& pos
= wxDefaultPosition
,
51 const wxSize
& size
= wxDefaultSize
,
53 const wxString
& name
= wxPanelNameStr
);
55 // implement base class pure virtuals
57 virtual void SetLabel( const wxString
& label
);
58 virtual wxString
GetLabel() const;
63 virtual bool Show( bool show
= true );
64 virtual bool Enable( bool enable
= true );
66 virtual void SetFocus();
67 virtual void SetFocusFromKbd();
69 virtual bool Reparent(wxWindowBase
*newParent
);
71 virtual void WarpPointer(int x
, int y
);
73 virtual void Refresh( bool eraseBackground
= true,
74 const wxRect
*rect
= NULL
);
75 virtual void Update();
77 virtual bool SetCursor( const wxCursor
&cursor
);
78 virtual bool SetFont( const wxFont
&font
);
80 virtual int GetCharHeight() const;
81 virtual int GetCharWidth() const;
83 #if wxUSE_MENUS_NATIVE
84 virtual bool DoPopupMenu( wxMenu
*menu
, int x
, int y
);
85 #endif // wxUSE_MENUS_NATIVE
87 virtual void SetScrollbar( int orient
, int pos
, int thumbVisible
,
88 int range
, bool refresh
= true );
89 virtual void SetScrollPos( int orient
, int pos
, bool refresh
= true );
90 virtual int GetScrollPos( int orient
) const;
91 virtual int GetScrollThumb( int orient
) const;
92 virtual int GetScrollRange( int orient
) const;
93 virtual void ScrollWindow( int dx
, int dy
,
94 const wxRect
* rect
= NULL
);
96 virtual bool ScrollLines(int lines
);
97 virtual bool ScrollPages(int pages
);
99 #if wxUSE_DRAG_AND_DROP
100 virtual void SetDropTarget( wxDropTarget
*dropTarget
);
101 #endif // wxUSE_DRAG_AND_DROP
103 // Accept files for dragging
104 virtual void DragAcceptFiles(bool accept
);
106 #ifndef __WXUNIVERSAL__
107 // Native resource loading (implemented in src/Palm/nativdlg.cpp)
108 // FIXME: should they really be all virtual?
109 virtual bool LoadNativeDialog(wxWindow
* parent
, wxWindowID
& id
);
110 virtual bool LoadNativeDialog(wxWindow
* parent
, const wxString
& name
);
111 wxWindow
* GetWindowChild1(wxWindowID id
);
112 wxWindow
* GetWindowChild(wxWindowID id
);
113 #endif // __WXUNIVERSAL__
116 // install and deinstall a system wide hotkey
117 virtual bool RegisterHotKey(int hotkeyId
, int modifiers
, int keycode
);
118 virtual bool UnregisterHotKey(int hotkeyId
);
119 #endif // wxUSE_HOTKEY
121 // implementation from now on
122 // --------------------------
127 WXHWND
GetHWND() const { return m_hWnd
; }
128 void SetHWND(WXHWND hWnd
) { m_hWnd
= hWnd
; }
129 virtual WXWidget
GetHandle() const { return GetHWND(); }
134 void OnEraseBackground(wxEraseEvent
& event
);
135 void OnPaint(wxPaintEvent
& event
);
138 wxWindow
*FindItem(long id
) const;
139 wxWindow
*FindItemByWinHandle(WXWINHANDLE handle
, bool controlOnly
= false) const;
141 // Palm only: true if this control is part of the main control
142 virtual bool ContainsWinHandle(WXWINHANDLE
WXUNUSED(handle
)) const { return false; }
144 // translate wxWidgets style flags for this control into the Windows style
145 // and optional extended style for the corresponding native control
147 // this is the function that should be overridden in the derived classes,
148 // but you will mostly use PalmGetCreateWindowFlags() below
149 virtual WXDWORD
PalmGetStyle(long flags
, WXDWORD
*exstyle
= NULL
) const ;
151 // get the Palm window flags corresponding to wxWidgets ones
153 // the functions returns the flags (WS_XXX) directly and puts the ext
154 // (WS_EX_XXX) flags into the provided pointer if not NULL
155 WXDWORD
PalmGetCreateWindowFlags(WXDWORD
*exflags
= NULL
) const
156 { return PalmGetStyle(GetWindowStyle(), exflags
); }
158 // translate wxWidgets coords into Windows ones suitable to be passed to
161 // returns true if non default coords are returned, false otherwise
162 bool PalmGetCreateWindowCoords(const wxPoint
& pos
,
165 int& w
, int& h
) const;
167 // creates the window of specified Windows class with given style, extended
168 // style, title and geometry (default values
170 // returns true if the window has been created, false if creation failed
171 bool PalmCreate(const wxChar
*wclass
,
172 const wxChar
*title
= NULL
,
173 const wxPoint
& pos
= wxDefaultPosition
,
174 const wxSize
& size
= wxDefaultSize
,
176 WXDWORD exendedStyle
= 0);
178 #ifndef __WXUNIVERSAL__
179 // Create an appropriate wxWindow from a WinHandle
180 virtual wxWindow
* CreateWindowFromWinHandle(wxWindow
* parent
, WXWINHANDLE handle
);
182 // Make sure the window style reflects the WinHandle style (roughly)
183 virtual void AdoptAttributesFromWinHandle();
184 #endif // __WXUNIVERSAL__
186 // Setup background and foreground colours correctly
187 virtual void SetupColours();
189 // ------------------------------------------------------------------------
190 // internal handlers for Palm messages: all handlers return a boolean value:
191 // true means that the handler processed the event and false that it didn't
192 // ------------------------------------------------------------------------
194 // scroll event (both horizontal and vertical)
195 virtual bool PalmOnScroll(int orientation
, WXWORD nSBCode
,
196 WXWORD pos
, WXWINHANDLE control
);
198 // virtual function for implementing internal idle
200 virtual void OnInternalIdle() ;
207 WXFORMPTR
GetFormPtr();
208 void SetFormPtr(WXFORMPTR FormPtr
);
210 // additional (Palm specific) flags
211 bool m_mouseInWindow
:1;
212 bool m_lastKeydownProcessed
:1;
214 // the size of one page for scrolling
218 #if wxUSE_MOUSEEVENT_HACK
219 // the coordinates of the last mouse event and the type of it
222 int m_lastMouseEvent
;
223 #endif // wxUSE_MOUSEEVENT_HACK
225 WXHMENU m_hMenu
; // Menu, if any
227 // implement the base class pure virtuals
228 virtual void DoGetTextExtent(const wxString
& string
,
231 int *externalLeading
= NULL
,
232 const wxFont
*font
= NULL
) const;
233 virtual void DoClientToScreen( int *x
, int *y
) const;
234 virtual void DoScreenToClient( int *x
, int *y
) const;
235 virtual void DoGetPosition( int *x
, int *y
) const;
236 virtual void DoGetSize( int *width
, int *height
) const;
237 virtual void DoGetClientSize( int *width
, int *height
) const;
238 virtual void DoSetSize(int x
, int y
,
239 int width
, int height
,
240 int sizeFlags
= wxSIZE_AUTO
);
241 virtual void DoSetClientSize(int width
, int height
);
243 virtual void DoCaptureMouse();
244 virtual void DoReleaseMouse();
246 // move the window to the specified location and resize it: this is called
247 // from both DoSetSize() and DoSetClientSize() and would usually just call
248 // ::MoveWindow() except for composite controls which will want to arrange
249 // themselves inside the given rectangle
250 virtual void DoMoveWindow(int x
, int y
, int width
, int height
);
253 virtual void DoSetToolTip( wxToolTip
*tip
);
255 // process TTN_NEEDTEXT message properly (i.e. fixing the bugs in
256 // comctl32.dll in our code -- see the function body for more info)
257 bool HandleTooltipNotify(WXUINT code
,
259 const wxString
& ttip
);
260 #endif // wxUSE_TOOLTIPS
263 // common part of all ctors
266 // the (non-virtual) handlers for the events
267 bool HandleMove(int x
, int y
);
268 bool HandleMoving(wxRect
& rect
);
269 bool HandleJoystickEvent(WXUINT msg
, int x
, int y
, WXUINT flags
);
271 DECLARE_DYNAMIC_CLASS(wxWindowPalm
)
272 wxDECLARE_NO_COPY_CLASS(wxWindowPalm
);
273 DECLARE_EVENT_TABLE()
276 // ----------------------------------------------------------------------------
278 // ----------------------------------------------------------------------------
280 // notice that this hash must be defined after wxWindow declaration as it
281 // needs to "see" its dtor and not just forward declaration
284 // pseudo-template WinHandle <-> wxWindow hash table
285 WX_DECLARE_HASH(wxWindowPalm
, wxWindowList
, wxWinHashTable
);
287 extern wxWinHashTable
*wxWinHandleHash
;