summaryrefslogtreecommitdiff
path: root/libs/gtkmm2/gtk/gtkmm/combo.h
blob: d0c973204dd498c2087d812f02e17a74786d4cf9 (plain)
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
// -*- c++ -*-
// Generated by gtkmmproc -- DO NOT MODIFY!
#ifndef _GTKMM_COMBO_H
#define _GTKMM_COMBO_H

#include <glibmm.h>

/* $Id$ */

/* combo.h
 * 
 * Copyright (C) 1998-2002 The gtkmm Development Team
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public
 * License along with this library; if not, write to the Free
 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#include <glibmm/listhandle.h>
#include <glibmm/helperlist.h>
#include <gtkmm/box.h>
#include <gtkmm/button.h>
#include <gtkmm/entry.h>
#include <gtkmm/item.h>


#ifndef DOXYGEN_SHOULD_SKIP_THIS
typedef struct _GtkListItem GtkListItem;
typedef struct _GtkListItemClass GtkListItemClass;
#endif /* DOXYGEN_SHOULD_SKIP_THIS */


namespace Gtk
{ class ComboDropDownItem_Class; } // namespace Gtk
#ifndef DOXYGEN_SHOULD_SKIP_THIS
typedef struct _GtkList GtkList;
typedef struct _GtkListClass GtkListClass;
#endif /* DOXYGEN_SHOULD_SKIP_THIS */


namespace Gtk
{ class ComboDropDown_Class; } // namespace Gtk
#ifndef DOXYGEN_SHOULD_SKIP_THIS
typedef struct _GtkCombo GtkCombo;
typedef struct _GtkComboClass GtkComboClass;
#endif /* DOXYGEN_SHOULD_SKIP_THIS */


namespace Gtk
{ class Combo_Class; } // namespace Gtk
namespace Gtk
{


/** An item in a ComboDropDownList.
 * 
 * Items in a ComboDropDownList inherit Item. Two signals are added.
 *
 * @deprecated Use the ComboBox widget instead. 
 */

class ComboDropDownItem : public Gtk::Item
{
  public:
#ifndef DOXYGEN_SHOULD_SKIP_THIS
  typedef ComboDropDownItem CppObjectType;
  typedef ComboDropDownItem_Class CppClassType;
  typedef GtkListItem BaseObjectType;
  typedef GtkListItemClass BaseClassType;
#endif /* DOXYGEN_SHOULD_SKIP_THIS */

  virtual ~ComboDropDownItem();

#ifndef DOXYGEN_SHOULD_SKIP_THIS

private:
  friend class ComboDropDownItem_Class;
  static CppClassType combodropdownitem_class_;

  // noncopyable
  ComboDropDownItem(const ComboDropDownItem&);
  ComboDropDownItem& operator=(const ComboDropDownItem&);

protected:
  explicit ComboDropDownItem(const Glib::ConstructParams& construct_params);
  explicit ComboDropDownItem(GtkListItem* castitem);

#endif /* DOXYGEN_SHOULD_SKIP_THIS */

public:
#ifndef DOXYGEN_SHOULD_SKIP_THIS
  static GType get_type()      G_GNUC_CONST;
  static GType get_base_type() G_GNUC_CONST;
#endif

  ///Provides access to the underlying C GtkObject.
  GtkListItem*       gobj()       { return reinterpret_cast<GtkListItem*>(gobject_); }

  ///Provides access to the underlying C GtkObject.
  const GtkListItem* gobj() const { return reinterpret_cast<GtkListItem*>(gobject_); }


public:
  //C++ methods used to invoke GTK+ virtual functions:

protected:
  //GTK+ Virtual Functions (override these to change behaviour):

  //Default Signal Handlers::
  virtual void on_scroll_horizontal(ScrollType scroll_type, float position);
  virtual void on_scroll_vertical(ScrollType scroll_type, float position);


private:

  
public:
  ComboDropDownItem();

  
  Glib::SignalProxy2< void,ScrollType,float > signal_scroll_horizontal();

  
  Glib::SignalProxy2< void,ScrollType,float > signal_scroll_vertical();


};


namespace ComboDropDown_Helpers
{

typedef Gtk::ComboDropDownItem Element;

 
class ComboDropDownList : public Glib::HelperList< ComboDropDownItem, const Element, Glib::List_Cpp_Iterator<GtkListItem,ComboDropDownItem> >
{
public:
  ComboDropDownList();
  explicit ComboDropDownList(GtkList* gparent);
  ComboDropDownList(const ComboDropDownList& src);
  virtual ~ComboDropDownList() {}

