virtual void CocoaSetEnabled(bool enable);
protected:
virtual wxSize DoGetBestSize() const;
+
+ // Provides a common implementation of title setting which strips mnemonics
+ // and then calls setTitle: with the stripped string. May be implemented
+ // to call setTitleWithMnemonic: on OpenStep-compatible systems. Only
+ // intended for use by views or cells which implement at least setTitle:
+ // and possibly setTitleWithMnemonic: such as NSBox and NSButton or NSCell
+ // classes, for example as used by wxRadioBox. Not usable with classes like
+ // NSTextField which expect setStringValue:.
+ static void CocoaSetLabelForObject(const wxString& labelWithWxMnemonic, struct objc_object *anObject);
};
#endif
[m_cocoaNSView release];
[GetNSButton() setBezelStyle:NSRoundedBezelStyle];
- [GetNSButton() setTitle:wxNSStringWithWxString(GetLabelText(label))];
+ CocoaSetLabelForObject(label, GetNSButton());
[GetNSControl() sizeToFit];
if(m_parent)
void wxButton::SetLabel(const wxString& label)
{
- [GetNSButton() setTitle:wxNSStringWithWxString(GetLabelText(label))];
+ CocoaSetLabelForObject(label, GetNSButton());
}
wxSize wxButton::DoGetBestSize() const
[m_cocoaNSView release];
[GetNSButton() setButtonType: NSSwitchButton];
[GetNSButton() setAllowsMixedState: Is3State()];
- [GetNSButton() setTitle:wxNSStringWithWxString(GetLabelText(label))];
+ CocoaSetLabelForObject(label, GetNSButton());
[GetNSControl() sizeToFit];
if(m_parent)
void wxCheckBox::SetLabel(const wxString& s)
{
wxAutoNSAutoreleasePool pool;
- [GetNSButton() setTitle:wxNSStringWithWxString(s)];
+ CocoaSetLabelForObject(s, GetNSButton());
}
wxString wxCheckBox::GetLabel() const
#endif
#include "wx/cocoa/autorelease.h"
+#include "wx/cocoa/string.h"
#include "wx/cocoa/trackingrectmanager.h"
#include "wx/cocoa/objc/objc_uniquifying.h"
{
[GetNSControl() setEnabled: enable];
}
+
+/*static*/ void wxControl::CocoaSetLabelForObject(const wxString& label, struct objc_object *aView)
+{
+ [aView setTitle:wxNSStringWithWxString(GetLabelText(label))];
+}
+
NSMutableArray *allCells = [NSMutableArray arrayWithCapacity:n];
for(int i=0; i<n; ++i)
{
- [currCell setTitle: wxNSStringWithWxString(wxStripMenuCodes(choices[i], wxStrip_Mnemonics))];
+ CocoaSetLabelForObject(choices[i], currCell);
[allCells addObject: currCell];
[currCell release];
// NOTE: We can still safely message currCell as the array has retained it.
[theBox release];
- [GetNSBox() setTitle:wxNSStringWithWxString(wxStripMenuCodes(title, wxStrip_Mnemonics))];
+ CocoaSetLabelForObject(title, GetNSBox());
// [GetNSBox() setBorderType:NSLineBorder]; // why??
SetMajorDim(majorDim, style);
{
int r = GetRowForIndex(n);
int c = GetColumnForIndex(n);
- [[GetNSMatrix() cellAtRow:r column:c] setTitle:wxNSStringWithWxString(wxStripMenuCodes(label, wxStrip_Mnemonics))];
+ CocoaSetLabelForObject(label, [GetNSMatrix() cellAtRow:r column:c]);
}
// change the individual radio button state
SetNSButton([[NSButton alloc] initWithFrame: MakeDefaultNSRect(size)]);
[m_cocoaNSView release];
[GetNSButton() setButtonType: NSRadioButton];
- [GetNSButton() setTitle:wxNSStringWithWxString(label)];
+ CocoaSetLabelForObject(label, GetNSButton());
// If it's the first in a group, it should be selected
if(style&wxRB_GROUP)
[GetNSButton() setState: NSOnState];
return false;
m_cocoaNSView = NULL;
SetNSBox([[NSBox alloc] initWithFrame:MakeDefaultNSRect(size)]);
- [GetNSBox() setTitle:wxNSStringWithWxString(GetLabelText(title))];
+ CocoaSetLabelForObject(title, GetNSBox());
if(m_parent)
m_parent->CocoaAddChild(this);
SetInitialFrameRect(pos,size);
void wxStaticBox::SetLabel(const wxString& label)
{
wxAutoNSAutoreleasePool pool;
- [GetNSBox() setTitle:wxNSStringWithWxString(label)];
+ CocoaSetLabelForObject(label, GetNSBox());
}
wxString wxStaticBox::GetLabel() const