]> git.saurik.com Git - wxWidgets.git/blob - src/cocoa/gauge.mm
Constructor now takes a wxTopLevelWindow * = NULL so that the new
[wxWidgets.git] / src / cocoa / gauge.mm
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: cocoa/gauge.mm
3 // Purpose: wxGauge
4 // Author: David Elliott
5 // Modified by:
6 // Created: 2003/07/15
7 // RCS-ID: $Id$
8 // Copyright: (c) 2003 David Elliott
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #include "wx/wxprec.h"
13 #if wxUSE_GAUGE
14
15 #ifndef WX_PRECOMP
16 #include "wx/app.h"
17 #include "wx/gauge.h"
18 #endif //WX_PRECOMP
19
20 #import <AppKit/NSProgressIndicator.h>
21
22 IMPLEMENT_DYNAMIC_CLASS(wxGauge, wxControl)
23 BEGIN_EVENT_TABLE(wxGauge, wxGaugeBase)
24 END_EVENT_TABLE()
25 // WX_IMPLEMENT_COCOA_OWNER(wxGauge,NSProgressIndicator,NSView,NSView)
26
27 bool wxGauge::Create(wxWindow *parent, wxWindowID winid, int range,
28 const wxPoint& pos, const wxSize& size, long style,
29 const wxValidator& validator, const wxString& name)
30 {
31 if(!CreateControl(parent,winid,pos,size,style,validator,name))
32 return false;
33 SetNSView([[NSProgressIndicator alloc] initWithFrame: MakeDefaultNSRect(size)]);
34 [m_cocoaNSView release];
35
36 [(NSProgressIndicator*)m_cocoaNSView setMaxValue:range];
37 [(NSProgressIndicator*)m_cocoaNSView setIndeterminate:NO];
38
39 if(m_parent)
40 m_parent->CocoaAddChild(this);
41 SetInitialFrameRect(pos,size);
42
43 return true;
44 }
45
46 wxGauge::~wxGauge()
47 {
48 }
49
50 int wxGauge::GetValue() const
51 {
52 return (int)[(NSProgressIndicator*)m_cocoaNSView doubleValue];
53 }
54
55 void wxGauge::SetValue(int value)
56 {
57 [(NSProgressIndicator*)m_cocoaNSView setDoubleValue:value];
58 }
59
60 int wxGauge::GetRange() const
61 {
62 return (int)[(NSProgressIndicator*)m_cocoaNSView maxValue];
63 }
64
65 void wxGauge::SetRange(int maxValue)
66 {
67 [(NSProgressIndicator*)m_cocoaNSView setMinValue:0.0];
68 [(NSProgressIndicator*)m_cocoaNSView setMaxValue:maxValue];
69 }
70
71 #endif // wxUSE_GAUGE