vdk 2.4.0
vdkcustom.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 VDKCUSTOM_H
28#define VDKCUSTOM_H
29#include <vdk/vdkobj.h>
30#include <vdk/value_sem_list.h>
31#include <vdk/vdkarray.h>
32#include <vdk/colors.h>
33#include <vdk/vdkprops.h>
34#ifndef _string_array_def
35#define _string_array_def
37#endif
43class Tuple: public StringArray
44{
45 int KeyIndex;
46 public:
52 Tuple(int n = 0, int key = 0): StringArray(n),KeyIndex(key) {}
53 virtual ~Tuple() {}
54 int operator <(Tuple& t)
55 {
56 return (*this)[KeyIndex] < t[KeyIndex];
57 }
58 int operator==(Tuple& t)
59 {
60 return (*this)[KeyIndex] == t[KeyIndex];
61 }
62
63};
64
65/*
66 */
95class VDKCustom: public VDKObject
96{
97 protected:
98 int select_connect,unselect_connect;
99 public:
100 // properties
104 VDKReadWriteValueProp<VDKCustom,GtkPolicyType> VPolicy;
108 VDKReadWriteValueProp<VDKCustom,GtkPolicyType> HPolicy;
112 VDKReadWriteValueProp<VDKCustom,GtkShadowType> BorderShadow;
118 VDKReadWriteValueProp<VDKCustom,int> RowHeight;
122 VDKReadWriteValueProp<VDKCustom,bool> AutoResize;
134 VDKReadWriteValueProp<VDKCustom,VDKRgb> SelectedForeground;
138 VDKReadWriteValueProp<VDKCustom,VDKRgb> UnselectedBackground;
142 VDKReadWriteValueProp<VDKCustom,VDKRgb> UnselectedForeground;
155 // int SelectedTitle;
156 VDKReadOnlyValueProp<VDKCustom,int> SelectedTitle;
157
158 protected:
159 GtkWidget* custom_widget;
160 int columns;
161 GtkSelectionMode mode;
162 virtual void ConnectSignals();
163 static void ColumnClick(GtkWidget* , gint column, gpointer s);
164 void SetRowHeight(int rh)
165 { gtk_clist_set_row_height(GTK_CLIST(custom_widget),rh); }
166 void SetAutoResize(bool flag);
167 GtkPolicyType GetVPolicy() { return VPolicy; }
168 GtkPolicyType GetHPolicy() { return HPolicy; }
169 //
170 void SetVPolicy(GtkPolicyType p)
171 {
172 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (widget),
173 HPolicy,
174 p);
175 }
176 void SetHPolicy(GtkPolicyType p)
177 {
178 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (widget),
179 p,
180 VPolicy);
181 }
182 void SetBorderShadow(GtkShadowType bs)
183 { gtk_clist_set_shadow_type (GTK_CLIST(custom_widget),bs); }
184
185 GtkShadowType GetBorderShadow() { return BorderShadow; }
186
187 virtual void SetBackground(VDKRgb color,
188 GtkStateType state = GTK_STATE_NORMAL);
189 // void SetSelectedBackground(VDKColor* bg);
190 void SetSelectedForeground(VDKRgb );
191 void SetUnselectedBackground(VDKRgb );
192 void SetUnselectedForeground(VDKRgb );
193 public:
194 VDKCustom(VDKForm* owner,
195 int columns = 1,
196 char **titles = NULL,
197 GtkSelectionMode mode = GTK_SELECTION_SINGLE);
198 virtual ~VDKCustom();
202 int ColumnClicked() { return SelectedTitle; }
206 GtkSelectionMode SelectionMode();
213 GtkWidget* CustomWidget() { return GTK_WIDGET(custom_widget); }
219 void ActiveTitle(int col, bool flag = true);
223 void ActiveTitles(bool flag = true);
228 void EnableTitles(bool flag = true);
232 void Freeze(){ gtk_clist_freeze(GTK_CLIST(custom_widget)); }
236 void Thaw() { gtk_clist_thaw(GTK_CLIST(custom_widget)); }
240 virtual void Clear() { gtk_clist_clear (GTK_CLIST(custom_widget)); }
244 int Size() { return GTK_CLIST(custom_widget)->rows; }
250 void ColumnSize(int col, int size);
256 void AutoResizeColumn(int col,bool flag);
257 /*
258 override VDKObject property set
259 */
260
261 virtual void SetForeground(VDKRgb, GtkStateType);
262 virtual void SetFont(VDKFont*);
263#ifdef USE_SIGCPLUSPLUS
264 public:
265 VDKSignal1<void, int> OnColumnClick;
266 protected:
267 static void make_gtksigc_connection(VDKCustom*);
268 private:
269 static void _handle_click_column(GtkWidget* wid, int col,
270 gpointer obj);
271
272#endif
273};
274#endif
275
276
Definition: vdkcustom.h:44
Tuple(int n=0, int key=0)
Definition: vdkcustom.h:52
provides a templatized array
Definition: vdkarray.h:73
This is a base class for derived VDKCustomList and VDKCustomTree Provides common functionalities for ...
Definition: vdkcustom.h:96
VDKReadWriteValueProp< VDKCustom, GtkPolicyType > VPolicy
Definition: vdkcustom.h:104
VDKReadWriteValueProp< VDKCustom, GtkPolicyType > HPolicy
Definition: vdkcustom.h:108
GtkSelectionMode SelectionMode()
Definition: vdkcustom.cc:197
void ActiveTitles(bool flag=true)
Definition: vdkcustom.cc:181
void AutoResizeColumn(int col, bool flag)
Definition: vdkcustom.cc:222
VDKReadWriteValueProp< VDKCustom, VDKRgb > UnselectedForeground
Definition: vdkcustom.h:142
VDKReadWriteValueProp< VDKCustom, VDKRgb > SelectedForeground
Definition: vdkcustom.h:134
virtual void SetForeground(VDKRgb, GtkStateType)
Definition: vdkcustom.cc:119
VDKReadWriteValueProp< VDKCustom, int > RowHeight
Definition: vdkcustom.h:118
void ActiveTitle(int col, bool flag=true)
Definition: vdkcustom.cc:170
void ColumnSize(int col, int size)
Definition: vdkcustom.cc:202
void EnableTitles(bool flag=true)
Definition: vdkcustom.cc:189
void Thaw()
Definition: vdkcustom.h:236
VDKObjectArray Titles
Definition: vdkcustom.h:151
virtual void Clear()
Definition: vdkcustom.h:240
int Size()
Definition: vdkcustom.h:244
int ColumnClicked()
Definition: vdkcustom.h:202
VDKReadWriteValueProp< VDKCustom, GtkShadowType > BorderShadow
Definition: vdkcustom.h:112
VDKReadWriteValueProp< VDKCustom, VDKRgb > UnselectedBackground
Definition: vdkcustom.h:138
VDKReadWriteValueProp< VDKCustom, bool > AutoResize
Definition: vdkcustom.h:122
virtual void SetFont(VDKFont *)
Definition: vdkcustom.cc:162
GtkWidget * CustomWidget()
Definition: vdkcustom.h:213
virtual void SetBackground(VDKRgb color, GtkStateType state=GTK_STATE_NORMAL)
Definition: vdkcustom.cc:99
VDKReadOnlyValueProp< VDKCustom, int > SelectedTitle
Definition: vdkcustom.h:156
void Freeze()
Definition: vdkcustom.h:232
Provides a raw font.
Definition: vdkfont.h:38
VDKForm widgets, generally the outermost widget container.
Definition: forms.h:69
Definition: vdkobj.h:141
GtkWidget * widget
Definition: vdkobj.h:241
Provides a simple RGB color structure.
Definition: vdkutils.h:38
provides a VDKValueList iterator
Definition: value_sem_list.h:180