1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/osx/carbon/scrolbar.cpp
3 // Purpose: wxScrollBar
4 // Author: Stefan Csomor
7 // RCS-ID: $Id: scrolbar.cpp 54129 2008-06-11 19:30:52Z SC $
8 // Copyright: (c) Stefan Csomor
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #include "wx/wxprec.h"
14 #include "wx/scrolbar.h"
19 #include "wx/settings.h"
22 #include "wx/osx/private.h"
24 IMPLEMENT_DYNAMIC_CLASS(wxScrollBar
, wxControl
)
26 BEGIN_EVENT_TABLE(wxScrollBar
, wxControl
)
30 bool wxScrollBar::Create( wxWindow
*parent
,
35 const wxValidator
& validator
,
36 const wxString
& name
)
38 m_macIsUserPane
= false;
40 if ( !wxControl::Create( parent
, id
, pos
, size
, style
, validator
, name
) )
43 m_peer
= wxWidgetImpl::CreateScrollBar( this, parent
, id
, pos
, size
, style
, GetExtraStyle() );
45 MacPostControlCreate( pos
, size
);
50 wxScrollBar::~wxScrollBar()
54 void wxScrollBar::SetThumbPosition( int viewStart
)
56 m_peer
->SetScrollThumb( viewStart
, m_viewSize
);
59 int wxScrollBar::GetThumbPosition() const
61 return m_peer
->GetValue();
64 void wxScrollBar::SetScrollbar( int position
,
68 bool WXUNUSED(refresh
) )
70 m_pageSize
= pageSize
;
71 m_viewSize
= thumbSize
;
74 int range1
= wxMax( (m_objectSize
- m_viewSize
), 0 );
76 m_peer
->SetMaximum( range1
);
77 m_peer
->SetScrollThumb( position
, m_viewSize
);
80 void wxScrollBar::Command( wxCommandEvent
& event
)
82 SetThumbPosition( event
.GetInt() );
83 ProcessCommand( event
);
86 bool wxScrollBar::HandleClicked( double timestampsec
)
88 int new_pos
= m_peer
->GetValue();
90 wxScrollEvent
event( wxEVT_SCROLL_THUMBRELEASE
, m_windowId
);
91 if ( m_windowStyle
& wxHORIZONTAL
)
92 event
.SetOrientation( wxHORIZONTAL
);
94 event
.SetOrientation( wxVERTICAL
);
96 event
.SetPosition( new_pos
);
97 event
.SetEventObject( this );
98 wxWindow
* window
= GetParent();
99 if (window
&& window
->MacIsWindowScrollbar( this ))
101 window
->MacOnScroll( event
);
103 HandleWindowEvent( event
);
109 wxSize
wxScrollBar::DoGetBestSize() const
116 w
= wxSystemSettings::GetMetric(wxSYS_VSCROLL_X
);
120 h
= wxSystemSettings::GetMetric(wxSYS_HSCROLL_Y
);