]> git.saurik.com Git - wxWidgets.git/blob - src/palmos/window.cpp
Correctly align background brush when erasing owner drawn bitmaps in wxMSW.
[wxWidgets.git] / src / palmos / window.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/palmos/window.cpp
3 // Purpose: wxWindow
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 // ===========================================================================
13 // declarations
14 // ===========================================================================
15
16 // ---------------------------------------------------------------------------
17 // headers
18 // ---------------------------------------------------------------------------
19
20 // For compilers that support precompilation, includes "wx.h".
21 #include "wx/wxprec.h"
22
23 #ifdef __BORLANDC__
24 #pragma hdrstop
25 #endif
26
27 #include "wx/window.h"
28
29 #ifndef WX_PRECOMP
30 #include "wx/accel.h"
31 #include "wx/menu.h"
32 #include "wx/dc.h"
33 #include "wx/dcclient.h"
34 #include "wx/dcmemory.h"
35 #include "wx/utils.h"
36 #include "wx/app.h"
37 #include "wx/layout.h"
38 #include "wx/dialog.h"
39 #include "wx/frame.h"
40 #include "wx/listbox.h"
41 #include "wx/button.h"
42 #include "wx/msgdlg.h"
43 #include "wx/settings.h"
44 #include "wx/statbox.h"
45 #include "wx/intl.h"
46 #include "wx/log.h"
47 #include "wx/textctrl.h"
48 #include "wx/menuitem.h"
49 #include "wx/module.h"
50 #endif
51
52 #if wxUSE_OWNER_DRAWN && !defined(__WXUNIVERSAL__)
53 #include "wx/ownerdrw.h"
54 #endif
55
56 #if wxUSE_DRAG_AND_DROP
57 #include "wx/dnd.h"
58 #endif
59
60 #if wxUSE_ACCESSIBILITY
61 #include "wx/access.h"
62 #endif
63
64 #if wxUSE_TOOLTIPS
65 #include "wx/tooltip.h"
66 #endif
67
68 #if wxUSE_CARET
69 #include "wx/caret.h"
70 #endif // wxUSE_CARET
71
72 #if wxUSE_SPINCTRL
73 #include "wx/spinctrl.h"
74 #endif // wxUSE_SPINCTRL
75
76 #include "wx/notebook.h"
77 #include "wx/listctrl.h"
78
79 #ifndef __WXUNIVERSAL__
80 #include <Window.h>
81
82 // ---------------------------------------------------------------------------
83 // global variables
84 // ---------------------------------------------------------------------------
85
86 // ---------------------------------------------------------------------------
87 // private functions
88 // ---------------------------------------------------------------------------
89
90 // ---------------------------------------------------------------------------
91 // event tables
92 // ---------------------------------------------------------------------------
93
94 // in wxUniv/Palm this class is abstract because it doesn't have DoPopupMenu()
95 // method
96 #ifdef __WXUNIVERSAL__
97 IMPLEMENT_ABSTRACT_CLASS(wxWindowPalm, wxWindowBase)
98 #endif // __WXUNIVERSAL__
99
100 BEGIN_EVENT_TABLE(wxWindowPalm, wxWindowBase)
101 EVT_ERASE_BACKGROUND(wxWindowPalm::OnEraseBackground)
102 EVT_INIT_DIALOG(wxWindowPalm::OnInitDialog)
103 END_EVENT_TABLE()
104
105 // ===========================================================================
106 // implementation
107 // ===========================================================================
108
109 // ---------------------------------------------------------------------------
110 // wxWindow utility functions
111 // ---------------------------------------------------------------------------
112
113 // Find an item given the MS Windows id
114 wxWindow *wxWindowPalm::FindItem(long id) const
115 {
116 return NULL;
117 }
118
119 // Find an item given the MS Windows handle
120 wxWindow *wxWindowPalm::FindItemByWinHandle(WXWINHANDLE handle, bool controlOnly) const
121 {
122 // TODO
123 return NULL;
124 }
125
126 bool wxGetKeyState(wxKeyCode key)
127 {
128 wxASSERT_MSG(key != WXK_LBUTTON && key != WXK_RBUTTON && key !=
129 WXK_MBUTTON, wxT("can't use wxGetKeyState() for mouse buttons"));
130
131 // TODO
132
133 return false;
134 }
135
136 // ----------------------------------------------------------------------------
137 // constructors and such
138 // ----------------------------------------------------------------------------
139
140 void wxWindowPalm::Init()
141 {
142 m_hWnd = 0;
143 }
144
145 // Destructor
146 wxWindowPalm::~wxWindowPalm()
147 {
148 }
149
150 // real construction (Init() must have been called before!)
151 bool wxWindowPalm::Create(wxWindow *parent,
152 wxWindowID id,
153 const wxPoint& pos,
154 const wxSize& size,
155 long style,
156 const wxString& name)
157 {
158 wxCHECK_MSG( parent, false, wxT("can't create wxWindow without parent") );
159
160 if ( !CreateBase(parent, id, pos, size, style, wxDefaultValidator, name) )
161 return false;
162
163 parent->AddChild(this);
164
165 InheritAttributes();
166
167 return true;
168 }
169
170 WXFORMPTR wxWindowPalm::GetFormPtr()
171 {
172 return FrameForm;
173 }
174 void wxWindowPalm::SetFormPtr(WXFORMPTR FormPtr)
175 {
176 FrameForm = FormPtr;
177 }
178
179 // ---------------------------------------------------------------------------
180 // basic operations
181 // ---------------------------------------------------------------------------
182
183 void wxWindowPalm::SetFocus()
184 {
185 }
186
187 void wxWindowPalm::SetFocusFromKbd()
188 {
189 }
190
191 // Get the window with the focus
192 wxWindow *wxWindowBase::DoFindFocus()
193 {
194 return NULL;
195 }
196
197 bool wxWindowPalm::Enable(bool enable)
198 {
199 return false;
200 }
201
202 bool wxWindowPalm::Show(bool show)
203 {
204 return false;
205 }
206
207 // Raise the window to the top of the Z order
208 void wxWindowPalm::Raise()
209 {
210 }
211
212 // Lower the window to the bottom of the Z order
213 void wxWindowPalm::Lower()
214 {
215 }
216
217 void wxWindowPalm::SetLabel( const wxString& WXUNUSED(label))
218 {
219 }
220
221 wxString wxWindowPalm::GetLabel() const
222 {
223 return wxEmptyString;
224 }
225
226 void wxWindowPalm::DoCaptureMouse()
227 {
228 }
229
230 void wxWindowPalm::DoReleaseMouse()
231 {
232 }
233
234 /* static */ wxWindow *wxWindowBase::GetCapture()
235 {
236 return NULL;
237 }
238
239 bool wxWindowPalm::SetFont(const wxFont& font)
240 {
241 return false;
242 }
243 bool wxWindowPalm::SetCursor(const wxCursor& cursor)
244 {
245 return false;
246 }
247
248 void wxWindowPalm::WarpPointer (int x, int y)
249 {
250 }
251
252 // ---------------------------------------------------------------------------
253 // scrolling stuff
254 // ---------------------------------------------------------------------------
255
256 // convert wxHORIZONTAL/wxVERTICAL to SB_HORZ/SB_VERT
257 static inline int wxDirToWinStyle(int orient)
258 {
259 return 0;
260 }
261
262 int wxWindowPalm::GetScrollPos(int orient) const
263 {
264 return 0;
265 }
266
267 // This now returns the whole range, not just the number
268 // of positions that we can scroll.
269 int wxWindowPalm::GetScrollRange(int orient) const
270 {
271 return 0;
272 }
273
274 int wxWindowPalm::GetScrollThumb(int orient) const
275 {
276 return 0;
277 }
278
279 void wxWindowPalm::SetScrollPos(int orient, int pos, bool refresh)
280 {
281 }
282
283 // New function that will replace some of the above.
284 void wxWindowPalm::SetScrollbar(int orient,
285 int pos,
286 int pageSize,
287 int range,
288 bool refresh)
289 {
290 }
291
292 void wxWindowPalm::ScrollWindow(int dx, int dy, const wxRect *prect)
293 {
294 }
295
296 bool wxWindowPalm::ScrollLines(int lines)
297 {
298 return false;
299 }
300
301 bool wxWindowPalm::ScrollPages(int pages)
302 {
303 return false;
304 }
305
306 // ----------------------------------------------------------------------------
307 // Style handling
308 // ----------------------------------------------------------------------------
309
310 WXDWORD wxWindowPalm::PalmGetStyle(long flags, WXDWORD *exstyle) const
311 {
312 return 0;
313 }
314
315 // Setup background and foreground colours correctly
316 void wxWindowPalm::SetupColours()
317 {
318 }
319
320 void wxWindowPalm::OnInternalIdle()
321 {
322 }
323
324 // Set this window to be the child of 'parent'.
325 bool wxWindowPalm::Reparent(wxWindowBase *parent)
326 {
327 return false;
328 }
329
330 void wxWindowPalm::Refresh(bool eraseBack, const wxRect *rect)
331 {
332 WinHandle handle = (WinHandle)GetHWND();
333 if(handle)
334 {
335 #ifdef __WXPALMOS6__
336 if(rect)
337 {
338 RectangleType dirtyRect;
339 dirtyRect.topLeft.x = rect->GetX() - 1;
340 dirtyRect.topLeft.y = rect->GetY() - 1;
341 dirtyRect.extent.x = rect->GetWidth() + 1;
342 dirtyRect.extent.y = rect->GetHeight() + 1;
343 WinInvalidateRect(handle, &dirtyRect);
344 }
345 else
346 {
347 WinInvalidateWindow(handle);
348 }
349 #else // __WXPALMOS5__
350 WinSetActiveWindow (handle);
351 #endif
352
353 }
354 }
355
356 void wxWindowPalm::Update()
357 {
358 }
359
360 // ---------------------------------------------------------------------------
361 // drag and drop
362 // ---------------------------------------------------------------------------
363
364
365 #if wxUSE_DRAG_AND_DROP
366 void wxWindowPalm::SetDropTarget(wxDropTarget *pDropTarget)
367 {
368 }
369 #endif // wxUSE_DRAG_AND_DROP
370
371 // old style file-manager drag&drop support: we retain the old-style
372 // DragAcceptFiles in parallel with SetDropTarget.
373 void wxWindowPalm::DragAcceptFiles(bool accept)
374 {
375 }
376
377 // ----------------------------------------------------------------------------
378 // tooltips
379 // ----------------------------------------------------------------------------
380
381 #if wxUSE_TOOLTIPS
382
383 void wxWindowPalm::DoSetToolTip(wxToolTip *tooltip)
384 {
385 }
386
387 #endif // wxUSE_TOOLTIPS
388
389 // ---------------------------------------------------------------------------
390 // moving and resizing
391 // ---------------------------------------------------------------------------
392
393 // Get total size
394 void wxWindowPalm::DoGetSize(int *x, int *y) const
395 {
396 }
397
398 // Get size *available for subwindows* i.e. excluding menu bar etc.
399 void wxWindowPalm::DoGetClientSize(int *x, int *y) const
400 {
401 }
402
403 void wxWindowPalm::DoGetPosition(int *x, int *y) const
404 {
405 if(x)
406 *x = 0;
407 if(y)
408 *y = 0;
409 }
410
411 void wxWindowPalm::DoScreenToClient(int *x, int *y) const
412 {
413 }
414
415 void wxWindowPalm::DoClientToScreen(int *x, int *y) const
416 {
417 }
418
419 void wxWindowPalm::DoMoveWindow(int x, int y, int width, int height)
420 {
421 }
422
423 // set the size of the window: if the dimensions are positive, just use them,
424 // but if any of them is equal to -1, it means that we must find the value for
425 // it ourselves (unless sizeFlags contains wxSIZE_ALLOW_MINUS_ONE flag, in
426 // which case -1 is a valid value for x and y)
427 //
428 // If sizeFlags contains wxSIZE_AUTO_WIDTH/HEIGHT flags (default), we calculate
429 // the width/height to best suit our contents, otherwise we reuse the current
430 // width/height
431 void wxWindowPalm::DoSetSize(int x, int y, int width, int height, int sizeFlags)
432 {
433 // get the current size and position...
434 int currentX, currentY;
435 GetPosition(&currentX, &currentY);
436 int currentW,currentH;
437 GetSize(&currentW, &currentH);
438
439 // ... and don't do anything (avoiding flicker) if it's already ok
440 if ( x == currentX && y == currentY &&
441 width == currentW && height == currentH )
442 {
443 return;
444 }
445
446 if ( x == wxDefaultCoord && !(sizeFlags & wxSIZE_ALLOW_MINUS_ONE) )
447 x = currentX;
448 if ( y == wxDefaultCoord && !(sizeFlags & wxSIZE_ALLOW_MINUS_ONE) )
449 y = currentY;
450
451 AdjustForParentClientOrigin(x, y, sizeFlags);
452
453 wxSize size = wxDefaultSize;
454 if ( width == wxDefaultCoord )
455 {
456 if ( sizeFlags & wxSIZE_AUTO_WIDTH )
457 {
458 size = DoGetBestSize();
459 width = size.x;
460 }
461 else
462 {
463 // just take the current one
464 width = currentW;
465 }
466 }
467
468 if ( height == wxDefaultCoord )
469 {
470 if ( sizeFlags & wxSIZE_AUTO_HEIGHT )
471 {
472 if ( size.x == wxDefaultCoord )
473 {
474 size = DoGetBestSize();
475 }
476 //else: already called DoGetBestSize() above
477
478 height = size.y;
479 }
480 else
481 {
482 // just take the current one
483 height = currentH;
484 }
485 }
486
487 DoMoveWindow(x, y, width, height);
488 }
489
490 void wxWindowPalm::DoSetClientSize(int width, int height)
491 {
492 }
493
494 // ---------------------------------------------------------------------------
495 // text metrics
496 // ---------------------------------------------------------------------------
497
498 int wxWindowPalm::GetCharHeight() const
499 {
500 return 0;
501 }
502
503 int wxWindowPalm::GetCharWidth() const
504 {
505 return 0;
506 }
507
508 void wxWindowPalm::DoGetTextExtent(const wxString& string,
509 int *x, int *y,
510 int *descent,
511 int *externalLeading,
512 const wxFont *theFont) const
513 {
514 }
515
516 // ---------------------------------------------------------------------------
517 // popup menu
518 // ---------------------------------------------------------------------------
519
520 #if wxUSE_MENUS_NATIVE
521
522 // yield for WM_COMMAND events only, i.e. process all WM_COMMANDs in the queue
523 // immediately, without waiting for the next event loop iteration
524 //
525 // NB: this function should probably be made public later as it can almost
526 // surely replace wxYield() elsewhere as well
527 static void wxYieldForCommandsOnly()
528 {
529 }
530
531 bool wxWindowPalm::DoPopupMenu(wxMenu *menu, int x, int y)
532 {
533 return false;
534 }
535
536 #endif // wxUSE_MENUS_NATIVE
537
538 // ----------------------------------------------------------------------------
539 // wxWindow <-> HWND map
540 // ----------------------------------------------------------------------------
541
542 wxWinHashTable *wxWinHandleHash = NULL;
543
544 wxWindow *wxFindWinFromWinHandle(WXWINHANDLE handle)
545 {
546 // TODO
547 return NULL;
548 }
549
550 void wxRemoveHandleAssociation(wxWindowPalm *win)
551 {
552 }
553
554 // ----------------------------------------------------------------------------
555 // various Palm specific class dependent functions
556 // ----------------------------------------------------------------------------
557
558 bool wxWindowPalm::PalmGetCreateWindowCoords(const wxPoint& pos,
559 const wxSize& size,
560 int& x, int& y,
561 int& w, int& h) const
562 {
563 return false;
564 }
565
566 bool wxWindowPalm::PalmCreate(const wxChar *wclass,
567 const wxChar *title,
568 const wxPoint& pos,
569 const wxSize& size,
570 WXDWORD style,
571 WXDWORD extendedStyle)
572 {
573 return false;
574 }
575
576 // ===========================================================================
577 // Palm message handlers
578 // ===========================================================================
579
580 // ---------------------------------------------------------------------------
581 // painting
582 // ---------------------------------------------------------------------------
583
584 // Can be called from an application's OnPaint handler
585 void wxWindowPalm::OnPaint(wxPaintEvent& event)
586 {
587 }
588
589 void wxWindowPalm::OnEraseBackground(wxEraseEvent& event)
590 {
591 }
592
593 // ---------------------------------------------------------------------------
594 // moving and resizing
595 // ---------------------------------------------------------------------------
596
597 bool wxWindowPalm::HandleMove(int x, int y)
598 {
599 return false;
600 }
601
602 bool wxWindowPalm::HandleMoving(wxRect& rect)
603 {
604 return false;
605 }
606
607 // ---------------------------------------------------------------------------
608 // joystick
609 // ---------------------------------------------------------------------------
610
611 bool wxWindowPalm::HandleJoystickEvent(WXUINT msg, int x, int y, WXUINT flags)
612 {
613 return false;
614 }
615
616 // ---------------------------------------------------------------------------
617 // scrolling
618 // ---------------------------------------------------------------------------
619
620 bool wxWindowPalm::PalmOnScroll(int orientation, WXWORD wParam,
621 WXWORD pos, WXWINHANDLE control)
622 {
623 // TODO
624 return false;
625 }
626
627 // ===========================================================================
628 // global functions
629 // ===========================================================================
630
631 void wxGetCharSize(WXWINHANDLE wnd, int *x, int *y, const wxFont *the_font)
632 {
633 // TODO
634 }
635
636 #if wxUSE_HOTKEY
637
638 bool wxWindowPalm::RegisterHotKey(int hotkeyId, int modifiers, int keycode)
639 {
640 return false;
641 }
642
643 bool wxWindowPalm::UnregisterHotKey(int hotkeyId)
644 {
645 return false;
646 }
647 #endif // # __WXUNIVERSAL__
648 #endif // wxUSE_HOTKEY