]> git.saurik.com Git - wxWidgets.git/blame - src/cocoa/gauge.mm
byte length for interim UniChar String corrected
[wxWidgets.git] / src / cocoa / gauge.mm
CommitLineData
24e97652
DE
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
449c5673 12#include "wx/wxprec.h"
24e97652
DE
13#if wxUSE_GAUGE
14
449c5673
DE
15#ifndef WX_PRECOMP
16 #include "wx/app.h"
17 #include "wx/gauge.h"
18#endif //WX_PRECOMP
24e97652
DE
19
20#import <AppKit/NSProgressIndicator.h>
21
22IMPLEMENT_DYNAMIC_CLASS(wxGauge, wxControl)
23BEGIN_EVENT_TABLE(wxGauge, wxGaugeBase)
24END_EVENT_TABLE()
25// WX_IMPLEMENT_COCOA_OWNER(wxGauge,NSProgressIndicator,NSView,NSView)
26
27bool 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;
8d656ea9 33 SetNSView([[NSProgressIndicator alloc] initWithFrame: MakeDefaultNSRect(size)]);
24e97652 34 [m_cocoaNSView release];
363f7de0
DE
35
36 [(NSProgressIndicator*)m_cocoaNSView setMaxValue:range];
37 [(NSProgressIndicator*)m_cocoaNSView setIndeterminate:NO];
38
24e97652
DE
39 if(m_parent)
40 m_parent->CocoaAddChild(this);
8d656ea9
DE
41 SetInitialFrameRect(pos,size);
42
24e97652
DE
43 return true;
44}
45
46wxGauge::~wxGauge()
47{
48}
49
363f7de0
DE
50int wxGauge::GetValue() const
51{
2108cc97 52 return (int)[(NSProgressIndicator*)m_cocoaNSView doubleValue];
363f7de0
DE
53}
54
55void wxGauge::SetValue(int value)
56{
57 [(NSProgressIndicator*)m_cocoaNSView setDoubleValue:value];
58}
59
60int wxGauge::GetRange() const
61{
2108cc97 62 return (int)[(NSProgressIndicator*)m_cocoaNSView maxValue];
363f7de0
DE
63}
64
65void wxGauge::SetRange(int maxValue)
66{
67 [(NSProgressIndicator*)m_cocoaNSView setMinValue:0.0];
68 [(NSProgressIndicator*)m_cocoaNSView setMaxValue:maxValue];
69}
70
24e97652 71#endif // wxUSE_GAUGE