gwenhywfar  4.7.0beta
w_gridlayout.c
Go to the documentation of this file.
1 /***************************************************************************
2  begin : Sun May 16 2010
3  copyright : (C) 2010 by Martin Preuss
4  email : martin@libchipcard.de
5 
6  ***************************************************************************
7  * Please see toplevel file COPYING for license details *
8  ***************************************************************************/
9 
10 
11 
14  int sortByRow;
17 
20 };
21 
22 
24 
25 
26 
27 static GWENHYWFAR_CB
30  int index,
31  int value,
32  int doSignal) {
33  GtkWidget *g;
34 
36  assert(g);
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  GtkWidget *g;
66 
68  assert(g);
69 
70  switch(prop) {
72  return (gtk_widget_get_sensitive(GTK_WIDGET(g))==TRUE)?1:0;
73 
75  return (gtk_widget_has_focus(GTK_WIDGET(g))==TRUE)?1:0;
76  return 0;
77 
78  default:
79  break;
80  }
81 
83  "Function is not appropriate for this type of widget (%s)",
85  return defaultValue;
86 }
87 
88 
89 
90 static GWENHYWFAR_CB
93  int index,
94  const char *value,
95  int doSignal) {
96  GtkWidget *g;
97 
99  assert(g);
100 
102  "Function is not appropriate for this type of widget (%s)",
104  return GWEN_ERROR_INVALID;
105 }
106 
107 
108 
109 static GWENHYWFAR_CB
112  int index,
113  const char *defaultValue) {
114  GtkWidget *g;
115 
117  assert(g);
118 
120  "Function is not appropriate for this type of widget (%s)",
122  return defaultValue;
123 }
124 
125 
126 
127 static GWENHYWFAR_CB
130  GtkWidget *g;
131  GtkWidget *gChild;
132  uint32_t cflags;
133  int x;
134  int y;
135 
136  assert(w);
138  assert(xw);
139 
140  cflags=GWEN_Widget_GetFlags(wChild);
141 
143  assert(g);
144 
145  gChild=GTK_WIDGET(GWEN_Widget_GetImplData(wChild, GTK2_DIALOG_WIDGET_REAL));
146  assert(gChild);
147 
148  if (xw->sortByRow) {
149  /* fill rows, enter next column if column full */
150  y=(xw->currentRow)++;
151  if (y>=xw->allocatedRows) {
152  xw->currentRow=0;
153  y=(xw->currentRow)++;
154  xw->currentColumn++;
155  }
156 
157  x=xw->currentColumn;
158  if (x>=xw->allocatedColumns) {
159  xw->allocatedColumns=x+1;
160  gtk_table_resize(GTK_TABLE(g), xw->allocatedRows, xw->allocatedColumns);
161  }
162  }
163  else {
164  /* fill columns, enter next row if row full */
165  x=(xw->currentColumn)++;
166  if (x>=xw->allocatedColumns) {
167  xw->currentColumn=0;
168  x=(xw->currentColumn)++;
169  xw->currentRow++;
170  }
171 
172  y=xw->currentRow;
173  if (y>=xw->allocatedRows) {
174  xw->allocatedRows=y+1;
175  gtk_table_resize(GTK_TABLE(g), xw->allocatedRows, xw->allocatedColumns);
176  }
177  }
178 
179  gtk_table_attach(GTK_TABLE(g), gChild,
180  x, x+1, y, y+1,
181  (cflags & GWEN_WIDGET_FLAGS_FILLX)?(GTK_FILL|GTK_EXPAND):0,
182  (cflags & GWEN_WIDGET_FLAGS_FILLY)?(GTK_FILL|GTK_EXPAND):0,
185 
186  return 0;
187 }
188 
189 
190 
191 
192 static GWENHYWFAR_CB
193 void Gtk2Gui_WGridLayout_FreeData(void *bp, void *p) {
195 
196  xw=(GTK2_GRIDLAYOUT_WIDGET*) p;
197 
198  GWEN_FREE_OBJECT(xw);
199 }
200 
201 
202 
204  GtkWidget *g;
205  uint32_t flags;
206  GWEN_WIDGET *wParent;
208  int rows;
209  int cols;
210 
213 
214  flags=GWEN_Widget_GetFlags(w);
215  wParent=GWEN_Widget_Tree_GetParent(w);
216  cols=GWEN_Widget_GetColumns(w);
217  rows=GWEN_Widget_GetRows(w);
218 
219  if (rows>0) {
220  xw->sortByRow=1;
221  xw->allocatedRows=rows;
222  xw->allocatedColumns=1;
223  }
224  else {
225  xw->sortByRow=0;
226  xw->allocatedColumns=cols;
227  xw->allocatedRows=1;
228  }
229 
230  g=gtk_table_new(xw->allocatedRows, xw->allocatedColumns, FALSE);
231 
234 
240 
241  if (wParent)
242  GWEN_Widget_AddChildGuiWidget(wParent, w);
243 
244  return 0;
245 }
246 
247