PageRenderTime 26ms CodeModel.GetById 14ms RepoModel.GetById 0ms app.codeStats 0ms

/ExtLibs/wxWidgets/src/palmos/window.cpp

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