libyui-mga-gtk  1.0.1
 All Classes Functions
YMGA_GCBTable.h
1 /*
2  Copyright 2013 by Angelo Naselli <anaselli at linux dot it>
3 
4  This library is free software; you can redistribute it and/or modify
5  it under the terms of the GNU Lesser General Public License as
6  published by the Free Software Foundation; either version 2.1 of the
7  License, or (at your option) version 3.0 of the License. This library
8  is distributed in the hope that it will be useful, but WITHOUT ANY
9  WARRANTY; without even the implied warranty of MERCHANTABILITY or
10  FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
11  License for more details. You should have received a copy of the GNU
12  Lesser General Public License along with this library; if not, write
13  to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
14  Floor, Boston, MA 02110-1301 USA
15 */
16 
17 
18 /*-/
19 
20  File: YMGA_GCBTable.h
21 
22  Author: Angelo Naselli <anaselli@linux.it>
23 
24 /-*/
25 
26 #ifndef YMGA_GCBTable_h
27 #define YMGA_GCBTable_h
28 
29 
30 #include <yui/mga/YMGA_CBTable.h>
31 #include <yui/gtk/ygtktreeview.h>
32 
33 
34 #include <yui/gtk/YGSelectionStore.h>
35 #include <yui/gtk/YGWidget.h>
36 
37 /* YMGA_GTreeView is YGTreeView into gtk implementation that unfortunately is not usable
38  TODO if needed by other classes move to a new header file
39  */
40 
41 class YMGA_GTreeView : public YGScrolledWidget, public YGSelectionStore
42 {
43 protected:
44  guint m_blockTimeout;
45  int markColumn;
46  GtkWidget *m_count;
47 
48 public:
49  YMGA_GTreeView (YWidget *ywidget, YWidget *parent, const std::string &label, bool tree);
50 
51  virtual ~YMGA_GTreeView();
52 
53  inline GtkTreeView *getView()
54  {
55  return GTK_TREE_VIEW (getWidget());
56  }
57  inline GtkTreeSelection *getSelection()
58  {
59  return gtk_tree_view_get_selection (getView());
60  }
61 
62  void addTextColumn (int iconCol, int textCol);
63  void addTextColumn (const std::string &header, YAlignmentType align, int icon_col, int text_col);
64 
65  void addCheckColumn (int check_col);
66  void addCheckColumn ( const std::string& header, int check_col );
67 
68  void readModel();
69 
70  void addCountWidget (YWidget *yparent);
71 
72  void syncCount();
73 
74  void focusItem (YItem *item, bool select);
75 
76  void unfocusAllItems();
77 
78  void unmarkAll();
79 
80  YItem *getFocusItem();
81 
82  virtual bool _immediateMode() {
83  return true;
84  }
85  virtual bool _shrinkable() {
86  return false;
87  }
88  virtual bool _recursiveSelection() {
89  return false;
90  }
91 
92  void setMark (GtkTreeIter *iter, YItem *yitem, gint column, bool state, bool recursive);
93 
94  void toggleMark (GtkTreePath *path, gint column);
95 
96  virtual unsigned int getMinSize (YUIDimension dim);
97 
98 protected:
99  static gboolean block_selected_timeout_cb (gpointer data);
100 
101  void blockSelected();
102 
103  static void block_init_cb (GtkWidget *widget, YMGA_GTreeView *pThis);
104 
105  static bool all_marked (GtkTreeModel *model, GtkTreeIter *iter, int mark_col);
106 
107  static void inconsistent_mark_cb (GtkTreeViewColumn *column,
108  GtkCellRenderer *cell, GtkTreeModel *model, GtkTreeIter *iter, gpointer data);
109 
110  static void selection_changed_cb (GtkTreeSelection *selection, YMGA_GTreeView *pThis);
111 
112  static void activated_cb (GtkTreeView *tree_view, GtkTreePath *path,
113  GtkTreeViewColumn *column, YMGA_GTreeView* pThis);
114 
115  static void toggled_cb (GtkCellRendererToggle *renderer, gchar *path_str,
116  YMGA_GTreeView *pThis);
117  static void right_click_cb (YGtkTreeView *view, gboolean outreach, YMGA_GTreeView *pThis);
118 
119 };
120 
121 
122 class YMGA_GCBTable : public YMGA_CBTable, public YMGA_GTreeView
123 {
124 public:
125  YMGA_GCBTable (YWidget *parent, YTableHeader *headers, YCBTableMode mode);
126 
127  void setSortable (bool sortable);
128 
129  void setCell (GtkTreeIter *iter, int column, const YTableCell *cell);
130 
131  // YGTreeView
132  virtual bool _immediateMode();
133 
134  // YTable
135  virtual void setKeepSorting (bool keepSorting);
136 
137  virtual void cellChanged (const YTableCell *cell);
138 
139  // YGSelectionStore
140  void doAddItem (YItem *_item);
141 
142  void doSelectItem (YItem *item, bool select);
143 
144  void doDeselectAllItems();
145 
146  virtual void checkItem( YItem * item, bool checked = true );
147 
148  // callbacks
149  static void activateButton (YWidget *button);
150 
151  static void hack_right_click_cb (YGtkTreeView *view, gboolean outreach, YMGA_GCBTable *pThis);
152 
153  static gboolean key_press_event_cb (GtkWidget *widget, GdkEventKey *event, YMGA_GCBTable *pThis);
154 
155  static gint tree_sort_cb (GtkTreeModel *model, GtkTreeIter *a, GtkTreeIter *b, gpointer _index);
156 
157 // YGLABEL_WIDGET_IMPL (YTable)
158 // YGSELECTION_WIDGET_IMPL (YTable)
159  YGLABEL_WIDGET_IMPL (YMGA_CBTable)
160  YGSELECTION_WIDGET_IMPL (YMGA_CBTable)
161 };
162 
163 
164 
165 
166 #endif // YQLabel_h