mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-23 06:51:44 +00:00
Add color for disabled state
This commit is contained in:
parent
ab83e1ef81
commit
fdd51ae2df
4 changed files with 37 additions and 8 deletions
|
@ -960,10 +960,13 @@ APPKIT_EXPORT NSString *GSThemeWillDeactivateNotification;
|
|||
|
||||
// NSSwitch drawing methods
|
||||
- (void) drawSwitchKnob: (NSRect)frame
|
||||
forState: (NSControlStateValue)value;
|
||||
forState: (NSControlStateValue)value
|
||||
enabled: (BOOL)enabled;
|
||||
|
||||
|
||||
- (void) drawSwitchBezel: (NSRect)frame
|
||||
forState: (NSControlStateValue)v;
|
||||
forState: (NSControlStateValue)v
|
||||
enabled: (BOOL)enabled;
|
||||
|
||||
- (void) drawSwitchInRect: (NSRect)rect
|
||||
forState: (NSControlStateValue)state
|
||||
|
|
|
@ -40,6 +40,7 @@ extern "C" {
|
|||
NSControlStateValue _state;
|
||||
id _target;
|
||||
SEL _action;
|
||||
BOOL _enabled;
|
||||
}
|
||||
|
||||
- (void) setState: (NSControlStateValue)s;
|
||||
|
|
|
@ -820,15 +820,21 @@
|
|||
|
||||
- (void) drawSwitchBezel: (NSRect)frame
|
||||
forState: (NSControlStateValue)v
|
||||
enabled: (BOOL)enabled
|
||||
{
|
||||
NSBezierPath *p;
|
||||
NSPoint point;
|
||||
CGFloat radius;
|
||||
NSColor *backgroundColor = [NSColor windowBackgroundColor]; // offColor;
|
||||
NSColor *backgroundColor = [NSColor selectedControlColor]; // onColor;
|
||||
|
||||
if (NSControlStateValueOn == v)
|
||||
if (NSControlStateValueOn != v)
|
||||
{
|
||||
backgroundColor = [NSColor selectedControlColor]; // onColor;
|
||||
backgroundColor = [NSColor windowBackgroundColor]; // offColor;
|
||||
}
|
||||
|
||||
if (enabled == NO)
|
||||
{
|
||||
backgroundColor = [NSColor disabledControlTextColor];
|
||||
}
|
||||
|
||||
// make smaller than enclosing frame
|
||||
|
@ -885,10 +891,11 @@
|
|||
|
||||
- (void) drawSwitchKnob: (NSRect)frame
|
||||
forState: (NSControlStateValue)value
|
||||
enabled: (BOOL)enabled
|
||||
{
|
||||
|
||||
// make smaller so that it does not touch frame
|
||||
NSColor *backgroundColor = [NSColor windowBackgroundColor];
|
||||
NSColor *backgroundColor = enabled ? [NSColor windowBackgroundColor] : [NSColor disabledControlTextColor];
|
||||
NSBezierPath *oval;
|
||||
NSRect rect = NSZeroRect;
|
||||
CGFloat w = (frame.size.width / 2) - 2;
|
||||
|
@ -932,11 +939,14 @@
|
|||
{
|
||||
// Draw the well bezel
|
||||
[self drawSwitchBezel: rect
|
||||
forState: state];
|
||||
forState: state
|
||||
enabled: enabled];
|
||||
|
||||
// Draw the knob
|
||||
[self drawSwitchKnob: rect
|
||||
forState: state];
|
||||
forState: state
|
||||
enabled: enabled];
|
||||
|
||||
}
|
||||
|
||||
// NSSegmentedControl drawing methods
|
||||
|
|
|
@ -66,6 +66,16 @@
|
|||
return _target;
|
||||
}
|
||||
|
||||
- (void) setEnabled: (BOOL)flag
|
||||
{
|
||||
_enabled = flag;
|
||||
}
|
||||
|
||||
- (BOOL) isEnabled
|
||||
{
|
||||
return _enabled;
|
||||
}
|
||||
|
||||
- (void) setDoubleValue: (double)val
|
||||
{
|
||||
if (val < 1.0)
|
||||
|
@ -221,6 +231,11 @@
|
|||
id t = [coder decodeObjectForKey: @"NSControlTarget"];
|
||||
[self setTarget: t];
|
||||
}
|
||||
if ([coder containsValueForKey: @"NSEnabled"])
|
||||
{
|
||||
BOOL f = [coder decodeBoolForKey: @"NSEnabled"];
|
||||
[self setEnabled: f];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue