gwenhywfar  4.99.8beta
gtk3/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 
12 typedef struct {
13  int sortByRow;
16 
20 
21 
23 
24 
25 
26 static GWENHYWFAR_CB
29  int index,
30  int value,
31  int doSignal) {
32  GtkWidget *g;
33 
35  assert(g);
36 
37  switch(prop) {
39  gtk_widget_set_sensitive(GTK_WIDGET(g), (value==0)?FALSE:TRUE);
40  return 0;
41 
43  gtk_widget_grab_focus(GTK_WIDGET(g));
44  return 0;
45 
46  default:
47  break;
48  }
49 
51  "Function is not appropriate for this type of widget (%s)",
53  return GWEN_ERROR_INVALID;
54 }
55 
56 
57 
58 
59 static GWENHYWFAR_CB
62  int index,
63  int defaultValue) {
64  GtkWidget *g;
65 
67  assert(g);
68 
69  switch(prop) {
71  return (gtk_widget_get_sensitive(GTK_WIDGET(g))==TRUE)?1:0;
72 
74  return (gtk_widget_has_focus(GTK_WIDGET(g))==TRUE)?1:0;
75  return 0;
76 
77  default:
78  break;
79  }
80 
82  "Function is not appropriate for this type of widget (%s)",
84  return defaultValue;
85 }
86 
87 
88 
89 static GWENHYWFAR_CB
92  int index,
93  const char *value,
94  int doSignal) {
95  GtkWidget *g;
96 
98  assert(g);
99 
101  "Function is not appropriate for this type of widget (%s)",
103  return GWEN_ERROR_INVALID;
104 }
105 
106 
107 
108 static GWENHYWFAR_CB
111  int index,
112  const char *defaultValue) {
113  GtkWidget *g;
114 
116  assert(g);
117 
119  "Function is not appropriate for this type of widget (%s)",
121  return defaultValue;
122 }
123 
124 
125 
126 static GWENHYWFAR_CB
129  GtkWidget *g;
130  GtkWidget *gChild;
131  int x;
132  int y;
133 
134  assert(w);
136  assert(xw);
137 
138 
140  assert(g);
141 
142  gChild=GTK_WIDGET(GWEN_Widget_GetImplData(wChild, GTK3_DIALOG_WIDGET_REAL));
143  assert(gChild);
144 
145  if (xw->sortByRow) {
146  /* fill rows, enter next column if column full */
147  y=(xw->currentRow)++;
148  if (y>=xw->allocatedRows) {
149  xw->currentRow=0;
150  y=(xw->currentRow)++;
151  xw->currentColumn++;
152  }
153 
154  x=xw->currentColumn;
155  if (x>=xw->allocatedColumns) {
156  xw->allocatedColumns=x+1;
157  }
158  }
159  else {
160  /* fill columns, enter next row if row full */
161  x=(xw->currentColumn)++;
162  if (x>=xw->allocatedColumns) {
163  xw->currentColumn=0;
164  x=(xw->currentColumn)++;
165  xw->currentRow++;
166  }
167 
168  y=xw->currentRow;
169  if (y>=xw->allocatedRows) {
170  xw->allocatedRows=y+1;
171  }
172  }
173 
174  gtk_grid_attach(GTK_GRID(g), gChild, x, y, 1, 1);
175 
176  return 0;
177 }
178 
179 
180 
181 
182 static GWENHYWFAR_CB
183 void Gtk3Gui_WGridLayout_FreeData(void *bp, void *p) {
185 
186  xw=(GTK3_GRIDLAYOUT_WIDGET*) p;
187 
188  GWEN_FREE_OBJECT(xw);
189 }
190 
191 
192 
194  GtkWidget *g;
195  GWEN_WIDGET *wParent;
197  int rows;
198  int cols;
199 
202 
203  wParent=GWEN_Widget_Tree_GetParent(w);
204  cols=GWEN_Widget_GetColumns(w);
205  rows=GWEN_Widget_GetRows(w);
206 
207  if (rows>0) {
208  xw->sortByRow=1;
209  xw->allocatedRows=rows;
210  xw->allocatedColumns=1;
211  }
212  else {
213  xw->sortByRow=0;
214  xw->allocatedColumns=cols;
215  xw->allocatedRows=1;
216  }
217 
218  g=gtk_grid_new();
219 
222 
228 
229  if (wParent)
230  GWEN_Widget_AddChildGuiWidget(wParent, w);
231 
232  return 0;
233 }
234 
235 
GWEN_WIDGET_TYPE GWEN_Widget_GetType(const GWEN_WIDGET *w)
Definition: widget.c:175
static GWENHYWFAR_CB int Gtk3Gui_WGridLayout_AddChildGuiWidget(GWEN_WIDGET *w, GWEN_WIDGET *wChild)
#define GWEN_ERROR_INVALID
Definition: error.h:67
#define GTK3_DIALOG_WIDGET_REAL
#define GTK3_DIALOG_WIDGET_CONTENT
GWEN_WIDGET_SETCHARPROPERTY_FN GWEN_Widget_SetSetCharPropertyFn(GWEN_WIDGET *w, GWEN_WIDGET_SETCHARPROPERTY_FN fn)
Definition: widget.c:663
GWEN_WIDGET_GETCHARPROPERTY_FN GWEN_Widget_SetGetCharPropertyFn(GWEN_WIDGET *w, GWEN_WIDGET_GETCHARPROPERTY_FN fn)
Definition: widget.c:677
static GWENHYWFAR_CB int Gtk3Gui_WGridLayout_SetIntProperty(GWEN_WIDGET *w, GWEN_DIALOG_PROPERTY prop, int index, int value, int doSignal)
GWEN_DIALOG_PROPERTY
Definition: dialog.h:215
#define GWEN_FREE_OBJECT(varname)
Definition: memory.h:92
#define DBG_WARN(dbg_logger, format, args...)
Definition: debug.h:118
static GWENHYWFAR_CB void Gtk3Gui_WGridLayout_FreeData(void *bp, void *p)
int GWEN_Widget_GetRows(const GWEN_WIDGET *w)
Definition: widget.c:207
#define GWEN_LOGDOMAIN
Definition: logger.h:35
void GWEN_Widget_SetImplData(GWEN_WIDGET *w, int index, void *ptr)
Store a pointer with the widget.
Definition: widget.c:131
static GWENHYWFAR_CB const char * Gtk3Gui_WGridLayout_GetCharProperty(GWEN_WIDGET *w, GWEN_DIALOG_PROPERTY prop, int index, const char *defaultValue)
GWEN_WIDGET_GETINTPROPERTY_FN GWEN_Widget_SetGetIntPropertyFn(GWEN_WIDGET *w, GWEN_WIDGET_GETINTPROPERTY_FN fn)
Definition: widget.c:649
#define GWEN_NEW_OBJECT(typ, varname)
Definition: memory.h:86
void * GWEN_Widget_GetImplData(const GWEN_WIDGET *w, int index)
Definition: widget.c:118
int GWEN_Widget_GetColumns(const GWEN_WIDGET *w)
Definition: widget.c:191
#define GWENHYWFAR_CB
Definition: gwenhywfarapi.h:89
GWEN_WIDGET_ADDCHILDGUIWIDGET_FN GWEN_Widget_SetAddChildGuiWidgetFn(GWEN_WIDGET *w, GWEN_WIDGET_ADDCHILDGUIWIDGET_FN fn)
Definition: widget.c:691
int Gtk3Gui_WGridLayout_Setup(GWEN_WIDGET *w)
GWEN_WIDGET_SETINTPROPERTY_FN GWEN_Widget_SetSetIntPropertyFn(GWEN_WIDGET *w, GWEN_WIDGET_SETINTPROPERTY_FN fn)
Definition: widget.c:635
struct GWEN_WIDGET GWEN_WIDGET
Definition: widget_be.h:34
int GWEN_Widget_AddChildGuiWidget(GWEN_WIDGET *w, GWEN_WIDGET *wChild)
Definition: widget.c:767
static GWENHYWFAR_CB int Gtk3Gui_WGridLayout_GetIntProperty(GWEN_WIDGET *w, GWEN_DIALOG_PROPERTY prop, int index, int defaultValue)
#define GWEN_INHERIT(bt, t)
Definition: inherit.h:264
const char * GWEN_Widget_Type_toString(GWEN_WIDGET_TYPE t)
Definition: widget.c:413
#define GWEN_INHERIT_SETDATA(bt, t, element, data, fn)
Definition: inherit.h:292
static GWENHYWFAR_CB int Gtk3Gui_WGridLayout_SetCharProperty(GWEN_WIDGET *w, GWEN_DIALOG_PROPERTY prop, int index, const char *value, int doSignal)
#define GWEN_INHERIT_GETDATA(bt, t, element)
Definition: inherit.h:271