X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/24e97652b0f3a5796c3fab61d87b1f636d64ce79..e9b964cfe591532f21c31204032357899cc2cbad:/src/cocoa/gauge.mm?ds=sidebyside diff --git a/src/cocoa/gauge.mm b/src/cocoa/gauge.mm index 17962bdde9..028064b74a 100644 --- a/src/cocoa/gauge.mm +++ b/src/cocoa/gauge.mm @@ -9,11 +9,13 @@ // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// -#include "wx/setup.h" +#include "wx/wxprec.h" #if wxUSE_GAUGE -#include "wx/app.h" -#include "wx/gauge.h" +#ifndef WX_PRECOMP + #include "wx/app.h" + #include "wx/gauge.h" +#endif //WX_PRECOMP #import @@ -28,10 +30,16 @@ bool wxGauge::Create(wxWindow *parent, wxWindowID winid, int range, { if(!CreateControl(parent,winid,pos,size,style,validator,name)) return false; - SetNSView([[NSProgressIndicator alloc] initWithFrame: NSMakeRect(10,10,20,20)]); + SetNSView([[NSProgressIndicator alloc] initWithFrame: MakeDefaultNSRect(size)]); [m_cocoaNSView release]; + + [(NSProgressIndicator*)m_cocoaNSView setMaxValue:range]; + [(NSProgressIndicator*)m_cocoaNSView setIndeterminate:NO]; + if(m_parent) m_parent->CocoaAddChild(this); + SetInitialFrameRect(pos,size); + return true; } @@ -39,4 +47,25 @@ wxGauge::~wxGauge() { } +int wxGauge::GetValue() const +{ + return (int)[(NSProgressIndicator*)m_cocoaNSView doubleValue]; +} + +void wxGauge::SetValue(int value) +{ + [(NSProgressIndicator*)m_cocoaNSView setDoubleValue:value]; +} + +int wxGauge::GetRange() const +{ + return (int)[(NSProgressIndicator*)m_cocoaNSView maxValue]; +} + +void wxGauge::SetRange(int maxValue) +{ + [(NSProgressIndicator*)m_cocoaNSView setMinValue:0.0]; + [(NSProgressIndicator*)m_cocoaNSView setMaxValue:maxValue]; +} + #endif // wxUSE_GAUGE