gwenhywfar 5.14.1
libtest.m
Go to the documentation of this file.
1/***************************************************************************
2 begin : August 03 2010
3 copyright : (C) 2010 by Samuel Strupp
4
5 ***************************************************************************
6 * Please see toplevel file COPYING for license details *
7 ***************************************************************************/
8
9
10//#include "../testdialogs/dlg_test.h"
11
12#include <gwenhywfar/gwenhywfar.h>
13#include <gwenhywfar/gui.h>
14#include <gwenhywfar/dialog.h>
15#include <gwenhywfar/debug.h>
16
17
18#include <unistd.h>
19
20#import <Foundation/Foundation.h>
21#import <AppKit/AppKit.h>
22
23@interface AppDelegate : NSObject {
24
25}
26
27- (void)applicationDidFinishLaunching:(NSNotification *)aNotification;
28
29@end
30
31@implementation AppDelegate
32
33-(id) init {
34 self = [super init];
35 if (self) {
36
37 }
38 return self;
39}
40
41-(void) dealloc {
42 [super dealloc];
43}
44
45- (void)windowWillClose:(NSNotification *)notification {
46 [NSApp stop:self];
47}
48
49- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
50
51 NSLog(@"Test");
52
53 NSWindow *window = [[NSWindow alloc] initWithContentRect:NSMakeRect(100.0, 100.0, 200.0, 200.0) styleMask:NSTitledWindowMask|NSClosableWindowMask backing:NSBackingStoreBuffered defer:YES];
54 [window setDelegate:self];
55 [window makeKeyAndOrderFront:nil];
56
57 test1();
58}
59
60@end
61
62
63int test1() {
64 //fprintf(stderr, "Test\n");
65
66 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
67
68 NSLog(@"Start");
69
70 GWEN_GUI *gui;
71 int rv;
72 GWEN_DIALOG *dlg;
73
74 rv=GWEN_Init();
75 if (rv) {
76 DBG_ERROR_ERR(0, rv);
77 return 2;
78 }
79
80 NSLog(@"GWEN Gui initialized");
81
83
84 //gtk_set_locale ();
85 //gtk_init (&argc, &argv);
86
87 // create GUI
88 gui=Cocoa_Gui_new();
89 GWEN_Gui_SetGui(gui);
90
91 NSLog(@"Cocoa Gui set");
92
93 dlg=Dlg_Test1_new();
94 if (dlg==NULL) {
95 fprintf(stderr, "Could not create dialog.\n");
96 return 2;
97 }
98
99 NSLog(@"Test new");
100
101 rv=GWEN_Gui_ExecDialog(dlg, 0);
102 fprintf(stderr, "Result: %d\n", rv);
103
104
105 /* GWEN_GUI *gui;
106 int rv;
107 GWEN_DIALOG *dlg;
108
109 rv=GWEN_Init();
110 if (rv) {
111 DBG_ERROR_ERR(0, rv);
112 return 2;
113 }
114
115 GWEN_Logger_SetLevel(0, GWEN_LoggerLevel_Info);
116
117 gtk_set_locale ();
118 gtk_init (&argc, &argv);
119
120 // create GUI
121 gui=Gtk2_Gui_new();
122 GWEN_Gui_SetGui(gui);
123
124 dlg=Dlg_Test1_new();
125 if (dlg==NULL) {
126 fprintf(stderr, "Could not create dialog.\n");
127 return 2;
128 }
129
130 rv=GWEN_Gui_ExecDialog(dlg, 0);
131 fprintf(stderr, "Result: %d\n", rv);*/
132
133 [pool release];
134
135 return 0;
136}
137
138
139
140
141
142/*int test2(int argc, char **argv) {
143 int rv;
144 uint32_t id1;
145 uint32_t id2;
146 uint64_t i1;
147 uint64_t i2;
148 GWEN_GUI *gui;
149
150 gtk_set_locale ();
151 gtk_init (&argc, &argv);
152
153 gui=Gtk2_Gui_new();
154 GWEN_Gui_SetGui(gui);
155
156 id1=GWEN_Gui_ProgressStart(GWEN_GUI_PROGRESS_SHOW_LOG |
157 GWEN_GUI_PROGRESS_SHOW_ABORT |
158 GWEN_GUI_PROGRESS_KEEP_OPEN,
159 "Progress-Title",
160 "<html>"
161 "<p><b>This</b> is an example <i>text</i>..</p>"
162 "<p>As you can see <font color=red>colors</font> can "
163 "be used.</p>"
164 "</html>",
165 10,
166 0);
167 for (i1=1; i1<=10; i1++) {
168 char numbuf[128];
169
170 snprintf(numbuf, sizeof(numbuf)-1, "Step %d\n", (int)i1);
171 GWEN_Gui_ProgressLog(id1, GWEN_LoggerLevel_Notice, numbuf);
172 id2=GWEN_Gui_ProgressStart(GWEN_GUI_PROGRESS_SHOW_LOG |
173 GWEN_GUI_PROGRESS_DELAY |
174 GWEN_GUI_PROGRESS_SHOW_ABORT,
175 "2nd progress",
176 "Starting 2nd progress...",
177 10,
178 id1);
179 for (i2=1; i2<=10; i2++) {
180 sleep(1);
181 fprintf(stderr, "Advancing %d/%d\n", (int)i1, (int)i2);
182 rv=GWEN_Gui_ProgressAdvance(id2, i2);
183 if (rv==GWEN_ERROR_USER_ABORTED) {
184 fprintf(stderr, "Aborted by user (2)\n");
185 break;
186 }
187 }
188 GWEN_Gui_ProgressEnd(id2);
189
190 rv=GWEN_Gui_ProgressAdvance(id1, i1);
191 if (rv==GWEN_ERROR_USER_ABORTED) {
192 fprintf(stderr, "Aborted by user (1)\n");
193 break;
194 }
195 }
196
197 GWEN_Gui_ProgressEnd(id1);
198
199 return 0;
200}*/
201
202
203
204int test3(int argc, char **argv) {
205 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
206
207 NSLog(@"Cocoa-Test");
208 NSString *cocoa_string = @"Das ist ein Cocoa String";
209
210 [pool release];
211 return 0;
212}
213
214
215
216
217
218int main(int argc, char **argv) {
219 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
220 NSApplication *app = [NSApplication sharedApplication];
221 AppDelegate *app_delegate = [[AppDelegate alloc] init];
222 NSMenu *menu = [[NSMenu alloc] initWithTitle:@"Testprogramm"];
223 [menu addItemWithTitle:@"Quit" action:@selector(windowWillClose:) keyEquivalent:@"Q"];
224 [app setDelegate:app_delegate];
225 [app setMainMenu:menu];
226 [NSApp run];
227 [menu release];
228 [pool release];
229 //test1(argc, argv);
230
231 //return test2(argc, argv);
232 //return test3(argc, argv);
233/*#if 0
234 GWEN_GUI *gui;
235
236 gtk_set_locale ();
237 gtk_init (&argc, &argv);
238
239 gui=Gtk2_Gui_new();
240 GWEN_Gui_SetGui(gui);
241
242 return 0;
243#endif*/
244}
245
246
#define NULL
Definition binreloc.c:300
COCOAGUI_API GWEN_GUI * Cocoa_Gui_new()
Definition cocoa_gui.m:37
#define DBG_ERROR_ERR(dbg_logger, dbg_err)
Definition debug.h:113
struct GWEN_DIALOG GWEN_DIALOG
Definition dialog.h:54
GWEN_DIALOG * Dlg_Test1_new()
Definition dlg_test.c:293
void GWEN_Gui_SetGui(GWEN_GUI *gui)
Definition gui.c:170
GWENHYWFAR_API int GWEN_Gui_ExecDialog(GWEN_DIALOG *dlg, uint32_t guiid)
struct GWEN_GUI GWEN_GUI
Definition gui.h:176
int GWEN_Init(void)
Definition gwenhywfar.c:92
int main(int argc, char **argv)
Definition libtest.m:218
int test3(int argc, char **argv)
Definition libtest.m:204
int test1()
Definition libtest.m:63
void GWEN_Logger_SetLevel(const char *logDomain, GWEN_LOGGER_LEVEL l)
Definition logger.c:472
@ GWEN_LoggerLevel_Info
Definition logger.h:68