gwenhywfar 5.12.0
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
14static 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
61static 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
95static 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
137static 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);
189
194
195 if (wParent)
197
198 return 0;
199}
200
201
#define COCOA_DIALOG_WIDGET_REAL
#define COCOA_DIALOG_WIDGET_CONTENT
#define DBG_WARN(dbg_logger, format,...)
Definition debug.h:125
GWEN_STRINGLIST * GWEN_Dialog_GetMediaPaths(const GWEN_DIALOG *dlg)
Definition dialog.c:295
#define GWEN_WIDGET_FLAGS_FILLY
Definition dialog.h:62
#define GWEN_WIDGET_FLAGS_FILLX
Definition dialog.h:61
GWEN_DIALOG_PROPERTY
Definition dialog.h:260
@ GWEN_DialogProperty_Height
Definition dialog.h:273
@ GWEN_DialogProperty_Enabled
Definition dialog.h:267
@ GWEN_DialogProperty_Value
Definition dialog.h:264
@ 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:35
const char * GWEN_StringListEntry_Data(const GWEN_STRINGLISTENTRY *se)
Definition stringlist.c:406
GWEN_STRINGLISTENTRY * GWEN_StringList_FirstEntry(const GWEN_STRINGLIST *sl)
Definition stringlist.c:390
struct GWEN_STRINGLISTSTRUCT GWEN_STRINGLIST
Definition stringlist.h:56
static GWENHYWFAR_CB int CocoaGui_WTextBrowser_GetIntProperty(GWEN_WIDGET *w, GWEN_DIALOG_PROPERTY prop, int index, int defaultValue)
int CocoaGui_WTextBrowser_Setup(GWEN_WIDGET *w)
static GWENHYWFAR_CB int CocoaGui_WTextBrowser_SetCharProperty(GWEN_WIDGET *w, GWEN_DIALOG_PROPERTY prop, int index, const char *value, int doSignal)
static GWENHYWFAR_CB int CocoaGui_WTextBrowser_SetIntProperty(GWEN_WIDGET *w, GWEN_DIALOG_PROPERTY prop, int index, int value, int doSignal)
static GWENHYWFAR_CB const char * CocoaGui_WTextBrowser_GetCharProperty(GWEN_WIDGET *w, GWEN_DIALOG_PROPERTY prop, int index, const char *defaultValue)
GWEN_WIDGET_GETCHARPROPERTY_FN GWEN_Widget_SetGetCharPropertyFn(GWEN_WIDGET *w, GWEN_WIDGET_GETCHARPROPERTY_FN fn)
Definition widget.c:732
GWEN_WIDGET_GETINTPROPERTY_FN GWEN_Widget_SetGetIntPropertyFn(GWEN_WIDGET *w, GWEN_WIDGET_GETINTPROPERTY_FN fn)
Definition widget.c:702
int GWEN_Widget_AddChildGuiWidget(GWEN_WIDGET *w, GWEN_WIDGET *wChild)
Definition widget.c:828
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:687
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:452
GWEN_DIALOG * GWEN_Widget_GetDialog(const GWEN_WIDGET *w)
Definition widget.c:92
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:717
struct GWEN_WIDGET GWEN_WIDGET
Definition widget_be.h:34