]>
Commit | Line | Data |
---|---|---|
ffecfa5a JS |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: wx/palmos/window.h | |
3 | // Purpose: wxWindow class | |
e1d63b79 | 4 | // Author: William Osborne - minimal working wxPalmOS port |
db101bd3 | 5 | // Modified by: Wlodzimierz ABX Skiba - more than minimal functionality |
ffecfa5a | 6 | // Created: 10/13/04 |
e1d63b79 | 7 | // RCS-ID: $Id$ |
db101bd3 | 8 | // Copyright: (c) William Osborne, Wlodzimierz Skiba |
ffecfa5a JS |
9 | // Licence: wxWindows licence |
10 | ///////////////////////////////////////////////////////////////////////////// | |
11 | ||
12 | #ifndef _WX_WINDOW_H_ | |
13 | #define _WX_WINDOW_H_ | |
14 | ||
ffecfa5a JS |
15 | // --------------------------------------------------------------------------- |
16 | // headers | |
17 | // --------------------------------------------------------------------------- | |
18 | ||
ffecfa5a JS |
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 | |
21 | // define below to 1 | |
22 | // | |
23 | // a better solution should be found later... | |
24 | #define wxUSE_MOUSEEVENT_HACK 0 | |
25 | ||
ffecfa5a JS |
26 | // --------------------------------------------------------------------------- |
27 | // wxWindow declaration for Palm | |
28 | // --------------------------------------------------------------------------- | |
29 | ||
53a2db12 | 30 | class WXDLLIMPEXP_CORE wxWindowPalm : public wxWindowBase |
ffecfa5a JS |
31 | { |
32 | public: | |
33 | wxWindowPalm() { Init(); } | |
34 | ||
35 | wxWindowPalm(wxWindow *parent, | |
36 | wxWindowID id, | |
37 | const wxPoint& pos = wxDefaultPosition, | |
38 | const wxSize& size = wxDefaultSize, | |
39 | long style = 0, | |
40 | const wxString& name = wxPanelNameStr) | |
41 | { | |
42 | Init(); | |
43 | Create(parent, id, pos, size, style, name); | |
44 | } | |
45 | ||
46 | virtual ~wxWindowPalm(); | |
47 | ||
48 | bool Create(wxWindow *parent, | |
49 | wxWindowID id, | |
50 | const wxPoint& pos = wxDefaultPosition, | |
51 | const wxSize& size = wxDefaultSize, | |
52 | long style = 0, | |
53 | const wxString& name = wxPanelNameStr); | |
54 | ||
55 | // implement base class pure virtuals | |
0ab48d64 WS |
56 | |
57 | virtual void SetLabel( const wxString& label); | |
58 | virtual wxString GetLabel() const; | |
ffecfa5a JS |
59 | |
60 | virtual void Raise(); | |
61 | virtual void Lower(); | |
62 | ||
e951b8e4 WS |
63 | virtual bool Show( bool show = true ); |
64 | virtual bool Enable( bool enable = true ); | |
ffecfa5a JS |
65 | |
66 | virtual void SetFocus(); | |
67 | virtual void SetFocusFromKbd(); | |
68 | ||
69 | virtual bool Reparent(wxWindowBase *newParent); | |
70 | ||
71 | virtual void WarpPointer(int x, int y); | |
72 | ||
e951b8e4 | 73 | virtual void Refresh( bool eraseBackground = true, |
324eeecb | 74 | const wxRect *rect = NULL ); |
ffecfa5a | 75 | virtual void Update(); |
ffecfa5a | 76 | |
ffecfa5a JS |
77 | virtual bool SetCursor( const wxCursor &cursor ); |
78 | virtual bool SetFont( const wxFont &font ); | |
79 | ||
80 | virtual int GetCharHeight() const; | |
81 | virtual int GetCharWidth() const; | |
ffecfa5a JS |
82 | |
83 | #if wxUSE_MENUS_NATIVE | |
84 | virtual bool DoPopupMenu( wxMenu *menu, int x, int y ); | |
85 | #endif // wxUSE_MENUS_NATIVE | |
86 | ||
87 | virtual void SetScrollbar( int orient, int pos, int thumbVisible, | |
e951b8e4 WS |
88 | int range, bool refresh = true ); |
89 | virtual void SetScrollPos( int orient, int pos, bool refresh = true ); | |
ffecfa5a JS |
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, | |
d3b9f782 | 94 | const wxRect* rect = NULL ); |
ffecfa5a JS |
95 | |
96 | virtual bool ScrollLines(int lines); | |
97 | virtual bool ScrollPages(int pages); | |
98 | ||
99 | #if wxUSE_DRAG_AND_DROP | |
100 | virtual void SetDropTarget( wxDropTarget *dropTarget ); | |
101 | #endif // wxUSE_DRAG_AND_DROP | |
102 | ||
103 | // Accept files for dragging | |
104 | virtual void DragAcceptFiles(bool accept); | |
105 | ||
ffecfa5a JS |
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__ | |
114 | ||
115 | #if wxUSE_HOTKEY | |
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 | |
120 | ||
121 | // implementation from now on | |
122 | // -------------------------- | |
123 | ||
124 | // simple accessors | |
125 | // ---------------- | |
126 | ||
e2fc40b4 VZ |
127 | WXHWND GetHWND() const { return m_hWnd; } |
128 | void SetHWND(WXHWND hWnd) { m_hWnd = hWnd; } | |
129 | virtual WXWidget GetHandle() const { return GetHWND(); } | |
ffecfa5a JS |
130 | |
131 | // event handlers | |
132 | // -------------- | |
133 | ||
134 | void OnEraseBackground(wxEraseEvent& event); | |
135 | void OnPaint(wxPaintEvent& event); | |
136 | ||
137 | public: | |
ffecfa5a | 138 | wxWindow *FindItem(long id) const; |
324eeecb | 139 | wxWindow *FindItemByWinHandle(WXWINHANDLE handle, bool controlOnly = false) const; |
ffecfa5a | 140 | |
e951b8e4 | 141 | // Palm only: true if this control is part of the main control |
324eeecb | 142 | virtual bool ContainsWinHandle(WXWINHANDLE WXUNUSED(handle)) const { return false; }; |
ffecfa5a JS |
143 | |
144 | // translate wxWidgets style flags for this control into the Windows style | |
145 | // and optional extended style for the corresponding native control | |
146 | // | |
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 ; | |
150 | ||
151 | // get the Palm window flags corresponding to wxWidgets ones | |
152 | // | |
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); } | |
157 | ||
158 | // translate wxWidgets coords into Windows ones suitable to be passed to | |
159 | // ::CreateWindow() | |
160 | // | |
e951b8e4 | 161 | // returns true if non default coords are returned, false otherwise |
ffecfa5a JS |
162 | bool PalmGetCreateWindowCoords(const wxPoint& pos, |
163 | const wxSize& size, | |
164 | int& x, int& y, | |
165 | int& w, int& h) const; | |
166 | ||
ffecfa5a JS |
167 | // creates the window of specified Windows class with given style, extended |
168 | // style, title and geometry (default values | |
169 | // | |
e951b8e4 | 170 | // returns true if the window has been created, false if creation failed |
ffecfa5a JS |
171 | bool PalmCreate(const wxChar *wclass, |
172 | const wxChar *title = NULL, | |
173 | const wxPoint& pos = wxDefaultPosition, | |
174 | const wxSize& size = wxDefaultSize, | |
175 | WXDWORD style = 0, | |
176 | WXDWORD exendedStyle = 0); | |
177 | ||
ffecfa5a | 178 | #ifndef __WXUNIVERSAL__ |
324eeecb WS |
179 | // Create an appropriate wxWindow from a WinHandle |
180 | virtual wxWindow* CreateWindowFromWinHandle(wxWindow* parent, WXWINHANDLE handle); | |
ffecfa5a | 181 | |
324eeecb WS |
182 | // Make sure the window style reflects the WinHandle style (roughly) |
183 | virtual void AdoptAttributesFromWinHandle(); | |
ffecfa5a JS |
184 | #endif // __WXUNIVERSAL__ |
185 | ||
186 | // Setup background and foreground colours correctly | |
187 | virtual void SetupColours(); | |
188 | ||
ffecfa5a JS |
189 | // ------------------------------------------------------------------------ |
190 | // internal handlers for Palm messages: all handlers return a boolean value: | |
e951b8e4 | 191 | // true means that the handler processed the event and false that it didn't |
ffecfa5a JS |
192 | // ------------------------------------------------------------------------ |
193 | ||
ffecfa5a JS |
194 | // scroll event (both horizontal and vertical) |
195 | virtual bool PalmOnScroll(int orientation, WXWORD nSBCode, | |
324eeecb | 196 | WXWORD pos, WXWINHANDLE control); |
ffecfa5a JS |
197 | |
198 | // virtual function for implementing internal idle | |
199 | // behaviour | |
200 | virtual void OnInternalIdle() ; | |
201 | ||
202 | protected: | |
203 | // the window handle | |
e2fc40b4 | 204 | WXHWND m_hWnd; |
20bc5ad8 | 205 | WXFORMPTR FrameForm; |
e951b8e4 | 206 | |
20bc5ad8 WS |
207 | WXFORMPTR GetFormPtr(); |
208 | void SetFormPtr(WXFORMPTR FormPtr); | |
ffecfa5a | 209 | |
ffecfa5a JS |
210 | // additional (Palm specific) flags |
211 | bool m_mouseInWindow:1; | |
212 | bool m_lastKeydownProcessed:1; | |
213 | ||
214 | // the size of one page for scrolling | |
215 | int m_xThumbSize; | |
216 | int m_yThumbSize; | |
217 | ||
218 | #if wxUSE_MOUSEEVENT_HACK | |
219 | // the coordinates of the last mouse event and the type of it | |
220 | long m_lastMouseX, | |
221 | m_lastMouseY; | |
222 | int m_lastMouseEvent; | |
223 | #endif // wxUSE_MOUSEEVENT_HACK | |
224 | ||
225 | WXHMENU m_hMenu; // Menu, if any | |
226 | ||
227 | // implement the base class pure virtuals | |
6de70470 VZ |
228 | virtual void DoGetTextExtent(const wxString& string, |
229 | int *x, int *y, | |
230 | int *descent = NULL, | |
231 | int *externalLeading = NULL, | |
232 | const wxFont *font = NULL) const; | |
ffecfa5a JS |
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); | |
242 | ||
243 | virtual void DoCaptureMouse(); | |
244 | virtual void DoReleaseMouse(); | |
245 | ||
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); | |
251 | ||
252 | #if wxUSE_TOOLTIPS | |
253 | virtual void DoSetToolTip( wxToolTip *tip ); | |
254 | ||
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, | |
258 | WXLPARAM lParam, | |
259 | const wxString& ttip); | |
260 | #endif // wxUSE_TOOLTIPS | |
261 | ||
ffecfa5a JS |
262 | private: |
263 | // common part of all ctors | |
264 | void Init(); | |
265 | ||
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); | |
270 | ||
ffecfa5a | 271 | DECLARE_DYNAMIC_CLASS(wxWindowPalm) |
c0c133e1 | 272 | wxDECLARE_NO_COPY_CLASS(wxWindowPalm); |
ffecfa5a JS |
273 | DECLARE_EVENT_TABLE() |
274 | }; | |
275 | ||
ffecfa5a JS |
276 | // ---------------------------------------------------------------------------- |
277 | // global objects | |
278 | // ---------------------------------------------------------------------------- | |
279 | ||
280 | // notice that this hash must be defined after wxWindow declaration as it | |
281 | // needs to "see" its dtor and not just forward declaration | |
282 | #include "wx/hash.h" | |
283 | ||
324eeecb | 284 | // pseudo-template WinHandle <-> wxWindow hash table |
ffecfa5a | 285 | WX_DECLARE_HASH(wxWindowPalm, wxWindowList, wxWinHashTable); |
ffecfa5a JS |
286 | |
287 | extern wxWinHashTable *wxWinHandleHash; | |
288 | ||
289 | #endif | |
290 | // _WX_WINDOW_H_ |