]> Dogcows Code - chaz/thecheat/blob - MenuExtras.m
update contact information and project URL
[chaz/thecheat] / MenuExtras.m
1
2 /*
3 * The Cheat - The legendary universal game trainer for Mac OS X.
4 * http://www.brokenzipper.com/trac/wiki/TheCheat
5 *
6 * Copyright (c) 2003-2011, Charles McGarvey et al.
7 *
8 * Distributable under the terms and conditions of the 2-clause BSD
9 * license; see the file COPYING for the legal text of the license.
10 */
11
12 #import "MenuExtras.h"
13
14
15 @implementation NSMenu ( MenuExtras )
16
17
18 - (void)removeItemWithTitle:(NSString *)title
19 {
20 int i, top = [self numberOfItems];
21
22 for ( i = 0; i < top; i++ )
23 {
24 if ( [[[self itemAtIndex:i] title] isEqualToString:title] )
25 {
26 [self removeItemAtIndex:i];
27 break;
28 }
29 }
30 }
31
32 - (void)removeAllItemsWithTitle:(NSString *)title
33 {
34 int i, top = [self numberOfItems] - 1;
35
36 for ( i = top; i >= 0; i-- )
37 {
38 if ( [[[self itemAtIndex:i] title] isEqualToString:title] )
39 {
40 [self removeItemAtIndex:i];
41 }
42 }
43 }
44
45 - (void)removeItemWithTag:(int)tag
46 {
47 int i, top = [self numberOfItems];
48
49 for ( i = 0; i < top; i++ )
50 {
51 if ( [[self itemAtIndex:i] tag] == tag )
52 {
53 [self removeItemAtIndex:i];
54 break;
55 }
56 }
57 }
58
59 - (void)removeItemWithRepresentedObject:(id)object
60 {
61 int i, top = [self numberOfItems];
62
63 for ( i = 0; i < top; i++ )
64 {
65 if ( [[[self itemAtIndex:i] representedObject] isEqual:object] )
66 {
67 [self removeItemAtIndex:i];
68 break;
69 }
70 }
71 }
72
73
74 - (void)removeAllItems
75 {
76 int i, top = [self numberOfItems];
77
78 for ( i = 0; i < top; i++ )
79 {
80 [self removeItemAtIndex:0];
81 }
82 }
83
84
85 - (void)enableAllItems
86 {
87 int i, top = [self numberOfItems];
88
89 for ( i = 0; i < top; i++ )
90 {
91 [[self itemAtIndex:i] setEnabled:YES];
92 }
93 }
94
95 - (void)disableAllItems
96 {
97 int i, top = [self numberOfItems];
98
99 for ( i = 0; i < top; i++ )
100 {
101 [[self itemAtIndex:i] setEnabled:NO];
102 }
103 }
104
105
106 @end
This page took 0.032513 seconds and 4 git commands to generate.