]> git.saurik.com Git - wxWidgets.git/blame - src/palmos/window.cpp
Fix UI in generic wxListCtrl when pressing cursor arrows while editing.
[wxWidgets.git] / src / palmos / window.cpp
CommitLineData
ffecfa5a 1/////////////////////////////////////////////////////////////////////////////
02761f6c 2// Name: src/palmos/window.cpp
ffecfa5a 3// Purpose: wxWindow
e2731512 4// Author: William Osborne - minimal working wxPalmOS port
ba889513 5// Modified by: Wlodzimierz ABX Skiba - more than minimal functionality
ffecfa5a 6// Created: 10/13/04
e2731512 7// RCS-ID: $Id$
ba889513 8// Copyright: (c) William Osborne, Wlodzimierz Skiba
ffecfa5a
JS
9// Licence: wxWindows licence
10/////////////////////////////////////////////////////////////////////////////
11
12// ===========================================================================
13// declarations
14// ===========================================================================
15
16// ---------------------------------------------------------------------------
17// headers
18// ---------------------------------------------------------------------------
19
ffecfa5a
JS
20// For compilers that support precompilation, includes "wx.h".
21#include "wx/wxprec.h"
22
23#ifdef __BORLANDC__
24 #pragma hdrstop
25#endif
26
e4db172a
WS
27#include "wx/window.h"
28
ffecfa5a 29#ifndef WX_PRECOMP
ffecfa5a 30 #include "wx/accel.h"
ffecfa5a
JS
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"
88a7a4e1 45 #include "wx/intl.h"
e4db172a 46 #include "wx/log.h"
fec9cc08 47 #include "wx/textctrl.h"
25466131 48 #include "wx/menuitem.h"
02761f6c 49 #include "wx/module.h"
ffecfa5a
JS
50#endif
51
52#if wxUSE_OWNER_DRAWN && !defined(__WXUNIVERSAL__)
53 #include "wx/ownerdrw.h"
54#endif
55
ffecfa5a
JS
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
ffecfa5a
JS
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
ffecfa5a
JS
76#include "wx/notebook.h"
77#include "wx/listctrl.h"
ffecfa5a 78
e2fc40b4 79#ifndef __WXUNIVERSAL__
20bc5ad8
WS
80#include <Window.h>
81
ffecfa5a
JS
82// ---------------------------------------------------------------------------
83// global variables
84// ---------------------------------------------------------------------------
85
ffecfa5a
JS
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)
28953245 98#endif // __WXUNIVERSAL__
ffecfa5a
JS
99
100BEGIN_EVENT_TABLE(wxWindowPalm, wxWindowBase)
101 EVT_ERASE_BACKGROUND(wxWindowPalm::OnEraseBackground)
ffecfa5a
JS
102 EVT_INIT_DIALOG(wxWindowPalm::OnInitDialog)
103END_EVENT_TABLE()
104
105// ===========================================================================
106// implementation
107// ===========================================================================
108
109// ---------------------------------------------------------------------------
110// wxWindow utility functions
111// ---------------------------------------------------------------------------
112
113// Find an item given the MS Windows id
114wxWindow *wxWindowPalm::FindItem(long id) const
115{
116 return NULL;
117}
118
119// Find an item given the MS Windows handle
324eeecb 120wxWindow *wxWindowPalm::FindItemByWinHandle(WXWINHANDLE handle, bool controlOnly) const
ffecfa5a 121{
324eeecb 122 // TODO
ffecfa5a
JS
123 return NULL;
124}
125
34deaa93
WS
126bool 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
ffecfa5a
JS
136// ----------------------------------------------------------------------------
137// constructors and such
138// ----------------------------------------------------------------------------
139
140void wxWindowPalm::Init()
141{
e2fc40b4 142 m_hWnd = 0;
ffecfa5a
JS
143}
144
145// Destructor
146wxWindowPalm::~wxWindowPalm()
147{
148}
149
150// real construction (Init() must have been called before!)
151bool wxWindowPalm::Create(wxWindow *parent,
324eeecb
WS
152 wxWindowID id,
153 const wxPoint& pos,
154 const wxSize& size,
155 long style,
156 const wxString& name)
ffecfa5a 157{
a152561c
WS
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;
ffecfa5a
JS
168}
169
20bc5ad8 170WXFORMPTR wxWindowPalm::GetFormPtr()
ffecfa5a
JS
171{
172 return FrameForm;
173}
20bc5ad8 174void wxWindowPalm::SetFormPtr(WXFORMPTR FormPtr)
ffecfa5a 175{
20bc5ad8 176 FrameForm = FormPtr;
ffecfa5a
JS
177}
178
179// ---------------------------------------------------------------------------
180// basic operations
181// ---------------------------------------------------------------------------
182
183void wxWindowPalm::SetFocus()
184{
185}
186
187void wxWindowPalm::SetFocusFromKbd()
188{
189}
190
191// Get the window with the focus
192wxWindow *wxWindowBase::DoFindFocus()
193{
194 return NULL;
195}
196
197bool wxWindowPalm::Enable(bool enable)
198{
199 return false;
200}
201
202bool wxWindowPalm::Show(bool show)
203{
204 return false;
205}
206
207// Raise the window to the top of the Z order
208void wxWindowPalm::Raise()
209{
210}
211
212// Lower the window to the bottom of the Z order
213void wxWindowPalm::Lower()
214{
215}
216
0ab48d64 217void wxWindowPalm::SetLabel( const wxString& WXUNUSED(label))
ffecfa5a
JS
218{
219}
220
0ab48d64 221wxString wxWindowPalm::GetLabel() const
ffecfa5a 222{
db101bd3 223 return wxEmptyString;
ffecfa5a
JS
224}
225
226void wxWindowPalm::DoCaptureMouse()
227{
228}
229
230void wxWindowPalm::DoReleaseMouse()
231{
232}
233
234/* static */ wxWindow *wxWindowBase::GetCapture()
235{
236 return NULL;
237}
238
239bool wxWindowPalm::SetFont(const wxFont& font)
240{
241 return false;
242}
243bool wxWindowPalm::SetCursor(const wxCursor& cursor)
244{
245 return false;
246}
247
248void wxWindowPalm::WarpPointer (int x, int y)
249{
250}
251
252// ---------------------------------------------------------------------------
253// scrolling stuff
254// ---------------------------------------------------------------------------
255
256// convert wxHORIZONTAL/wxVERTICAL to SB_HORZ/SB_VERT
257static inline int wxDirToWinStyle(int orient)
258{
259 return 0;
260}
261
262int 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.
269int wxWindowPalm::GetScrollRange(int orient) const
270{
271 return 0;
272}
273
274int wxWindowPalm::GetScrollThumb(int orient) const
275{
276 return 0;
277}
278
279void wxWindowPalm::SetScrollPos(int orient, int pos, bool refresh)
280{
281}
282
283// New function that will replace some of the above.
284void wxWindowPalm::SetScrollbar(int orient,
285 int pos,
286 int pageSize,
287 int range,
288 bool refresh)
289{
290}
291
292void wxWindowPalm::ScrollWindow(int dx, int dy, const wxRect *prect)
293{
294}
295
296bool wxWindowPalm::ScrollLines(int lines)
297{
298 return false;
299}
300
301bool wxWindowPalm::ScrollPages(int pages)
302{
303 return false;
304}
305
ffecfa5a
JS
306// ----------------------------------------------------------------------------
307// Style handling
308// ----------------------------------------------------------------------------
309
ffecfa5a
JS
310WXDWORD wxWindowPalm::PalmGetStyle(long flags, WXDWORD *exstyle) const
311{
312 return 0;
313}
314
315// Setup background and foreground colours correctly
316void wxWindowPalm::SetupColours()
317{
318}
319
ffecfa5a
JS
320void wxWindowPalm::OnInternalIdle()
321{
322}
323
324// Set this window to be the child of 'parent'.
325bool wxWindowPalm::Reparent(wxWindowBase *parent)
326{
327 return false;
328}
329
ffecfa5a
JS
330void wxWindowPalm::Refresh(bool eraseBack, const wxRect *rect)
331{
e2fc40b4 332 WinHandle handle = (WinHandle)GetHWND();
324eeecb
WS
333 if(handle)
334 {
6afc1b46 335#ifdef __WXPALMOS6__
324eeecb
WS
336 if(rect)
337 {
338 RectangleType dirtyRect;
d2893292
WS
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;
324eeecb
WS
343 WinInvalidateRect(handle, &dirtyRect);
344 }
345 else
346 {
347 WinInvalidateWindow(handle);
348 }
6afc1b46
VZ
349#else // __WXPALMOS5__
350 WinSetActiveWindow (handle);
351#endif
352
324eeecb 353 }
ffecfa5a
JS
354}
355
356void wxWindowPalm::Update()
357{
358}
359
360// ---------------------------------------------------------------------------
361// drag and drop
362// ---------------------------------------------------------------------------
363
364
365#if wxUSE_DRAG_AND_DROP
366void 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.
373void wxWindowPalm::DragAcceptFiles(bool accept)
374{
375}
376
377// ----------------------------------------------------------------------------
378// tooltips
379// ----------------------------------------------------------------------------
380
381#if wxUSE_TOOLTIPS
382
383void wxWindowPalm::DoSetToolTip(wxToolTip *tooltip)
384{
385}
386
387#endif // wxUSE_TOOLTIPS
388
389// ---------------------------------------------------------------------------
390// moving and resizing
391// ---------------------------------------------------------------------------
392
393// Get total size
394void wxWindowPalm::DoGetSize(int *x, int *y) const
395{
396}
397
398// Get size *available for subwindows* i.e. excluding menu bar etc.
399void wxWindowPalm::DoGetClientSize(int *x, int *y) const
400{
401}
402
403void wxWindowPalm::DoGetPosition(int *x, int *y) const
404{
d2893292
WS
405 if(x)
406 *x = 0;
407 if(y)
408 *y = 0;
ffecfa5a
JS
409}
410
411void wxWindowPalm::DoScreenToClient(int *x, int *y) const
412{
413}
414
415void wxWindowPalm::DoClientToScreen(int *x, int *y) const
416{
417}
418
419void 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
431void wxWindowPalm::DoSetSize(int x, int y, int width, int height, int sizeFlags)
432{
324eeecb
WS
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);
ffecfa5a
JS
488}
489
490void wxWindowPalm::DoSetClientSize(int width, int height)
491{
492}
493
ffecfa5a
JS
494// ---------------------------------------------------------------------------
495// text metrics
496// ---------------------------------------------------------------------------
497
498int wxWindowPalm::GetCharHeight() const
499{
500 return 0;
501}
502
503int wxWindowPalm::GetCharWidth() const
504{
505 return 0;
506}
507
6de70470
VZ
508void wxWindowPalm::DoGetTextExtent(const wxString& string,
509 int *x, int *y,
510 int *descent,
511 int *externalLeading,
512 const wxFont *theFont) const
ffecfa5a
JS
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
527static void wxYieldForCommandsOnly()
528{
529}
530
531bool wxWindowPalm::DoPopupMenu(wxMenu *menu, int x, int y)
532{
533 return false;
534}
535
536#endif // wxUSE_MENUS_NATIVE
537
ffecfa5a
JS
538// ----------------------------------------------------------------------------
539// wxWindow <-> HWND map
540// ----------------------------------------------------------------------------
541
542wxWinHashTable *wxWinHandleHash = NULL;
543
324eeecb 544wxWindow *wxFindWinFromWinHandle(WXWINHANDLE handle)
ffecfa5a 545{
324eeecb 546 // TODO
ffecfa5a
JS
547 return NULL;
548}
549
550void wxRemoveHandleAssociation(wxWindowPalm *win)
551{
552}
553
554// ----------------------------------------------------------------------------
324eeecb 555// various Palm specific class dependent functions
ffecfa5a
JS
556// ----------------------------------------------------------------------------
557
ffecfa5a 558bool wxWindowPalm::PalmGetCreateWindowCoords(const wxPoint& pos,
324eeecb
WS
559 const wxSize& size,
560 int& x, int& y,
561 int& w, int& h) const
ffecfa5a
JS
562{
563 return false;
564}
565
ffecfa5a 566bool wxWindowPalm::PalmCreate(const wxChar *wclass,
324eeecb
WS
567 const wxChar *title,
568 const wxPoint& pos,
569 const wxSize& size,
570 WXDWORD style,
571 WXDWORD extendedStyle)
ffecfa5a
JS
572{
573 return false;
574}
575
576// ===========================================================================
577// Palm message handlers
578// ===========================================================================
579
ffecfa5a
JS
580// ---------------------------------------------------------------------------
581// painting
582// ---------------------------------------------------------------------------
583
ffecfa5a
JS
584// Can be called from an application's OnPaint handler
585void wxWindowPalm::OnPaint(wxPaintEvent& event)
586{
587}
588
ffecfa5a
JS
589void wxWindowPalm::OnEraseBackground(wxEraseEvent& event)
590{
591}
592
593// ---------------------------------------------------------------------------
594// moving and resizing
595// ---------------------------------------------------------------------------
596
ffecfa5a
JS
597bool wxWindowPalm::HandleMove(int x, int y)
598{
599 return false;
600}
601
602bool wxWindowPalm::HandleMoving(wxRect& rect)
603{
604 return false;
605}
606
ffecfa5a
JS
607// ---------------------------------------------------------------------------
608// joystick
609// ---------------------------------------------------------------------------
610
611bool wxWindowPalm::HandleJoystickEvent(WXUINT msg, int x, int y, WXUINT flags)
612{
613 return false;
614}
615
616// ---------------------------------------------------------------------------
617// scrolling
618// ---------------------------------------------------------------------------
619
620bool wxWindowPalm::PalmOnScroll(int orientation, WXWORD wParam,
324eeecb 621 WXWORD pos, WXWINHANDLE control)
4055ed82 622{
324eeecb 623 // TODO
ffecfa5a
JS
624 return false;
625}
626
627// ===========================================================================
628// global functions
629// ===========================================================================
630
324eeecb 631void wxGetCharSize(WXWINHANDLE wnd, int *x, int *y, const wxFont *the_font)
ffecfa5a 632{
324eeecb 633 // TODO
ffecfa5a
JS
634}
635
636#if wxUSE_HOTKEY
637
638bool wxWindowPalm::RegisterHotKey(int hotkeyId, int modifiers, int keycode)
639{
640 return false;
641}
642
643bool wxWindowPalm::UnregisterHotKey(int hotkeyId)
644{
645 return false;
646}
e2fc40b4 647#endif // # __WXUNIVERSAL__
ffecfa5a 648#endif // wxUSE_HOTKEY