libyui-gtk  2.43.7
 All Classes
YGSelectionStore.h
1 /********************************************************************
2  * YaST2-GTK - http://en.opensuse.org/YaST2-GTK *
3  ********************************************************************/
4 
5 /* Provides a basic model common to YSelectedWidget widgets. */
6 
7 #ifndef YGSELECTION_STORE_H
8 #define YGSELECTION_STORE_H
9 
10 #include <gtk/gtk.h>
11 struct YItem;
12 struct YSelectionWidget;
13 
15 {
16  YGSelectionStore (bool tree);
17  virtual ~YGSelectionStore();
18 
19  GtkTreeModel *getModel() { return m_model; }
20  void createStore (int cols, const GType types[]);
21 
22  void addRow (YItem *item, GtkTreeIter *iter, GtkTreeIter *parent = 0);
23  void setRowText (GtkTreeIter *iter, int iconCol, const std::string &icon,
24  int labelCol, const std::string &label, const YSelectionWidget *widget);
25  void setRowMark (GtkTreeIter *iter, int markCol, bool mark);
26  void doDeleteAllItems();
27 
28  YItem *getYItem (GtkTreeIter *iter);
29  void getTreeIter (const YItem *item, GtkTreeIter *iter);
30 
31  GtkListStore *getListStore();
32  GtkTreeStore *getTreeStore();
33 
34  bool isEmpty();
35  int getTreeDepth();
36 
37  bool findLabel (int labelCol, const std::string &label, GtkTreeIter *iter);
38 
39 protected:
40  GtkTreeModel *m_model;
41  bool isTree;
42  gpointer m_nextRowId;
43 };
44 
45 #define YGSELECTION_WIDGET_IMPL(ParentClass) \
46  virtual void addItem(YItem *item) { \
47  ParentClass::addItem (item); \
48  doAddItem (item); \
49  } \
50  virtual void deleteAllItems() { \
51  ParentClass::deleteAllItems(); \
52  blockSelected(); \
53  doDeleteAllItems(); \
54  } \
55  virtual void selectItem (YItem *item, bool select) { \
56  ParentClass::selectItem (item, select); \
57  doSelectItem (item, select); \
58  } \
59  virtual void deselectAllItems() { \
60  ParentClass::deselectAllItems(); \
61  doDeselectAllItems(); \
62  }
63 
64 #endif /*YGSELECTION_STORE_H*/
65