File: x114.html

package info (click to toggle)
gtkextra 3.3.4-7
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 10,580 kB
  • sloc: ansic: 60,728; xml: 28,485; sh: 4,758; makefile: 476
file content (550 lines) | stat: -rw-r--r-- 11,215 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/loose.dtd">
<HTML
><HEAD
><TITLE
>Modifying cell contents</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK
REL="HOME"
TITLE="GtkExtra 3.0 Tutorial"
HREF="book1.html"><LINK
REL="UP"
TITLE="GtkSheet"
HREF="c32.html"><LINK
REL="PREVIOUS"
TITLE="Sheet Signals"
HREF="x52.html"><LINK
REL="NEXT"
TITLE="Modifying sheet state"
HREF="x191.html"></HEAD
><BODY
CLASS="SECT1"
BGCOLOR="#FFFFFF"
TEXT="#000000"
LINK="#0000FF"
VLINK="#840084"
ALINK="#0000FF"
><DIV
CLASS="NAVHEADER"
><TABLE
SUMMARY="Header navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="3"
ALIGN="center"
>GtkExtra 3.0 Tutorial</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="x52.html"
ACCESSKEY="P"
>&#60;&#60;&#60; Previous</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
>GtkSheet</TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="x191.html"
ACCESSKEY="N"
>Next &#62;&#62;&#62;</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><DIV
CLASS="SECT1"
><H1
CLASS="SECT1"
><A
NAME="SEC-MODIFYINGCELLCONTENTS"
>Modifying cell contents</A
></H1
><P
>As previously stated , a cell may contain text, picture or other widgets.
GtkSheet functions can be categorized after the number of modified cells:</P
><DIV
CLASS="SECT2"
><H2
CLASS="SECT2"
><A
NAME="SEC-FUNCTIONSTHATMODIFYACELL"
>Functions that modify a cell</A
></H2
><P
><I
CLASS="EMPHASIS"
> A cell text is set by:</I
> </P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><PRE
CLASS="PROGRAMLISTING"
>/* Set a cell text with justification */

void  gtk_sheet_set_cell  (GtkSheet *sheet, 
                           gint row, gint col,
                           GtkJustification justification,
                           const gchar *text);

/* No justification is made */
void gtk_sheet_set_cell_text (GtkSheet *sheet, 
                              gint row, gint col, 
                              const gchar  *text); </PRE
></TD
></TR
></TABLE
><P
>The text string will be strdup()ed by the gtkextra library so you may free your string after this line.
Do not free the internally allocated string !
This will be done by the library at the destruction of the sheet or when the gtk_sheet_set_cell is called again.</P
><P
>The text justification in the cell may be : GTK_JUSTIFY_LEFT, GTK_JUSTIFY_RIGHT, GTK_JUSTIFY_CENTER</P
><P
><I
CLASS="EMPHASIS"
> A cell text is read by:</I
> </P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><PRE
CLASS="PROGRAMLISTING"
>gchar *  gtk_sheet_cell_get_text (GtkSheet *sheet, gint row, gint col);</PRE
></TD
></TR
></TABLE
><P
><SPAN
CLASS="INLINEMEDIAOBJECT"
><IMG
SRC="images/gtksheet_cell_text.jpg"></SPAN
></P
><P
><I
CLASS="EMPHASIS"
> A cell text is deleted by:</I
> </P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><PRE
CLASS="PROGRAMLISTING"
>void gtk_sheet_cell_clear(GtkSheet *sheet, gint row, gint col); /*- delete cell contents */
void gtk_sheet_cell_delete(GGtSheet *sheet, gint row, gint col); /* - delete + remove links*/</PRE
></TD
></TR
></TABLE
><P
><I
CLASS="EMPHASIS"
> You can pack a xpm into a cell like this:</I
> </P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><PRE
CLASS="PROGRAMLISTING"
>GtkWidget *sheet,*bullet;
GdkPixmap *pixmap;
GdkColormap *colormap;
GdkBitmap *mask;
............
sheet=gtk_sheet_new(...);
.......
colormap = gdk_colormap_get_system();
pixmap = gdk_pixmap_colormap_create_from_xpm_d(NULL, colormap, &#38;mask, NULL,
                                               bullet_xpm);
