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