gwenhywfar  4.8.0beta
w_gridlayout.mm
Go to the documentation of this file.
1 /***************************************************************************
2  begin : August 16 2010
3  copyright : (C) 2010 by Samuel Strupp
4 
5  ***************************************************************************
6  * Please see toplevel file COPYING for license details *
7  ***************************************************************************/
8 
9 
10 
11 /*typedef struct GTK2_GRIDLAYOUT_WIDGET GTK2_GRIDLAYOUT_WIDGET;
12  struct GTK2_GRIDLAYOUT_WIDGET {
13  int sortByRow;
14  int allocatedColumns;
15  int allocatedRows;
16 
17  int currentColumn;
18  int currentRow;
19  };*/
20 
21 
22 //GWEN_INHERIT(GWEN_WIDGET, GTK2_GRIDLAYOUT_WIDGET)
23 
24 #import "CocoaGridLayout.h"
25 
26 
27 static GWENHYWFAR_CB
30  int index,
31  int value,
32  int doSignal) {
33  CocoaGridLayout *gridLayout;
34 
36  assert(gridLayout);
37 
38  switch(prop) {
40  //gtk_widget_set_sensitive(GTK_WIDGET(g), (value==0)?FALSE:TRUE);
41  return 0;
42 
44  //gtk_widget_grab_focus(GTK_WIDGET(g));
45  return 0;
46 
47  default:
48  break;
49  }
50 
52  "Function is not appropriate for this type of widget (%s)",
54  return GWEN_ERROR_INVALID;
55 }
56 
57 
58 
59 
60 static GWENHYWFAR_CB
63  int index,
64  int defaultValue) {
65  CocoaGridLayout *gridLayout;
66 
68  assert(gridLayout);
69 
70  switch(prop) {
72  //return (gtk_widget_get_sensitive(GTK_WIDGET(g))==TRUE)?1:0;
73  return 1;
74 
76  //return (gtk_widget_has_focus(GTK_WIDGET(g))==TRUE)?1:0;
77  return 0;
78 
79  default:
80  break;
81  }
82 
84  "Function is not appropriate for this type of widget (%s)",
86  return defaultValue;
87 }
88 
89 
90 
91 static GWENHYWFAR_CB
94  int index,
95  const char *value,
96  int doSignal) {
97  CocoaGridLayout *gridLayout;
98 
100  assert(gridLayout);
101 
103  "Function is not appropriate for this type of widget (%s)",
105  return GWEN_ERROR_INVALID;
106 }
107 
108 
109 
110 static GWENHYWFAR_CB
113  int index,
114  const char *defaultValue) {
115  CocoaGridLayout *gridLayout;
116 
118  assert(gridLayout);
119 
121  "Function is not appropriate for this type of widget (%s)",
123  return defaultValue;
124 }
125 
126 
127 
128 static GWENHYWFAR_CB
130  CocoaGridLayout *gridLayout;
131  NSView *childView;
132  uint32_t cflags;
133 
135  assert(gridLayout);
136 
137  childView=(NSView*)(GWEN_Widget_GetImplData(wChild, COCOA_DIALOG_WIDGET_REAL));
138  assert(childView);
139 
140  cflags=GWEN_Widget_GetFlags(wChild);
141 
142  [gridLayout addLayoutSubview:childView];
143 
144  return 0;
145 
146  /* GTK2_GRIDLAYOUT_WIDGET *xw;
147  GtkWidget *g;
148  GtkWidget *gChild;
149  uint32_t cflags;
150  int x;
151  int y;
152 
153  assert(w);
154  xw=GWEN_INHERIT_GETDATA(GWEN_WIDGET, GTK2_GRIDLAYOUT_WIDGET, w);
155  assert(xw);
156 
157  cflags=GWEN_Widget_GetFlags(wChild);
158 
159  g=GTK_WIDGET(GWEN_Widget_GetImplData(w, GTK2_DIALOG_WIDGET_REAL));
160  assert(g);
161 
162  gChild=GTK_WIDGET(GWEN_Widget_GetImplData(wChild, GTK2_DIALOG_WIDGET_REAL));
163  assert(gChild);
164 
165  if (xw->sortByRow) {
166  // fill rows, enter next column if column full
167  y=(xw->currentRow)++;
168  if (y>=xw->allocatedRows) {
169  xw->currentRow=0;
170  y=(xw->currentRow)++;
171  xw->currentColumn++;
172  }
173 
174  x=xw->currentColumn;
175  if (x>=xw->allocatedColumns) {
176  xw->allocatedColumns=x+1;
177  gtk_table_resize(GTK_TABLE(g), xw->allocatedRows, xw->allocatedColumns);
178  }
179  }
180  else {
181  // fill columns, enter next row if row full
182  x=(xw->currentColumn)++;
183  if (x>=xw->allocatedColumns) {
184  xw->currentColumn=0;
185  x=(xw->currentColumn)++;
186  xw->currentRow++;
187  }
188 
189  y=xw->currentRow;
190  if (y>=xw->allocatedRows) {
191  xw->allocatedRows=y+1;
192  gtk_table_resize(GTK_TABLE(g), xw->allocatedRows, xw->allocatedColumns);
193  }
194  }
195 
196  gtk_table_attach(GTK_TABLE(g), gChild,
197  x, x+1, y, y+1,
198  (cflags & GWEN_WIDGET_FLAGS_FILLX)?(GTK_FILL|GTK_EXPAND):0,
199  (cflags & GWEN_WIDGET_FLAGS_FILLY)?(GTK_FILL|GTK_EXPAND):0,
200  GTK2_GUI_DIALOG_DEFAULT_BOX_SPACING,
201  GTK2_GUI_DIALOG_DEFAULT_BOX_SPACING);*/
202 
203  return 0;
204 }
205 
206 
207 
208 
209 /*static GWENHYWFAR_CB
210  void Gtk2Gui_WGridLayout_FreeData(void *bp, void *p) {
211  GTK2_GRIDLAYOUT_WIDGET *xw;
212 
213  xw=(GTK2_GRIDLAYOUT_WIDGET*) p;
214 
215  GWEN_FREE_OBJECT(xw);
216  }*/
217 
218 
219 
221  CocoaGridLayout *gridLayout;
222  uint32_t flags;
223  GWEN_WIDGET *wParent;
224  //GTK2_GRIDLAYOUT_WIDGET *xw;
225  int rows;
226  int cols;
227 
228  //GWEN_NEW_OBJECT(GTK2_GRIDLAYOUT_WIDGET, xw);
229  //GWEN_INHERIT_SETDATA(GWEN_WIDGET, GTK2_GRIDLAYOUT_WIDGET, w, xw, Gtk2Gui_WGridLayout_FreeData);*/
230 
231  flags=GWEN_Widget_GetFlags(w);
232  wParent=GWEN_Widget_Tree_GetParent(w);
233  cols=GWEN_Widget_GetColumns(w);
234  rows=GWEN_Widget_GetRows(w);
235 
236 
237  gridLayout = [[[CocoaGridLayout alloc] initWithFrame:NSMakeRect(10.0, 10.0, 200.0, 200.0)] autorelease];
238  gridLayout.columns = cols;
239  gridLayout.rows = rows;
240  if (flags & GWEN_WIDGET_FLAGS_FILLX) gridLayout.fillX = YES;
241  if (flags & GWEN_WIDGET_FLAGS_FILLY) gridLayout.fillY = YES;
242 
243 
244  GWEN_Widget_SetImplData(w, COCOA_DIALOG_WIDGET_REAL, (void*) gridLayout);
246 
252 
253  if (wParent)
254  GWEN_Widget_AddChildGuiWidget(wParent, w);
255 
256  return 0;
257 }
258 
259