00001 #ifndef OglGui_SideBar_h
00002 #define OglGui_SideBar_h
00003
00004 #ifndef OglGui_Window_h
00005 #include "OglGui/Window.h"
00006 #endif
00007
00008 namespace OglGui
00009 {
00010
00011
00012
00013
00014 class SideBar : public Window
00015 {
00016 public:
00017
00018 SideBar(Window* parent, int wndSide=South, int size=24,
00019 int lMargin=0, int tMargin=0, int rMargin=0, int bMargin=0) :
00020 Window(parent, 0, 0, 20, 20)
00021 {
00022 Init(wndSide, size, lMargin, tMargin, rMargin, bMargin);
00023 }
00024
00025 enum WndSide {
00026 North = 1,
00027 East = 2,
00028 South = 4,
00029 West = 8
00030 };
00031
00032 void
00033 DoSideConnect(int wndSide, int size, int lM, int tM, int rM, int bM)
00034 {
00035 Window* parent = this->GetParent();
00036 int pW = parent->WndWidth();
00037 int pH = parent->WndHeight();
00038
00039 if (mSideConnect)
00040 delete mSideConnect;
00041
00042 mSideConnect = 0;
00043
00044 if (wndSide == North)
00045 {
00046 SetDimensions(lM, pH-size-tM, pW-lM-rM, size);
00047 mSideConnect = ConnectTo(parent, L2L | R2R | B2T | T2T | TPARENT);
00048 }
00049 if (wndSide == East)
00050 {
00051 SetDimensions(pW-size-rM, bM, size, pH-bM-tM);
00052 mSideConnect = ConnectTo(parent, L2R | R2R | B2B | T2T | TPARENT);
00053 }
00054 if (wndSide == South)
00055 {
00056 SetDimensions(lM, bM, pW-lM-rM, size);
00057 mSideConnect = ConnectTo(parent, L2L | R2R | B2B | T2B | TPARENT);
00058 }
00059 if (wndSide == West)
00060 {
00061 SetDimensions(lM, bM, size, pH-bM-tM);
00062 mSideConnect = ConnectTo(parent, L2L | R2L | B2B | T2T | TPARENT);
00063 }
00064 }
00065
00066 protected:
00067
00068 LayoutListener* mSideConnect;
00069
00070 private :
00071
00072 void
00073 Init(int wndSide, int size, int lM, int tM, int rM, int bM)
00074 {
00075 mSideConnect = 0;
00076 SetBorderType(BEV_ETCHED);
00077 DoSideConnect(wndSide, size, lM, tM, rM, bM);
00078 }
00079 };
00080
00081 }
00082 #endif