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
  
/* -*- C -*- */ 
class GTK2.Label; 
inherit GTK2.Misc; 
 
//! A simple text label. 
//! IMG: GTK2.Label("A simple text label") 
//! IMG: GTK2.Label("Multi\nline text\nlabel here") 
//! IMG: GTK2.Label("Multi\nline text\nlabel here")->set_justify(GTK2.JUSTIFY_LEFT) 
//! IMG: GTK2.Label("Multi\nline text\nlabel here")->set_justify(GTK2.JUSTIFY_RIGHT) 
 
//! Properties: 
//! float angle 
require pango; 
//! Pango.AttrList attributes 
endrequire; 
//! int cursor-position 
//! int ellipsize CONST(PANGO_ELLIPSIZE_) 
//! int justfy CONST(GTK_JUSTIFY_) 
//! string label 
//! int max-width-chars 
//! int mnemonic-keyval 
//! int mnemonic-widget 
//! string pattern 
//! int selectable 
//! int single-line-mode 
//! int use-markup 
//! int use-underline 
//! int width-chars 
//! int wrap 
 
signal copy_clipboard; 
signal move_cursor; 
signal populate_popup; 
 
void create(string|mapping(string:mixed)|void text_or_props) 
//! Creates a new label. 
{ 
  pgtk2_verify_not_inited(); 
  pgtk2_verify_setup(); 
  if (args) { 
    if (TYPEOF(Pike_sp[-args]) == PIKE_T_STRING) { 
      struct pike_string *t; 
      GtkWidget *gl; 
      get_all_args(NULL,args,"%T",&t); 
      if (t) { 
        ref_push_string(t); 
        f_string_to_utf8(1); 
        gl=gtk_label_new((char *)STR0(Pike_sp[-1].u.string)); 
        pop_stack(); 
      } else 
        gl=gtk_label_new(NULL); 
      THIS->obj=G_OBJECT(gl); 
    } else { 
      INIT_WITH_PROPS(GTK_TYPE_LABEL); 
    } 
    pgtk2_pop_n_elems(args); 
  } else { 
    GtkWidget *gl; 
    gl=gtk_label_new(NULL); 
    THIS->obj=G_OBJECT(gl); 
  } 
  pgtk2__init_this_object(); 
} 
 
void set_text(sprintf_format text, sprintf_args ... fmt) 
//! Set the text in the label 
{ 
  pgtk2_get_string_arg_with_sprintf(args); 
  pgtk2_verify_inited(); 
  gtk_label_set_text(GTK_LABEL(THIS->obj),Pike_sp[-1].u.string->str); 
  pgtk2_return_this(1); 
} 
 
require pango; 
void set_markup(string text); 
//! Parses text which is marked up with the Pango text markup language, 
//! setting the label's text and attribute list based on the parse results. 
 
void set_markup_with_mnemonic(string text); 
//! Parses text which is marked up with the Pango text markup language, 
//! setting the label's text and attribute list based on the parse results. 
//! If characters in text are preceded by an underscore, they are underline 
//! indicating that they represent a keyboard accelerator called a mnemonic. 
//! <p> 
//! The mnemonic key can be used to activate another widget, chosen 
//! automatically, or explicitly using set_mnemonic_widget(). 
endrequire; 
 
void set_pattern(string pattern_string); 
//! A string with either spaces or underscores.<br /> 
//! It should be of the same length as the text. 
//! <p> 
//! When a character in the text has a matching _ in the pattern, the 
//! character in the label will be underlined. 
//! </p> 
 
void set_justify(int jtype); 
//! Sets the alignment of the lines in the text of the label relative to each 
//! other.  GTK2.JUSTIFY_LEFT is the default value when the widget is first 
//! created.  If you instead want to set the alignment of the label as a 
//! whole, use set_alignment() instead.  set_justify() has no efect on labels 
//! containing only a single line.  One of CONST(GTK_JUSTIFY_). 
 
require gtk26; 
void set_ellipsize(int mode); 
//! Sets the mode used to ellipsize (add an ellipsis: "...") to the text if 
//! there is not enough space to render the entire string. 
//! One of CONST(PANGO_ELLIPSIZE_). 
 
void set_width_chars(int n_chars); 
//! Sets the desired width in characters to n_chars. 
 
void set_max_width_chars(int n_chars); 
//! Sets the desired maximum width in characters to n_chars. 
endrequire; 
 
void set_line_wrap(int wrap); 
//! Toggles line wrapping within the widget.  True makes it break lines if 
//! text exceeds the widget's size.  False lets the text get cut off by the 
//! edge of the widget if it exceeds the widget size. 
 
 
require pango; 
require gtk210; 
void set_line_wrap_mode(int wrap_mode); 
//! If line wrapping is on, this controls how the line wrapping is done.  The 
//! Default is Pango.WRAP_WORD, which means wrap on word boundaries. 
endrequire; 
 
mapping(string:int) get_layout_offsets() 
//! Obtains the coordinates where the label will draw the Pango.Layout 
//! representing the text in the label; useful to convert mouse events into 
//! coordinates inside the Pango.Layout, e.g. to take some action if some part 
//! of the label is clicked.  Of course, you will need to create a GTK2.EventBox 
//! to receive the events, and pack the label inside it, since labels are a 
//! GTK2.NO_WINDOW widget.  Remember when using the Pango.Layout functions you 
//! need to convert to and from pixels using GTK2.PANGO_SCALE. 
{ 
  pgtk2_verify_inited(); 
  pgtk2_pop_n_elems(args); 
  { 
    gint x,y; 
    gtk_label_get_layout_offsets(GTK_LABEL(THIS->obj),&x,&y); 
    ref_push_string(_STR("x")); push_int(x); 
    ref_push_string(_STR("y")); push_int(y); 
    f_aggregate_mapping(4); 
  } 
} 
endrequire; 
 
