]> git.saurik.com Git - wxWidgets.git/blob - src/generic/scrlwing.cpp
changed wxString::StartsWidth/EndsWidth to take wxString argument instead of wxChar*
[wxWidgets.git] / src / generic / scrlwing.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/generic/scrlwing.cpp
3 // Purpose: wxScrolledWindow implementation
4 // Author: Julian Smart
5 // Modified by: Vadim Zeitlin on 31.08.00: wxScrollHelper allows to implement.
6 // Ron Lee on 10.4.02: virtual size / auto scrollbars et al.
7 // Created: 01/02/97
8 // RCS-ID: $Id$
9 // Copyright: (c) wxWidgets team
10 // Licence: wxWindows licence
11 /////////////////////////////////////////////////////////////////////////////
12
13 // ============================================================================
14 // declarations
15 // ============================================================================
16
17 // ----------------------------------------------------------------------------
18 // headers
19 // ----------------------------------------------------------------------------
20
21 #ifdef __VMS
22 #define XtDisplay XTDISPLAY
23 #endif
24
25 // For compilers that support precompilation, includes "wx.h".
26 #include "wx/wxprec.h"
27
28 #ifdef __BORLANDC__
29 #pragma hdrstop
30 #endif
31
32 #include "wx/scrolwin.h"
33
34 #ifndef WX_PRECOMP
35 #include "wx/utils.h"
36 #include "wx/panel.h"
37 #include "wx/dcclient.h"
38 #if wxUSE_TIMER
39 #include "wx/timer.h"
40 #endif
41 #include "wx/sizer.h"
42 #endif
43
44 #ifdef __WXMAC__
45 #include "wx/scrolbar.h"
46 #endif
47
48 #include "wx/recguard.h"
49
50 #ifdef __WXMSW__
51 #include <windows.h> // for DLGC_WANTARROWS
52 #include "wx/msw/winundef.h"
53 #endif
54
55 #ifdef __WXMOTIF__
56 // For wxRETAINED implementation
57 #ifdef __VMS__ //VMS's Xm.h is not (yet) compatible with C++
58 //This code switches off the compiler warnings
59 # pragma message disable nosimpint
60 #endif
61 #include <Xm/Xm.h>
62 #ifdef __VMS__
63 # pragma message enable nosimpint
64 #endif
65 #endif
66
67 /*
68 TODO PROPERTIES
69 style wxHSCROLL | wxVSCROLL
70 */
71
72 // ----------------------------------------------------------------------------
73 // wxScrollHelperEvtHandler: intercept the events from the window and forward
74 // them to wxScrollHelper
75 // ----------------------------------------------------------------------------
76
77 class WXDLLEXPORT wxScrollHelperEvtHandler : public wxEvtHandler
78 {
79 public:
80 wxScrollHelperEvtHandler(wxScrollHelper *scrollHelper)
81 {
82 m_scrollHelper = scrollHelper;
83 }
84
85 virtual bool ProcessEvent(wxEvent& event);
86
87 void ResetDrawnFlag() { m_hasDrawnWindow = false; }
88
89 private:
90 wxScrollHelper *m_scrollHelper;
91
92 bool m_hasDrawnWindow;
93
94 DECLARE_NO_COPY_CLASS(wxScrollHelperEvtHandler)
95 };
96
97 #if wxUSE_TIMER
98 // ----------------------------------------------------------------------------
99 // wxAutoScrollTimer: the timer used to generate a stream of scroll events when
100 // a captured mouse is held outside the window
101 // ----------------------------------------------------------------------------
102
103 class wxAutoScrollTimer : public wxTimer
104 {
105 public:
106 wxAutoScrollTimer(wxWindow *winToScroll, wxScrollHelper *scroll,
107 wxEventType eventTypeToSend,
108 int pos, int orient);
109
110 virtual void Notify();
111
112 private:
113 wxWindow *m_win;
114 wxScrollHelper *m_scrollHelper;
115 wxEventType m_eventType;
116 int m_pos,
117 m_orient;
118
119 DECLARE_NO_COPY_CLASS(wxAutoScrollTimer)
120 };
121
122 // ============================================================================
123 // implementation
124 // ============================================================================
125
126 // ----------------------------------------------------------------------------
127 // wxAutoScrollTimer
128 // ----------------------------------------------------------------------------
129
130 wxAutoScrollTimer::wxAutoScrollTimer(wxWindow *winToScroll,
131 wxScrollHelper *scroll,
132 wxEventType eventTypeToSend,
133 int pos, int orient)
134 {
135 m_win = winToScroll;
136 m_scrollHelper = scroll;
137 m_eventType = eventTypeToSend;
138 m_pos = pos;
139 m_orient = orient;
140 }
141
142 void wxAutoScrollTimer::Notify()
143 {
144 // only do all this as long as the window is capturing the mouse
145 if ( wxWindow::GetCapture() != m_win )
146 {
147 Stop();
148 }
149 else // we still capture the mouse, continue generating events
150 {
151 // first scroll the window if we are allowed to do it
152 wxScrollWinEvent event1(m_eventType, m_pos, m_orient);
153 event1.SetEventObject(m_win);
154 if ( m_scrollHelper->SendAutoScrollEvents(event1) &&
155 m_win->GetEventHandler()->ProcessEvent(event1) )
156 {
157 // and then send a pseudo mouse-move event to refresh the selection
158 wxMouseEvent event2(wxEVT_MOTION);
159 wxGetMousePosition(&event2.m_x, &event2.m_y);
160
161 // the mouse event coordinates should be client, not screen as
162 // returned by wxGetMousePosition
163 wxWindow *parentTop = m_win;
164 while ( parentTop->GetParent() )
165 parentTop = parentTop->GetParent();
166 wxPoint ptOrig = parentTop->GetPosition();
167 event2.m_x -= ptOrig.x;
168 event2.m_y -= ptOrig.y;
169
170 event2.SetEventObject(m_win);
171
172 // FIXME: we don't fill in the other members - ok?
173
174 m_win->GetEventHandler()->ProcessEvent(event2);
175 }
176 else // can't scroll further, stop
177 {
178 Stop();
179 }
180 }
181 }
182 #endif
183
184 // ----------------------------------------------------------------------------
185 // wxScrollHelperEvtHandler
186 // ----------------------------------------------------------------------------
187
188 bool wxScrollHelperEvtHandler::ProcessEvent(wxEvent& event)
189 {
190 wxEventType evType = event.GetEventType();
191
192 // the explanation of wxEVT_PAINT processing hack: for historic reasons
193 // there are 2 ways to process this event in classes deriving from
194 // wxScrolledWindow. The user code may
195 //
196 // 1. override wxScrolledWindow::OnDraw(dc)
197 // 2. define its own OnPaint() handler
198 //
199 // In addition, in wxUniversal wxWindow defines OnPaint() itself and
200 // always processes the draw event, so we can't just try the window
201 // OnPaint() first and call our HandleOnPaint() if it doesn't process it
202 // (the latter would never be called in wxUniversal).
203 //
204 // So the solution is to have a flag telling us whether the user code drew
205 // anything in the window. We set it to true here but reset it to false in
206 // wxScrolledWindow::OnPaint() handler (which wouldn't be called if the
207 // user code defined OnPaint() in the derived class)
208 m_hasDrawnWindow = true;
209
210 // pass it on to the real handler
211 bool processed = wxEvtHandler::ProcessEvent(event);
212
213 // always process the size events ourselves, even if the user code handles
214 // them as well, as we need to AdjustScrollbars()
215 //
216 // NB: it is important to do it after processing the event in the normal
217 // way as HandleOnSize() may generate a wxEVT_SIZE itself if the
218 // scrollbar[s] (dis)appear and it should be seen by the user code
219 // after this one
220 if ( evType == wxEVT_SIZE )
221 {
222 m_scrollHelper->HandleOnSize((wxSizeEvent &)event);
223
224 return true;
225 }
226
227 if ( processed )
228 {
229 // normally, nothing more to do here - except if it was a paint event
230 // which wasn't really processed, then we'll try to call our
231 // OnDraw() below (from HandleOnPaint)
232 if ( m_hasDrawnWindow || event.IsCommandEvent() )
233 {
234 return true;
235 }
236 }
237
238 if ( evType == wxEVT_PAINT )
239 {
240 m_scrollHelper->HandleOnPaint((wxPaintEvent &)event);
241 return true;
242 }
243
244 // reset the skipped flag (which might have been set to true in
245 // ProcessEvent() above) to be able to test it below
246 bool wasSkipped = event.GetSkipped();
247 if ( wasSkipped )
248 event.Skip(false);
249
250 if ( evType == wxEVT_SCROLLWIN_TOP ||
251 evType == wxEVT_SCROLLWIN_BOTTOM ||
252 evType == wxEVT_SCROLLWIN_LINEUP ||
253 evType == wxEVT_SCROLLWIN_LINEDOWN ||
254 evType == wxEVT_SCROLLWIN_PAGEUP ||
255 evType == wxEVT_SCROLLWIN_PAGEDOWN ||
256 evType == wxEVT_SCROLLWIN_THUMBTRACK ||
257 evType == wxEVT_SCROLLWIN_THUMBRELEASE )
258 {
259 m_scrollHelper->HandleOnScroll((wxScrollWinEvent &)event);
260 if ( !event.GetSkipped() )
261 {
262 // it makes sense to indicate that we processed the message as we
263 // did scroll the window (and also notice that wxAutoScrollTimer
264 // relies on our return value to stop scrolling when we are at top
265 // or bottom already)
266 processed = true;
267 wasSkipped = false;
268 }
269 }
270
271 if ( evType == wxEVT_ENTER_WINDOW )
272 {
273 m_scrollHelper->HandleOnMouseEnter((wxMouseEvent &)event);
274 }
275 else if ( evType == wxEVT_LEAVE_WINDOW )
276 {
277 m_scrollHelper->HandleOnMouseLeave((wxMouseEvent &)event);
278 }
279 #if wxUSE_MOUSEWHEEL
280 else if ( evType == wxEVT_MOUSEWHEEL )
281 {
282 m_scrollHelper->HandleOnMouseWheel((wxMouseEvent &)event);
283 }
284 #endif // wxUSE_MOUSEWHEEL
285 else if ( evType == wxEVT_CHAR )
286 {
287 m_scrollHelper->HandleOnChar((wxKeyEvent &)event);
288 if ( !event.GetSkipped() )
289 {
290 processed = true;
291 wasSkipped = false;
292 }
293 }
294
295 if ( processed )
296 event.Skip(wasSkipped);
297
298 return processed;
299 }
300
301 // ----------------------------------------------------------------------------
302 // wxScrollHelper construction
303 // ----------------------------------------------------------------------------
304
305 wxScrollHelper::wxScrollHelper(wxWindow *win)
306 {
307 wxASSERT_MSG( win, _T("associated window can't be NULL in wxScrollHelper") );
308
309 m_xScrollPixelsPerLine =
310 m_yScrollPixelsPerLine =
311 m_xScrollPosition =
312 m_yScrollPosition =
313 m_xScrollLines =
314 m_yScrollLines =
315 m_xScrollLinesPerPage =
316 m_yScrollLinesPerPage = 0;
317
318 m_xScrollingEnabled =
319 m_yScrollingEnabled = true;
320
321 m_scaleX =
322 m_scaleY = 1.0;
323 #if wxUSE_MOUSEWHEEL
324 m_wheelRotation = 0;
325 #endif
326
327 m_win =
328 m_targetWindow = (wxWindow *)NULL;
329
330 m_timerAutoScroll = (wxTimer *)NULL;
331
332 m_handler = NULL;
333
334 m_win = win;
335
336 m_win->SetScrollHelper( this );
337
338 // by default, the associated window is also the target window
339 DoSetTargetWindow(win);
340 }
341
342 wxScrollHelper::~wxScrollHelper()
343 {
344 StopAutoScrolling();
345
346 DeleteEvtHandler();
347 }
348
349 // ----------------------------------------------------------------------------
350 // setting scrolling parameters
351 // ----------------------------------------------------------------------------
352
353 void wxScrollHelper::SetScrollbars(int pixelsPerUnitX,
354 int pixelsPerUnitY,
355 int noUnitsX,
356 int noUnitsY,
357 int xPos,
358 int yPos,
359 bool noRefresh)
360 {
361 int xpos, ypos;
362
363 CalcUnscrolledPosition(xPos, yPos, &xpos, &ypos);
364 bool do_refresh =
365 (
366 (noUnitsX != 0 && m_xScrollLines == 0) ||
367 (noUnitsX < m_xScrollLines && xpos > pixelsPerUnitX * noUnitsX) ||
368
369 (noUnitsY != 0 && m_yScrollLines == 0) ||
370 (noUnitsY < m_yScrollLines && ypos > pixelsPerUnitY * noUnitsY) ||
371 (xPos != m_xScrollPosition) ||
372 (yPos != m_yScrollPosition)
373 );
374
375 m_xScrollPixelsPerLine = pixelsPerUnitX;
376 m_yScrollPixelsPerLine = pixelsPerUnitY;
377 m_xScrollPosition = xPos;
378 m_yScrollPosition = yPos;
379
380 int w = noUnitsX * pixelsPerUnitX;
381 int h = noUnitsY * pixelsPerUnitY;
382
383 // For better backward compatibility we set persisting limits
384 // here not just the size. It makes SetScrollbars 'sticky'
385 // emulating the old non-autoscroll behaviour.
386 // m_targetWindow->SetVirtualSizeHints( w, h );
387
388 // The above should arguably be deprecated, this however we still need.
389
390 // take care not to set 0 virtual size, 0 means that we don't have any
391 // scrollbars and hence we should use the real size instead of the virtual
392 // one which is indicated by using wxDefaultCoord
393 m_targetWindow->SetVirtualSize( w ? w : wxDefaultCoord,
394 h ? h : wxDefaultCoord);
395
396 if (do_refresh && !noRefresh)
397 m_targetWindow->Refresh(true, GetScrollRect());
398
399 #ifndef __WXUNIVERSAL__
400 // If the target is not the same as the window with the scrollbars,
401 // then we need to update the scrollbars here, since they won't have
402 // been updated by SetVirtualSize().
403 if ( m_targetWindow != m_win )
404 #endif // !__WXUNIVERSAL__
405 {
406 AdjustScrollbars();
407 }
408 #ifndef __WXUNIVERSAL__
409 else
410 {
411 // otherwise this has been done by AdjustScrollbars, above
412 }
413 #endif // !__WXUNIVERSAL__
414 }
415
416 // ----------------------------------------------------------------------------
417 // [target] window handling
418 // ----------------------------------------------------------------------------
419
420 void wxScrollHelper::DeleteEvtHandler()
421 {
422 // search for m_handler in the handler list
423 if ( m_win && m_handler )
424 {
425 if ( m_win->RemoveEventHandler(m_handler) )
426 {
427 delete m_handler;
428 }
429 //else: something is very wrong, so better [maybe] leak memory than
430 // risk a crash because of double deletion
431
432 m_handler = NULL;
433 }
434 }
435
436 void wxScrollHelper::DoSetTargetWindow(wxWindow *target)
437 {
438 m_targetWindow = target;
439 #ifdef __WXMAC__
440 target->MacSetClipChildren( true ) ;
441 #endif
442
443 // install the event handler which will intercept the events we're
444 // interested in (but only do it for our real window, not the target window
445 // which we scroll - we don't need to hijack its events)
446 if ( m_targetWindow == m_win )
447 {
448 // if we already have a handler, delete it first
449 DeleteEvtHandler();
450
451 m_handler = new wxScrollHelperEvtHandler(this);
452 m_targetWindow->PushEventHandler(m_handler);
453 }
454 }
455
456 void wxScrollHelper::SetTargetWindow(wxWindow *target)
457 {
458 wxCHECK_RET( target, wxT("target window must not be NULL") );
459
460 if ( target == m_targetWindow )
461 return;
462
463 DoSetTargetWindow(target);
464 }
465
466 wxWindow *wxScrollHelper::GetTargetWindow() const
467 {
468 return m_targetWindow;
469 }
470
471 #ifdef __WXMAC__
472 static bool wxScrolledWindowHasChildren(wxWindow* win)
473 {
474 wxWindowList::compatibility_iterator node = win->GetChildren().GetFirst();
475 while ( node )
476 {
477 wxWindow* child = node->GetData();
478 if ( !child->IsKindOf(CLASSINFO(wxScrollBar)) )
479 return true;
480
481 node = node->GetNext();
482 }
483 return false;
484 }
485 #endif
486
487 // ----------------------------------------------------------------------------
488 // scrolling implementation itself
489 // ----------------------------------------------------------------------------
490
491 void wxScrollHelper::HandleOnScroll(wxScrollWinEvent& event)
492 {
493 int nScrollInc = CalcScrollInc(event);
494 if ( nScrollInc == 0 )
495 {
496 // can't scroll further
497 event.Skip();
498
499 return;
500 }
501
502 bool needsRefresh = false;
503 int dx = 0,
504 dy = 0;
505 int orient = event.GetOrientation();
506 if (orient == wxHORIZONTAL)
507 {
508 if ( m_xScrollingEnabled )
509 {
510 dx = -m_xScrollPixelsPerLine * nScrollInc;
511 }
512 else
513 {
514 needsRefresh = true;
515 }
516 }
517 else
518 {
519 if ( m_yScrollingEnabled )
520 {
521 dy = -m_yScrollPixelsPerLine * nScrollInc;
522 }
523 else
524 {
525 needsRefresh = true;
526 }
527 }
528
529 if ( !needsRefresh )
530 {
531 // flush all pending repaints before we change m_{x,y}ScrollPosition, as
532 // otherwise invalidated area could be updated incorrectly later when
533 // ScrollWindow() makes sure they're repainted before scrolling them
534 #ifdef __WXMAC__
535 // wxWindowMac is taking care of making sure the update area is correctly
536 // set up, while not forcing an immediate redraw
537 #else
538 m_targetWindow->Update();
539 #endif
540 }
541
542 if (orient == wxHORIZONTAL)
543 {
544 m_xScrollPosition += nScrollInc;
545 m_win->SetScrollPos(wxHORIZONTAL, m_xScrollPosition);
546 }
547 else
548 {
549 m_yScrollPosition += nScrollInc;
550 m_win->SetScrollPos(wxVERTICAL, m_yScrollPosition);
551 }
552
553 if ( needsRefresh )
554 {
555 m_targetWindow->Refresh(true, GetScrollRect());
556 }
557 else
558 {
559 m_targetWindow->ScrollWindow(dx, dy, GetScrollRect());
560 }
561 }
562
563 int wxScrollHelper::CalcScrollInc(wxScrollWinEvent& event)
564 {
565 int pos = event.GetPosition();
566 int orient = event.GetOrientation();
567
568 int nScrollInc = 0;
569 if (event.GetEventType() == wxEVT_SCROLLWIN_TOP)
570 {
571 if (orient == wxHORIZONTAL)
572 nScrollInc = - m_xScrollPosition;
573 else
574 nScrollInc = - m_yScrollPosition;
575 } else
576 if (event.GetEventType() == wxEVT_SCROLLWIN_BOTTOM)
577 {
578 if (orient == wxHORIZONTAL)
579 nScrollInc = m_xScrollLines - m_xScrollPosition;
580 else
581 nScrollInc = m_yScrollLines - m_yScrollPosition;
582 } else
583 if (event.GetEventType() == wxEVT_SCROLLWIN_LINEUP)
584 {
585 nScrollInc = -1;
586 } else
587 if (event.GetEventType() == wxEVT_SCROLLWIN_LINEDOWN)
588 {
589 nScrollInc = 1;
590 } else
591 if (event.GetEventType() == wxEVT_SCROLLWIN_PAGEUP)
592 {
593 if (orient == wxHORIZONTAL)
594 nScrollInc = -GetScrollPageSize(wxHORIZONTAL);
595 else
596 nScrollInc = -GetScrollPageSize(wxVERTICAL);
597 } else
598 if (event.GetEventType() == wxEVT_SCROLLWIN_PAGEDOWN)
599 {
600 if (orient == wxHORIZONTAL)
601 nScrollInc = GetScrollPageSize(wxHORIZONTAL);
602 else
603 nScrollInc = GetScrollPageSize(wxVERTICAL);
604 } else
605 if ((event.GetEventType() == wxEVT_SCROLLWIN_THUMBTRACK) ||
606 (event.GetEventType() == wxEVT_SCROLLWIN_THUMBRELEASE))
607 {
608 if (orient == wxHORIZONTAL)
609 nScrollInc = pos - m_xScrollPosition;
610 else
611 nScrollInc = pos - m_yScrollPosition;
612 }
613
614 if (orient == wxHORIZONTAL)
615 {
616 if ( m_xScrollPosition + nScrollInc < 0 )
617 {
618 // As -ve as we can go
619 nScrollInc = -m_xScrollPosition;
620 }
621 else // check for the other bound
622 {
623 const int posMax = m_xScrollLines - m_xScrollLinesPerPage;
624 if ( m_xScrollPosition + nScrollInc > posMax )
625 {
626 // As +ve as we can go
627 nScrollInc = posMax - m_xScrollPosition;
628 }
629 }
630 }
631 else // wxVERTICAL
632 {
633 if ( m_yScrollPosition + nScrollInc < 0 )
634 {
635 // As -ve as we can go
636 nScrollInc = -m_yScrollPosition;
637 }
638 else // check for the other bound
639 {
640 const int posMax = m_yScrollLines - m_yScrollLinesPerPage;
641 if ( m_yScrollPosition + nScrollInc > posMax )
642 {
643 // As +ve as we can go
644 nScrollInc = posMax - m_yScrollPosition;
645 }
646 }
647 }
648
649 return nScrollInc;
650 }
651
652 // Adjust the scrollbars - new version.
653 void wxScrollHelper::AdjustScrollbars()
654 {
655 static wxRecursionGuardFlag s_flagReentrancy;
656 wxRecursionGuard guard(s_flagReentrancy);
657 if ( guard.IsInside() )
658 {
659 // don't reenter AdjustScrollbars() while another call to
660 // AdjustScrollbars() is in progress because this may lead to calling
661 // ScrollWindow() twice and this can really happen under MSW if
662 // SetScrollbar() call below adds or removes the scrollbar which
663 // changes the window size and hence results in another
664 // AdjustScrollbars() call
665 return;
666 }
667
668 int w = 0, h = 0;
669 int oldw, oldh;
670
671 int oldXScroll = m_xScrollPosition;
672 int oldYScroll = m_yScrollPosition;
673
674 // VZ: at least under Windows this loop is useless because when scrollbars
675 // [dis]appear we get a WM_SIZE resulting in another call to
676 // AdjustScrollbars() anyhow. As it doesn't seem to do any harm I leave
677 // it here for now but it would be better to ensure that all ports
678 // generate EVT_SIZE when scrollbars [dis]appear, emulating it if
679 // necessary, and remove it later
680 // JACS: Stop potential infinite loop by limiting number of iterations
681 int iterationCount = 0;
682 const int iterationMax = 5;
683 do
684 {
685 iterationCount ++;
686
687 GetTargetSize(&w, 0);
688
689 // scroll lines per page: if 0, no scrolling is needed
690 int linesPerPage;
691
692 if ( m_xScrollPixelsPerLine == 0 )
693 {
694 // scrolling is disabled
695 m_xScrollLines = 0;
696 m_xScrollPosition = 0;
697 linesPerPage = 0;
698 }
699 else // might need scrolling
700 {
701 // Round up integer division to catch any "leftover" client space.
702 const int wVirt = m_targetWindow->GetVirtualSize().GetWidth();
703 m_xScrollLines = (wVirt + m_xScrollPixelsPerLine - 1) / m_xScrollPixelsPerLine;
704
705 // Calculate page size i.e. number of scroll units you get on the
706 // current client window.
707 linesPerPage = w / m_xScrollPixelsPerLine;
708
709 // Special case. When client and virtual size are very close but
710 // the client is big enough, kill scrollbar.
711 if ((linesPerPage < m_xScrollLines) && (w >= wVirt)) ++linesPerPage;
712
713 if (linesPerPage >= m_xScrollLines)
714 {
715 // we're big enough to not need scrolling
716 linesPerPage =
717 m_xScrollLines =
718 m_xScrollPosition = 0;
719 }
720 else // we do need a scrollbar
721 {
722 if ( linesPerPage < 1 )
723 linesPerPage = 1;
724
725 // Correct position if greater than extent of canvas minus
726 // the visible portion of it or if below zero
727 const int posMax = m_xScrollLines - linesPerPage;
728 if ( m_xScrollPosition > posMax )
729 m_xScrollPosition = posMax;
730 else if ( m_xScrollPosition < 0 )
731 m_xScrollPosition = 0;
732 }
733 }
734
735 m_win->SetScrollbar(wxHORIZONTAL, m_xScrollPosition,
736 linesPerPage, m_xScrollLines);
737
738 // The amount by which we scroll when paging
739 SetScrollPageSize(wxHORIZONTAL, linesPerPage);
740
741 GetTargetSize(0, &h);
742
743 if ( m_yScrollPixelsPerLine == 0 )
744 {
745 // scrolling is disabled
746 m_yScrollLines = 0;
747 m_yScrollPosition = 0;
748 linesPerPage = 0;
749 }
750 else // might need scrolling
751 {
752 // Round up integer division to catch any "leftover" client space.
753 const int hVirt = m_targetWindow->GetVirtualSize().GetHeight();
754 m_yScrollLines = ( hVirt + m_yScrollPixelsPerLine - 1 ) / m_yScrollPixelsPerLine;
755
756 // Calculate page size i.e. number of scroll units you get on the
757 // current client window.
758 linesPerPage = h / m_yScrollPixelsPerLine;
759
760 // Special case. When client and virtual size are very close but
761 // the client is big enough, kill scrollbar.
762 if ((linesPerPage < m_yScrollLines) && (h >= hVirt)) ++linesPerPage;
763
764 if (linesPerPage >= m_yScrollLines)
765 {
766 // we're big enough to not need scrolling
767 linesPerPage =
768 m_yScrollLines =
769 m_yScrollPosition = 0;
770 }
771 else // we do need a scrollbar
772 {
773 if ( linesPerPage < 1 )
774 linesPerPage = 1;
775
776 // Correct position if greater than extent of canvas minus
777 // the visible portion of it or if below zero
778 const int posMax = m_yScrollLines - linesPerPage;
779 if ( m_yScrollPosition > posMax )
780 m_yScrollPosition = posMax;
781 else if ( m_yScrollPosition < 0 )
782 m_yScrollPosition = 0;
783 }
784 }
785
786 m_win->SetScrollbar(wxVERTICAL, m_yScrollPosition,
787 linesPerPage, m_yScrollLines);
788
789 // The amount by which we scroll when paging
790 SetScrollPageSize(wxVERTICAL, linesPerPage);
791
792
793 // If a scrollbar (dis)appeared as a result of this, adjust them again.
794 oldw = w;
795 oldh = h;
796
797 GetTargetSize( &w, &h );
798 } while ( (w != oldw || h != oldh) && (iterationCount < iterationMax) );
799
800 #ifdef __WXMOTIF__
801 // Sorry, some Motif-specific code to implement a backing pixmap
802 // for the wxRETAINED style. Implementing a backing store can't
803 // be entirely generic because it relies on the wxWindowDC implementation
804 // to duplicate X drawing calls for the backing pixmap.
805
806 if ( m_targetWindow->GetWindowStyle() & wxRETAINED )
807 {
808 Display* dpy = XtDisplay((Widget)m_targetWindow->GetMainWidget());
809
810 int totalPixelWidth = m_xScrollLines * m_xScrollPixelsPerLine;
811 int totalPixelHeight = m_yScrollLines * m_yScrollPixelsPerLine;
812 if (m_targetWindow->GetBackingPixmap() &&
813 !((m_targetWindow->GetPixmapWidth() == totalPixelWidth) &&
814 (m_targetWindow->GetPixmapHeight() == totalPixelHeight)))
815 {
816 XFreePixmap (dpy, (Pixmap) m_targetWindow->GetBackingPixmap());
817 m_targetWindow->SetBackingPixmap((WXPixmap) 0);
818 }
819
820 if (!m_targetWindow->GetBackingPixmap() &&
821 (m_xScrollLines != 0) && (m_yScrollLines != 0))
822 {
823 int depth = wxDisplayDepth();
824 m_targetWindow->SetPixmapWidth(totalPixelWidth);
825 m_targetWindow->SetPixmapHeight(totalPixelHeight);
826 m_targetWindow->SetBackingPixmap((WXPixmap) XCreatePixmap (dpy, RootWindow (dpy, DefaultScreen (dpy)),
827 m_targetWindow->GetPixmapWidth(), m_targetWindow->GetPixmapHeight(), depth));
828 }
829
830 }
831 #endif // Motif
832
833 if (oldXScroll != m_xScrollPosition)
834 {
835 if (m_xScrollingEnabled)
836 m_targetWindow->ScrollWindow( m_xScrollPixelsPerLine * (oldXScroll - m_xScrollPosition), 0,
837 GetScrollRect() );
838 else
839 m_targetWindow->Refresh(true, GetScrollRect());
840 }
841
842 if (oldYScroll != m_yScrollPosition)
843 {
844 if (m_yScrollingEnabled)
845 m_targetWindow->ScrollWindow( 0, m_yScrollPixelsPerLine * (oldYScroll-m_yScrollPosition),
846 GetScrollRect() );
847 else
848 m_targetWindow->Refresh(true, GetScrollRect());
849 }
850 }
851
852 void wxScrollHelper::DoPrepareDC(wxDC& dc)
853 {
854 wxPoint pt = dc.GetDeviceOrigin();
855 #ifdef __WXGTK__
856 // It may actually be correct to always query
857 // the m_sign from the DC here, but I leve the
858 // #ifdef GTK for now.
859 if (m_win->GetLayoutDirection() == wxLayout_RightToLeft)
860 dc.SetDeviceOrigin( pt.x + m_xScrollPosition * m_xScrollPixelsPerLine,
861 pt.y - m_yScrollPosition * m_yScrollPixelsPerLine );
862 else
863 #endif
864 dc.SetDeviceOrigin( pt.x - m_xScrollPosition * m_xScrollPixelsPerLine,
865 pt.y - m_yScrollPosition * m_yScrollPixelsPerLine );
866 dc.SetUserScale( m_scaleX, m_scaleY );
867 }
868
869 void wxScrollHelper::SetScrollRate( int xstep, int ystep )
870 {
871 int old_x = m_xScrollPixelsPerLine * m_xScrollPosition;
872 int old_y = m_yScrollPixelsPerLine * m_yScrollPosition;
873
874 m_xScrollPixelsPerLine = xstep;
875 m_yScrollPixelsPerLine = ystep;
876
877 int new_x = m_xScrollPixelsPerLine * m_xScrollPosition;
878 int new_y = m_yScrollPixelsPerLine * m_yScrollPosition;
879
880 m_win->SetScrollPos( wxHORIZONTAL, m_xScrollPosition );
881 m_win->SetScrollPos( wxVERTICAL, m_yScrollPosition );
882 m_targetWindow->ScrollWindow( old_x - new_x, old_y - new_y );
883
884 AdjustScrollbars();
885 }
886
887 void wxScrollHelper::GetScrollPixelsPerUnit (int *x_unit, int *y_unit) const
888 {
889 if ( x_unit )
890 *x_unit = m_xScrollPixelsPerLine;
891 if ( y_unit )
892 *y_unit = m_yScrollPixelsPerLine;
893 }
894
895
896 int wxScrollHelper::GetScrollLines( int orient ) const
897 {
898 if ( orient == wxHORIZONTAL )
899 return m_xScrollLines;
900 else
901 return m_yScrollLines;
902 }
903
904 int wxScrollHelper::GetScrollPageSize(int orient) const
905 {
906 if ( orient == wxHORIZONTAL )
907 return m_xScrollLinesPerPage;
908 else
909 return m_yScrollLinesPerPage;
910 }
911
912 void wxScrollHelper::SetScrollPageSize(int orient, int pageSize)
913 {
914 if ( orient == wxHORIZONTAL )
915 m_xScrollLinesPerPage = pageSize;
916 else
917 m_yScrollLinesPerPage = pageSize;
918 }
919
920 /*
921 * Scroll to given position (scroll position, not pixel position)
922 */
923 void wxScrollHelper::Scroll( int x_pos, int y_pos )
924 {
925 if (!m_targetWindow)
926 return;
927
928 if (((x_pos == -1) || (x_pos == m_xScrollPosition)) &&
929 ((y_pos == -1) || (y_pos == m_yScrollPosition))) return;
930
931 int w = 0, h = 0;
932 GetTargetSize(&w, &h);
933
934 // compute new position:
935 int new_x = m_xScrollPosition;
936 int new_y = m_yScrollPosition;
937
938 if ((x_pos != -1) && (m_xScrollPixelsPerLine))
939 {
940 new_x = x_pos;
941
942 // Calculate page size i.e. number of scroll units you get on the
943 // current client window
944 int noPagePositions = w/m_xScrollPixelsPerLine;
945 if (noPagePositions < 1) noPagePositions = 1;
946
947 // Correct position if greater than extent of canvas minus
948 // the visible portion of it or if below zero
949 new_x = wxMin( m_xScrollLines-noPagePositions, new_x );
950 new_x = wxMax( 0, new_x );
951 }
952 if ((y_pos != -1) && (m_yScrollPixelsPerLine))
953 {
954 new_y = y_pos;
955
956 // Calculate page size i.e. number of scroll units you get on the
957 // current client window
958 int noPagePositions = h/m_yScrollPixelsPerLine;
959 if (noPagePositions < 1) noPagePositions = 1;
960
961 // Correct position if greater than extent of canvas minus
962 // the visible portion of it or if below zero
963 new_y = wxMin( m_yScrollLines-noPagePositions, new_y );
964 new_y = wxMax( 0, new_y );
965 }
966
967 if ( new_x == m_xScrollPosition && new_y == m_yScrollPosition )
968 return; // nothing to do, the position didn't change
969
970 // flush all pending repaints before we change m_{x,y}ScrollPosition, as
971 // otherwise invalidated area could be updated incorrectly later when
972 // ScrollWindow() makes sure they're repainted before scrolling them
973 m_targetWindow->Update();
974
975 // update the position and scroll the window now:
976 if (m_xScrollPosition != new_x)
977 {
978 int old_x = m_xScrollPosition;
979 m_xScrollPosition = new_x;
980 m_win->SetScrollPos( wxHORIZONTAL, new_x );
981 m_targetWindow->ScrollWindow( (old_x-new_x)*m_xScrollPixelsPerLine, 0,
982 GetScrollRect() );
983 }
984
985 if (m_yScrollPosition != new_y)
986 {
987 int old_y = m_yScrollPosition;
988 m_yScrollPosition = new_y;
989 m_win->SetScrollPos( wxVERTICAL, new_y );
990 m_targetWindow->ScrollWindow( 0, (old_y-new_y)*m_yScrollPixelsPerLine,
991 GetScrollRect() );
992 }
993 }
994
995 void wxScrollHelper::EnableScrolling (bool x_scroll, bool y_scroll)
996 {
997 m_xScrollingEnabled = x_scroll;
998 m_yScrollingEnabled = y_scroll;
999 }
1000
1001 // Where the current view starts from
1002 void wxScrollHelper::GetViewStart (int *x, int *y) const
1003 {
1004 if ( x )
1005 *x = m_xScrollPosition;
1006 if ( y )
1007 *y = m_yScrollPosition;
1008 }
1009
1010 void wxScrollHelper::DoCalcScrolledPosition(int x, int y, int *xx, int *yy) const
1011 {
1012 if ( xx )
1013 *xx = x - m_xScrollPosition * m_xScrollPixelsPerLine;
1014 if ( yy )
1015 *yy = y - m_yScrollPosition * m_yScrollPixelsPerLine;
1016 }
1017
1018 void wxScrollHelper::DoCalcUnscrolledPosition(int x, int y, int *xx, int *yy) const
1019 {
1020 if ( xx )
1021 *xx = x + m_xScrollPosition * m_xScrollPixelsPerLine;
1022 if ( yy )
1023 *yy = y + m_yScrollPosition * m_yScrollPixelsPerLine;
1024 }
1025
1026 // ----------------------------------------------------------------------------
1027 // geometry
1028 // ----------------------------------------------------------------------------
1029
1030 bool wxScrollHelper::ScrollLayout()
1031 {
1032 if ( m_win->GetSizer() && m_targetWindow == m_win )
1033 {
1034 // If we're the scroll target, take into account the
1035 // virtual size and scrolled position of the window.
1036
1037 int x = 0, y = 0, w = 0, h = 0;
1038 CalcScrolledPosition(0,0, &x,&y);
1039 m_win->GetVirtualSize(&w, &h);
1040 m_win->GetSizer()->SetDimension(x, y, w, h);
1041 return true;
1042 }
1043
1044 // fall back to default for LayoutConstraints
1045 return m_win->wxWindow::Layout();
1046 }
1047
1048 void wxScrollHelper::ScrollDoSetVirtualSize(int x, int y)
1049 {
1050 m_win->wxWindow::DoSetVirtualSize( x, y );
1051 AdjustScrollbars();
1052
1053 if (m_win->GetAutoLayout())
1054 m_win->Layout();
1055 }
1056
1057 // wxWindow's GetBestVirtualSize returns the actual window size,
1058 // whereas we want to return the virtual size
1059 wxSize wxScrollHelper::ScrollGetBestVirtualSize() const
1060 {
1061 wxSize clientSize(m_win->GetClientSize());
1062 if ( m_win->GetSizer() )
1063 clientSize.IncTo(m_win->GetSizer()->CalcMin());
1064
1065 return clientSize;
1066 }
1067
1068 // return the window best size from the given best virtual size
1069 wxSize
1070 wxScrollHelper::ScrollGetWindowSizeForVirtualSize(const wxSize& size) const
1071 {
1072 // Only use the content to set the window size in the direction
1073 // where there's no scrolling; otherwise we're going to get a huge
1074 // window in the direction in which scrolling is enabled
1075 int ppuX, ppuY;
1076 GetScrollPixelsPerUnit(&ppuX, &ppuY);
1077
1078 wxSize minSize = m_win->GetMinSize();
1079 if ( !minSize.IsFullySpecified() )
1080 minSize = m_win->GetSize();
1081
1082 wxSize best(size);
1083 if (ppuX > 0)
1084 best.x = minSize.x;
1085 if (ppuY > 0)
1086 best.y = minSize.y;
1087
1088 return best;
1089 }
1090
1091 // ----------------------------------------------------------------------------
1092 // event handlers
1093 // ----------------------------------------------------------------------------
1094
1095 // Default OnSize resets scrollbars, if any
1096 void wxScrollHelper::HandleOnSize(wxSizeEvent& WXUNUSED(event))
1097 {
1098 if ( m_targetWindow->GetAutoLayout() )
1099 {
1100 wxSize size = m_targetWindow->GetBestVirtualSize();
1101
1102 // This will call ::Layout() and ::AdjustScrollbars()
1103 m_win->SetVirtualSize( size );
1104 }
1105 else
1106 {
1107 AdjustScrollbars();
1108 }
1109 }
1110
1111 // This calls OnDraw, having adjusted the origin according to the current
1112 // scroll position
1113 void wxScrollHelper::HandleOnPaint(wxPaintEvent& WXUNUSED(event))
1114 {
1115 // don't use m_targetWindow here, this is always called for ourselves
1116 wxPaintDC dc(m_win);
1117 DoPrepareDC(dc);
1118
1119 OnDraw(dc);
1120 }
1121
1122 // kbd handling: notice that we use OnChar() and not OnKeyDown() for
1123 // compatibility here - if we used OnKeyDown(), the programs which process
1124 // arrows themselves in their OnChar() would never get the message and like
1125 // this they always have the priority
1126 void wxScrollHelper::HandleOnChar(wxKeyEvent& event)
1127 {
1128 int stx = 0, sty = 0, // view origin
1129 szx = 0, szy = 0, // view size (total)
1130 clix = 0, cliy = 0; // view size (on screen)
1131
1132 GetViewStart(&stx, &sty);
1133 GetTargetSize(&clix, &cliy);
1134 m_targetWindow->GetVirtualSize(&szx, &szy);
1135
1136 if( m_xScrollPixelsPerLine )
1137 {
1138 clix /= m_xScrollPixelsPerLine;
1139 szx /= m_xScrollPixelsPerLine;
1140 }
1141 else
1142 {
1143 clix = 0;
1144 szx = -1;
1145 }
1146 if( m_yScrollPixelsPerLine )
1147 {
1148 cliy /= m_yScrollPixelsPerLine;
1149 szy /= m_yScrollPixelsPerLine;
1150 }
1151 else
1152 {
1153 cliy = 0;
1154 szy = -1;
1155 }
1156
1157 int xScrollOld = m_xScrollPosition,
1158 yScrollOld = m_yScrollPosition;
1159
1160 int dsty;
1161 switch ( event.GetKeyCode() )
1162 {
1163 case WXK_PAGEUP:
1164 dsty = sty - (5 * cliy / 6);
1165 Scroll(-1, (dsty == -1) ? 0 : dsty);
1166 break;
1167
1168 case WXK_PAGEDOWN:
1169 Scroll(-1, sty + (5 * cliy / 6));
1170 break;
1171
1172 case WXK_HOME:
1173 Scroll(0, event.ControlDown() ? 0 : -1);
1174 break;
1175
1176 case WXK_END:
1177 Scroll(szx - clix, event.ControlDown() ? szy - cliy : -1);
1178 break;
1179
1180 case WXK_UP:
1181 Scroll(-1, sty - 1);
1182 break;
1183
1184 case WXK_DOWN:
1185 Scroll(-1, sty + 1);
1186 break;
1187
1188 case WXK_LEFT:
1189 Scroll(stx - 1, -1);
1190 break;
1191
1192 case WXK_RIGHT:
1193 Scroll(stx + 1, -1);
1194 break;
1195
1196 default:
1197 // not for us
1198 event.Skip();
1199 }
1200
1201 if ( m_xScrollPosition != xScrollOld )
1202 {
1203 wxScrollWinEvent event(wxEVT_SCROLLWIN_THUMBTRACK, m_xScrollPosition,
1204 wxHORIZONTAL);
1205 event.SetEventObject(m_win);
1206 m_win->GetEventHandler()->ProcessEvent(event);
1207 }
1208
1209 if ( m_yScrollPosition != yScrollOld )
1210 {
1211 wxScrollWinEvent event(wxEVT_SCROLLWIN_THUMBTRACK, m_yScrollPosition,
1212 wxVERTICAL);
1213 event.SetEventObject(m_win);
1214 m_win->GetEventHandler()->ProcessEvent(event);
1215 }
1216 }
1217
1218 // ----------------------------------------------------------------------------
1219 // autoscroll stuff: these functions deal with sending fake scroll events when
1220 // a captured mouse is being held outside the window
1221 // ----------------------------------------------------------------------------
1222
1223 bool wxScrollHelper::SendAutoScrollEvents(wxScrollWinEvent& event) const
1224 {
1225 // only send the event if the window is scrollable in this direction
1226 wxWindow *win = (wxWindow *)event.GetEventObject();
1227 return win->HasScrollbar(event.GetOrientation());
1228 }
1229
1230 void wxScrollHelper::StopAutoScrolling()
1231 {
1232 #if wxUSE_TIMER
1233 if ( m_timerAutoScroll )
1234 {
1235 delete m_timerAutoScroll;
1236 m_timerAutoScroll = (wxTimer *)NULL;
1237 }
1238 #endif
1239 }
1240
1241 void wxScrollHelper::HandleOnMouseEnter(wxMouseEvent& event)
1242 {
1243 StopAutoScrolling();
1244
1245 event.Skip();
1246 }
1247
1248 void wxScrollHelper::HandleOnMouseLeave(wxMouseEvent& event)
1249 {
1250 // don't prevent the usual processing of the event from taking place
1251 event.Skip();
1252
1253 // when a captured mouse leave a scrolled window we start generate
1254 // scrolling events to allow, for example, extending selection beyond the
1255 // visible area in some controls
1256 if ( wxWindow::GetCapture() == m_targetWindow )
1257 {
1258 // where is the mouse leaving?
1259 int pos, orient;
1260 wxPoint pt = event.GetPosition();
1261 if ( pt.x < 0 )
1262 {
1263 orient = wxHORIZONTAL;
1264 pos = 0;
1265 }
1266 else if ( pt.y < 0 )
1267 {
1268 orient = wxVERTICAL;
1269 pos = 0;
1270 }
1271 else // we're lower or to the right of the window
1272 {
1273 wxSize size = m_targetWindow->GetClientSize();
1274 if ( pt.x > size.x )
1275 {
1276 orient = wxHORIZONTAL;
1277 pos = m_xScrollLines;
1278 }
1279 else if ( pt.y > size.y )
1280 {
1281 orient = wxVERTICAL;
1282 pos = m_yScrollLines;
1283 }
1284 else // this should be impossible
1285 {
1286 // but seems to happen sometimes under wxMSW - maybe it's a bug
1287 // there but for now just ignore it
1288
1289 //wxFAIL_MSG( _T("can't understand where has mouse gone") );
1290
1291 return;
1292 }
1293 }
1294
1295 // only start the auto scroll timer if the window can be scrolled in
1296 // this direction
1297 if ( !m_targetWindow->HasScrollbar(orient) )
1298 return;
1299
1300 #if wxUSE_TIMER
1301 delete m_timerAutoScroll;
1302 m_timerAutoScroll = new wxAutoScrollTimer
1303 (
1304 m_targetWindow, this,
1305 pos == 0 ? wxEVT_SCROLLWIN_LINEUP
1306 : wxEVT_SCROLLWIN_LINEDOWN,
1307 pos,
1308 orient
1309 );
1310 m_timerAutoScroll->Start(50); // FIXME: make configurable
1311 #else
1312 wxUnusedVar(pos);
1313 #endif
1314 }
1315 }
1316
1317 #if wxUSE_MOUSEWHEEL
1318
1319 void wxScrollHelper::HandleOnMouseWheel(wxMouseEvent& event)
1320 {
1321 m_wheelRotation += event.GetWheelRotation();
1322 int lines = m_wheelRotation / event.GetWheelDelta();
1323 m_wheelRotation -= lines * event.GetWheelDelta();
1324
1325 if (lines != 0)
1326 {
1327
1328 wxScrollWinEvent newEvent;
1329
1330 newEvent.SetPosition(0);
1331 newEvent.SetOrientation( event.GetWheelAxis() == 0 ? wxVERTICAL : wxHORIZONTAL);
1332 newEvent.SetEventObject(m_win);
1333
1334 if (event.IsPageScroll())
1335 {
1336 if (lines > 0)
1337 newEvent.SetEventType(wxEVT_SCROLLWIN_PAGEUP);
1338 else
1339 newEvent.SetEventType(wxEVT_SCROLLWIN_PAGEDOWN);
1340
1341 m_win->GetEventHandler()->ProcessEvent(newEvent);
1342 }
1343 else
1344 {
1345 lines *= event.GetLinesPerAction();
1346 if (lines > 0)
1347 newEvent.SetEventType(wxEVT_SCROLLWIN_LINEUP);
1348 else
1349 newEvent.SetEventType(wxEVT_SCROLLWIN_LINEDOWN);
1350
1351 int times = abs(lines);
1352 for (; times > 0; times--)
1353 m_win->GetEventHandler()->ProcessEvent(newEvent);
1354 }
1355 }
1356 }
1357
1358 #endif // wxUSE_MOUSEWHEEL
1359
1360 // ----------------------------------------------------------------------------
1361 // wxScrolledWindow implementation
1362 // ----------------------------------------------------------------------------
1363
1364 IMPLEMENT_DYNAMIC_CLASS(wxScrolledWindow, wxPanel)
1365
1366 BEGIN_EVENT_TABLE(wxScrolledWindow, wxPanel)
1367 EVT_PAINT(wxScrolledWindow::OnPaint)
1368 END_EVENT_TABLE()
1369
1370 bool wxScrolledWindow::Create(wxWindow *parent,
1371 wxWindowID id,
1372 const wxPoint& pos,
1373 const wxSize& size,
1374 long style,
1375 const wxString& name)
1376 {
1377 m_targetWindow = this;
1378 #ifdef __WXMAC__
1379 MacSetClipChildren( true ) ;
1380 #endif
1381
1382 // by default, we're scrollable in both directions (but if one of the
1383 // styles is specified explicitly, we shouldn't add the other one
1384 // automatically)
1385 if ( !(style & (wxHSCROLL | wxVSCROLL)) )
1386 style |= wxHSCROLL | wxVSCROLL;
1387
1388 bool ok = wxPanel::Create(parent, id, pos, size, style, name);
1389
1390 return ok;
1391 }
1392
1393 wxScrolledWindow::~wxScrolledWindow()
1394 {
1395 }
1396
1397 void wxScrolledWindow::OnPaint(wxPaintEvent& event)
1398 {
1399 // the user code didn't really draw the window if we got here, so set this
1400 // flag to try to call OnDraw() later
1401 m_handler->ResetDrawnFlag();
1402
1403 event.Skip();
1404 }
1405
1406 #ifdef __WXMSW__
1407 WXLRESULT wxScrolledWindow::MSWWindowProc(WXUINT nMsg,
1408 WXWPARAM wParam,
1409 WXLPARAM lParam)
1410 {
1411 WXLRESULT rc = wxPanel::MSWWindowProc(nMsg, wParam, lParam);
1412
1413 #ifndef __WXWINCE__
1414 // we need to process arrows ourselves for scrolling
1415 if ( nMsg == WM_GETDLGCODE )
1416 {
1417 rc |= DLGC_WANTARROWS;
1418 }
1419 #endif
1420
1421 return rc;
1422 }
1423
1424 #endif // __WXMSW__