bullet = gtk_pixmap_new(pixmap, mask);
gtk_sheet_attach(GTK_SHEET(sheet), bullet, 1, 1, 0,0 ,.5, .5);
........
gtk_widget_show_all (bullet); 
gtk_widget_show_all (window);</PRE
></TD
></TR
></TABLE
><P
> See full example here: <A
HREF="xpm.c"
TARGET="_top"
>xpm.c</A
> </P
><P
><SPAN
CLASS="INLINEMEDIAOBJECT"
><IMG
SRC="images/gtksheet_pack_xpm.jpg"></SPAN
></P
><P
><I
CLASS="EMPHASIS"
> You can pack a combo box into a cell:</I
> </P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><PRE
CLASS="PROGRAMLISTING"
>GtkWidget *sheet,*combo;
GList *combo_items;
..................
combo=gtk_combo_new();
combo_items=NULL;
combo_items=g_list_append (combo_items, "NULL");
combo_items=g_list_append (combo_items, "NOT NULL");
gtk_combo_set_popdown_strings (GTK_COMBO (nul_combo), combo_items);
g_list_free(combo_items);

// From GtkExtra 1.0 the cell may be resized automatically to fit the widget
gtk_sheet_attach_default (GTK_SHEET(sheet), current_combo, row, col,0,0);</PRE
></TD
></TR
></TABLE
><P
><SPAN
CLASS="INLINEMEDIAOBJECT"
><IMG
SRC="images/gtksheet_pack_combo.jpg"></SPAN
></P
><P
>The widgets can be added to a cell using these  functions.
Some of them expand/shrink cell depending of widget size ,others don't.
See the GtkSheet manual for details.</P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><PRE
CLASS="PROGRAMLISTING"
>/* Attach widget at (row x,col y) starting at the upper left of the cell */
GtkSheetChild *gtk_sheet_put (GtkSheet *sheet, GtkWidget *widget, gint x, gint y); 
void gtk_sheet_attach (GtkSheet *sheet,GtkWidget *widget,gint row, gint col,gint xoptions,gint yoptions,gint xpadding,gint ypadding); 
void gtk_sheet_attach_default (GtkSheet *sheet,GtkWidget *widget,gint row, gint col); 
void gtk_sheet_attach_floating (GtkSheet *sheet,GtkWidget *widget,gint row, gint col);</PRE
></TD
></TR
></TABLE
><P
><I
CLASS="EMPHASIS"
>You can set a link for each cell.</I
>
This is in fact a pointer you want to be associated to the cell.</P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><PRE
CLASS="PROGRAMLISTING"
>void gtk_sheet_link_cell(GtkSheet *sheet, gint row, gint col,gpointer link);
gpointer gtk_sheet_get_link(GtkSheet *sheet, gint row, gint col);
void gtk_sheet_remove_link(GtkSheet *sheet, gint row, gint col);</PRE
></TD
></TR
></TABLE
></DIV
><DIV
CLASS="SECT2"
><H2
CLASS="SECT2"
><A
NAME="SEC-FUNCTIONSTHATMODIFYARANGE"
>Functions that modify a range of cells</A
></H2
><P
><I
CLASS="EMPHASIS"
>A range of cells</I
>is in fact:</P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><PRE
CLASS="PROGRAMLISTING"
>struct _GtkSheetRange
{
  gint row0,col0; /* upper-left cell */
  gint rowi,coli; /* lower-right cell */
};</PRE
></TD
></TR
></TABLE
><P
>Some functions operating on range of cells:</P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><PRE
CLASS="PROGRAMLISTING"
>void  gtk_sheet_get_visible_range (GtkSheet *sheet,GtkSheetRange *range); 
void  gtk_sheet_range_set_background (GtkSheet *sheet, const GtkSheetRange *range, const GdkColor *color);
void  gtk_sheet_range_set_foreground (GtkSheet *sheet, const GtkSheetRange *range,const GdkColor *color);
void  gtk_sheet_select_range (GtkSheet *sheet, const GtkSheetRange *range);
void  gtk_sheet_unselect_range (GtkSheet *sheet);
void  gtk_sheet_range_clear (GtkSheet *sheet, const GtkSheetRange *range);
void  gtk_sheet_range_delete (GtkSheet *sheet, const GtkSheetRange *range);
void  gtk_sheet_range_set_editable (GtkSheet *sheet, const GtkSheetRange *range, gint editable);
void  gtk_sheet_range_set_visible (GtkSheet *sheet, const GtkSheetRange *range, gboolean visible);
void  gtk_sheet_range_set_border (GtkSheet *sheet, const GtkSheetRange *range, gint mask, guint width, gint line_style);
void  gtk_sheet_range_set_border_color GtkSheet *sheet, const GtkSheetRange *range, const GdkColor  *color);</PRE
></TD
></TR
></TABLE
><P
><I
CLASS="EMPHASIS"
>Remark:</I
></P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><PRE
CLASS="PROGRAMLISTING"
>/* When you declare a range like this:*/