int get_mnemonic_keyval(); 
//! If the label has been set so that is has a mnemonic key, this function 
//! returns the keyval used for the mnemonic accelerator.  If there is no 
//! mnemonic set up it returns GDK_VoidSymbol. 
 
int get_selectable(); 
//! Gets the value set by set_selectable(). 
 
string get_text(); 
//! Fetches the text from a label widget, as displayed on the screen.  This 
//! does not include any embedded underlines indicating mnemonics or Pango 
//! markup. (see get_label()). 
 
void select_region(int start_offset, int end_offset); 
//! Selects a range of characters in the label, if the label is selectable. 
//! See set_selectable().  If the label is not selectable, this function has 
//! no effect.  If start_offset or end_offset are -1, then the end of the 
//! label will be substituted. 
 
void set_mnemonic_widget(GTK2.Widget widget); 
//! If the label has been set so that it has a mnemonic key (using i.e.  
//! set_markup_with_mnemonic(), set_text_with_mnemonic(), or the  
//! "use_underline" property) the label can be associated with a widget that 
//! is the target of the mnemonic.  When the label is inside a widget (like a 
//! GTK2.Button or GTK2.Notebook tab) it is automatically associated with the 
//! correct widget, but sometimes (i.e. when the target is a GTK2.Entry next 
//! to the label) you need to set it explicitly using this function. 
//! <p> 
//! The target widget will be accelerated by emitting "mnemonic_activate" on 
//! it.  The default handler for this signal will activate the widget if there 
//! are no mnemonic collisions and toggle focus between the colliding widgets 
//! otherwise. 
 
void set_selectable(int setting); 
//! Selectable labels allow the user to select text from the label, for copy 
//! and past. 
 
void set_text_with_mnemonic(sprintf_format text, sprintf_args ... fmt) 
//! Sets the label's text from the string text.  If characters in text are 
//! preceded by an underscore, they are underlined indicating that they 
//! represent a keyboard accelerator called a mnemonic.  The mnemonic key can 
//! be used to activate another widget, chose automatically, or explicitly 
//! using set_mnemonic_widget(). 
{ 
  pgtk2_get_string_arg_with_sprintf(args); 
  pgtk2_verify_inited(); 
  gtk_label_set_text_with_mnemonic(GTK_LABEL(THIS->obj),Pike_sp[-1].u.string->str); 
  pgtk2_return_this(1); 
} 
 
int get_justify(); 
//! Returns the justification of the label. 
 
require gtk26; 
int get_ellipsize(); 
//! Returns the ellipsizing position of the label. 
 
int get_width_chars(); 
//! Retrieves the desired width, in characters. 
 
int get_max_width_chars(); 
//! Retrieves the desired maximum width, in characters. 
endrequire; 
 
string get_label(); 
//! Fetches the text from a label widget including any underlines indicating 
//! mnemonics and Pango markup. 
 
require pango; 
+Pango.Layout get_layout(); 
//! Gets the Pango.Layout used to display the label.  The layout is useful to 
//! e.g. convert text positions to pixel positions, in combination with 
//! get_layout_offsets(). 
endrequire; 
 
int get_line_wrap(); 
//! Returns whether lines in the label are automatically wrapped. 
 
require gtk210; 
require pango; 
int get_line_wrap_mode(); 
//! Returns line wrap mode used by the label. 
endrequire; 
endrequire; 
 
+GTK2.Widget get_mnemonic_widget(); 
//! Retrieves the target of the mnemonic (keyboard shortcut). 
 
mapping(string:int) get_selection_bounds() 
//! Gets the selected range of characters in the label.  If there isn't a 
//! selection, returns -1 for both start and end. 
{ 
  pgtk2_verify_inited(); 
  { 
    gint start,end; 
    int res=gtk_label_get_selection_bounds(GTK_LABEL(THIS->obj),&start,&end); 
    pgtk2_pop_n_elems(args); 
    ref_push_string(_STR("start")); 
    push_int(res?start:-1); 
    ref_push_string(_STR("end")); 
    push_int(res?end:-1); 
    f_aggregate_mapping(4); 
  } 
} 
 
int get_use_markup(); 
//! Returns whether the label's text is interpreted as marked up with the 
//! Pango text markup language. 
 
int get_use_underline(); 
//! Returns whether an embedded underline in the label indicates a mnemonic. 
 
require gtk26; 
int get_single_line_mode(); 
//! Returns whether the label is in single line mode. 
 
float get_angle(); 
//! Gets the angle of rotation for the label. 
endrequire; 
 
void set_label(string text); 
//! Sets the text of the label.  The label is interpreted as including 
//! embedded underlines and/or Pango markup depending on the values of 
//! use-underline and use-markup. 
 
void set_use_markup(int setting); 
//! Sets whether the text of the label contains markup in Pango's text markup 
//! language. 
 
void set_use_underline(int setting); 
//! If true, an underline in the text indicates the next character should be 
//! used for the mnemonic accelerator key. 
 
require gtk26; 
void set_single_line_mode(int mode); 
//! Sets whether the label is in single line mode. 
 
void set_angle(double angle); 
//! Sets the angle of rotation for the label.  An angle of 90 reads from  
//! bottom to top, and angle of 270, from top to bottom.  The angle setting 
//! for the label is igrnored if the lable is selectable, wrapped, or  
//! ellipsized. 
endrequire;