1/*
2   NSStatusItem.h
3
4   The status item class
5
6   Copyright (C) 2013 Free Software Foundation, Inc.
7
8   Author:  Gregory Casamento <greg.casamento@gmail.com>
9   Date: 2013
10   Author: Dr. H. Nikolaus Schaller
11
12   This file is part of the GNUstep GUI Library.
13
14   This library is free software; you can redistribute it and/or
15   modify it under the terms of the GNU Lesser General Public
16   License as published by the Free Software Foundation; either
17   version 2 of the License, or (at your option) any later version.
18
19   This library is distributed in the hope that it will be useful,
20   but WITHOUT ANY WARRANTY; without even the implied warranty of
21   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the GNU
22   Lesser General Public License for more details.
23
24   You should have received a copy of the GNU Lesser General Public
25   License along with this library; see the file COPYING.LIB.
26   If not, see <http://www.gnu.org/licenses/> or write to the
27   Free Software Foundation, 51 Franklin Street, Fifth Floor,
28   Boston, MA 02110-1301, USA.
29*/
30
31// FIXME: This class is currently a placeholder to allow compilation of
32// apps which require NSStatusItem.  Currently there is not a clean,
33// cross-platform way to implement this functionality.
34
35#import <Foundation/NSAttributedString.h>
36#import <Foundation/NSString.h>
37
38#import <AppKit/NSStatusItem.h>
39#import <AppKit/NSMenuItem.h>
40#import <AppKit/NSView.h>
41
42@implementation NSStatusItem
43
44- (id) _initForStatusBar: (NSStatusBar*)bar
45              withLength: (CGFloat)len
46{
47  if ((self = [super init]))
48    {
49      _statusBar = bar;
50      _menuItem = [[NSMenuItem alloc] initWithTitle: @"?"
51                                             action: NULL
52                                      keyEquivalent: @""];
53      [_menuItem setRepresentedObject: self];
54      [self setLength: len];
55    }
56
57  return self;
58}
59
60- (void) dealloc
61{
62  RELEASE(_menuItem);
63  [super dealloc];
64}
65
66- (SEL) action
67{
68  return [_menuItem action];
69}
70
71- (NSAttributedString*) attributedTitle
72{
73  return [_menuItem attributedTitle];
74}
75
76- (SEL) doubleAction
77{
78  // NIMP
79  return NULL;
80}
81
82- (void) drawStatusBarBackgroundInRect: (NSRect)rect withHighlight: (BOOL)flag
83{
84  // NIMP
85}
86
87- (BOOL) highlightMode
88{
89  return _highlightMode;
90}
91
92- (NSImage*) image
93{
94  return [_menuItem image];
95}
96
97- (BOOL) isEnabled
98{
99  return [_menuItem isEnabled];
100}
101
102- (CGFloat) length
103{
104  return _length;
105}
106
107- (NSMenu *) menu
108{
109  return [_menuItem submenu];
110}
111
112- (void) popUpStatusItemMenu: (NSMenu*)menu
113{
114  // NIMP
115}
116
117- (NSInteger) sendActionOn: (NSInteger)mask
118{
119  //NIMP
120  return 0;
121}
122
123- (void) setAction: (SEL)action
124{
125  [_menuItem setAction: action];
126}
127
128- (void) setAttributedTitle: (NSAttributedString*) title
129{
130  [_menuItem setAttributedTitle: title];
131}
132
133- (void) setDoubleAction: (SEL)sel
134{
135  // NIMP
136}
137
138- (void) setEnabled: (BOOL)flag
139{
140  [_menuItem setEnabled: flag];
141}
142
143- (void) setHighlightMode: (BOOL)highlightMode
144{
145  _highlightMode = highlightMode;
146}
147
148- (void) setImage: (NSImage*)image
149{
150  [_menuItem setImage: image];
151}
152
153- (void) setLength: (CGFloat)len
154{
155  _length = len;
156  //[_menuItem _changed];
157}
158
159- (void) setMenu: (NSMenu*)menu
160{
161  [_menuItem setSubmenu: menu];
162}
163
164- (void) setTarget: (id)target
165{
166  [_menuItem setTarget: target];
167}
168
169- (void) setTitle: (NSString*)title
170{
171  [_menuItem setTitle: title];
172}
173
174- (void) setToolTip: (NSString*)toolTip
175{
176  [_menuItem setToolTip: toolTip];
177}
178
179- (void) setView: (NSView*)view
180{
181  ASSIGN(_view, view);
182}
183
184- (NSStatusBar*) statusBar
185{
186  return _statusBar;
187}
188
189- (id) target
190{
191  return [_menuItem target];
192}
193
194- (NSString*) title
195{
196  return [_menuItem title];
197}
198
199- (NSString*) toolTip
200{
201  return [_menuItem toolTip];
202}
203
204- (NSView*) view
205{
206  return _view;
207}
208
209- (NSImage*) alternateImage
210{
211  //NIMP
212  return nil;
213}
214
215- (void) setAlternateImage: (NSImage*)img
216{
217  //NIMP
218}
219
220@end
221