Clean up menus and text drawing
FossilOrigin-Name: f17992369e439fa68605017c6ffb0d11eece9d29a4cdb5768656bd874248d623
This commit is contained in:
parent
623076a034
commit
0bd8f1920f
14 changed files with 331 additions and 225 deletions
31
src/MenuItem.m
Normal file
31
src/MenuItem.m
Normal file
|
@ -0,0 +1,31 @@
|
|||
#import "MenuItem.h"
|
||||
|
||||
@implementation MenuItem
|
||||
- (instancetype)initWithText:(OFString *)text action:(OFString *)action
|
||||
{
|
||||
self = [super init];
|
||||
|
||||
_text = [text copy];
|
||||
_action = [action copy];
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (OFComparisonResult)compare:(id)otherObject
|
||||
{
|
||||
MenuItem *otherItem;
|
||||
|
||||
if (![otherObject isKindOfClass:[MenuItem class]])
|
||||
@throw [OFInvalidArgumentException exception];
|
||||
|
||||
int x = (int)_text.longLongValue;
|
||||
int y = (int)otherItem.text.longLongValue;
|
||||
|
||||
if (x > y)
|
||||
return OFOrderedAscending;
|
||||
if (x < y)
|
||||
return OFOrderedDescending;
|
||||
|
||||
return OFOrderedSame;
|
||||
}
|
||||
@end
|
Loading…
Add table
Add a link
Reference in a new issue