Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #include <gwenhywfar/gwenhywfar.h>
00013 #include <gwenhywfar/gui.h>
00014 #include <gwenhywfar/dialog.h>
00015 #include <gwenhywfar/debug.h>
00016
00017
00018 #include <unistd.h>
00019
00020 #import <Foundation/Foundation.h>
00021 #import <AppKit/AppKit.h>
00022
00023 @interface AppDelegate : NSObject {
00024
00025 }
00026
00027 - (void)applicationDidFinishLaunching:(NSNotification *)aNotification;
00028
00029 @end
00030
00031 @implementation AppDelegate
00032
00033 -(id) init {
00034 self = [super init];
00035 if (self) {
00036
00037 }
00038 return self;
00039 }
00040
00041 -(void) dealloc {
00042 [super dealloc];
00043 }
00044
00045 - (void)windowWillClose:(NSNotification *)notification {
00046 [NSApp stop:self];
00047 }
00048
00049 - (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
00050
00051 NSLog(@"Test");
00052
00053 NSWindow *window = [[NSWindow alloc] initWithContentRect:NSMakeRect(100.0, 100.0, 200.0, 200.0) styleMask:NSTitledWindowMask|NSClosableWindowMask backing:NSBackingStoreBuffered defer:YES];
00054 [window setDelegate:self];
00055 [window makeKeyAndOrderFront:nil];
00056
00057 test1();
00058 }
00059
00060 @end
00061
00062
00063 int test1() {
00064
00065
00066 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
00067
00068 NSLog(@"Start");
00069
00070 GWEN_GUI *gui;
00071 int rv;
00072 GWEN_DIALOG *dlg;
00073
00074 rv=GWEN_Init();
00075 if (rv) {
00076 DBG_ERROR_ERR(0, rv);
00077 return 2;
00078 }
00079
00080 NSLog(@"GWEN Gui initialized");
00081
00082 GWEN_Logger_SetLevel(0, GWEN_LoggerLevel_Info);
00083
00084
00085
00086
00087
00088 gui=Cocoa_Gui_new();
00089 GWEN_Gui_SetGui(gui);
00090
00091 NSLog(@"Cocoa Gui set");
00092
00093 dlg=Dlg_Test1_new();
00094 if (dlg==NULL) {
00095 fprintf(stderr, "Could not create dialog.\n");
00096 return 2;
00097 }
00098
00099 NSLog(@"Test new");
00100
00101 rv=GWEN_Gui_ExecDialog(dlg, 0);
00102 fprintf(stderr, "Result: %d\n", rv);
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133 [pool release];
00134
00135 return 0;
00136 }
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204 int test3(int argc, char **argv) {
00205 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
00206
00207 NSLog(@"Cocoa-Test");
00208 NSString *cocoa_string = @"Das ist ein Cocoa String";
00209
00210 [pool release];
00211 return 0;
00212 }
00213
00214
00215
00216
00217
00218 int main(int argc, char **argv) {
00219 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
00220 NSApplication *app = [NSApplication sharedApplication];
00221 AppDelegate *app_delegate = [[AppDelegate alloc] init];
00222 NSMenu *menu = [[NSMenu alloc] initWithTitle:@"Testprogramm"];
00223 [menu addItemWithTitle:@"Quit" action:@selector(windowWillClose:) keyEquivalent:@"Q"];
00224 [app setDelegate:app_delegate];
00225 [app setMainMenu:menu];
00226 [NSApp run];
00227 [menu release];
00228 [pool release];
00229
00230
00231
00232
00233
00234
00235
00236
00237
00238
00239
00240
00241
00242
00243
00244 }
00245
00246