source: launchers/macosx/obj-cpp/AppDelegate.h @ 2664c41

Last change on this file since 2664c41 was 0b01cc5, checked in by meeh <meeh@…>, 2 years ago

Adding codebase for the Objective-C++ part of the Mac OS X launcher/wrapper.

  • Property mode set to 100644
File size: 3.1 KB
Line 
1#ifndef __APPDELEGATE_H__
2#define __APPDELEGATE_H__
3
4#include <algorithm>
5#include <string>
6#include <memory>
7
8#include <Cocoa/Cocoa.h>
9
10#include "StatusItemButton.h"
11#include "JavaHelper.h"
12
13extern JvmListSharedPtr gRawJvmList;
14
15@interface MenuBarCtrl : NSObject <StatusItemButtonDelegate, NSMenuDelegate>
16@property BOOL enableLogging;
17@property BOOL enableVerboseLogging;
18@property (strong) NSMenu *menu;
19@property (strong) StatusItemButton* statusBarButton;
20@property (strong) NSUserDefaults *userPreferences;
21@property (strong, nonatomic) NSImage * image;
22@property (strong, nonatomic) NSStatusItem *statusItem;
23// Event handlers
24- (void) statusItemButtonLeftClick: (StatusItemButton *) button;
25- (void) statusItemButtonRightClick: (StatusItemButton *) button;
26- (void) statusBarImageBtnClicked;
27- (void) btnPressedAction:(id)sender;
28- (void) menuWillOpen:(NSMenu *)menu;
29
30- (void) startJavaRouterBtnHandler: (NSMenuItem *) menuItem;
31- (void) restartJavaRouterBtnHandler: (NSMenuItem *) menuItem;
32- (void) stopJavaRouterBtnHandler: (NSMenuItem *) menuItem;
33- (void) quitWrapperBtnHandler: (NSMenuItem *) menuItem;
34// Methods
35- (MenuBarCtrl *) init;
36- (void) dealloc;
37- (NSMenu *) createStatusBarMenu;
38@end
39
40@protocol MenuBarCtrlDelegate
41- (void) menuBarCtrlStatusChanged: (BOOL) active;
42@end
43
44@interface AppDelegate : NSObject <NSUserNotificationCenterDelegate, NSApplicationDelegate> {
45@public
46  //NSImageView *imageCell;
47}
48@property (strong) MenuBarCtrl *menuBarCtrl;
49@property (strong) NSUserDefaults *userPreferences;
50@property BOOL enableLogging;
51@property BOOL enableVerboseLogging;
52- (void)applicationDidFinishLaunching:(NSNotification *)aNotification;
53- (void)applicationWillTerminate:(NSNotification *)aNotification;
54- (void)setApplicationDefaultPreferences;
55- (void)userChooseJavaHome;
56- (AppDelegate *)initWithArgc:(int)argc argv:(const char **)argv;
57- (NSString *)userSelectJavaHome:(JvmListPtr)rawJvmList;
58@end
59
60
61/*
62
63
64@implementation CNSStatusBarCtrl
65-(id)initWithSysTray:(I2PCtrlSysIcon *)sys
66{
67  self = [super init];
68  if (self) {
69    item = [[[NSStatusBar systemStatusBar] statusItemWithLength:NSSquareStatusItemLength] retain];
70    menu = 0;
71    systray = sys;
72    imageCell = [[NSImageView alloc] initWithParent:self];
73    [item setView: imageCell];
74    [item setHidden: NO];
75    CFShow(CFSTR("CNSStatusBarCtrl::initWithSysTray executed"));
76  }
77  return self;
78}
79-(NSStatusItem*)item {
80    return item;
81}
82-(void)dealloc {
83  [[NSStatusBar systemStatusBar] removeStatusItem:item];
84  [[NSNotificationCenter defaultCenter] removeObserver:imageCell];
85  [imageCell release];
86  [item release];
87  [super dealloc];
88}
89@end
90
91
92class CSystemTrayIcon
93{
94public:
95  CSystemTrayIcon(I2PCtrlSysIcon *sys)
96  {
97    item = [[CNSStatusBarCtrl alloc] initWithSysTray:sys];
98    [[NSUserNotificationCenter defaultUserNotificationCenter] setDelegate:item];
99    const int menuHeight = [[NSStatusBar systemStatusBar] thickness];
100    printf("menuHeight: %d\n", menuHeight);
101    [[[item item] view] setHidden: NO];
102  }
103  ~CSystemTrayIcon()
104  {
105    [[[item item] view] setHidden: YES];
106    [[NSUserNotificationCenter defaultUserNotificationCenter] setDelegate:nil];
107    [item release];
108  }
109  CNSStatusBarCtrl *item;
110};
111*/
112
113
114#endif
Note: See TracBrowser for help on using the repository browser.