00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
#ifndef VDKCUSTOM_H
00028
#define VDKCUSTOM_H
00029
#include <vdk/vdkobj.h>
00030
#include <vdk/value_sem_list.h>
00031
#include <vdk/vdkarray.h>
00032
#include <vdk/colors.h>
00033
#include <vdk/vdkprops.h>
00034
#ifndef _string_array_def
00035
#define _string_array_def
00036
typedef VDKArray<VDKString> StringArray;
00037
#endif
00038
00043 class Tuple:
public StringArray
00044 {
00045
int KeyIndex;
00046
public:
00052 Tuple(
int n = 0,
int key = 0): StringArray(n),KeyIndex(key) {}
00053
virtual ~
Tuple() {}
00054
int operator <(
Tuple& t)
00055 {
00056
return (*this)[KeyIndex] < t[KeyIndex];
00057 }
00058
int operator==(
Tuple& t)
00059 {
00060
return (*this)[KeyIndex] == t[KeyIndex];
00061 }
00062
00063 };
00064
00065
00066
00067
typedef VDKValueList<Tuple> TupleList;
00068
typedef VDKValueListIterator<Tuple> TupleListIterator;
00069
typedef VDKArray<VDKObject*> VDKObjectArray;
00070
typedef VDKArray<int> VDKIntArray;
00095 class VDKCustom:
public VDKObject
00096 {
00097
protected:
00098
int select_connect,unselect_connect;
00099
public:
00100
00104 VDKReadWriteValueProp<VDKCustom,GtkPolicyType>
VPolicy;
00108 VDKReadWriteValueProp<VDKCustom,GtkPolicyType>
HPolicy;
00112 VDKReadWriteValueProp<VDKCustom,GtkShadowType>
BorderShadow;
00118 VDKReadWriteValueProp<VDKCustom,int>
RowHeight;
00122 VDKReadWriteValueProp<VDKCustom,bool>
AutoResize;
00134 VDKReadWriteValueProp<VDKCustom,VDKRgb>
SelectedForeground;
00138 VDKReadWriteValueProp<VDKCustom,VDKRgb>
UnselectedBackground;
00142 VDKReadWriteValueProp<VDKCustom,VDKRgb>
UnselectedForeground;
00151 VDKObjectArray
Titles;
00155
00156 VDKReadOnlyValueProp<VDKCustom,int>
SelectedTitle;
00157
00158
protected:
00159 GtkWidget* custom_widget;
00160
int columns;
00161 GtkSelectionMode mode;
00162
virtual void ConnectSignals();
00163
static void ColumnClick(GtkWidget* , gint column, gpointer s);
00164
void SetRowHeight(
int rh)
00165 { gtk_clist_set_row_height(GTK_CLIST(custom_widget),rh); }
00166
void SetAutoResize(
bool flag);
00167 GtkPolicyType GetVPolicy() {
return VPolicy; }
00168 GtkPolicyType GetHPolicy() {
return HPolicy; }
00169
00170
void SetVPolicy(GtkPolicyType p)
00171 {
00172 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (widget),
00173 HPolicy,
00174 p);
00175 }
00176
void SetHPolicy(GtkPolicyType p)
00177 {
00178 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (widget),
00179 p,
00180 VPolicy);
00181 }
00182
void SetBorderShadow(GtkShadowType bs)
00183 { gtk_clist_set_shadow_type (GTK_CLIST(custom_widget),bs); }
00184
00185 GtkShadowType GetBorderShadow() {
return BorderShadow; }
00186
00187
virtual void SetBackground(
VDKRgb color,
00188 GtkStateType state = GTK_STATE_NORMAL);
00189
00190
void SetSelectedForeground(
VDKRgb );
00191
void SetUnselectedBackground(
VDKRgb );
00192
void SetUnselectedForeground(
VDKRgb );
00193
public:
00194
VDKCustom(
VDKForm* owner,
00195
int columns = 1,
00196
char **titles = NULL,
00197 GtkSelectionMode mode = GTK_SELECTION_SINGLE);
00198
virtual ~
VDKCustom();
00202 int ColumnClicked() {
return SelectedTitle; }
00206 GtkSelectionMode
SelectionMode();
00213 GtkWidget*
CustomWidget() {
return GTK_WIDGET(custom_widget); }
00219
void ActiveTitle(
int col,
bool flag =
true);
00223
void ActiveTitles(
bool flag =
true);
00228
void EnableTitles(
bool flag =
true);
00232 void Freeze(){ gtk_clist_freeze(GTK_CLIST(custom_widget)); }
00236 void Thaw() { gtk_clist_thaw(GTK_CLIST(custom_widget)); }
00240 virtual void Clear() { gtk_clist_clear (GTK_CLIST(custom_widget)); }
00244 int Size() {
return GTK_CLIST(custom_widget)->rows; }
00250
void ColumnSize(
int col,
int size);
00256
void AutoResizeColumn(
int col,
bool flag);
00257
00258
00259
00260
00261
virtual void SetForeground(
VDKRgb, GtkStateType);
00262
virtual void SetFont(
VDKFont*);
00263
#ifdef USE_SIGCPLUSPLUS
00264
public:
00265 VDKSignal1<void, int> OnColumnClick;
00266
protected:
00267
static void make_gtksigc_connection(
VDKCustom*);
00268
private:
00269
static void _handle_click_column(GtkWidget* wid,
int col,
00270 gpointer obj);
00271
00272
#endif
00273
};
00274
#endif
00275
00276