Make appropriate use of MakeDefaultNSRect and SetInitialFrameRect

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@22815 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
David Elliott
2003-08-13 20:28:35 +00:00
parent 771eb7a2a2
commit 8d656ea93c
14 changed files with 39 additions and 19 deletions

View File

@@ -36,9 +36,8 @@ bool wxBitmapButton::Create(wxWindow *parent, wxWindowID winid,
if(!CreateControl(parent,winid,pos,size,style,validator,name)) if(!CreateControl(parent,winid,pos,size,style,validator,name))
return false; return false;
wxLogDebug("Created control with id=%d",GetId()); wxLogDebug("Created control with id=%d",GetId());
NSRect cocoaRect = NSMakeRect(10,10,20,20);
m_cocoaNSView = NULL; 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). // NOTE: YES we want to release this (to match the alloc).
// DoAddChild(this) will retain us again since addSubView doesn't. // DoAddChild(this) will retain us again since addSubView doesn't.
[m_cocoaNSView release]; [m_cocoaNSView release];
@@ -49,6 +48,7 @@ bool wxBitmapButton::Create(wxWindow *parent, wxWindowID winid,
if(m_parent) if(m_parent)
m_parent->CocoaAddChild(this); m_parent->CocoaAddChild(this);
SetInitialFrameRect(pos,size);
return true; return true;
} }

View File

@@ -36,9 +36,8 @@ bool wxButton::Create(wxWindow *parent, wxWindowID winid,
if(!CreateControl(parent,winid,pos,size,style,validator,name)) if(!CreateControl(parent,winid,pos,size,style,validator,name))
return false; return false;
wxLogDebug("Created control with id=%d",GetId()); wxLogDebug("Created control with id=%d",GetId());
NSRect cocoaRect = NSMakeRect(10,10,20,20);
m_cocoaNSView = NULL; 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). // NOTE: YES we want to release this (to match the alloc).
// DoAddChild(this) will retain us again since addSubView doesn't. // DoAddChild(this) will retain us again since addSubView doesn't.
[m_cocoaNSView release]; [m_cocoaNSView release];
@@ -49,6 +48,7 @@ bool wxButton::Create(wxWindow *parent, wxWindowID winid,
if(m_parent) if(m_parent)
m_parent->CocoaAddChild(this); m_parent->CocoaAddChild(this);
SetInitialFrameRect(pos,size);
return true; return true;
} }

View File

@@ -35,8 +35,7 @@ bool wxCheckBox::Create(wxWindow *parent, wxWindowID winid,
if(!CreateControl(parent,winid,pos,size,style,validator,name)) if(!CreateControl(parent,winid,pos,size,style,validator,name))
return false; return false;
m_cocoaNSView = NULL; m_cocoaNSView = NULL;
NSRect cocoaRect = NSMakeRect(10,10,20,20); SetNSButton([[NSButton alloc] initWithFrame: MakeDefaultNSRect(size)]);
SetNSButton([[NSButton alloc] initWithFrame: cocoaRect]);
[m_cocoaNSView release]; [m_cocoaNSView release];
[GetNSButton() setButtonType: NSSwitchButton]; [GetNSButton() setButtonType: NSSwitchButton];
[GetNSButton() setTitle:[NSString stringWithCString: label.c_str()]]; [GetNSButton() setTitle:[NSString stringWithCString: label.c_str()]];
@@ -44,6 +43,8 @@ bool wxCheckBox::Create(wxWindow *parent, wxWindowID winid,
if(m_parent) if(m_parent)
m_parent->CocoaAddChild(this); m_parent->CocoaAddChild(this);
SetInitialFrameRect(pos,size);
return true; return true;
} }

View File

@@ -41,12 +41,14 @@ bool wxComboBox::Create(wxWindow *parent, wxWindowID winid,
return false; return false;
m_cocoaNSView = NULL; m_cocoaNSView = NULL;
SetNSTextField([[NSComboBox alloc] initWithFrame:NSMakeRect(0,0,30,30)]); SetNSTextField([[NSComboBox alloc] initWithFrame:MakeDefaultNSRect(size)]);
[m_cocoaNSView release]; [m_cocoaNSView release];
[GetNSTextField() setStringValue:wxNSStringWithWxString(value.c_str())]; [GetNSTextField() setStringValue:wxNSStringWithWxString(value.c_str())];
[GetNSControl() sizeToFit]; [GetNSControl() sizeToFit];
if(m_parent) if(m_parent)
m_parent->CocoaAddChild(this); m_parent->CocoaAddChild(this);
SetInitialFrameRect(pos,size);
return true; return true;
} }

