vdk 2.4.0
vdkclist.h
1 /*
2  * ===========================
3  * VDK Visual Development Kit
4  * Version 0.5
5  * November 1998
6  * ===========================
7  *
8  * Copyright (C) 1998, Mario Motta
9  * Developed by Mario Motta <mmotta@guest.net>
10  *
11  * This library is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU Library General Public
13  * License as published by the Free Software Foundation; either
14  * version 2 of the License, or (at your option) any later version.
15  *
16  * This library is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19  * Library General Public License for more details.
20  *
21  * You should have received a copy of the GNU Library General Public
22  * License along with this library; if not, write to the Free Software
23  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
24  * 02111-130
25  */
26 
27 #ifndef VDKCLIST_H
28 #define VDKCLIST_H
29 #include <vdk/vdkcustom.h>
30 //#include <vector>
31 //#include <string>
32 /*
33  */
34 class VDKCustomList;
35 
36 typedef VDKReadWriteValueProp<VDKCustomList,VDKPoint>
37  CustomListSelProperty;
38 
39 class SelectionProp: public CustomListSelProperty
40 {
41  public:
42  SelectionProp(
43  char* name,
44  VDKCustomList* object,
45  VDKPoint defValue,
46  void (VDKCustomList::*write)(VDKPoint),
47  VDKPoint (VDKCustomList::*read)(void) =
48  (VDKPoint (VDKCustomList::*)(void)) NULL
49  ):CustomListSelProperty(name,object,defValue,write,read)
50  { }
51 
52  int Row()const { return Value().X();}
53  int Col()const { return Value().Y();}
54 
55 };
56 
98 class VDKCustomList: public VDKCustom
99 {
100 
101  protected:
102  VDKIntArray WideSelection;
103  VDKPoint selection, unselection; // selected row,column
104  // extended selection
105  int pointer;
106  // wide selection
107  int start,end;
108  void _update_pix(int row,const char* s, char** pixdata = NULL, int col = 0);
109  void _update_size(int row,int *W, int *H);
110  void SetStyle(int row);
111  void ConnectSignals();
112  // handle title clicks
113  static void ColumnClick(GtkWidget* w,
114  gint column,
115  gpointer s);
116 
117  // handle selection in modes != EXTENDED
118  static int RowSelection(GtkWidget *wid,
119  gint row,
120  gint column,
121  GdkEvent *event,
122  gpointer data);
123  static int RowUnselection(GtkWidget *wid,
124  gint row,
125  gint column,
126  GdkEventButton *event,
127  gpointer data);
128 
129 
130  public:
131  // properties
136  SelectionProp Selected;
141  SelectionProp Unselected;
153 
154  public:
161  VDKCustomList(VDKForm* owner,
162  int columns = 1,
163  char **titles = NULL,
164  GtkSelectionMode mode = GTK_SELECTION_SINGLE);
168  virtual ~VDKCustomList();
169  //void AddRow(vector<string> v, char** pixdata = NULL, int col = 0);
176  void AddRow(char **texts, char** pixdata = NULL, int col = 0);
183  void UpdateRow(int row, char** s,
184  char** pixdata = NULL, int col = 0);
188  void UpdateRow(int row, Tuple& t,
189  char** pixdata = NULL, int col = 0);
197  void UpdateCell(int row, int col,
198  const char* s, char** pixdata = NULL);
203  void RemoveRow(int row);
207  VDKPoint Selection() { return selection; }
211  VDKPoint Unselection() { return unselection; }
217  void SelectRow(int row, int col);
222  void SelectRow(VDKPoint p) { SelectRow(p.X(),p.Y()); }
228  void UnselectRow(int row, int col);
233  void UnselectRow(VDKPoint p) { UnselectRow(p.X(),p.Y()); }
234 
235  virtual void Clear();
242 #ifdef USE_SIGCPLUSPLUS
243  public:
250  VDKSignal2<void, int, int> OnRowSelect;
257  VDKSignal2<void, int, int> OnRowUnselect;
264  VDKSignal2<void, int, int> OnRowMove;
265 
266 // VDKSignal2<void, int, const char**> OnRowInsert;
267 // VDKSignal1<void, int> OnRowRemove;
268  protected:
269  static void make_gtksigc_connection(VDKCustomList*);
270  private:
271  static void _handle_row_move(GtkWidget* wid, int, int,
272  gpointer obj);
273 // static void _handle_row_insert(GtkWidget* wid, int, char**,
274 // gpointer obj);
275 // static void _handle_row_remove(GtkWidget* wid, int row,
276 // gpointer obj);
277 #endif /* USE_SIGCPLUSPLUS */
278 };
279 #endif
280 
void AddRow(char **texts, char **pixdata=NULL, int col=0)
Definition: vdkclist.cc:223
void UpdateCell(int row, int col, const char *s, char **pixdata=NULL)
Definition: vdkclist.cc:294
void UnselectRow(VDKPoint p)
Definition: vdkclist.h:233
void UpdateRow(int row, char **s, char **pixdata=NULL, int col=0)
Definition: vdkclist.cc:261
void UnselectRow(int row, int col)
Definition: vdkclist.cc:352
virtual ~VDKCustomList()
Definition: vdkclist.cc:185
SelectionProp Unselected
Definition: vdkclist.h:141
VDKForm widgets, generally the outermost widget container.
Definition: forms.h:68
This class wraps gtkclist widget.
Definition: vdkclist.h:98
void SelectRow(VDKPoint p)
Definition: vdkclist.h:222
VDKCustomList(VDKForm *owner, int columns=1, char **titles=NULL, GtkSelectionMode mode=GTK_SELECTION_SINGLE)
Definition: vdkclist.cc:96
Definition: vdkcustom.h:43
Provides a simple point object.
Definition: vdkutils.h:94
void SelectRow(int row, int col)
Definition: vdkclist.cc:337
virtual void Clear()
Definition: vdkclist.cc:386
void RemoveRow(int row)
Definition: vdkclist.cc:307
SelectionProp Selected
Definition: vdkclist.h:136
This is a base class for derived VDKCustomList and VDKCustomTree Provides common functionalities for ...
Definition: vdkcustom.h:95
VDKIntArray & Selections()
Definition: vdkclist.cc:359
TupleList Tuples
Definition: vdkclist.h:152
VDKPoint Selection()
Definition: vdkclist.h:207
VDKPoint Unselection()
Definition: vdkclist.h:211