gwenhywfar  4.7.0beta
w_textbrowser.mm
Go to the documentation of this file.
1 /***************************************************************************
2  begin : Aug 18 2010
3  copyright : (C) 2010 by Samuel Strupp
4 
5  ***************************************************************************
6  * Please see toplevel file COPYING for license details *
7  ***************************************************************************/
8 
9 
10 #import "CocoaTextBrowser.h"
11 
12 
13 
14 static GWENHYWFAR_CB
17  int index,
18  int value,
19  int doSignal) {
20 
21  CocoaTextBrowser *textBrowser;
23  assert(textBrowser);
24 
25 
26  switch(prop) {
28  return 0;
29 
31  return 0;
32 
34  NSRect frame = [textBrowser frame];
35  frame.size.width = value;
36  [textBrowser setFrame:frame];
37  }
38  return 0;
39 
41  NSRect frame = [textBrowser frame];
42  frame.size.height = value;
43  [textBrowser setFrame:frame];
44  }
45  return 0;
46 
47 
48  default:
49  break;
50  }
51 
53  "Function is not appropriate for this type of widget (%s)",
55  return GWEN_ERROR_INVALID;
56 }
57 
58 
59 
60 
61 static GWENHYWFAR_CB
64  int index,
65  int defaultValue) {
66  CocoaTextBrowser *textBrowser;
68  assert(textBrowser);
69 
70  switch(prop) {
72  return 1;
73 
75  return 0;
76 
78  return [textBrowser frame].size.width;
79 
81  return [textBrowser frame].size.height;
82 
83  default:
84  break;
85  }
86 
88  "Function is not appropriate for this type of widget (%s)",
90  return defaultValue;
91 }
92 
93 
94 
95 static GWENHYWFAR_CB
98  int index,
99  const char *value,
100  int doSignal) {
101  CocoaTextBrowser *textBrowser;
103  assert(textBrowser);
104 
105  switch(prop) {
107  if (value && *value) {
108  GWEN_STRINGLIST *sl;
109 
110  //take the first media path as base url
112  const char * basePath = GWEN_StringListEntry_Data(GWEN_StringList_FirstEntry(sl));
113  NSString *basePathString = nil;
114  if (basePath && *basePath) {
115  basePathString = [[NSString alloc] initWithCString:basePath encoding:NSUTF8StringEncoding];
116  }
117 
118  NSString *stringValue = [[NSString alloc] initWithCString:value encoding:NSUTF8StringEncoding];
119  [textBrowser setStringValue:stringValue BasePath:basePathString];
120  [stringValue release];
121  [basePathString release];
122  }
123  return 0;
124  }
125  default:
126  break;
127  }
128 
130  "Function is not appropriate for this type of widget (%s)",
132  return GWEN_ERROR_INVALID;
133 }
134 
135 
136 
137 static GWENHYWFAR_CB
140  int index,
141  const char *defaultValue) {
142  CocoaTextBrowser *textBrowser;
144  assert(textBrowser);
145 
146  switch(prop) {
148  NSString* stringValue = [textBrowser stringValue];
149  if (stringValue && [stringValue length] > 0)
150  return [stringValue cStringUsingEncoding:NSUTF8StringEncoding];
151  return defaultValue;
152  }
153 
154  default:
155  break;
156  }
157 
159  "Function is not appropriate for this type of widget (%s)",
161  return defaultValue;
162 }
163 
164 
165 
167  CocoaTextBrowser *textBrowser;
168  const char *s;
169  uint32_t flags;
170  GWEN_WIDGET *wParent;
171 
172  flags=GWEN_Widget_GetFlags(w);
173  wParent=GWEN_Widget_Tree_GetParent(w);
174  s=GWEN_Widget_GetText(w, 0);
175 
176 
177  textBrowser = [[[CocoaTextBrowser alloc] initWithFrame:NSMakeRect(0.0, 0.0, 30.0, 30.0) frameName:nil groupName:nil] autorelease];
178  if (flags & GWEN_WIDGET_FLAGS_FILLX) textBrowser.fillX = YES;
179  if (flags & GWEN_WIDGET_FLAGS_FILLY) textBrowser.fillY = YES;
180 
181  if (s && *s) {
182  NSString *stringValue = [[NSString alloc] initWithCString:s encoding:NSUTF8StringEncoding];
183  [textBrowser setStringValue:stringValue];
184  [stringValue release];
185  }
186 
187  GWEN_Widget_SetImplData(w, COCOA_DIALOG_WIDGET_REAL, (void*) textBrowser);
188  GWEN_Widget_SetImplData(w, COCOA_DIALOG_WIDGET_CONTENT, (void*) textBrowser);
189 
194 
195  if (wParent)
196  GWEN_Widget_AddChildGuiWidget(wParent, w);
197 
198  return 0;
199 }
200 
201