View File

@@ -33,9 +33,8 @@ bool wxControl::Create(wxWindow *parent, wxWindowID winid,
if(!CreateControl(parent,winid,pos,size,style,validator,name)) if(!CreateControl(parent,winid,pos,size,style,validator,name))
return false; return false;
wxLogDebug("Created control with id=%d",GetId()); wxLogDebug("Created control with id=%d",GetId());
NSRect cocoaRect = NSMakeRect(10,10,20,20);
m_cocoaNSView = NULL; 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). // NOTE: YES we want to release this (to match the alloc).
// DoAddChild(this) will retain us again since addSubView doesn't. // DoAddChild(this) will retain us again since addSubView doesn't.
[m_cocoaNSView release]; [m_cocoaNSView release];
@@ -44,6 +43,7 @@ bool wxControl::Create(wxWindow *parent, wxWindowID winid,
if(m_parent) if(m_parent)
m_parent->CocoaAddChild(this); m_parent->CocoaAddChild(this);
SetInitialFrameRect(pos,size);
return true; return true;
} }

View File

@@ -28,10 +28,12 @@ bool wxGauge::Create(wxWindow *parent, wxWindowID winid, int range,
{ {
if(!CreateControl(parent,winid,pos,size,style,validator,name)) if(!CreateControl(parent,winid,pos,size,style,validator,name))
return false; return false;
SetNSView([[NSProgressIndicator alloc] initWithFrame: NSMakeRect(10,10,20,20)]); SetNSView([[NSProgressIndicator alloc] initWithFrame: MakeDefaultNSRect(size)]);
[m_cocoaNSView release]; [m_cocoaNSView release];
if(m_parent) if(m_parent)
m_parent->CocoaAddChild(this); m_parent->CocoaAddChild(this);
SetInitialFrameRect(pos,size);
return true; return true;
} }

View File

@@ -30,10 +30,12 @@ bool wxRadioBox::Create(wxWindow *parent, wxWindowID winid,
{ {
if(!CreateControl(parent,winid,pos,size,style,validator,name)) if(!CreateControl(parent,winid,pos,size,style,validator,name))
return false; return false;
SetNSView([[NSView alloc] initWithFrame: NSMakeRect(10,10,20,20)]); SetNSView([[NSView alloc] initWithFrame: MakeDefaultNSRect(size)]);
[m_cocoaNSView release]; [m_cocoaNSView release];
if(m_parent) if(m_parent)
m_parent->CocoaAddChild(this); m_parent->CocoaAddChild(this);
SetInitialFrameRect(pos,size);
return true; return true;
} }

View File

@@ -35,8 +35,7 @@ bool wxRadioButton::Create(wxWindow *parent, wxWindowID winid,
if(!CreateControl(parent,winid,pos,size,style,validator,name)) if(!CreateControl(parent,winid,pos,size,style,validator,name))
return false; return false;
m_cocoaNSView = NULL; m_cocoaNSView = NULL;
NSRect cocoaRect = NSMakeRect(10,10,20,20); SetNSButton([[NSButton alloc] initWithFrame: MakeDefaultNSRect(size)]);
SetNSButton([[NSButton alloc] initWithFrame: cocoaRect]);
[m_cocoaNSView release]; [m_cocoaNSView release];
[GetNSButton() setButtonType: NSRadioButton]; [GetNSButton() setButtonType: NSRadioButton];
[GetNSButton() setTitle:wxNSStringWithWxString(label)]; [GetNSButton() setTitle:wxNSStringWithWxString(label)];
@@ -44,6 +43,8 @@ bool wxRadioButton::Create(wxWindow *parent, wxWindowID winid,
if(m_parent) if(m_parent)
m_parent->CocoaAddChild(this); m_parent->CocoaAddChild(this);
SetInitialFrameRect(pos,size);
return true; return true;
} }

View File

@@ -29,10 +29,12 @@ bool wxSlider::Create(wxWindow *parent, wxWindowID winid,
{ {
if(!CreateControl(parent,winid,pos,size,style,validator,name)) if(!CreateControl(parent,winid,pos,size,style,validator,name))
return false; return false;
SetNSView([[NSView alloc] initWithFrame: NSMakeRect(10,10,20,20)]); SetNSView([[NSView alloc] initWithFrame: MakeDefaultNSRect(size)]);
[m_cocoaNSView release]; [m_cocoaNSView release];
if(m_parent) if(m_parent)
m_parent->CocoaAddChild(this); m_parent->CocoaAddChild(this);
SetInitialFrameRect(pos,size);
return true; return true;
} }

View File

@@ -30,10 +30,12 @@ bool wxSpinButton::Create(wxWindow *parent, wxWindowID winid,
{ {
if(!CreateControl(parent,winid,pos,size,style,wxDefaultValidator,name)) if(!CreateControl(parent,winid,pos,size,style,wxDefaultValidator,name))
return false; return false;
SetNSControl([[NSStepper alloc] initWithFrame: NSMakeRect(10,10,20,20)]); SetNSControl([[NSStepper alloc] initWithFrame: MakeDefaultNSRect(size)]);
[m_cocoaNSView release]; [m_cocoaNSView release];
if(m_parent) if(m_parent)
m_parent->CocoaAddChild(this); m_parent->CocoaAddChild(this);
SetInitialFrameRect(pos,size);
return true; return true;
} }

View File

@@ -29,10 +29,12 @@ bool wxStaticBitmap::Create(wxWindow *parent, wxWindowID winid,
if(!CreateControl(parent,winid,pos,size,style,wxDefaultValidator,name)) if(!CreateControl(parent,winid,pos,size,style,wxDefaultValidator,name))
return false; return false;
m_cocoaNSView = NULL; m_cocoaNSView = NULL;
SetNSView([[NSView alloc] initWithFrame: NSMakeRect(10,10,20,20)]); SetNSView([[NSView alloc] initWithFrame: MakeDefaultNSRect(size)]);
[m_cocoaNSView release]; [m_cocoaNSView release];
if(m_parent) if(m_parent)
m_parent->CocoaAddChild(this); m_parent->CocoaAddChild(this);
SetInitialFrameRect(pos,size);
return true; return true;
} }

View File

@@ -33,10 +33,12 @@ bool wxStaticBox::Create(wxWindow *parent, wxWindowID winid,
if(!CreateControl(parent,winid,pos,size,style,validator,name)) if(!CreateControl(parent,winid,pos,size,style,validator,name))
return false; return false;
m_cocoaNSView = NULL; 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()]]; [GetNSBox() setTitle:[NSString stringWithCString:title.c_str()]];
if(m_parent) if(m_parent)
m_parent->CocoaAddChild(this); m_parent->CocoaAddChild(this);
SetInitialFrameRect(pos,size);
return true; return true;
} }

