wxCocoa: Implement wxControl::GetLabel/SetLabel by stowing the label in the
wxNonControlNSControl instance used when the wxControl is a non-native subclass (e.g. a generic control). Not needed in trunk since there is now m_labelOrig. Copyright 2007 Software 2000 Ltd. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_8_BRANCH@47603 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -61,6 +61,9 @@ public:
|
||||
|
||||
// Enables the control
|
||||
virtual void CocoaSetEnabled(bool enable);
|
||||
|
||||
wxString GetLabel() const;
|
||||
void SetLabel(const wxString& label);
|
||||
protected:
|
||||
virtual wxSize DoGetBestSize() const;
|
||||
};
|
||||
|
@@ -17,6 +17,7 @@
|
||||
#include "wx/log.h"
|
||||
#endif
|
||||
|
||||
#include "wx/cocoa/string.h"
|
||||
#include "wx/cocoa/autorelease.h"
|
||||
#include "wx/cocoa/objc/objc_uniquifying.h"
|
||||
|
||||
@@ -30,6 +31,7 @@
|
||||
{
|
||||
}
|
||||
|
||||
- (id)initWithFrame: (NSRect)frameRect;
|
||||
- (void)drawRect: (NSRect)rect;
|
||||
- (void)mouseDown:(NSEvent *)theEvent;
|
||||
- (void)mouseDragged:(NSEvent *)theEvent;
|
||||
@@ -49,6 +51,19 @@ WX_DECLARE_GET_OBJC_CLASS(wxNonControlNSControl,NSControl)
|
||||
|
||||
@implementation wxNonControlNSControl : NSControl
|
||||
|
||||
- (id)initWithFrame: (NSRect)frameRect
|
||||
{
|
||||
if( (self = [super initWithFrame:frameRect]) == nil)
|
||||
return nil;
|
||||
// NSControl by default has no cell as it is semi-abstract.
|
||||
// Provide a normal NSCell for the sole purpose of making
|
||||
// setStringValue/stringValue work for labels in 2.8.
|
||||
NSCell *newCell = [[NSCell alloc] initTextCell:@""];
|
||||
[self setCell:newCell];
|
||||
[newCell release];
|
||||
return self;
|
||||
}
|
||||
|
||||
- (BOOL)acceptsFirstMouse:(NSEvent *)theEvent
|
||||
{
|
||||
bool acceptsFirstMouse = false;
|
||||
@@ -233,3 +248,25 @@ void wxControl::CocoaSetEnabled(bool enable)
|
||||
{
|
||||
[GetNSControl() setEnabled: enable];
|
||||
}
|
||||
|
||||
wxString wxControl::GetLabel() const
|
||||
{
|
||||
if([GetNSControl() isKindOfClass:[WX_GET_OBJC_CLASS(wxNonControlNSControl) class]])
|
||||
{
|
||||
return wxStringWithNSString([GetNSControl() stringValue]);
|
||||
}
|
||||
else
|
||||
return wxControlBase::GetLabel();
|
||||
}
|
||||
|
||||
void wxControl::SetLabel(const wxString& label)
|
||||
{
|
||||
wxControlBase::SetLabel(label);
|
||||
// wx 2.8 hack: we need somewhere to stuff the label for
|
||||
// platform-independent subclasses of wxControl.
|
||||
if([GetNSControl() isKindOfClass:[WX_GET_OBJC_CLASS(wxNonControlNSControl) class]])
|
||||
{
|
||||
[GetNSControl() setStringValue:wxNSStringWithWxString(label)];
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user