]> git.saurik.com Git - wxWidgets.git/blame - src/osx/cocoa/slider.mm
fixed typo in XRC error message
[wxWidgets.git] / src / osx / cocoa / slider.mm
CommitLineData
dbeddfb9
SC
1/////////////////////////////////////////////////////////////////////////////
2// Name: src/osx/cocoa/slider.mm
3// Purpose: wxSlider
4// Author: Stefan Csomor
5// Modified by:
6// Created: 1998-01-01
7// RCS-ID: $Id: slider.cpp 54129 2008-06-11 19:30:52Z SC $
8// Copyright: (c) Stefan Csomor
9// Licence: wxWindows licence
10/////////////////////////////////////////////////////////////////////////////
11
12#include "wx/wxprec.h"
13
14#if wxUSE_SLIDER
15
16#include "wx/slider.h"
17#include "wx/osx/private.h"
18
19@interface wxNSSlider : NSSlider
20{
21 wxWidgetImpl* impl;
22}
23
24- (void)setImplementation: (wxWidgetImpl *) theImplementation;
25- (wxWidgetImpl*) implementation;
26- (BOOL) isFlipped;
27 - (void) clickedAction: (id) sender;
28
29@end
30
31@implementation wxNSSlider
32
33- (id)initWithFrame:(NSRect)frame
34{
35 [super initWithFrame:frame];
36 impl = NULL;
37 [self setTarget: self];
38 [self setAction: @selector(clickedAction:)];
39 return self;
40}
41
42- (void) clickedAction: (id) sender
43{
44 if ( impl )
45 {
46 wxWindow* wxpeer = (wxWindow*) impl->GetWXPeer();
47 if ( wxpeer )
48 wxpeer->HandleClicked(0);
49 }
50}
51
52- (void)setImplementation: (wxWidgetImpl *) theImplementation
53{
54 impl = theImplementation;
55}
56
57- (wxWidgetImpl*) implementation
58{
59 return impl;
60}
61
62- (BOOL) isFlipped
63{
64 return YES;
65}
66
67@end
68
69wxWidgetImplType* wxWidgetImpl::CreateSlider( wxWindowMac* wxpeer,
70 wxWindowMac* parent,
71 wxWindowID id,
72 wxInt32 value,
73 wxInt32 minimum,
74 wxInt32 maximum,
75 const wxPoint& pos,
76 const wxSize& size,
77 long style,
78 long extraStyle)
79{
80 NSView* sv = (wxpeer->GetParent()->GetHandle() );
81
82 NSRect r = wxOSXGetFrameForControl( wxpeer, pos , size ) ;
83 wxNSSlider* v = [[wxNSSlider alloc] initWithFrame:r];
84
85 int tickMarks = 0;
86 if ( style & wxSL_AUTOTICKS )
87 {
88 tickMarks = (maximum - minimum) + 1; // +1 for the 0 value
89
90 // keep the number of tickmarks from becoming unwieldly, therefore below it is ok to cast
91 // it to a UInt16
92 while (tickMarks > 20)
93 tickMarks /= 5;
94
95 [v setNumberOfTickMarks:tickMarks];
96 [v setTickMarkPosition:NSTickMarkBelow];
97 }
98
99 [v setMinValue: minimum];
100 [v setMaxValue: maximum];
101 [v setFloatValue: (double) value];
102 [sv addSubview:v];
103 wxWidgetCocoaImpl* c = new wxWidgetCocoaImpl( wxpeer, v );
104 [v setImplementation:c];
105 return c;
106}
107
108#endif // wxUSE_SLIDER