1 /////////////////////////////////////////////////////////////////////////////
2 // Name: gtk/scrolwin.cpp
3 // Purpose: wxScrolledWindow implementation
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart and Markus Holzem
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
12 // ============================================================================
14 // ============================================================================
16 // ----------------------------------------------------------------------------
18 // ----------------------------------------------------------------------------
21 #pragma implementation "scrolwin.h"
24 // For compilers that support precompilation, includes "wx.h".
25 #include "wx/wxprec.h"
32 #include "wx/dcclient.h"
34 #include "wx/gtk/scrolwin.h"
38 #include "wx/gtk/win_gtk.h"
40 // ----------------------------------------------------------------------------
42 // ----------------------------------------------------------------------------
44 BEGIN_EVENT_TABLE(wxScrolledWindow
, wxPanel
)
45 EVT_SCROLLWIN(wxScrolledWindow::OnScroll
)
46 EVT_SIZE(wxScrolledWindow::OnSize
)
47 EVT_PAINT(wxScrolledWindow::OnPaint
)
48 EVT_CHAR(wxScrolledWindow::OnChar
)
51 IMPLEMENT_DYNAMIC_CLASS(wxScrolledWindow
, wxPanel
)
53 // ============================================================================
55 // ============================================================================
57 //-----------------------------------------------------------------------------
59 //-----------------------------------------------------------------------------
61 extern bool g_blockEventsOnDrag
;
63 //-----------------------------------------------------------------------------
65 //-----------------------------------------------------------------------------
67 extern void wxapp_install_idle_handler();
70 //-----------------------------------------------------------------------------
71 // "value_changed" from m_vAdjust
72 //-----------------------------------------------------------------------------
74 static void gtk_scrolled_window_vscroll_callback( GtkAdjustment
*adjust
, wxScrolledWindow
*win
)
77 wxapp_install_idle_handler();
79 if (g_blockEventsOnDrag
) return;
81 if (!win
->m_hasVMT
) return;
83 win
->GtkVScroll( adjust
->value
);
86 //-----------------------------------------------------------------------------
87 // "value_changed" from m_hAdjust
88 //-----------------------------------------------------------------------------
90 static void gtk_scrolled_window_hscroll_callback( GtkAdjustment
*adjust
, wxScrolledWindow
*win
)
93 wxapp_install_idle_handler();
95 if (g_blockEventsOnDrag
) return;
96 if (!win
->m_hasVMT
) return;
98 win
->GtkHScroll( adjust
->value
);
101 //-----------------------------------------------------------------------------
102 // InsertChild for wxScrolledWindow
103 //-----------------------------------------------------------------------------
105 static void wxInsertChildInScrolledWindow( wxWindow
* parent
, wxWindow
* child
)
107 // The window might have been scrolled already, do we
108 // have to adapt the position.
109 GtkPizza
*pizza
= GTK_PIZZA(parent
->m_wxwindow
);
110 child
->m_x
+= pizza
->xoffset
;
111 child
->m_y
+= pizza
->yoffset
;
113 gtk_pizza_put( GTK_PIZZA(parent
->m_wxwindow
),
114 GTK_WIDGET(child
->m_widget
),
121 // ----------------------------------------------------------------------------
122 // wxScrolledWindow creation
123 // ----------------------------------------------------------------------------
125 void wxScrolledWindow::Init()
127 m_xScrollPixelsPerLine
= 0;
128 m_yScrollPixelsPerLine
= 0;
129 m_xScrollingEnabled
= TRUE
;
130 m_yScrollingEnabled
= TRUE
;
131 m_xScrollPosition
= 0;
132 m_yScrollPosition
= 0;
135 m_xScrollLinesPerPage
= 0;
136 m_yScrollLinesPerPage
= 0;
137 m_targetWindow
= (wxWindow
*) NULL
;
140 m_hasScrolling
= TRUE
;
143 bool wxScrolledWindow::Create(wxWindow
*parent
,
148 const wxString
& name
)
152 if (!PreCreation( parent
, pos
, size
) ||
153 !CreateBase( parent
, id
, pos
, size
, style
, wxDefaultValidator
, name
))
155 wxFAIL_MSG( wxT("wxWindow creation failed") );
159 m_insertCallback
= wxInsertChildInScrolledWindow
;
161 m_targetWindow
= this;
163 m_widget
= gtk_scrolled_window_new( (GtkAdjustment
*) NULL
, (GtkAdjustment
*) NULL
);
164 GTK_WIDGET_UNSET_FLAGS( m_widget
, GTK_CAN_FOCUS
);
166 GtkScrolledWindow
*scrolledWindow
= GTK_SCROLLED_WINDOW(m_widget
);
168 GtkScrolledWindowClass
*scroll_class
= GTK_SCROLLED_WINDOW_CLASS( GTK_OBJECT_GET_CLASS(m_widget
) );
169 scroll_class
->scrollbar_spacing
= 0;
171 gtk_scrolled_window_set_policy( scrolledWindow
, GTK_POLICY_AUTOMATIC
, GTK_POLICY_AUTOMATIC
);
173 m_hAdjust
= gtk_range_get_adjustment( GTK_RANGE(scrolledWindow
->hscrollbar
) );
174 m_vAdjust
= gtk_range_get_adjustment( GTK_RANGE(scrolledWindow
->vscrollbar
) );
176 m_wxwindow
= gtk_pizza_new();
178 gtk_container_add( GTK_CONTAINER(m_widget
), m_wxwindow
);
180 GtkPizza
*pizza
= GTK_PIZZA(m_wxwindow
);
182 if (HasFlag(wxRAISED_BORDER
))
184 gtk_pizza_set_shadow_type( pizza
, GTK_MYSHADOW_OUT
);
186 else if (HasFlag(wxSUNKEN_BORDER
))
188 gtk_pizza_set_shadow_type( pizza
, GTK_MYSHADOW_IN
);
190 else if (HasFlag(wxSIMPLE_BORDER
))
192 gtk_pizza_set_shadow_type( pizza
, GTK_MYSHADOW_THIN
);
196 gtk_pizza_set_shadow_type( pizza
, GTK_MYSHADOW_NONE
);
199 GTK_WIDGET_SET_FLAGS( m_wxwindow
, GTK_CAN_FOCUS
);
200 m_acceptsFocus
= TRUE
;
202 // I _really_ don't want scrollbars in the beginning
203 m_vAdjust
->lower
= 0.0;
204 m_vAdjust
->upper
= 1.0;
205 m_vAdjust
->value
= 0.0;
206 m_vAdjust
->step_increment
= 1.0;
207 m_vAdjust
->page_increment
= 1.0;
208 gtk_signal_emit_by_name( GTK_OBJECT(m_vAdjust
), "changed" );
209 m_hAdjust
->lower
= 0.0;
210 m_hAdjust
->upper
= 1.0;
211 m_hAdjust
->value
= 0.0;
212 m_hAdjust
->step_increment
= 1.0;
213 m_hAdjust
->page_increment
= 1.0;
214 gtk_signal_emit_by_name( GTK_OBJECT(m_hAdjust
), "changed" );
216 // Handlers for new scrollbar values
220 gtk_widget_show( m_wxwindow
);
223 m_parent
->DoAddChild( this );
232 // ----------------------------------------------------------------------------
233 // setting scrolling parameters
234 // ----------------------------------------------------------------------------
237 * pixelsPerUnitX/pixelsPerUnitY: number of pixels per unit (e.g. pixels per text line)
238 * noUnitsX/noUnitsY: : no. units per scrollbar
240 void wxScrolledWindow::SetScrollbars (int pixelsPerUnitX
, int pixelsPerUnitY
,
241 int noUnitsX
, int noUnitsY
,
242 int xPos
, int yPos
, bool noRefresh
)
244 int old_x
= m_xScrollPixelsPerLine
* m_xScrollPosition
;
245 int old_y
= m_yScrollPixelsPerLine
* m_yScrollPosition
;
247 m_xScrollPixelsPerLine
= pixelsPerUnitX
;
248 m_yScrollPixelsPerLine
= pixelsPerUnitY
;
249 m_xScrollLines
= noUnitsX
;
250 m_yScrollLines
= noUnitsY
;
251 m_xScrollPosition
= xPos
;
252 m_yScrollPosition
= yPos
;
254 m_hAdjust
->lower
= 0.0;
255 m_hAdjust
->upper
= noUnitsX
;
256 m_hAdjust
->value
= xPos
;
257 m_hAdjust
->step_increment
= 1.0;
258 m_hAdjust
->page_increment
= 2.0;
260 m_vAdjust
->lower
= 0.0;
261 m_vAdjust
->upper
= noUnitsY
;
262 m_vAdjust
->value
= yPos
;
263 m_vAdjust
->step_increment
= 1.0;
264 m_vAdjust
->page_increment
= 2.0;
270 int new_x
= m_xScrollPixelsPerLine
* m_xScrollPosition
;
271 int new_y
= m_yScrollPixelsPerLine
* m_yScrollPosition
;
273 m_targetWindow
->ScrollWindow( old_x
-new_x
, old_y
-new_y
);
277 void wxScrolledWindow::AdjustScrollbars()
280 m_targetWindow
->GetClientSize( &w
, &h
);
282 if (m_xScrollPixelsPerLine
== 0)
283 m_hAdjust
->page_size
= 1.0;
285 m_hAdjust
->page_size
= (w
/ m_xScrollPixelsPerLine
);
287 if (m_yScrollPixelsPerLine
== 0)
288 m_vAdjust
->page_size
= 1.0;
290 m_vAdjust
->page_size
= (h
/ m_yScrollPixelsPerLine
);
292 m_xScrollLinesPerPage
= (int)(m_hAdjust
->page_size
+ 0.5);
293 m_yScrollLinesPerPage
= (int)(m_vAdjust
->page_size
+ 0.5);
295 gtk_signal_emit_by_name( GTK_OBJECT(m_vAdjust
), "changed" );
296 gtk_signal_emit_by_name( GTK_OBJECT(m_hAdjust
), "changed" );
299 // ----------------------------------------------------------------------------
300 // target window handling
301 // ----------------------------------------------------------------------------
303 void wxScrolledWindow::SetTargetWindow( wxWindow
*target
)
305 wxASSERT_MSG( target
, wxT("target window must not be NULL") );
306 m_targetWindow
= target
;
309 wxWindow
*wxScrolledWindow::GetTargetWindow()
311 return m_targetWindow
;
314 // Override this function if you don't want to have wxScrolledWindow
315 // automatically change the origin according to the scroll position.
316 void wxScrolledWindow::PrepareDC(wxDC
& dc
)
318 dc
.SetDeviceOrigin( -m_xScrollPosition
* m_xScrollPixelsPerLine
,
319 -m_yScrollPosition
* m_yScrollPixelsPerLine
);
322 void wxScrolledWindow::GetScrollPixelsPerUnit (int *x_unit
, int *y_unit
) const
325 *x_unit
= m_xScrollPixelsPerLine
;
327 *y_unit
= m_yScrollPixelsPerLine
;
330 int wxScrolledWindow::GetScrollPageSize(int orient
) const
332 if ( orient
== wxHORIZONTAL
)
333 return m_xScrollLinesPerPage
;
335 return m_yScrollLinesPerPage
;
338 void wxScrolledWindow::SetScrollPageSize(int orient
, int pageSize
)
340 if ( orient
== wxHORIZONTAL
)
341 m_xScrollLinesPerPage
= pageSize
;
343 m_yScrollLinesPerPage
= pageSize
;
346 void wxScrolledWindow::OnScroll(wxScrollWinEvent
& event
)
348 int orient
= event
.GetOrientation();
350 int nScrollInc
= CalcScrollInc(event
);
351 if (nScrollInc
== 0) return;
353 if (orient
== wxHORIZONTAL
)
355 int newPos
= m_xScrollPosition
+ nScrollInc
;
356 SetScrollPos(wxHORIZONTAL
, newPos
, TRUE
);
360 int newPos
= m_yScrollPosition
+ nScrollInc
;
361 SetScrollPos(wxVERTICAL
, newPos
, TRUE
);
364 if (orient
== wxHORIZONTAL
)
366 m_xScrollPosition
+= nScrollInc
;
370 m_yScrollPosition
+= nScrollInc
;
373 if (orient
== wxHORIZONTAL
)
375 if (m_xScrollingEnabled
)
376 m_targetWindow
->ScrollWindow(-m_xScrollPixelsPerLine
* nScrollInc
, 0, (const wxRect
*) NULL
);
378 m_targetWindow
->Refresh();
382 if (m_yScrollingEnabled
)
383 m_targetWindow
->ScrollWindow(0, -m_yScrollPixelsPerLine
* nScrollInc
, (const wxRect
*) NULL
);
385 m_targetWindow
->Refresh();
389 void wxScrolledWindow::Scroll( int x_pos
, int y_pos
)
394 if (((x_pos
== -1) || (x_pos
== m_xScrollPosition
)) &&
395 ((y_pos
== -1) || (y_pos
== m_yScrollPosition
))) return;
397 if ((x_pos
!= -1) && (m_xScrollPixelsPerLine
))
399 int max
= (int)(m_hAdjust
->upper
- m_hAdjust
->page_size
+ 0.5);
400 if (max
< 0) max
= 0;
401 if (x_pos
> max
) x_pos
= max
;
402 if (x_pos
< 0) x_pos
= 0;
404 int old_x
= m_xScrollPosition
;
405 m_xScrollPosition
= x_pos
;
406 m_hAdjust
->value
= x_pos
;
408 m_targetWindow
->ScrollWindow( (old_x
-m_xScrollPosition
)*m_xScrollPixelsPerLine
, 0 );
410 // Just update the scrollbar, don't send any wxWindows event
411 GtkHDisconnectEvent();
412 gtk_signal_emit_by_name( GTK_OBJECT(m_hAdjust
), "value_changed" );
416 if ((y_pos
!= -1) && (m_yScrollPixelsPerLine
))
418 int max
= (int)(m_vAdjust
->upper
- m_vAdjust
->page_size
+ 0.5);
419 if (max
< 0) max
= 0;
420 if (y_pos
> max
) y_pos
= max
;
421 if (y_pos
< 0) y_pos
= 0;
423 int old_y
= m_yScrollPosition
;
424 m_yScrollPosition
= y_pos
;
425 m_vAdjust
->value
= y_pos
;
427 m_targetWindow
->ScrollWindow( 0, (old_y
-m_yScrollPosition
)*m_yScrollPixelsPerLine
);
429 // Just update the scrollbar, don't send any wxWindows event
430 GtkVDisconnectEvent();
431 gtk_signal_emit_by_name( GTK_OBJECT(m_vAdjust
), "value_changed" );
436 void wxScrolledWindow::GtkVScroll( float value
)
441 if (m_yScrollPixelsPerLine
== 0)
444 int y_pos
= (int)(value
+0.5);
446 if (y_pos
== m_yScrollPosition
)
449 GtkScrolledWindow
*scrolledWindow
= GTK_SCROLLED_WINDOW(m_widget
);
450 GtkRange
*range
= GTK_RANGE(scrolledWindow
->vscrollbar
);
452 wxEventType command
= wxEVT_SCROLLWIN_THUMBTRACK
;
453 if (range
->scroll_type
== GTK_SCROLL_STEP_BACKWARD
) command
= wxEVT_SCROLLWIN_LINEUP
;
454 else if (range
->scroll_type
== GTK_SCROLL_STEP_FORWARD
) command
= wxEVT_SCROLLWIN_LINEDOWN
;
455 else if (range
->scroll_type
== GTK_SCROLL_PAGE_BACKWARD
) command
= wxEVT_SCROLLWIN_PAGEUP
;
456 else if (range
->scroll_type
== GTK_SCROLL_PAGE_FORWARD
) command
= wxEVT_SCROLLWIN_PAGEDOWN
;
458 wxScrollWinEvent
event( command
, y_pos
, wxVERTICAL
);
459 event
.SetEventObject( this );
460 GetEventHandler()->ProcessEvent( event
);
463 void wxScrolledWindow::GtkHScroll( float value
)
468 if (m_xScrollPixelsPerLine
== 0)
471 int x_pos
= (int)(value
+0.5);
473 if (x_pos
== m_xScrollPosition
)
476 GtkScrolledWindow
*scrolledWindow
= GTK_SCROLLED_WINDOW(m_widget
);
477 GtkRange
*range
= GTK_RANGE(scrolledWindow
->hscrollbar
);
479 wxEventType command
= wxEVT_SCROLLWIN_THUMBTRACK
;
480 if (range
->scroll_type
== GTK_SCROLL_STEP_BACKWARD
) command
= wxEVT_SCROLLWIN_LINEUP
;
481 else if (range
->scroll_type
== GTK_SCROLL_STEP_FORWARD
) command
= wxEVT_SCROLLWIN_LINEDOWN
;
482 else if (range
->scroll_type
== GTK_SCROLL_PAGE_BACKWARD
) command
= wxEVT_SCROLLWIN_PAGEUP
;
483 else if (range
->scroll_type
== GTK_SCROLL_PAGE_FORWARD
) command
= wxEVT_SCROLLWIN_PAGEDOWN
;
485 wxScrollWinEvent
event( command
, x_pos
, wxHORIZONTAL
);
486 event
.SetEventObject( this );
487 GetEventHandler()->ProcessEvent( event
);
490 void wxScrolledWindow::EnableScrolling (bool x_scroll
, bool y_scroll
)
492 m_xScrollingEnabled
= x_scroll
;
493 m_yScrollingEnabled
= y_scroll
;
496 void wxScrolledWindow::GetVirtualSize (int *x
, int *y
) const
499 *x
= m_xScrollPixelsPerLine
* m_xScrollLines
;
501 *y
= m_yScrollPixelsPerLine
* m_yScrollLines
;
504 // Where the current view starts from
505 void wxScrolledWindow::GetViewStart (int *x
, int *y
) const
508 *x
= m_xScrollPosition
;
510 *y
= m_yScrollPosition
;
513 void wxScrolledWindow::CalcScrolledPosition(int x
, int y
, int *xx
, int *yy
) const
516 *xx
= x
- m_xScrollPosition
* m_xScrollPixelsPerLine
;
518 *yy
= y
- m_yScrollPosition
* m_yScrollPixelsPerLine
;
521 void wxScrolledWindow::CalcUnscrolledPosition(int x
, int y
, int *xx
, int *yy
) const
524 *xx
= x
+ m_xScrollPosition
* m_xScrollPixelsPerLine
;
526 *yy
= y
+ m_yScrollPosition
* m_yScrollPixelsPerLine
;
529 int wxScrolledWindow::CalcScrollInc(wxScrollWinEvent
& event
)
531 int pos
= event
.GetPosition();
532 int orient
= event
.GetOrientation();
535 if (event
.GetEventType() == wxEVT_SCROLLWIN_TOP
)
537 if (orient
== wxHORIZONTAL
)
538 nScrollInc
= - m_xScrollPosition
;
540 nScrollInc
= - m_yScrollPosition
;
542 if (event
.GetEventType() == wxEVT_SCROLLWIN_BOTTOM
)
544 if (orient
== wxHORIZONTAL
)
545 nScrollInc
= m_xScrollLines
- m_xScrollPosition
;
547 nScrollInc
= m_yScrollLines
- m_yScrollPosition
;
549 if (event
.GetEventType() == wxEVT_SCROLLWIN_LINEUP
)
553 if (event
.GetEventType() == wxEVT_SCROLLWIN_LINEDOWN
)
557 if (event
.GetEventType() == wxEVT_SCROLLWIN_PAGEUP
)
559 if (orient
== wxHORIZONTAL
)
560 nScrollInc
= -GetScrollPageSize(wxHORIZONTAL
);
562 nScrollInc
= -GetScrollPageSize(wxVERTICAL
);
564 if (event
.GetEventType() == wxEVT_SCROLLWIN_PAGEDOWN
)
566 if (orient
== wxHORIZONTAL
)
567 nScrollInc
= GetScrollPageSize(wxHORIZONTAL
);
569 nScrollInc
= GetScrollPageSize(wxVERTICAL
);
571 if ((event
.GetEventType() == wxEVT_SCROLLWIN_THUMBTRACK
) ||
572 (event
.GetEventType() == wxEVT_SCROLLWIN_THUMBRELEASE
))
574 if (orient
== wxHORIZONTAL
)
575 nScrollInc
= pos
- m_xScrollPosition
;
577 nScrollInc
= pos
- m_yScrollPosition
;
580 if (orient
== wxHORIZONTAL
)
582 if (m_xScrollPixelsPerLine
> 0)
584 int max
= (int)(m_hAdjust
->upper
- m_hAdjust
->page_size
+ 0.5);
585 if (max
< 0) max
= 0;
587 if ( (m_xScrollPosition
+ nScrollInc
) < 0 )
588 nScrollInc
= -m_xScrollPosition
; // As -ve as we can go
589 else if ( (m_xScrollPosition
+ nScrollInc
) > max
)
590 nScrollInc
= max
- m_xScrollPosition
; // As +ve as we can go
593 m_targetWindow
->Refresh();
597 if (m_yScrollPixelsPerLine
> 0)
599 int max
= (int)(m_vAdjust
->upper
- m_vAdjust
->page_size
+ 0.5);
600 if (max
< 0) max
= 0;
602 if ( (m_yScrollPosition
+ nScrollInc
) < 0 )
603 nScrollInc
= -m_yScrollPosition
; // As -ve as we can go
604 else if ( (m_yScrollPosition
+ nScrollInc
) > max
)
605 nScrollInc
= max
- m_yScrollPosition
; // As +ve as we can go
608 m_targetWindow
->Refresh();
614 void wxScrolledWindow::SetScrollPos( int orient
, int pos
, bool WXUNUSED(refresh
) )
616 wxCHECK_RET( m_widget
!= NULL
, wxT("invalid window") );
618 wxCHECK_RET( m_wxwindow
!= NULL
, wxT("window needs client area for scrolling") );
620 if (orient
== wxHORIZONTAL
)
622 int max
= (int)(m_hAdjust
->upper
- m_hAdjust
->page_size
+ 0.5);
623 if (max
< 0) max
= 0;
625 if (pos
> max
) pos
= 0;
626 if (pos
< 0) pos
= 0;
628 if (pos
== (int)(m_hAdjust
->value
+0.5)) return;
629 m_hAdjust
->value
= pos
;
633 int max
= (int)(m_vAdjust
->upper
- m_vAdjust
->page_size
+ 0.5);
634 if (max
< 0) max
= 0;
636 if (pos
> max
) pos
= 0;
637 if (pos
< 0) pos
= 0;
639 if (pos
== (int)(m_vAdjust
->value
+0.5)) return;
640 m_vAdjust
->value
= pos
;
643 if (m_wxwindow
->window
)
645 if (orient
== wxHORIZONTAL
)
647 // Just update the scrollbar, don't send any wxWindows event
648 GtkHDisconnectEvent();
649 gtk_signal_emit_by_name( GTK_OBJECT(m_hAdjust
), "value_changed" );
654 // Just update the scrollbar, don't send any wxWindows event
655 GtkVDisconnectEvent();
656 gtk_signal_emit_by_name( GTK_OBJECT(m_vAdjust
), "value_changed" );
662 void wxScrolledWindow::GtkVConnectEvent()
664 gtk_signal_connect( GTK_OBJECT(m_vAdjust
), "value_changed",
665 (GtkSignalFunc
) gtk_scrolled_window_vscroll_callback
, (gpointer
) this );
668 void wxScrolledWindow::GtkHConnectEvent()
670 gtk_signal_connect( GTK_OBJECT(m_hAdjust
), "value_changed",
671 (GtkSignalFunc
) gtk_scrolled_window_hscroll_callback
, (gpointer
) this );
674 void wxScrolledWindow::GtkHDisconnectEvent()
676 gtk_signal_disconnect_by_func( GTK_OBJECT(m_hAdjust
),
677 (GtkSignalFunc
) gtk_scrolled_window_hscroll_callback
, (gpointer
) this );
680 void wxScrolledWindow::GtkVDisconnectEvent()
682 gtk_signal_disconnect_by_func( GTK_OBJECT(m_vAdjust
),
683 (GtkSignalFunc
) gtk_scrolled_window_vscroll_callback
, (gpointer
) this );
686 // ----------------------------------------------------------------------------
688 // ----------------------------------------------------------------------------
690 // Default OnSize resets scrollbars, if any
691 void wxScrolledWindow::OnSize(wxSizeEvent
& WXUNUSED(event
))
693 #if wxUSE_CONSTRAINTS
701 // This calls OnDraw, having adjusted the origin according to the current
703 void wxScrolledWindow::OnPaint(wxPaintEvent
& WXUNUSED(event
))
711 // kbd handling: notice that we use OnChar() and not OnKeyDown() for
712 // compatibility here - if we used OnKeyDown(), the programs which process
713 // arrows themselves in their OnChar() would never get the message and like
714 // this they always have the priority
715 void wxScrolledWindow::OnChar(wxKeyEvent
& event
)
717 int stx
, sty
, // view origin
718 szx
, szy
, // view size (total)
719 clix
, cliy
; // view size (on screen)
721 ViewStart(&stx
, &sty
);
722 GetClientSize(&clix
, &cliy
);
723 GetVirtualSize(&szx
, &szy
);
725 if( m_xScrollPixelsPerLine
)
727 clix
/= m_xScrollPixelsPerLine
;
728 szx
/= m_xScrollPixelsPerLine
;
735 if( m_yScrollPixelsPerLine
)
737 cliy
/= m_yScrollPixelsPerLine
;
738 szy
/= m_yScrollPixelsPerLine
;
746 int xScrollOld
= GetScrollPos(wxHORIZONTAL
),
747 yScrollOld
= GetScrollPos(wxVERTICAL
);
750 switch ( event
.KeyCode() )
754 dsty
= sty
- (5 * cliy
/ 6);
755 Scroll(-1, (dsty
== -1) ? 0 : dsty
);
760 Scroll(-1, sty
+ (5 * cliy
/ 6));
764 Scroll(0, event
.ControlDown() ? 0 : -1);
768 Scroll(szx
- clix
, event
.ControlDown() ? szy
- cliy
: -1);
793 int xScroll
= GetScrollPos(wxHORIZONTAL
);
794 if ( xScroll
!= xScrollOld
)
796 wxScrollWinEvent
event(wxEVT_SCROLLWIN_THUMBTRACK
, xScroll
,
798 event
.SetEventObject(this);
799 GetEventHandler()->ProcessEvent(event
);
802 int yScroll
= GetScrollPos(wxVERTICAL
);
803 if ( yScroll
!= yScrollOld
)
805 wxScrollWinEvent
event(wxEVT_SCROLLWIN_THUMBTRACK
, yScroll
,
807 event
.SetEventObject(this);
808 GetEventHandler()->ProcessEvent(event
);