......
GtkSheetRange range;
.................

/* You must call the range functions like this : */

void  gtk_sheet_range_clear (sheet, &#38;range); </PRE
></TD
></TR
></TABLE
><P
><I
CLASS="EMPHASIS"
>Screenshot:</I
>Modifying the background color of a range.</P
><P
><SPAN
CLASS="INLINEMEDIAOBJECT"
><IMG
SRC="images/gtksheet_range_bg.jpg"></SPAN
></P
></DIV
><DIV
CLASS="SECT2"
><H2
CLASS="SECT2"
><A
NAME="SEC-FUNCTIONSTHATMODIFYALLCELLS"
>Functions that modify all cells from sheet</A
></H2
><P
>These functions are used if you want the cells to contain the same widget.
These are some of them:</P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><PRE
CLASS="PROGRAMLISTING"
>GtkWidget *gtk_sheet_new_with_custom_entry (guint rows, guint columns, const gchar *title,GtkType entry_type); 
void  gtk_sheet_set_foreground (GtkSheet *sheet,GdkColor *fg_color);
void  gtk_sheet_set_background (GtkSheet *sheet,GdkColor *bg_color);</PRE
></TD
></TR
></TABLE
></DIV
><DIV
CLASS="SECT2"
><H2
CLASS="SECT2"
><A
NAME="SEC-FUNCTIONSTHATSETROWCOLUMNS"
>Functions that set row/column titles , sheet title , etc</A
></H2
><P
><I
CLASS="EMPHASIS"
>A row/column title </I
>can be set with:</P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><PRE
CLASS="PROGRAMLISTING"
>void gtk_sheet_row_button_add_label	(GtkSheet *sheet, gint row, const gchar *label); 
void gtk_sheet_column_button_add_label	(GtkSheet *sheet, gint row, const gchar *label); </PRE
></TD
></TR
></TABLE
><P
><I
CLASS="EMPHASIS"
>gtk_sheet_set_row_title() </I
> is used for setting an internal label associated with a row.</P
><P
><I
CLASS="EMPHASIS"
>The sheet title  </I
> may be set with : </P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><PRE
CLASS="PROGRAMLISTING"
>void gtk_sheet_set_title (GtkSheet *sheet, const gchar *title);</PRE
></TD
></TR
></TABLE
><P
><I
CLASS="EMPHASIS"
>The dimensions of the row/column titles </I
> may be set with the next functions: 
These functions exist because you may want to resize the width of a column or height of a row,
unless you set the autoresize flag, which will do it automaticaly for you.</P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><PRE
CLASS="PROGRAMLISTING"
>void gtk_sheet_set_row_titles_width(GtkSheet *sheet, guint width); 
void gtk_sheet_set_column_titles_height(GtkSheet *sheet, guint height);</PRE
></TD
></TR
></TABLE
><P
><I
CLASS="EMPHASIS"
> Row/column title justification </I
> is done by: </P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><PRE
CLASS="PROGRAMLISTING"
>void gtk_sheet_set_row_titles_width(GtkSheet *sheet, guint width); 
void gtk_sheet_set_column_titles_height(GtkSheet *sheet, guint height);</PRE
></TD
></TR
></TABLE
></DIV
></DIV
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"><TABLE
SUMMARY="Footer navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="x52.html"
ACCESSKEY="P"
>&#60;&#60;&#60; Previous</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="book1.html"
ACCESSKEY="H"
>Home</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="x191.html"
ACCESSKEY="N"
>Next &#62;&#62;&#62;</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>Sheet Signals</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="c32.html"
ACCESSKEY="U"
>Up</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>Modifying sheet state</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>