1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/osx/cocoa/scrolbar.mm
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 @interface wxNSScroller : NSScroller
29 - (void)setImplementation: (wxWidgetImpl *) theImplementation;
30 - (wxWidgetImpl*) implementation;
32 - (void) clickedAction: (id) sender;
36 @implementation wxNSScroller
38 - (id)initWithFrame:(NSRect)frame
40 [super initWithFrame:frame];
42 [self setTarget: self];
43 [self setAction: @selector(clickedAction:)];
47 - (void) clickedAction: (id) sender
51 wxWindow* wxpeer = (wxWindow*) impl->GetWXPeer();
53 wxpeer->HandleClicked(0);
57 - (void)setImplementation: (wxWidgetImpl *) theImplementation
59 impl = theImplementation;
62 - (wxWidgetImpl*) implementation
74 class wxOSXScrollBarCocoaImpl : public wxWidgetCocoaImpl
77 wxOSXScrollBarCocoaImpl( wxWindowMac* peer, WXWidget w) : wxWidgetCocoaImpl( peer, w )
81 void SetMaximum(wxInt32 v)
86 void SetScrollThumb( wxInt32 value, wxInt32 thumbSize )
88 double v = ((double) value)/m_maximum;
89 double t = ((double) thumbSize)/m_maximum;
90 #if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_5
91 [(wxNSScroller*) m_osxView setFloatValue:v knobProportion:t];
93 [(wxNSScroller*) m_osxView setDoubleValue:v];
94 [(wxNSScroller*) m_osxView setKnobProportion:t];
98 wxInt32 GetValue() const
100 return [(wxNSScroller*) m_osxView floatValue] * m_maximum;
106 wxWidgetImplType* wxWidgetImpl::CreateScrollBar( wxWindowMac* wxpeer,
114 NSRect r = wxOSXGetFrameForControl( wxpeer, pos , size ) ;
115 wxNSScroller* v = [[wxNSScroller alloc] initWithFrame:r];
117 wxWidgetCocoaImpl* c = new wxOSXScrollBarCocoaImpl( wxpeer, v );
118 [v setImplementation:c];