00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef __AUTORESIZE_TREEVIEW_H
00022 #define __AUTORESIZE_TREEVIEW_H
00023
00024 #include <QTreeView>
00025 #include <QResizeEvent>
00026
00027 #include <iostream>
00028
00029 class gf_AutoResizeTreeView : public QTreeView
00030 {
00031 public:
00032 enum gf_growDirection {gf_GD_NONE =0, gf_GD_WIDTH =1, gf_GD_HEIGHT=2, gf_GD_BOTH=3};
00033 enum gf_growPolicy {gf_GP_NONE =0, gf_GP_GREEDY = 1, gf_GP_FRIENDLY = 2, gf_GP_STAGGERED = 4};
00034 enum gf_status {gf_S_NORMAL, gf_S_GROWING, gf_S_SHRINKING, gf_S_GROWN, gf_S_SHRUNK};
00035
00036 private:
00037 gf_AutoResizeTreeView * gf_twin;
00038 gf_growDirection gf_gd;
00039 gf_growPolicy gf_gp;
00040 gf_status status;
00041 int gf_friendlyMin;
00042 int gf_shrinkToWidth;
00043 int gf_shrinkToHeight;
00044 bool gf_hold;
00045
00046
00047 public:
00048 gf_AutoResizeTreeView (QWidget * parent = 0);
00049 void focusInEvent ( QFocusEvent * event );
00050 void focusOutEvent ( QFocusEvent * event );
00051 inline void setTwin(gf_AutoResizeTreeView * pTwin){gf_twin = pTwin;}
00052 inline void setGrowDirection(gf_growDirection dirn){gf_gd = dirn;}
00053 void storeSize();
00054 void restoreSize();
00055 void setStatus(gf_status s){status = s;}
00056 gf_status getStatus(){return status;}
00057
00058 inline void growWidth(int w){if (w>0) resize(width() +w,height());}
00059 inline void growHeight(int h){if (h>0) resize(width(),height() +h);}
00060 protected:
00061 virtual void resizeEvent(QResizeEvent * event);
00062
00063 private:
00064 void selectGrow();
00065 void grow(int smallWidth, int smallHeight);
00066 void staggeredGrow();
00067 void shrink();
00068 };
00069
00070 #endif