mirror of
https://github.com/ksherlock/ample.git
synced 2024-06-10 00:29:55 +00:00
make default card/ram italic.
This commit is contained in:
parent
49363d6efd
commit
3dde3a2f38
|
@ -84,10 +84,48 @@
|
||||||
[self setArgs: @[]];
|
[self setArgs: @[]];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static NSFont *ItalicMenuFont(void) {
|
||||||
|
NSFont *font = [NSFont menuFontOfSize: 0];
|
||||||
|
NSFontDescriptor *fd = [font fontDescriptor];
|
||||||
|
NSFontDescriptor *fd2 = [fd fontDescriptorWithSymbolicTraits: NSFontDescriptorTraitItalic];
|
||||||
|
return [NSFont fontWithDescriptor: fd2 size: [font pointSize]];
|
||||||
|
}
|
||||||
|
|
||||||
|
static void SetDefaultMenu(NSArray *items, NSPopUpButton *button) {
|
||||||
|
|
||||||
|
static NSDictionary *attr = nil;
|
||||||
|
if (!attr) {
|
||||||
|
attr = @{
|
||||||
|
NSFontAttributeName: ItalicMenuFont()
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned ix = 0;
|
||||||
|
|
||||||
|
|
||||||
|
for (NSDictionary *d in items) {
|
||||||
|
BOOL def = [(NSNumber *)[d objectForKey: @"default"] boolValue];
|
||||||
|
if (!def) {
|
||||||
|
++ix;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
NSMenuItem *item = [button itemAtIndex: ix];
|
||||||
|
NSString *title = [d objectForKey: @"description"];
|
||||||
|
NSAttributedString *t = [[NSAttributedString alloc] initWithString: title attributes: attr];
|
||||||
|
[item setAttributedTitle: t];
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
-(void)syncMemory {
|
-(void)syncMemory {
|
||||||
|
|
||||||
int ix = 0;
|
int ix = 0;
|
||||||
NSArray *items = [_machine objectForKey: @"RAM"];
|
NSArray *items = [_machine objectForKey: @"RAM"];
|
||||||
|
|
||||||
|
SetDefaultMenu(items, _ram_menu);
|
||||||
|
|
||||||
for (NSDictionary *d in items) {
|
for (NSDictionary *d in items) {
|
||||||
unsigned size = [(NSNumber *)[d objectForKey: @"value"] unsignedIntValue];
|
unsigned size = [(NSNumber *)[d objectForKey: @"value"] unsignedIntValue];
|
||||||
if (size == _memoryBytes) {
|
if (size == _memoryBytes) {
|
||||||
|
@ -108,10 +146,12 @@
|
||||||
-(void)syncSlot: (NSString *)slot button: (NSPopUpButton *)button {
|
-(void)syncSlot: (NSString *)slot button: (NSPopUpButton *)button {
|
||||||
|
|
||||||
NSString *value = [self valueForKey: slot];
|
NSString *value = [self valueForKey: slot];
|
||||||
|
NSArray *items = [_machine objectForKey: slot];
|
||||||
|
|
||||||
|
SetDefaultMenu(items, button);
|
||||||
|
|
||||||
if (![value length]) return;
|
if (![value length]) return;
|
||||||
|
|
||||||
NSArray *items = [_machine objectForKey: slot];
|
|
||||||
|
|
||||||
if (![items count]) {
|
if (![items count]) {
|
||||||
[self setValue: @"" forKey: slot];
|
[self setValue: @"" forKey: slot];
|
||||||
|
|
Loading…
Reference in New Issue
Block a user