]> git.saurik.com Git - wxWidgets.git/blame - include/wx/palmos/window.h
Expand tabs
[wxWidgets.git] / include / wx / palmos / window.h
CommitLineData
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
19#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
20 #pragma interface "window.h"
21#endif
22
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
25// define below to 1
26//
27// a better solution should be found later...
28#define wxUSE_MOUSEEVENT_HACK 0
29
ffecfa5a
JS
30// ---------------------------------------------------------------------------
31// wxWindow declaration for Palm
32// ---------------------------------------------------------------------------
33
34class WXDLLEXPORT wxWindowPalm : public wxWindowBase
35{
36public:
37 wxWindowPalm() { Init(); }
38
39 wxWindowPalm(wxWindow *parent,
40 wxWindowID id,
41 const wxPoint& pos = wxDefaultPosition,
42 const wxSize& size = wxDefaultSize,
43 long style = 0,
44 const wxString& name = wxPanelNameStr)
45 {
46 Init();
47 Create(parent, id, pos, size, style, name);
48 }
49
50 virtual ~wxWindowPalm();
51
52 bool Create(wxWindow *parent,
53 wxWindowID id,
54 const wxPoint& pos = wxDefaultPosition,
55 const wxSize& size = wxDefaultSize,
56 long style = 0,
57 const wxString& name = wxPanelNameStr);
58
59 // implement base class pure virtuals
60 virtual void SetTitle( const wxString& title);
61 virtual wxString GetTitle() const;
62
63 virtual void Raise();
64 virtual void Lower();
65
e951b8e4
WS
66 virtual bool Show( bool show = true );
67 virtual bool Enable( bool enable = true );
ffecfa5a
JS
68
69 virtual void SetFocus();
70 virtual void SetFocusFromKbd();
71
72 virtual bool Reparent(wxWindowBase *newParent);
73
74 virtual void WarpPointer(int x, int y);
75
e951b8e4 76 virtual void Refresh( bool eraseBackground = true,
324eeecb 77 const wxRect *rect = NULL );
ffecfa5a
JS
78 virtual void Update();
79 virtual void Freeze();
80 virtual void Thaw();
81
ffecfa5a
JS
82 virtual bool SetCursor( const wxCursor &cursor );
83 virtual bool SetFont( const wxFont &font );
84
85 virtual int GetCharHeight() const;
86 virtual int GetCharWidth() const;
87 virtual void GetTextExtent(const wxString& string,
88 int *x, int *y,
89 int *descent = (int *) NULL,
90 int *externalLeading = (int *) NULL,
91 const wxFont *theFont = (const wxFont *) NULL)
92 const;
93
94#if wxUSE_MENUS_NATIVE
95 virtual bool DoPopupMenu( wxMenu *menu, int x, int y );
96#endif // wxUSE_MENUS_NATIVE
97
98 virtual void SetScrollbar( int orient, int pos, int thumbVisible,
e951b8e4
WS
99 int range, bool refresh = true );
100 virtual void SetScrollPos( int orient, int pos, bool refresh = true );
ffecfa5a
JS
101 virtual int GetScrollPos( int orient ) const;
102 virtual int GetScrollThumb( int orient ) const;
103 virtual int GetScrollRange( int orient ) const;
104 virtual void ScrollWindow( int dx, int dy,
105 const wxRect* rect = (wxRect *) NULL );
106
107 virtual bool ScrollLines(int lines);
108 virtual bool ScrollPages(int pages);
109
110#if wxUSE_DRAG_AND_DROP
111 virtual void SetDropTarget( wxDropTarget *dropTarget );
112#endif // wxUSE_DRAG_AND_DROP
113
114 // Accept files for dragging
115 virtual void DragAcceptFiles(bool accept);
116
ffecfa5a
JS
117#ifndef __WXUNIVERSAL__
118 // Native resource loading (implemented in src/Palm/nativdlg.cpp)
119 // FIXME: should they really be all virtual?
120 virtual bool LoadNativeDialog(wxWindow* parent, wxWindowID& id);
121 virtual bool LoadNativeDialog(wxWindow* parent, const wxString& name);
122 wxWindow* GetWindowChild1(wxWindowID id);
123 wxWindow* GetWindowChild(wxWindowID id);
124#endif // __WXUNIVERSAL__
125
126#if wxUSE_HOTKEY
127 // install and deinstall a system wide hotkey
128 virtual bool RegisterHotKey(int hotkeyId, int modifiers, int keycode);
129 virtual bool UnregisterHotKey(int hotkeyId);
130#endif // wxUSE_HOTKEY
131
132 // implementation from now on
133 // --------------------------
134
135 // simple accessors
136 // ----------------
137
324eeecb
WS
138 virtual WXWINHANDLE GetWinHandle() const { return m_handle; }
139 virtual WXWidget GetHandle() const { return GetWinHandle(); }
ffecfa5a
JS
140
141 // event handlers
142 // --------------
143
144 void OnEraseBackground(wxEraseEvent& event);
145 void OnPaint(wxPaintEvent& event);
146
147public:
ffecfa5a 148 wxWindow *FindItem(long id) const;
324eeecb 149 wxWindow *FindItemByWinHandle(WXWINHANDLE handle, bool controlOnly = false) const;
ffecfa5a 150
e951b8e4 151 // Palm only: true if this control is part of the main control
324eeecb 152 virtual bool ContainsWinHandle(WXWINHANDLE WXUNUSED(handle)) const { return false; };
ffecfa5a
JS
153
154 // translate wxWidgets style flags for this control into the Windows style
155 // and optional extended style for the corresponding native control
156 //
157 // this is the function that should be overridden in the derived classes,
158 // but you will mostly use PalmGetCreateWindowFlags() below
159 virtual WXDWORD PalmGetStyle(long flags, WXDWORD *exstyle = NULL) const ;
160
161 // get the Palm window flags corresponding to wxWidgets ones
162 //
163 // the functions returns the flags (WS_XXX) directly and puts the ext
164 // (WS_EX_XXX) flags into the provided pointer if not NULL
165 WXDWORD PalmGetCreateWindowFlags(WXDWORD *exflags = NULL) const
166 { return PalmGetStyle(GetWindowStyle(), exflags); }
167
168 // translate wxWidgets coords into Windows ones suitable to be passed to
169 // ::CreateWindow()
170 //
e951b8e4 171 // returns true if non default coords are returned, false otherwise
ffecfa5a
JS
172 bool PalmGetCreateWindowCoords(const wxPoint& pos,
173 const wxSize& size,
174 int& x, int& y,
175 int& w, int& h) const;
176
ffecfa5a
JS
177 // creates the window of specified Windows class with given style, extended
178 // style, title and geometry (default values
179 //
e951b8e4 180 // returns true if the window has been created, false if creation failed
ffecfa5a
JS
181 bool PalmCreate(const wxChar *wclass,
182 const wxChar *title = NULL,
183 const wxPoint& pos = wxDefaultPosition,
184 const wxSize& size = wxDefaultSize,
185 WXDWORD style = 0,
186 WXDWORD exendedStyle = 0);
187
ffecfa5a 188#ifndef __WXUNIVERSAL__
324eeecb
WS
189 // Create an appropriate wxWindow from a WinHandle
190 virtual wxWindow* CreateWindowFromWinHandle(wxWindow* parent, WXWINHANDLE handle);
ffecfa5a 191
324eeecb
WS
192 // Make sure the window style reflects the WinHandle style (roughly)
193 virtual void AdoptAttributesFromWinHandle();
ffecfa5a
JS
194#endif // __WXUNIVERSAL__
195
196 // Setup background and foreground colours correctly
197 virtual void SetupColours();
198
ffecfa5a
JS
199 // ------------------------------------------------------------------------
200 // internal handlers for Palm messages: all handlers return a boolean value:
e951b8e4 201 // true means that the handler processed the event and false that it didn't
ffecfa5a
JS
202 // ------------------------------------------------------------------------
203
ffecfa5a
JS
204 // scroll event (both horizontal and vertical)
205 virtual bool PalmOnScroll(int orientation, WXWORD nSBCode,
324eeecb 206 WXWORD pos, WXWINHANDLE control);
ffecfa5a
JS
207
208 // virtual function for implementing internal idle
209 // behaviour
210 virtual void OnInternalIdle() ;
211
212protected:
213 // the window handle
20bc5ad8
WS
214 WXWINHANDLE m_handle;
215 WXFORMPTR FrameForm;
e951b8e4 216
20bc5ad8
WS
217 WXFORMPTR GetFormPtr();
218 void SetFormPtr(WXFORMPTR FormPtr);
ffecfa5a 219
ffecfa5a
JS
220 // additional (Palm specific) flags
221 bool m_mouseInWindow:1;
222 bool m_lastKeydownProcessed:1;
223
224 // the size of one page for scrolling
225 int m_xThumbSize;
226 int m_yThumbSize;
227
228#if wxUSE_MOUSEEVENT_HACK
229 // the coordinates of the last mouse event and the type of it
230 long m_lastMouseX,
231 m_lastMouseY;
232 int m_lastMouseEvent;
233#endif // wxUSE_MOUSEEVENT_HACK
234
235 WXHMENU m_hMenu; // Menu, if any
236
237 // implement the base class pure virtuals
238 virtual void DoClientToScreen( int *x, int *y ) const;
239 virtual void DoScreenToClient( int *x, int *y ) const;
240 virtual void DoGetPosition( int *x, int *y ) const;
241 virtual void DoGetSize( int *width, int *height ) const;
242 virtual void DoGetClientSize( int *width, int *height ) const;
243 virtual void DoSetSize(int x, int y,
244 int width, int height,
245 int sizeFlags = wxSIZE_AUTO);
246 virtual void DoSetClientSize(int width, int height);
247
248 virtual void DoCaptureMouse();
249 virtual void DoReleaseMouse();
250
251 // move the window to the specified location and resize it: this is called
252 // from both DoSetSize() and DoSetClientSize() and would usually just call
253 // ::MoveWindow() except for composite controls which will want to arrange
254 // themselves inside the given rectangle
255 virtual void DoMoveWindow(int x, int y, int width, int height);
256
257#if wxUSE_TOOLTIPS
258 virtual void DoSetToolTip( wxToolTip *tip );
259
260 // process TTN_NEEDTEXT message properly (i.e. fixing the bugs in
261 // comctl32.dll in our code -- see the function body for more info)
262 bool HandleTooltipNotify(WXUINT code,
263 WXLPARAM lParam,
264 const wxString& ttip);
265#endif // wxUSE_TOOLTIPS
266
ffecfa5a
JS
267private:
268 // common part of all ctors
269 void Init();
270
271 // the (non-virtual) handlers for the events
272 bool HandleMove(int x, int y);
273 bool HandleMoving(wxRect& rect);
274 bool HandleJoystickEvent(WXUINT msg, int x, int y, WXUINT flags);
275
ffecfa5a
JS
276 // list of disabled children before last call to our Disable()
277 wxWindowList *m_childrenDisabled;
278
279 // number of calls to Freeze() minus number of calls to Thaw()
280 unsigned int m_frozenness;
281
282 DECLARE_DYNAMIC_CLASS(wxWindowPalm)
283 DECLARE_NO_COPY_CLASS(wxWindowPalm)
284 DECLARE_EVENT_TABLE()
285};
286
ffecfa5a
JS
287// ----------------------------------------------------------------------------
288// global objects
289// ----------------------------------------------------------------------------
290
291// notice that this hash must be defined after wxWindow declaration as it
292// needs to "see" its dtor and not just forward declaration
293#include "wx/hash.h"
294
324eeecb 295// pseudo-template WinHandle <-> wxWindow hash table
ffecfa5a 296WX_DECLARE_HASH(wxWindowPalm, wxWindowList, wxWinHashTable);
ffecfa5a
JS
297
298extern wxWinHashTable *wxWinHandleHash;
299
300#endif
301 // _WX_WINDOW_H_