gwenhywfar
4.6.0beta
Main Page
Related Pages
Modules
Data Structures
Files
File List
Globals
gui
cocoa
w_hlayout.mm
Go to the documentation of this file.
1
/***************************************************************************
2
begin : August 10 2010
3
copyright : (C) 2010 by Samuel Strupp
4
5
***************************************************************************
6
* Please see toplevel file COPYING for license details *
7
***************************************************************************/
8
9
10
11
#import "
CocoaHLayout.h
"
12
13
14
15
static
GWENHYWFAR_CB
16
int
CocoaGui_WHLayout_SetIntProperty
(
GWEN_WIDGET
*w,
17
GWEN_DIALOG_PROPERTY
prop,
18
int
index,
19
int
value,
20
int
doSignal) {
21
CocoaHLayout
*hlayout;
22
23
hlayout=(
CocoaHLayout
*)(
GWEN_Widget_GetImplData
(w,
COCOA_DIALOG_WIDGET_REAL
));
24
assert(hlayout);
25
26
switch
(prop) {
27
case
GWEN_DialogProperty_Enabled
:
28
//gtk_widget_set_sensitive(GTK_WIDGET(g), (value==0)?FALSE:TRUE);
29
return
0;
30
31
case
GWEN_DialogProperty_Focus
:
32
//gtk_widget_grab_focus(GTK_WIDGET(g));
33
return
0;
34
35
default
:
36
break
;
37
}
38
39
DBG_WARN
(
GWEN_LOGDOMAIN
,
40
"Function is not appropriate for this type of widget (%s)"
,
41
GWEN_Widget_Type_toString
(
GWEN_Widget_GetType
(w)));
42
return
GWEN_ERROR_INVALID
;
43
}
44
45
46
47
48
static
GWENHYWFAR_CB
49
int
CocoaGui_WHLayout_GetIntProperty
(
GWEN_WIDGET
*w,
50
GWEN_DIALOG_PROPERTY
prop,
51
int
index,
52
int
defaultValue) {
53
CocoaHLayout
*hlayout;
54
55
hlayout=(
CocoaHLayout
*)(
GWEN_Widget_GetImplData
(w,
COCOA_DIALOG_WIDGET_REAL
));
56
assert(hlayout);
57
58
switch
(prop) {
59
case
GWEN_DialogProperty_Enabled
:
60
//return (gtk_widget_get_sensitive(GTK_WIDGET(g))==TRUE)?1:0;
61
return
1;
62
63
case
GWEN_DialogProperty_Focus
:
64
//return (gtk_widget_has_focus(GTK_WIDGET(g))==TRUE)?1:0;
65
return
0;
66
67
default
:
68
break
;
69
}
70
DBG_WARN
(
GWEN_LOGDOMAIN
,
71
"Function is not appropriate for this type of widget (%s)"
,
72
GWEN_Widget_Type_toString
(
GWEN_Widget_GetType
(w)));
73
return
defaultValue;
74
}
75
76
77
78
static
GWENHYWFAR_CB
79
int
CocoaGui_WHLayout_SetCharProperty
(
GWEN_WIDGET
*w,
80
GWEN_DIALOG_PROPERTY
prop,
81
int
index,
82
const
char
*value,
83
int
doSignal) {
84
/*CocoaHLayout *hlayout;
85
86
hlayout=(CocoaHLayout*)(GWEN_Widget_GetImplData(w, COCOA_DIALOG_WIDGET_REAL));
87
assert(hlayout);*/
88
89
DBG_WARN
(
GWEN_LOGDOMAIN
,
90
"Function is not appropriate for this type of widget (%s)"
,
91
GWEN_Widget_Type_toString
(
GWEN_Widget_GetType
(w)));
92
return
GWEN_ERROR_INVALID
;
93
}
94
95
96
97
static
GWENHYWFAR_CB
98
const
char
*
CocoaGui_WHLayout_GetCharProperty
(
GWEN_WIDGET
*w,
99
GWEN_DIALOG_PROPERTY
prop,
100
int
index,
101
const
char
*defaultValue) {
102
/*CocoaHLayout *hlayout;
103
104
hlayout=(CocoaHLayout*)(GWEN_Widget_GetImplData(w, COCOA_DIALOG_WIDGET_REAL));
105
assert(hlayout);*/
106
107
DBG_WARN
(
GWEN_LOGDOMAIN
,
108
"Function is not appropriate for this type of widget (%s)"
,
109
GWEN_Widget_Type_toString
(
GWEN_Widget_GetType
(w)));
110
return
defaultValue;
111
}
112
113
114
115
static
GWENHYWFAR_CB
116
int
CocoaGui_WHLayout_AddChildGuiWidget
(
GWEN_WIDGET
*w,
GWEN_WIDGET
*wChild) {
117
CocoaHLayout
*hlayout;
118
NSView *childView;
119
uint32_t cflags;
120
121
hlayout=(
CocoaHLayout
*)(
GWEN_Widget_GetImplData
(w,
COCOA_DIALOG_WIDGET_REAL
));
122
assert(hlayout);
123
124
childView=(NSView*)(
GWEN_Widget_GetImplData
(wChild,
COCOA_DIALOG_WIDGET_REAL
));
125
assert(childView);
126
127
cflags=
GWEN_Widget_GetFlags
(wChild);
128
129
[hlayout
addLayoutSubview
:childView];
130
131
/*gtk_box_pack_start(GTK_BOX(g), gChild,
132
(cflags & GWEN_WIDGET_FLAGS_FILLX)?TRUE:FALSE,
133
(cflags & GWEN_WIDGET_FLAGS_FILLX)?TRUE:FALSE,
134
0);*/
135
136
return
0;
137
}
138
139
140
141
int
CocoaGui_WHLayout_Setup
(
GWEN_WIDGET
*w) {
142
CocoaHLayout
*hlayout;
143
uint32_t flags;
144
GWEN_WIDGET
*wParent;
145
146
flags=
GWEN_Widget_GetFlags
(w);
147
wParent=GWEN_Widget_Tree_GetParent(w);
148
149
150
hlayout = [[[
CocoaHLayout
alloc] initWithFrame:NSMakeRect(10.0, 10.0, 200.0, 200.0)] autorelease];
151
if
(flags &
GWEN_WIDGET_FLAGS_FILLX
) hlayout.
fillX
= YES;
152
if
(flags &
GWEN_WIDGET_FLAGS_FILLY
) hlayout.
fillY
= YES;
153
/*#if 0
154
// using equal width here doesn't seem to be working as expected:
155
// I would expect al children be of equal width, but instead all children are
156
// equally distant to each other while still being of different width...
157
//
158
g=gtk_hbox_new((flags & GWEN_WIDGET_FLAGS_EQUAL_WIDTH)?TRUE:FALSE,
159
GTK2_GUI_DIALOG_DEFAULT_BOX_SPACING);
160
#else
161
g=gtk_hbox_new(FALSE, GTK2_GUI_DIALOG_DEFAULT_BOX_SPACING);
162
#endif*/
163
GWEN_Widget_SetImplData
(w,
COCOA_DIALOG_WIDGET_REAL
, (
void
*) hlayout);
164
GWEN_Widget_SetImplData
(w,
COCOA_DIALOG_WIDGET_CONTENT
, (
void
*) hlayout);
165
166
GWEN_Widget_SetSetIntPropertyFn
(w,
CocoaGui_WHLayout_SetIntProperty
);
167
GWEN_Widget_SetGetIntPropertyFn
(w,
CocoaGui_WHLayout_GetIntProperty
);
168
GWEN_Widget_SetSetCharPropertyFn
(w,
CocoaGui_WHLayout_SetCharProperty
);
169
GWEN_Widget_SetGetCharPropertyFn
(w,
CocoaGui_WHLayout_GetCharProperty
);
170
GWEN_Widget_SetAddChildGuiWidgetFn
(w,
CocoaGui_WHLayout_AddChildGuiWidget
);
171
172
if
(wParent)
173
GWEN_Widget_AddChildGuiWidget
(wParent, w);
174
175
return
0;
176
}
177
178
Generated on Sun May 26 2013 16:42:55 for gwenhywfar by
1.8.1.2