00001 // **************************************************************************** 00002 // copyright (c) 2000-2005 Horst Knorr <hk_classes@knoda.org> 00003 // This file is part of the hk_classes library. 00004 // This file may be distributed and/or modified under the terms of the 00005 // GNU Library Public License version 2 as published by the Free Software 00006 // Foundation and appearing in the file COPYING included in the 00007 // packaging of this file. 00008 // This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 00009 // WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 00010 // **************************************************************************** 00011 #ifndef HK_DSGRID 00012 #define HK_DSGRID 00013 #include "hk_dsvisible.h" 00014 #include "hk_dsgridcolumn.h" 00015 #include <vector> 00016 #include <list> 00017 using namespace std; 00018 class hk_column; 00026 class hk_dsgrid:public hk_dsvisible 00027 { 00028 friend class hk_dsgridcolumn; 00029 public: 00030 hk_dsgrid(hk_form* form=NULL ); 00031 virtual ~hk_dsgrid(void); 00036 hk_dsgridcolumn* gridcolumn(unsigned int c); 00040 unsigned int columnscount(void); 00046 void set_gridcolumnwidth(unsigned int col,int newwidth); 00052 void change_columnposition(unsigned int from,unsigned int to); 00057 void set_gridcolumns(vector<hk_dsgridcolumn>& c,bool registerchange=true); 00062 void set_gridcolumns(list<hk_string>&sl); 00063 void clear_gridcolumn(void); 00069 void set_hold_rowdefinition(bool h=true); 00076 void set_enablingbehaviour(bool add_col,bool del_col); 00077 // bool save_grid(const hk_string& name="",bool ask=true); 00078 virtual void savedata(ostream& s,bool saveall); 00079 virtual void savedata(ostream&s ); 00080 virtual void loaddata(const hk_string& definition); 00081 virtual void set_datasource(hk_datasource*); 00082 list <hk_string>* visible_columns(void); 00083 list <hk_string>* nonvisible_columns(void); 00084 bool save_table(const hk_string& s="",bool ask=true); 00085 bool load_table(void); 00086 bool save_view(const hk_string& s="",bool ask=true); 00087 bool load_view(void); 00088 void set_rowheight(int,bool registerchange=true); 00089 int rowheight(void); 00090 00091 00092 00093 00094 protected: 00095 bool datasource_enable(void); 00096 bool datasource_disable(void); 00097 bool columns_new_created(void); 00098 virtual void before_store_changed_data(void); 00099 virtual bool table_structure_changes(void); 00100 virtual void widget_specific_columns_created(void){} 00101 virtual void widget_specific_rowheight_changes(void){} 00102 00103 00104 00105 private: 00106 00107 void delete_nonexisting_columns(void); 00108 void add_new_columns(void); 00109 void clear_cols(void); 00110 void resize_cols(int n); 00111 vector<hk_dsgridcolumn*> p_cols; 00112 bool p_automatic_columns; 00113 bool p_delete_nonexisting_columns; 00114 bool p_add_new_columns; 00115 bool p_holdrowdefinition; 00116 int p_rowheight; 00117 list<hk_string> p_visiblecols; 00118 list<hk_string> p_nonvisiblecols; 00119 }; 00120 #endif