View File

@@ -27,10 +27,12 @@ bool wxStaticLine::Create(wxWindow *parent, wxWindowID winid,
{ {
if(!CreateControl(parent,winid,pos,size,style,wxDefaultValidator,name)) if(!CreateControl(parent,winid,pos,size,style,wxDefaultValidator,name))
return false; return false;
SetNSView([[NSView alloc] initWithFrame: NSMakeRect(10,10,20,20)]); SetNSView([[NSView alloc] initWithFrame: MakeDefaultNSRect(size)]);
[m_cocoaNSView release]; [m_cocoaNSView release];
if(m_parent) if(m_parent)
m_parent->CocoaAddChild(this); m_parent->CocoaAddChild(this);
SetInitialFrameRect(pos,size);
return true; return true;
} }

View File

@@ -34,7 +34,7 @@ bool wxStaticText::Create(wxWindow *parent, wxWindowID winid,
if(!CreateControl(parent,winid,pos,size,style,wxDefaultValidator,name)) if(!CreateControl(parent,winid,pos,size,style,wxDefaultValidator,name))
return false; return false;
m_cocoaNSView = NULL; m_cocoaNSView = NULL;
SetNSTextField([[NSTextField alloc] initWithFrame:NSMakeRect(0,0,30,30)]); SetNSTextField([[NSTextField alloc] initWithFrame:MakeDefaultNSRect(size)]);
[m_cocoaNSView release]; [m_cocoaNSView release];
[GetNSTextField() setStringValue:[NSString stringWithCString:label.c_str()]]; [GetNSTextField() setStringValue:[NSString stringWithCString:label.c_str()]];
// [GetNSTextField() setBordered: NO]; // [GetNSTextField() setBordered: NO];
@@ -50,6 +50,8 @@ bool wxStaticText::Create(wxWindow *parent, wxWindowID winid,
if(m_parent) if(m_parent)
m_parent->CocoaAddChild(this); m_parent->CocoaAddChild(this);
SetInitialFrameRect(pos,size);
return true; return true;
} }