Main Page | Class Hierarchy | Class List | Directories | File List | Class Members | Related Pages

autoResizeTreeView.h

00001 /***************************************************************************
00002  *   Copyright (C) 2006 by Graeme Foster                                   *
00003  *   email    foster.graeme@gmail.com                                      *
00004  *                                                                         *
00005  *   This program is free software; you can redistribute it and/or modify  *
00006  *   it under the terms of the GNU General Public License as published by  *
00007  *   the Free Software Foundation; either version 2 of the License, or     *
00008  *   (at your option) any later version.                                   *
00009  *                                                                         *
00010  *   This program is distributed in the hope that it will be useful,       *
00011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00013  *   GNU General Public License for more details.                          *
00014  *                                                                         *
00015  *   You should have received a copy of the GNU General Public License     *
00016  *   along with this program; if not, write to the                         *
00017  *   Free Software Foundation, Inc.,                                       *
00018  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
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: // Enumerated types
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: // member variables
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: // member functions
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: // member functions
00064         void selectGrow();
00065         void grow(int smallWidth, int smallHeight);
00066         void staggeredGrow();
00067         void shrink();
00068 };
00069 
00070 #endif

Generated on Thu Apr 6 16:27:17 2006 for time-table by  doxygen 1.4.4