]> git.saurik.com Git - wxWidgets.git/blame_incremental - src/osx/carbon/scrolbar.cpp
Really set standard cursor when over title bar and decos
[wxWidgets.git] / src / osx / carbon / scrolbar.cpp
... / ...
CommitLineData
1/////////////////////////////////////////////////////////////////////////////
2// Name: src/osx/carbon/scrolbar.cpp
3// Purpose: wxScrollBar
4// Author: Stefan Csomor
5// Modified by:
6// Created: 1998-01-01
7// RCS-ID: $Id$
8// Copyright: (c) Stefan Csomor
9// Licence: wxWindows licence
10/////////////////////////////////////////////////////////////////////////////
11
12#include "wx/wxprec.h"
13
14#include "wx/scrolbar.h"
15
16#ifndef WX_PRECOMP
17 #include "wx/intl.h"
18 #include "wx/log.h"
19 #include "wx/settings.h"
20#endif
21
22#include "wx/osx/private.h"
23
24class wxOSXScrollBarCarbonImpl : public wxMacControl
25{
26public :
27 wxOSXScrollBarCarbonImpl( wxWindowMac* peer) : wxMacControl( peer )
28 {
29 }
30
31 void SetScrollThumb( wxInt32 value, wxInt32 thumbSize )
32 {
33 SetValue( value );
34 SetControlViewSize(m_controlRef , thumbSize );
35 }
36protected:
37};
38
39wxWidgetImplType* wxWidgetImpl::CreateScrollBar( wxWindowMac* wxpeer,
40 wxWindowMac* parent,
41 wxWindowID id,
42 const wxPoint& pos,
43 const wxSize& size,
44 long style,
45 long extraStyle)
46{
47 Rect bounds = wxMacGetBoundsForControl( wxpeer, pos, size );
48
49 wxMacControl* peer = new wxOSXScrollBarCarbonImpl( wxpeer );
50 OSStatus err = CreateScrollBarControl(
51 MAC_WXHWND(parent->MacGetTopLevelWindowRef()), &bounds,
52 0, 0, 100, 1, true /* liveTracking */,
53 GetwxMacLiveScrollbarActionProc(),
54 peer->GetControlRefAddr() );
55 verify_noerr( err );
56 return peer;
57}
58
59void wxScrollBar::MacHandleControlClick( WXWidget WXUNUSED(control), wxInt16 controlpart, bool mouseStillDown )
60{
61#if wxOSX_USE_CARBON
62
63 int position = m_peer->GetValue();
64 int minPos = 0 ;
65 int maxPos = m_peer->GetMaximum();
66
67 wxEventType scrollEvent = wxEVT_NULL;
68 int nScrollInc = 0;
69
70 // all events have already been reported during mouse down, except for THUMBRELEASE
71 if ( !mouseStillDown && controlpart != kControlIndicatorPart )
72 return;
73
74 switch ( controlpart )
75 {
76 case kControlUpButtonPart:
77 nScrollInc = -1;
78 scrollEvent = wxEVT_SCROLL_LINEUP;
79 break;
80
81 case kControlDownButtonPart:
82 nScrollInc = 1;
83 scrollEvent = wxEVT_SCROLL_LINEDOWN;
84 break;
85
86 case kControlPageUpPart:
87 nScrollInc = -m_pageSize;
88 scrollEvent = wxEVT_SCROLL_PAGEUP;
89 break;
90
91 case kControlPageDownPart:
92 nScrollInc = m_pageSize;
93 scrollEvent = wxEVT_SCROLL_PAGEDOWN;
94 break;
95
96 case kControlIndicatorPart:
97 nScrollInc = 0;
98 if ( mouseStillDown )
99 scrollEvent = wxEVT_SCROLL_THUMBTRACK;
100 else
101 scrollEvent = wxEVT_SCROLL_THUMBRELEASE;
102 break;
103
104 default:
105 wxFAIL_MSG(wxT("unknown scrollbar selector"));
106 break;
107 }
108
109 int new_pos = position + nScrollInc;
110
111 if (new_pos < minPos)
112 new_pos = minPos;
113 else if (new_pos > maxPos)
114 new_pos = maxPos;
115
116 if ( nScrollInc )
117 SetThumbPosition( new_pos );
118
119 wxScrollEvent event( scrollEvent, m_windowId );
120 if ( m_windowStyle & wxHORIZONTAL )
121 event.SetOrientation( wxHORIZONTAL );
122 else
123 event.SetOrientation( wxVERTICAL );
124
125 event.SetPosition( new_pos );
126 event.SetEventObject( this );
127
128 wxWindow* window = GetParent();
129 if (window && window->MacIsWindowScrollbar( this ))
130 // this is hardcoded
131 window->MacOnScroll( event );
132 else
133 HandleWindowEvent( event );
134#endif
135}