gwenhywfar  4.7.0beta
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 
15 static GWENHYWFAR_CB
18  int index,
19  int value,
20  int doSignal) {
21  NSWindow *window = nil;
22 
23  window=(NSWindow*)(GWEN_Widget_GetImplData(w, COCOA_DIALOG_WIDGET_REAL));
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 
65 static GWENHYWFAR_CB
68  int index,
69  int defaultValue) {
70  NSWindow *window = nil;
71 
72  window=(NSWindow*)(GWEN_Widget_GetImplData(w, COCOA_DIALOG_WIDGET_REAL));
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 
100 static GWENHYWFAR_CB
103  int index,
104  const char *value,
105  int doSignal) {
106  NSWindow *window = nil;
107 
108  NSLog(@"CocoaGui_WDialog_SetCharProperty");
109 
110  window=(NSWindow*)(GWEN_Widget_GetImplData(w, COCOA_DIALOG_WIDGET_REAL));
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 
132 static GWENHYWFAR_CB
135  int index,
136  const char *defaultValue) {
137  NSWindow *window = nil;
138 
139  window=(NSWindow*)(GWEN_Widget_GetImplData(w, COCOA_DIALOG_WIDGET_REAL));
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 
157 static GWENHYWFAR_CB
159 
160  NSLog(@"CocoaGui_WDialog_AddChildGuiWidget");
161 
162  NSWindow *window = nil;
163  window=(NSWindow*)(GWEN_Widget_GetImplData(w, COCOA_DIALOG_WIDGET_REAL));
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=/*|NSClosableWindowMask*/[[CocoaWindow alloc] initWithContentRect:NSMakeRect(50.0, 50.0, 400.0, 200.0) styleMask:NSTitledWindowMask|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 
206  GWEN_Widget_SetImplData(w, COCOA_DIALOG_WIDGET_REAL, (void*) newWindow);
208 
214 
215  return 0;
216 }
217 
218