  ComboDropDownList& operator=(const ComboDropDownList& src);

  typedef Glib::HelperList< ComboDropDownItem, const Element,  Glib::List_Cpp_Iterator<GtkListItem,ComboDropDownItem> > type_base;

  GtkList* gparent();
  const GtkList* gparent() const;

  virtual GList*& glist() const;      // front of list

  virtual void erase(iterator start, iterator stop);
  virtual iterator erase(iterator);  //Implented as custom or by LIST_CONTAINER_REMOVE
  virtual void remove(const_reference); //Implented as custom or by LIST_CONTAINER_REMOVE

  /// This is order n. (use at own risk)
  reference operator[](size_type l) const;

public:
  iterator insert(iterator position, element_type& e); //custom-implemented.

  template <class InputIterator>
  inline void insert(iterator position, InputIterator first, InputIterator last)
  {
    for(;first != last; ++first)
      position = insert(position, *first);
  }

 inline void push_front(element_type& e)
    { insert(begin(), e); }
  inline void push_back(element_type& e)
    { insert(end(), e); }


  iterator find(const_reference c);
  iterator find(Widget&);

  };


} /* namespace ComboDropDown_Helpers */


class Combo;

/** The dropdown list of a Combo.
 * 
 * A combo is a compound widget which crosses a text entry area and a pull
 * down list. The dropdown list is implemented with the deprecated GtkList
 * widget on the gtk+ side. ComboDropDown is a thin wrapper around GtkList
 * containing just the functionality necessary for a Combo's list. To add
 * and remove items use the STL-style interface that is accessible through
 * ComboDropDown::children().
 *
 * @deprecated Use the ComboBox widget instead.
 */

class ComboDropDown : public Gtk::Container
{
  public:
#ifndef DOXYGEN_SHOULD_SKIP_THIS
  typedef ComboDropDown CppObjectType;
  typedef ComboDropDown_Class CppClassType;
  typedef GtkList BaseObjectType;
  typedef GtkListClass BaseClassType;
#endif /* DOXYGEN_SHOULD_SKIP_THIS */

  virtual ~ComboDropDown();

#ifndef DOXYGEN_SHOULD_SKIP_THIS

private:
  friend class ComboDropDown_Class;
  static CppClassType combodropdown_class_;

  // noncopyable
  ComboDropDown(const ComboDropDown&);
  ComboDropDown& operator=(const ComboDropDown&);

protected:
  explicit ComboDropDown(const Glib::ConstructParams& construct_params);
  explicit ComboDropDown(GtkList* castitem);

#endif /* DOXYGEN_SHOULD_SKIP_THIS */

public:
#ifndef DOXYGEN_SHOULD_SKIP_THIS
  static GType get_type()      G_GNUC_CONST;
  static GType get_base_type() G_GNUC_CONST;
#endif

  ///Provides access to the underlying C GtkObject.
  GtkList*       gobj()       { return reinterpret_cast<GtkList*>(gobject_); }

  ///Provides access to the underlying C GtkObject.
  const GtkList* gobj() const { return reinterpret_cast<GtkList*>(gobject_); }


public:
  //C++ methods used to invoke GTK+ virtual functions:

protected:
  //GTK+ Virtual Functions (override these to change behaviour):

  //Default Signal Handlers::
  virtual void on_select_child(Widget& item);
  virtual void on_selection_changed();
  virtual void on_unselect_child(Widget& item);


private:

  
public:
  typedef ComboDropDown_Helpers::ComboDropDownList ComboDropDownList;

protected:
  ComboDropDown();
  friend class Combo;
public:

  
  void scroll_horizontal(ScrollType scroll_type, float position);
  
  void scroll_vertical(ScrollType scroll_type, float position);

