]> git.saurik.com Git - wxWidgets.git/blob - include/wx/palmos/window.h
Add wxUSE_RIBBON to wx/setup_inc.h and wx/chkconf.h.
[wxWidgets.git] / include / wx / palmos / window.h
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
6 // Created: 10/13/04
7 // RCS-ID: $Id$
8 // Copyright: (c) William Osborne, Wlodzimierz Skiba
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_WINDOW_H_
13 #define _WX_WINDOW_H_
14
15 // ---------------------------------------------------------------------------
16 // headers
17 // ---------------------------------------------------------------------------
18
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
26 // ---------------------------------------------------------------------------
27 // wxWindow declaration for Palm
28 // ---------------------------------------------------------------------------
29
30 class WXDLLIMPEXP_CORE wxWindowPalm : public wxWindowBase
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
56
57 virtual void SetLabel( const wxString& label);
58 virtual wxString GetLabel() const;
59
60 virtual void Raise();
61 virtual void Lower();
62
63 virtual bool Show( bool show = true );
64 virtual bool Enable( bool enable = true );
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
73 virtual void Refresh( bool eraseBackground = true,
74 const wxRect *rect = NULL );
75 virtual void Update();
76
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;
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,
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 );
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
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
127 WXHWND GetHWND() const { return m_hWnd; }
128 void SetHWND(WXHWND hWnd) { m_hWnd = hWnd; }
129 virtual WXWidget GetHandle() const { return GetHWND(); }
130
131 // event handlers
132 // --------------
133
134 void OnEraseBackground(wxEraseEvent& event);
135 void OnPaint(wxPaintEvent& event);
136
137 public:
138 wxWindow *FindItem(long id) const;
139 wxWindow *FindItemByWinHandle(WXWINHANDLE handle, bool controlOnly = false) const;
140
141 // Palm only: true if this control is part of the main control
142 virtual bool ContainsWinHandle(WXWINHANDLE WXUNUSED(handle)) const { return false; };
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 //
161 // returns true if non default coords are returned, false otherwise
162 bool PalmGetCreateWindowCoords(const wxPoint& pos,
163 const wxSize& size,
164 int& x, int& y,
165 int& w, int& h) const;
166
167 // creates the window of specified Windows class with given style, extended
168 // style, title and geometry (default values
169 //
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,
175 WXDWORD style = 0,
176 WXDWORD exendedStyle = 0);
177
178 #ifndef __WXUNIVERSAL__
179 // Create an appropriate wxWindow from a WinHandle
180 virtual wxWindow* CreateWindowFromWinHandle(wxWindow* parent, WXWINHANDLE handle);
181
182 // Make sure the window style reflects the WinHandle style (roughly)
183 virtual void AdoptAttributesFromWinHandle();
184 #endif // __WXUNIVERSAL__
185
186 // Setup background and foreground colours correctly
187 virtual void SetupColours();
188
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 // ------------------------------------------------------------------------
193
194 // scroll event (both horizontal and vertical)
195 virtual bool PalmOnScroll(int orientation, WXWORD nSBCode,
196 WXWORD pos, WXWINHANDLE control);
197
198 // virtual function for implementing internal idle
199 // behaviour
200 virtual void OnInternalIdle() ;
201
202 protected:
203 // the window handle
204 WXHWND m_hWnd;
205 WXFORMPTR FrameForm;
206
207 WXFORMPTR GetFormPtr();
208 void SetFormPtr(WXFORMPTR FormPtr);
209
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
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;
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
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
271 DECLARE_DYNAMIC_CLASS(wxWindowPalm)
272 wxDECLARE_NO_COPY_CLASS(wxWindowPalm);
273 DECLARE_EVENT_TABLE()
274 };
275
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
284 // pseudo-template WinHandle <-> wxWindow hash table
285 WX_DECLARE_HASH(wxWindowPalm, wxWindowList, wxWinHashTable);
286
287 extern wxWinHashTable *wxWinHandleHash;
288
289 #endif
290 // _WX_WINDOW_H_