From 8d656ea93c0f3d53f97a1c67244baa39d72b7334 Mon Sep 17 00:00:00 2001 From: David Elliott Date: Wed, 13 Aug 2003 20:28:35 +0000 Subject: [PATCH] Make appropriate use of MakeDefaultNSRect and SetInitialFrameRect git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@22815 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/cocoa/bmpbuttn.mm | 4 ++-- src/cocoa/button.mm | 4 ++-- src/cocoa/checkbox.mm | 5 +++-- src/cocoa/combobox.mm | 4 +++- src/cocoa/control.mm | 4 ++-- src/cocoa/gauge.mm | 4 +++- src/cocoa/radiobox.mm | 4 +++- src/cocoa/radiobut.mm | 5 +++-- src/cocoa/slider.mm | 4 +++- src/cocoa/spinbutt.mm | 4 +++- src/cocoa/statbmp.mm | 4 +++- src/cocoa/statbox.mm | 4 +++- src/cocoa/statline2.mm | 4 +++- src/cocoa/stattext.mm | 4 +++- 14 files changed, 39 insertions(+), 19 deletions(-) diff --git a/src/cocoa/bmpbuttn.mm b/src/cocoa/bmpbuttn.mm index 2ae02dfdd0..0388a1d9db 100644 --- a/src/cocoa/bmpbuttn.mm +++ b/src/cocoa/bmpbuttn.mm @@ -36,9 +36,8 @@ bool wxBitmapButton::Create(wxWindow *parent, wxWindowID winid, if(!CreateControl(parent,winid,pos,size,style,validator,name)) return false; wxLogDebug("Created control with id=%d",GetId()); - NSRect cocoaRect = NSMakeRect(10,10,20,20); m_cocoaNSView = NULL; - SetNSButton([[NSButton alloc] initWithFrame: cocoaRect]); + SetNSButton([[NSButton alloc] initWithFrame: MakeDefaultNSRect(size)]); // NOTE: YES we want to release this (to match the alloc). // DoAddChild(this) will retain us again since addSubView doesn't. [m_cocoaNSView release]; @@ -49,6 +48,7 @@ bool wxBitmapButton::Create(wxWindow *parent, wxWindowID winid, if(m_parent) m_parent->CocoaAddChild(this); + SetInitialFrameRect(pos,size); return true; } diff --git a/src/cocoa/button.mm b/src/cocoa/button.mm index 08d2b9853c..74a927eb32 100644 --- a/src/cocoa/button.mm +++ b/src/cocoa/button.mm @@ -36,9 +36,8 @@ bool wxButton::Create(wxWindow *parent, wxWindowID winid, if(!CreateControl(parent,winid,pos,size,style,validator,name)) return false; wxLogDebug("Created control with id=%d",GetId()); - NSRect cocoaRect = NSMakeRect(10,10,20,20); m_cocoaNSView = NULL; - SetNSButton([[NSButton alloc] initWithFrame: cocoaRect]); + SetNSButton([[NSButton alloc] initWithFrame: MakeDefaultNSRect(size)]); // NOTE: YES we want to release this (to match the alloc). // DoAddChild(this) will retain us again since addSubView doesn't. [m_cocoaNSView release]; @@ -49,6 +48,7 @@ bool wxButton::Create(wxWindow *parent, wxWindowID winid, if(m_parent) m_parent->CocoaAddChild(this); + SetInitialFrameRect(pos,size); return true; } diff --git a/src/cocoa/checkbox.mm b/src/cocoa/checkbox.mm index 921a1d3a28..1dfd1f6331 100644 --- a/src/cocoa/checkbox.mm +++ b/src/cocoa/checkbox.mm @@ -35,8 +35,7 @@ bool wxCheckBox::Create(wxWindow *parent, wxWindowID winid, if(!CreateControl(parent,winid,pos,size,style,validator,name)) return false; m_cocoaNSView = NULL; - NSRect cocoaRect = NSMakeRect(10,10,20,20); - SetNSButton([[NSButton alloc] initWithFrame: cocoaRect]); + SetNSButton([[NSButton alloc] initWithFrame: MakeDefaultNSRect(size)]); [m_cocoaNSView release]; [GetNSButton() setButtonType: NSSwitchButton]; [GetNSButton() setTitle:[NSString stringWithCString: label.c_str()]]; @@ -44,6 +43,8 @@ bool wxCheckBox::Create(wxWindow *parent, wxWindowID winid, if(m_parent) m_parent->CocoaAddChild(this); + SetInitialFrameRect(pos,size); + return true; } diff --git a/src/cocoa/combobox.mm b/src/cocoa/combobox.mm index eb3f4b104f..ae2b9015fd 100644 --- a/src/cocoa/combobox.mm +++ b/src/cocoa/combobox.mm @@ -41,12 +41,14 @@ bool wxComboBox::Create(wxWindow *parent, wxWindowID winid, return false; m_cocoaNSView = NULL; - SetNSTextField([[NSComboBox alloc] initWithFrame:NSMakeRect(0,0,30,30)]); + SetNSTextField([[NSComboBox alloc] initWithFrame:MakeDefaultNSRect(size)]); [m_cocoaNSView release]; [GetNSTextField() setStringValue:wxNSStringWithWxString(value.c_str())]; [GetNSControl() sizeToFit]; if(m_parent) m_parent->CocoaAddChild(this); + SetInitialFrameRect(pos,size); + return true; } diff --git a/src/cocoa/control.mm b/src/cocoa/control.mm index 1f28f4532b..d7c80c56c7 100644 --- a/src/cocoa/control.mm +++ b/src/cocoa/control.mm @@ -33,9 +33,8 @@ bool wxControl::Create(wxWindow *parent, wxWindowID winid, if(!CreateControl(parent,winid,pos,size,style,validator,name)) return false; wxLogDebug("Created control with id=%d",GetId()); - NSRect cocoaRect = NSMakeRect(10,10,20,20); m_cocoaNSView = NULL; - SetNSControl([[NSControl alloc] initWithFrame: cocoaRect]); + SetNSControl([[NSControl alloc] initWithFrame: MakeDefaultNSRect(size)]); // NOTE: YES we want to release this (to match the alloc). // DoAddChild(this) will retain us again since addSubView doesn't. [m_cocoaNSView release]; @@ -44,6 +43,7 @@ bool wxControl::Create(wxWindow *parent, wxWindowID winid, if(m_parent) m_parent->CocoaAddChild(this); + SetInitialFrameRect(pos,size); return true; } diff --git a/src/cocoa/gauge.mm b/src/cocoa/gauge.mm index 17962bdde9..aafc5b6b76 100644 --- a/src/cocoa/gauge.mm +++ b/src/cocoa/gauge.mm @@ -28,10 +28,12 @@ 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]; if(m_parent) m_parent->CocoaAddChild(this); + SetInitialFrameRect(pos,size); + return true; } diff --git a/src/cocoa/radiobox.mm b/src/cocoa/radiobox.mm index db1e609dca..37cffde012 100644 --- a/src/cocoa/radiobox.mm +++ b/src/cocoa/radiobox.mm @@ -30,10 +30,12 @@ bool wxRadioBox::Create(wxWindow *parent, wxWindowID winid, { if(!CreateControl(parent,winid,pos,size,style,validator,name)) return false; - SetNSView([[NSView alloc] initWithFrame: NSMakeRect(10,10,20,20)]); + SetNSView([[NSView alloc] initWithFrame: MakeDefaultNSRect(size)]); [m_cocoaNSView release]; if(m_parent) m_parent->CocoaAddChild(this); + SetInitialFrameRect(pos,size); + return true; } diff --git a/src/cocoa/radiobut.mm b/src/cocoa/radiobut.mm index d486f62ade..2ee422760d 100644 --- a/src/cocoa/radiobut.mm +++ b/src/cocoa/radiobut.mm @@ -35,8 +35,7 @@ bool wxRadioButton::Create(wxWindow *parent, wxWindowID winid, if(!CreateControl(parent,winid,pos,size,style,validator,name)) return false; m_cocoaNSView = NULL; - NSRect cocoaRect = NSMakeRect(10,10,20,20); - SetNSButton([[NSButton alloc] initWithFrame: cocoaRect]); + SetNSButton([[NSButton alloc] initWithFrame: MakeDefaultNSRect(size)]); [m_cocoaNSView release]; [GetNSButton() setButtonType: NSRadioButton]; [GetNSButton() setTitle:wxNSStringWithWxString(label)]; @@ -44,6 +43,8 @@ bool wxRadioButton::Create(wxWindow *parent, wxWindowID winid, if(m_parent) m_parent->CocoaAddChild(this); + SetInitialFrameRect(pos,size); + return true; } diff --git a/src/cocoa/slider.mm b/src/cocoa/slider.mm index 7e319e4844..f2fdeb9a83 100644 --- a/src/cocoa/slider.mm +++ b/src/cocoa/slider.mm @@ -29,10 +29,12 @@ bool wxSlider::Create(wxWindow *parent, wxWindowID winid, { if(!CreateControl(parent,winid,pos,size,style,validator,name)) return false; - SetNSView([[NSView alloc] initWithFrame: NSMakeRect(10,10,20,20)]); + SetNSView([[NSView alloc] initWithFrame: MakeDefaultNSRect(size)]); [m_cocoaNSView release]; if(m_parent) m_parent->CocoaAddChild(this); + SetInitialFrameRect(pos,size); + return true; } diff --git a/src/cocoa/spinbutt.mm b/src/cocoa/spinbutt.mm index ff0c9d11bf..60d3cd59ef 100644 --- a/src/cocoa/spinbutt.mm +++ b/src/cocoa/spinbutt.mm @@ -30,10 +30,12 @@ bool wxSpinButton::Create(wxWindow *parent, wxWindowID winid, { if(!CreateControl(parent,winid,pos,size,style,wxDefaultValidator,name)) return false; - SetNSControl([[NSStepper alloc] initWithFrame: NSMakeRect(10,10,20,20)]); + SetNSControl([[NSStepper alloc] initWithFrame: MakeDefaultNSRect(size)]); [m_cocoaNSView release]; if(m_parent) m_parent->CocoaAddChild(this); + SetInitialFrameRect(pos,size); + return true; } diff --git a/src/cocoa/statbmp.mm b/src/cocoa/statbmp.mm index 832ce11acd..f288054134 100644 --- a/src/cocoa/statbmp.mm +++ b/src/cocoa/statbmp.mm @@ -29,10 +29,12 @@ bool wxStaticBitmap::Create(wxWindow *parent, wxWindowID winid, if(!CreateControl(parent,winid,pos,size,style,wxDefaultValidator,name)) return false; m_cocoaNSView = NULL; - SetNSView([[NSView alloc] initWithFrame: NSMakeRect(10,10,20,20)]); + SetNSView([[NSView alloc] initWithFrame: MakeDefaultNSRect(size)]); [m_cocoaNSView release]; if(m_parent) m_parent->CocoaAddChild(this); + SetInitialFrameRect(pos,size); + return true; } diff --git a/src/cocoa/statbox.mm b/src/cocoa/statbox.mm index 0a8ecab190..00a22bc123 100644 --- a/src/cocoa/statbox.mm +++ b/src/cocoa/statbox.mm @@ -33,10 +33,12 @@ bool wxStaticBox::Create(wxWindow *parent, wxWindowID winid, if(!CreateControl(parent,winid,pos,size,style,validator,name)) return false; m_cocoaNSView = NULL; - SetNSBox([[NSBox alloc] initWithFrame:NSMakeRect(0,0,30,30)]); + SetNSBox([[NSBox alloc] initWithFrame:MakeDefaultNSRect(size)]); [GetNSBox() setTitle:[NSString stringWithCString:title.c_str()]]; if(m_parent) m_parent->CocoaAddChild(this); + SetInitialFrameRect(pos,size); + return true; } diff --git a/src/cocoa/statline2.mm b/src/cocoa/statline2.mm index 6afc341f54..75e8da18ae 100644 --- a/src/cocoa/statline2.mm +++ b/src/cocoa/statline2.mm @@ -27,10 +27,12 @@ bool wxStaticLine::Create(wxWindow *parent, wxWindowID winid, { if(!CreateControl(parent,winid,pos,size,style,wxDefaultValidator,name)) return false; - SetNSView([[NSView alloc] initWithFrame: NSMakeRect(10,10,20,20)]); + SetNSView([[NSView alloc] initWithFrame: MakeDefaultNSRect(size)]); [m_cocoaNSView release]; if(m_parent) m_parent->CocoaAddChild(this); + SetInitialFrameRect(pos,size); + return true; } diff --git a/src/cocoa/stattext.mm b/src/cocoa/stattext.mm index ff30c7cb2f..29e247c9c9 100644 --- a/src/cocoa/stattext.mm +++ b/src/cocoa/stattext.mm @@ -34,7 +34,7 @@ bool wxStaticText::Create(wxWindow *parent, wxWindowID winid, if(!CreateControl(parent,winid,pos,size,style,wxDefaultValidator,name)) return false; m_cocoaNSView = NULL; - SetNSTextField([[NSTextField alloc] initWithFrame:NSMakeRect(0,0,30,30)]); + SetNSTextField([[NSTextField alloc] initWithFrame:MakeDefaultNSRect(size)]); [m_cocoaNSView release]; [GetNSTextField() setStringValue:[NSString stringWithCString:label.c_str()]]; // [GetNSTextField() setBordered: NO]; @@ -50,6 +50,8 @@ bool wxStaticText::Create(wxWindow *parent, wxWindowID winid, if(m_parent) m_parent->CocoaAddChild(this); + SetInitialFrameRect(pos,size); + return true; } -- 2.45.2