  ComboDropDownList& children();
  const ComboDropDownList& children() const;

  
  Glib::SignalProxy1< void,Widget& > signal_select_child();

  
  Glib::SignalProxy0< void > signal_selection_changed();

  
  Glib::SignalProxy1< void,Widget& > signal_unselect_child();


protected:
#ifndef DOXYGEN_SHOULD_SKIP_THIS
  mutable ComboDropDownList children_proxy_;
#endif /* DOXYGEN_SHOULD_SKIP_THIS */


};


class ScrolledWindow;
class Window;

/** A text entry field with a dropdown list.
 * 
 * A combo is a compound widget which crosses a text entry area and a pull
 * down list.  It may allow text entry or it may just allow list
 * values depending on the settings.
 *
 * Access members allow altering of the widget components.
 *
 * @deprecated Use the ComboBox widget instead.
 */

class Combo : public HBox
{
  public:
#ifndef DOXYGEN_SHOULD_SKIP_THIS
  typedef Combo CppObjectType;
  typedef Combo_Class CppClassType;
  typedef GtkCombo BaseObjectType;
  typedef GtkComboClass BaseClassType;
#endif /* DOXYGEN_SHOULD_SKIP_THIS */

  virtual ~Combo();

#ifndef DOXYGEN_SHOULD_SKIP_THIS

private:
  friend class Combo_Class;
  static CppClassType combo_class_;

  // noncopyable
  Combo(const Combo&);
  Combo& operator=(const Combo&);

protected:
  explicit Combo(const Glib::ConstructParams& construct_params);
  explicit Combo(GtkCombo* castitem);

#endif /* DOXYGEN_SHOULD_SKIP_THIS */

public:
#ifndef DOXYGEN_SHOULD_SKIP_THIS
  static GType get_type()      G_GNUC_CONST;
  static GType get_base_type() G_GNUC_CONST;
#endif

  ///Provides access to the underlying C GtkObject.
  GtkCombo*       gobj()       { return reinterpret_cast<GtkCombo*>(gobject_); }

  ///Provides access to the underlying C GtkObject.
  const GtkCombo* gobj() const { return reinterpret_cast<GtkCombo*>(gobject_); }


public:
  //C++ methods used to invoke GTK+ virtual functions:

protected:
  //GTK+ Virtual Functions (override these to change behaviour):

  //Default Signal Handlers::


private:

public:

  Combo();
  

  /** Allow direct text entry
   * Whether the text in the entry must be or not be in the list.
   *
   * @param value Set to true if the value must be in list.
   * @param empty Set to true if the text area is allowed to be empty.
   */
  
  void set_value_in_list(bool value = true, bool empty = false);

  /** Set arrows keys to change value
   * Up and down will scroll through the list items.
   * Useful when there is a small list of value that the
   * list must have.
   *
   * @param arrows_on true indicates the arrow keys scroll.
   */
  
  void set_use_arrows(bool arrows_on = true);

  /** Set arrows keys to change if value not in list
   * Up and down will scroll through the list items but only
   * change the current value if the text does not match a list item..
   * Useful when there is a small list of value that the
   * list must have.
   *
   * @param arrows_always true indicates the value will change.
   */
  
  void set_use_arrows_always(bool arrows_always = true);

  /** Sets list case sensitive
   * Determines if the list items and text comparisons for
   * set_use_arrows_always() should be case sensitive.
   */
  
  void set_case_sensitive(bool val = true);

  /** Set the current entry Glib::ustring
   * Call this function on an item if it isn't a label or you
   * want it to have a different value to be displayed in the entry
   */
  
  void set_item_string(Gtk::Item& item, const Glib::ustring& item_value);
   void remove_item_string(Gtk::Item& item);

  /// Insert a list of items.
  
  void set_popdown_strings(const Glib::ListHandle<Glib::ustring>& strings);

  Glib::ListHandle<Glib::ustring> get_popdown_strings() const;

  
  void disable_activate();

  Entry* get_entry();
  const Entry* get_entry() const;
  ComboDropDown* get_list();
  const ComboDropDown* get_list() const;

