Home || Architecture || Video Search || Visual Search || Scripts || Applications || Important Messages || OGL || Src

ColumnHeaders.h

Go to the documentation of this file.
00001 //345678901234567890123456789012345678901234567890123456789012345678901234567890
00002 // ColumnHeaders.h
00003 // Author: Richard van Balen
00004 
00005 #ifndef OglGui_ColumnHeaders_h
00006 #define OglGui_ColumnHeaders_h
00007 
00008 #ifndef OglGui_SizableStaticText_h
00009 #include "OglGui/SizableStaticText.h"
00010 #endif
00011 
00012 namespace OglGui {
00013 
00014 class ColumnHeaders : public Window,
00015                       public WindowListener
00016 {
00017 public:
00018     ColumnHeaders(Window* parent, int w, int h) :
00019         Window(parent,w,h)
00020     {
00021         Init(120,h);
00022     }
00023 
00024     ColumnHeaders(Window* parent,int x,int y,int w,int h) :
00025         Window(parent,x,y,w,h)
00026     {
00027         Init(120,h);
00028     }
00029 
00030     SizableStaticText*
00031     CreateHeader(strconst title, int labelW = -1)
00032     {
00033         if (labelW == -1)
00034             labelW = mLabelWidth;
00035 
00036         int x = 0;
00037         if (mHeaders.size()!=0)
00038         {
00039             SizableStaticText* curHdr = mHeaders[mHeaders.size()-1];
00040             x = curHdr->X() + curHdr->W();
00041         }
00042         SizableStaticText* colHdr;
00043         colHdr = MakeHeader(this,x,0,labelW,mLabelHeight,title);
00044         if (x!=0)
00045         {
00046             LayoutListener* l;
00047             l = colHdr->ConnectTo(mHeaders[mHeaders.size()-1],L2R|R2R);
00048             mLayoutListeners.push_back(l);
00049             colHdr->SetWindowListener(this, (void*)(mLayoutListeners.size()-1));
00050         }
00051         mHeaders.push_back(colHdr);
00052         return colHdr;
00053     }
00054 
00056 // Getters/Setters
00057     SizableStaticText* Header(int idx)
00058     {
00059         if (idx<0 || idx>mHeaders.size()-1)
00060             return 0;
00061         return mHeaders[idx];
00062     }
00063 
00064     SizableStaticText* Header(strconst str)
00065     {
00066         for (int i=0; i<mHeaders.size(); i++)
00067             if (mHeaders[i]->GetText() == str)
00068                 return Header(i);
00069         return 0;
00070     }
00071 
00073 // Listeners
00074     virtual void
00075     WindowMouseEvent(Window *src, int msg, int but, int state,
00076                      int x, int y, void* userData )
00077     {
00078         if (msg == oglMouseUp)
00079         {
00080             int idx = (long long) userData;
00081             delete mLayoutListeners[idx];
00082             mLayoutListeners[idx] =
00083                 mHeaders[idx+1]->ConnectTo(mHeaders[idx],L2R|R2R);
00084         }
00085     }
00086 
00087 protected:
00088     SizableStaticText*
00089     MakeHeader(Window* parent, int x, int y, int w, int h, strconst title)
00090     {
00091         SizableStaticText* colHdr
00092             = new SizableStaticText(parent,x,y,w,h,title);
00093         StaticText* txt = colHdr->GetStaticText();
00094         txt->SetAlign(oglLeftAlign, oglCenterAlign);
00095         txt->SetAlignOffsets(4,0);
00096 
00097         colHdr->SetAllowMove(false);
00098         colHdr->SetAllowHighlight(false);
00099         colHdr->SetBorderType(BEV_RAISED);
00100         colHdr->SetHighLightBorderType(BEV_RAISED);
00101         colHdr->SetAllowSizeDirections(SizableWindow::AllDir,false);
00102         colHdr->SetAllowSizeDirections(SizableWindow::East,true);
00103         return colHdr;
00104     }
00105 
00106 private:
00107     void Init(int labelW, int labelH)
00108     {
00109         mLabelWidth  = labelW;
00110         mLabelHeight = labelH;
00111         SetBorderType(BEV_ETCHED);
00112     }
00113 
00114     std::vector<LayoutListener*>    mLayoutListeners;
00115     std::vector<SizableStaticText*> mHeaders;
00116 
00117     int                             mLabelWidth;
00118     int                             mLabelHeight;
00119 };
00120 
00121 } // Namespace OglGui
00122 #endif
00123 

Generated on Fri Mar 19 09:31:34 2010 for ImpalaSrc by  doxygen 1.5.1