gwenhywfar 5.14.1
w_dialog.mm
Go to the documentation of this file.
1/***************************************************************************
2 begin : August 09 2010
3 copyright : (C) 2010 by Samuel Strupp
4
5 ***************************************************************************
6 * Please see toplevel file COPYING for license details *
7 ***************************************************************************/
8
9
10#import "CocoaWindow.h"
11
13
14
15static GWENHYWFAR_CB
18 int index,
19 int value,
20 int doSignal) {
21 NSWindow *window = nil;
22
24 assert(window);
25
26 if (window) {
27 switch(prop) {
29 // just ignore
30 return 0;
31
33 //[window makeKeyAndOrderFront:nil];
34 return 0;
35
37 NSLog(@"setWidth %i", value);
38 NSRect frame = [window frame];
39 frame.size.width = value;
40 [window setFrame:frame display:YES];
41 }
42 return 0;
43
45 NSRect frame = [window frame];
46 frame.size.height = value;
47 [window setFrame:frame display:YES];
48 }
49 return 0;
50
51 default:
52 break;
53 }
54 }
55
57 "Function is not appropriate for this type of widget (%s)",
59 return GWEN_ERROR_INVALID;
60}
61
62
63
64
65static GWENHYWFAR_CB
68 int index,
69 int defaultValue) {
70 NSWindow *window = nil;
71
73 assert(window);
74
75 switch(prop) {
77 return 1;
78
80 return [window isKeyWindow];
81
83 return [window frame].size.width;
84
86 return [window frame].size.height;
87
88 default:
89 break;
90 }
91
93 "Function is not appropriate for this type of widget (%s)",
95 return defaultValue;
96}
97
98
99
100static GWENHYWFAR_CB
103 int index,
104 const char *value,
105 int doSignal) {
106 NSWindow *window = nil;
107
108 NSLog(@"CocoaGui_WDialog_SetCharProperty");
109
111 assert(window);
112
113 switch(prop) {
115 NSString *newTitle = [[NSString alloc] initWithCString:value encoding:NSUTF8StringEncoding];
116 [window setTitle:newTitle];
117 [newTitle release];
118 }
119 return 0;
120 default:
121 break;
122 }
123
125 "Function is not appropriate for this type of widget (%s)",
127 return GWEN_ERROR_INVALID;
128}
129
130
131
132static GWENHYWFAR_CB
135 int index,
136 const char *defaultValue) {
137 NSWindow *window = nil;
138
140 assert(window);
141
142 switch(prop) {
144 return [[window title] cStringUsingEncoding:NSUTF8StringEncoding];
145 default:
146 break;
147 }
148
150 "Function is not appropriate for this type of widget (%s)",
152 return defaultValue;
153}
154
155
156
157static GWENHYWFAR_CB
159
160 NSLog(@"CocoaGui_WDialog_AddChildGuiWidget");
161
162 NSWindow *window = nil;
164 assert(window);
165
166 NSView *subview = (NSView*)(GWEN_Widget_GetImplData(wChild, COCOA_DIALOG_WIDGET_REAL));
167 assert(subview);
168
169 NSRect bounds = [[window contentView] bounds];
170 [subview setFrame:bounds];
171 [subview setAutoresizingMask:NSViewWidthSizable|NSViewHeightSizable];
172
173 CocoaWindowContentView *contentView = (CocoaWindowContentView*)[window contentView];
174 [contentView addLayoutSubview:subview];
175
176 return 0;
177}
178
179
180
182 CocoaWindow *newWindow;
183 const char *s;
184 uint32_t flags;
185
186 flags=GWEN_Widget_GetFlags(w);
187 s=GWEN_Widget_GetText(w, 0);
188
189 newWindow=[[CocoaWindow alloc] initWithContentRect:NSMakeRect(50.0, 50.0, 400.0, 200.0) styleMask:NSTitledWindowMask/*|NSClosableWindowMask*/|NSResizableWindowMask backing:NSBackingStoreBuffered defer:YES];
190 [newWindow setReleasedWhenClosed:NO];
191
192 CocoaWindowContentView *newContentView = [[CocoaWindowContentView alloc] initWithFrame:[[newWindow contentView] frame]];
193 [newContentView setAutoresizingMask:NSViewWidthSizable|NSViewHeightSizable];
194 [newWindow setContentView:newContentView];
195 [newContentView release];
196
197 NSLog(@"getWindow Title");
198 if (s && *s) {
199 //DBG_WARN(GWEN_LOGDOMAIN, "String s = (%s)",s );
200 NSString *stringValue = [[NSString alloc] initWithCString:s encoding:NSUTF8StringEncoding];
201 NSLog(@"Window Title = %@", stringValue);
202 [newWindow setTitle:stringValue];
203 [stringValue release];
204 }
205
208
214
215 return 0;
216}
217
218
#define COCOA_DIALOG_WIDGET_REAL
#define COCOA_DIALOG_WIDGET_CONTENT
#define DBG_WARN(dbg_logger, format,...)
Definition debug.h:125
GWEN_DIALOG_PROPERTY
Definition dialog.h:260
@ GWEN_DialogProperty_Title
Definition dialog.h:263
@ GWEN_DialogProperty_Height
Definition dialog.h:273
@ GWEN_DialogProperty_Enabled
Definition dialog.h:267
@ GWEN_DialogProperty_Focus
Definition dialog.h:276
@ GWEN_DialogProperty_Width
Definition dialog.h:272
#define GWEN_ERROR_INVALID
Definition error.h:67
#define GWENHYWFAR_CB
#define GWEN_LOGDOMAIN
Definition logger.h:32
static GWENHYWFAR_CB const char * CocoaGui_WDialog_GetCharProperty(GWEN_WIDGET *w, GWEN_DIALOG_PROPERTY prop, int index, const char *defaultValue)
Definition w_dialog.mm:133
static GWENHYWFAR_CB int CocoaGui_WDialog_SetCharProperty(GWEN_WIDGET *w, GWEN_DIALOG_PROPERTY prop, int index, const char *value, int doSignal)
Definition w_dialog.mm:101
static GWENHYWFAR_CB int CocoaGui_WDialog_GetIntProperty(GWEN_WIDGET *w, GWEN_DIALOG_PROPERTY prop, int index, int defaultValue)
Definition w_dialog.mm:66
int CocoaGui_WDialog_Setup(GWEN_WIDGET *w)
Definition w_dialog.mm:181
static GWENHYWFAR_CB int CocoaGui_WDialog_AddChildGuiWidget(GWEN_WIDGET *w, GWEN_WIDGET *wChild)
Definition w_dialog.mm:158
static GWENHYWFAR_CB int CocoaGui_WDialog_SetIntProperty(GWEN_WIDGET *w, GWEN_DIALOG_PROPERTY prop, int index, int value, int doSignal)
Definition w_dialog.mm:16
GWEN_WIDGET_GETCHARPROPERTY_FN GWEN_Widget_SetGetCharPropertyFn(GWEN_WIDGET *w, GWEN_WIDGET_GETCHARPROPERTY_FN fn)
Definition widget.c:740
GWEN_WIDGET_GETINTPROPERTY_FN GWEN_Widget_SetGetIntPropertyFn(GWEN_WIDGET *w, GWEN_WIDGET_GETINTPROPERTY_FN fn)
Definition widget.c:710
GWEN_WIDGET_ADDCHILDGUIWIDGET_FN GWEN_Widget_SetAddChildGuiWidgetFn(GWEN_WIDGET *w, GWEN_WIDGET_ADDCHILDGUIWIDGET_FN fn)
Definition widget.c:755
void GWEN_Widget_SetImplData(GWEN_WIDGET *w, int index, void *ptr)
Store a pointer with the widget.
Definition widget.c:136
void * GWEN_Widget_GetImplData(const GWEN_WIDGET *w, int index)
Definition widget.c:122
GWEN_WIDGET_SETINTPROPERTY_FN GWEN_Widget_SetSetIntPropertyFn(GWEN_WIDGET *w, GWEN_WIDGET_SETINTPROPERTY_FN fn)
Definition widget.c:695
const char * GWEN_Widget_GetText(const GWEN_WIDGET *w, int idx)
Definition widget.c:293
uint32_t GWEN_Widget_GetFlags(const GWEN_WIDGET *w)
Definition widget.c:149
const char * GWEN_Widget_Type_toString(GWEN_WIDGET_TYPE t)
Definition widget.c:456
GWEN_WIDGET_TYPE GWEN_Widget_GetType(const GWEN_WIDGET *w)
Definition widget.c:185
GWEN_WIDGET_SETCHARPROPERTY_FN GWEN_Widget_SetSetCharPropertyFn(GWEN_WIDGET *w, GWEN_WIDGET_SETCHARPROPERTY_FN fn)
Definition widget.c:725
struct GWEN_WIDGET GWEN_WIDGET
Definition widget_be.h:34