Main Page | Namespace List | Class Hierarchy | Alphabetical List | Data Structures | File List | Data Fields | Globals | Related Pages

CSBar.cpp

Go to the documentation of this file.
00001 #ifdef WIN32
00002 #pragma warning(disable : 4786 )
00003 #endif
00004 
00005 #include "CSBar.h"
00006 #include "CSBorder.h"
00007 #include "CSDesktop.h"
00008 
00009 const char *CSBar::CLASS = "CSBar";
00010 /** Create a new \a CSBar.
00011     CSBar are not viewported!<BR>
00012     If \a autoPlacing is enabled the to be added elements are positioned automatically.
00013     If bar is of type TYPE_HORIZONTAL, they are added from left to right (centered vertically).
00014     If bar is of type TYPE_VERTICAL, they are added from upper to lower (centered horizontally.
00015 
00016     \param type either \a TYPE_HORIZONTAL or \a TYPE_VERTICAL
00017     \param autoPlacing true if components are to be placed automatically (by CSBAR)
00018 */
00019 CSBar::CSBar(int type) : CSGrafikElement(0, 0)
00020 {
00021     static char *functionName="CSBar";
00022     LOG_ENTER 
00023     mAutoPlacingType = type;
00024     initBar();
00025     LOG_EXIT
00026 }
00027 
00028 CSBar::~CSBar()
00029 {
00030     static char *functionName="~CSBar";
00031 }
00032 
00033 void CSBar::initBar()
00034 {
00035     static char *functionName="initBar";
00036     LOG_ENTER 
00037     if (mAutoPlacingType == TYPE_HORIZONTAL)
00038     {
00039         CSLayoutData layout;
00040         setLayoutManager(new CSLayoutManagerStackHorizontal());
00041         layout.setPosition(POSITION_ORDER_TOP);
00042         layout.setPackedVertical(true);
00043         layout.setStretchedHorizontal(true);
00044         layout.setSpacing(0,2);
00045         setLayoutData(layout);
00046         setInset(CSInset(0,0,1,1));
00047     }
00048     else
00049     {
00050         CSLayoutData layout;
00051         setLayoutManager(new CSLayoutManagerStackVertical());
00052         layout.setPosition(POSITION_ORDER_LEFT);
00053         layout.setPackedHorizontal(true);
00054         layout.setStretchedVertical(true);
00055         layout.setSpacing(2,0);
00056         setLayoutData(layout);
00057         setInset(CSInset(1));
00058     }
00059     LOG_EXIT
00060 }
00061 
00062 //! the added element will be freed by this instance of Bar
00063 //! first pos is 0
00064 void CSBar::addElementAt(CSGrafikElement *element, int place)
00065 {
00066     static char *functionName="addElementAt";
00067     LOG_ENTER 
00068         
00069     CSGrafikElements elements;
00070 
00071     CSGrafikElements::iterator iter = mElements.begin();
00072     while (iter != mElements.end())
00073     {
00074         CSGrafikElement *element = *iter;
00075         elements.push_back(element);
00076         removeElement(element);
00077         iter = mElements.begin();
00078     }
00079 
00080     iter = elements.begin();
00081     int count=0;
00082     CSLayoutData layoutData;
00083     if (mAutoPlacingType == TYPE_HORIZONTAL)
00084     {
00085         layoutData = CSLayoutData(POSITION_WEST);
00086     }
00087     else
00088     {
00089         layoutData = CSLayoutData(POSITION_NORTH);
00090     }
00091     layoutData.setSpacing(getVerticalElementSpacing(), getHorizontalElementSpacing());
00092 
00093     while (iter != elements.end())
00094     {
00095         CSGrafikElement *oldElement = *iter;
00096         if (count == place)
00097         {
00098             element->setLayoutData(layoutData);
00099             addElement(element);
00100         }
00101         oldElement->setLayoutData(layoutData);
00102         addElement(oldElement); 
00103         count++;
00104         iter++;
00105     }
00106     if (count <= place)
00107     {
00108         element->setLayoutData(layoutData);
00109         addElement(element);
00110     }
00111     LOG_EXIT
00112 }
00113 
00114 void CSBar::layoutSetupBar()
00115 {
00116     static char *functionName="layoutSetupBar";
00117     LOG_ENTER 
00118     LOG_EXIT
00119 }
00120 
00121 

Generated on Wed Jul 14 00:43:28 2004 for CSLib by doxygen 1.3.6