  /** Whether the arrow keys move through the list of items.
   *
   * You rarely need to use properties because there are get_ and set_ methods for almost all of them.
   * @return A PropertyProxy that allows you to get or set the property of the value, or receive notification when
   * the value of the property changes.
   */
  Glib::PropertyProxy<bool> property_enable_arrow_keys() ;

/** Whether the arrow keys move through the list of items.
   *
   * You rarely need to use properties because there are get_ and set_ methods for almost all of them.
   * @return A PropertyProxy that allows you to get or set the property of the value, or receive notification when
   * the value of the property changes.
   */
  Glib::PropertyProxy_ReadOnly<bool> property_enable_arrow_keys() const;

  /** Obsolete property
   *
   * You rarely need to use properties because there are get_ and set_ methods for almost all of them.
   * @return A PropertyProxy that allows you to get or set the property of the value, or receive notification when
   * the value of the property changes.
   */
  Glib::PropertyProxy<bool> property_enable_arrows_always() ;

/** Obsolete property
   *
   * You rarely need to use properties because there are get_ and set_ methods for almost all of them.
   * @return A PropertyProxy that allows you to get or set the property of the value, or receive notification when
   * the value of the property changes.
   */
  Glib::PropertyProxy_ReadOnly<bool> property_enable_arrows_always() const;

  /** Whether list item matching is case sensitive.
   *
   * You rarely need to use properties because there are get_ and set_ methods for almost all of them.
   * @return A PropertyProxy that allows you to get or set the property of the value, or receive notification when
   * the value of the property changes.
   */
  Glib::PropertyProxy<bool> property_case_sensitive() ;

/** Whether list item matching is case sensitive.
   *
   * You rarely need to use properties because there are get_ and set_ methods for almost all of them.
   * @return A PropertyProxy that allows you to get or set the property of the value, or receive notification when
   * the value of the property changes.
   */
  Glib::PropertyProxy_ReadOnly<bool> property_case_sensitive() const;

  /** Whether an empty value may be entered in this field.
   *
   * You rarely need to use properties because there are get_ and set_ methods for almost all of them.
   * @return A PropertyProxy that allows you to get or set the property of the value, or receive notification when
   * the value of the property changes.
   */
  Glib::PropertyProxy<bool> property_allow_empty() ;

/** Whether an empty value may be entered in this field.
   *
   * You rarely need to use properties because there are get_ and set_ methods for almost all of them.
   * @return A PropertyProxy that allows you to get or set the property of the value, or receive notification when
   * the value of the property changes.
   */
  Glib::PropertyProxy_ReadOnly<bool> property_allow_empty() const;

  /** Whether entered values must already be present in the list.
   *
   * You rarely need to use properties because there are get_ and set_ methods for almost all of them.
   * @return A PropertyProxy that allows you to get or set the property of the value, or receive notification when
   * the value of the property changes.
   */
  Glib::PropertyProxy<bool> property_value_in_list() ;

/** Whether entered values must already be present in the list.
   *
   * You rarely need to use properties because there are get_ and set_ methods for almost all of them.
   * @return A PropertyProxy that allows you to get or set the property of the value, or receive notification when
   * the value of the property changes.
   */
  Glib::PropertyProxy_ReadOnly<bool> property_value_in_list() const;


};


} /* namespace Gtk */


namespace Glib
{
  /** @relates Gtk::ComboDropDownItem
   * @param object The C instance
   * @param take_copy False if the result should take ownership of the C instance. True if it should take a new copy or ref.
   * @result A C++ instance that wraps this C instance.
   */
  Gtk::ComboDropDownItem* wrap(GtkListItem* object, bool take_copy = false);
}
namespace Glib
{
  /** @relates Gtk::ComboDropDown
   * @param object The C instance
   * @param take_copy False if the result should take ownership of the C instance. True if it should take a new copy or ref.
   * @result A C++ instance that wraps this C instance.
   */
  Gtk::ComboDropDown* wrap(GtkList* object, bool take_copy = false);
}
namespace Glib
{
  /** @relates Gtk::Combo
   * @param object The C instance
   * @param take_copy False if the result should take ownership of the C instance. True if it should take a new copy or ref.
   * @result A C++ instance that wraps this C instance.
   */
  Gtk::Combo* wrap(GtkCombo* object, bool take_copy = false);
}
#endif /* _GTKMM_COMBO_H */