#include <CSLayoutManager.h>
Inheritance diagram for CSLayoutManagerStackHorizontal:
Public Member Functions | |
virtual std::string | getType () |
CSLayoutManagerStackHorizontal () | |
virtual | ~CSLayoutManagerStackHorizontal () |
virtual int | getMinimumWidth (CSGrafikElement *element) |
virtual int | getMinimumHeight (CSGrafikElement *element) |
Static Public Attributes | |
const char * | CLASS = "CSLayoutManagerStackHorizontal" |
Protected Member Functions | |
virtual void | layoutElements () |
|
Definition at line 174 of file CSLayoutManager.h.
00174 {} |
|
Definition at line 175 of file CSLayoutManager.h.
00175 {} |
|
Only layout elements, which have position: POSITION_ORDER_LEFT, or POSITION_ORDER_RIGHT Only vertical Center / stretch allowed! (is must) Reimplemented from CSLayoutManager. Definition at line 795 of file CSLayoutManager.cpp. References CSGrafikElements, CSLayoutData::getCenteredVertical(), CSLayoutManager::getElements(), CSGrafikElement::getHeight(), CSLayoutManager::getHostingElement(), CSLayoutManager::getLayoutData(), CSGrafikElement::getLayoutManager(), CSLayoutManager::getMinimumHeight(), CSLayoutManager::getMinimumWidth(), CSLayoutData::getPackedHorizontal(), CSLayoutData::getPackedVertical(), CSLayoutData::getPosition(), CSLayoutData::getSpacing(), CSLayoutData::getStretchedHorizontal(), CSLayoutData::getStretchedVertical(), CSLayoutManager::getViewportHeight(), CSLayoutManager::getViewportWidth(), CSGrafikElement::getVisible(), CSGrafikElement::getWidth(), POSITION_ORDER_LEFT, POSITION_ORDER_RIGHT, and CSLayoutManager::setLayout().
00796 { 00797 CSGrafikElement *host = getHostingElement(); 00798 if (host == 0) 00799 { 00800 return; 00801 } 00802 CSGrafikElements *elements = getElements(host); 00803 00804 int verticalSpacing; 00805 int horizontalSpacing; 00806 CSLayoutData *layoutData = getLayoutData(host); 00807 layoutData->getSpacing(verticalSpacing, horizontalSpacing); 00808 int width; 00809 int height; 00810 width = getViewportWidth(host); 00811 height = getViewportHeight(host); 00812 00813 int x; 00814 int y = 0; 00815 int w, h; 00816 int stretchCounter = 0; 00817 int nonStretchSize = 0; 00818 00819 int packCounter = 0; 00820 int packSize = 0; 00821 00822 int verticalMinimum = 0; 00823 int horizontalMinimum = 0; 00824 int horizontalSpacingCollect = 0; 00825 int count = 0; 00826 CSGrafikElements::iterator iter = elements->begin(); 00827 while (iter != elements->end()) 00828 { 00829 CSGrafikElement *visitor = *iter; 00830 if (!visitor->getVisible()) 00831 { 00832 iter++; 00833 continue; 00834 } 00835 CSLayoutData *visitorLayoutData = getLayoutData(visitor); 00836 w = visitor->getWidth(); 00837 if (visitorLayoutData->getStretchedHorizontal()) 00838 { 00839 stretchCounter++; 00840 } 00841 else if (visitorLayoutData->getPackedHorizontal()) 00842 { 00843 packSize += visitor->getLayoutManager()->getMinimumWidth(visitor); 00844 } 00845 else 00846 { 00847 nonStretchSize += w; 00848 } 00849 00850 horizontalMinimum += visitor->getLayoutManager()->getMinimumWidth(visitor); 00851 00852 if (verticalMinimum < visitor->getLayoutManager()->getMinimumHeight(visitor)) 00853 { 00854 verticalMinimum = visitor->getLayoutManager()->getMinimumHeight(visitor); 00855 } 00856 00857 if (count != 0) 00858 { 00859 horizontalMinimum += horizontalSpacing; 00860 horizontalSpacingCollect += horizontalSpacing; 00861 if (visitorLayoutData->getPackedHorizontal()) 00862 { 00863 packSize += horizontalSpacing; 00864 } 00865 } 00866 count++; 00867 iter++; 00868 } 00869 00870 if (height < verticalMinimum) 00871 { 00872 height = verticalMinimum; 00873 } 00874 if (width < horizontalMinimum) 00875 { 00876 width = horizontalMinimum; 00877 } 00878 int oneStretchedSize = 0; 00879 int xMax; 00880 int xMin; 00881 xMin = getViewportWidth(host); 00882 xMax = 0; 00883 if (stretchCounter) 00884 { 00885 oneStretchedSize = (width-horizontalSpacingCollect-nonStretchSize-packSize) / stretchCounter; 00886 } 00887 int stretchCounterNew = 0; 00888 count = 0; 00889 int leftCount = 0; 00890 int rightCount = 0; 00891 iter = elements->begin(); 00892 while (iter != elements->end()) 00893 { 00894 CSGrafikElement *visitor = *iter; 00895 if (!visitor->getVisible()) 00896 { 00897 iter++; 00898 continue; 00899 } 00900 CSLayoutData *visitorLayoutData = getLayoutData(visitor); 00901 y = 0; 00902 w = visitor->getWidth(); 00903 h = visitor->getHeight(); 00904 if (visitorLayoutData->getStretchedHorizontal()) 00905 { 00906 w = oneStretchedSize; 00907 stretchCounterNew++; 00908 if (stretchCounterNew < (width-horizontalSpacingCollect-nonStretchSize-packSize) - oneStretchedSize * stretchCounter) 00909 { 00910 w++; 00911 } 00912 } 00913 else if (visitorLayoutData->getPackedHorizontal()) 00914 { 00915 if (visitorLayoutData->getPosition() == POSITION_ORDER_LEFT) 00916 { 00917 w = visitor->getLayoutManager()->getMinimumWidth(visitor); 00918 } 00919 if (visitorLayoutData->getPosition() == POSITION_ORDER_RIGHT) 00920 { 00921 w = visitor->getLayoutManager()->getMinimumWidth(visitor); 00922 } 00923 } 00924 else 00925 { 00926 // minimum even if not packed! 00927 int w2 = visitor->getLayoutManager()->getMinimumWidth(visitor); 00928 if (w2 > w) 00929 { 00930 w = w2; 00931 } 00932 00933 } 00934 00935 if (visitorLayoutData->getStretchedVertical()) 00936 { 00937 h = height; 00938 } 00939 else if (visitorLayoutData->getPackedVertical()) 00940 { 00941 h = visitor->getLayoutManager()->getMinimumHeight(visitor); 00942 } 00943 else 00944 { 00945 // minimum even if not packed! 00946 int h2 = visitor->getLayoutManager()->getMinimumHeight(visitor); 00947 if (h2 > h) 00948 { 00949 h = h2; 00950 } 00951 } 00952 if (visitorLayoutData->getCenteredVertical()) 00953 { 00954 y = height/2 - h/2; 00955 } 00956 if (visitorLayoutData->getPosition() == POSITION_ORDER_LEFT) 00957 { 00958 if (leftCount != 0) 00959 { 00960 xMax += horizontalSpacing; 00961 } 00962 leftCount++; 00963 x = xMax; 00964 xMax += w; 00965 } 00966 else if (visitorLayoutData->getPosition() == POSITION_ORDER_RIGHT) 00967 { 00968 if (rightCount != 0) 00969 { 00970 xMin -= horizontalSpacing; 00971 } 00972 rightCount++; 00973 xMin -= w; 00974 x = xMin; 00975 } 00976 else // centered if (visitorLayoutData->getCenteredVertical()) 00977 { 00978 x = width/2 - w/2; 00979 } 00980 setLayout(visitor, x, y, w, h); 00981 count++; 00982 iter++; 00983 } 00984 } |
Here is the call graph for this function:
|
Reimplemented from CSLayoutManager. Definition at line 173 of file CSLayoutManager.h. References CLASS.
00173 {return (std::string) CLASS;} |
|
Implements CSLayoutManager. Definition at line 1456 of file CSLayoutManager.cpp. References CSGrafikElements, CSLayoutManager::getBorderWidth(), CSLayoutManager::getElements(), CSLayoutManager::getInsetWidth(), CSLayoutManager::getLayoutData(), CSGrafikElement::getLayoutManager(), CSLayoutManager::getMinimumWidth(), CSLayoutManager::getMinWidth(), CSLayoutData::getSpacing(), and CSGrafikElement::getVisible().
01457 { 01458 if (element == 0) 01459 { 01460 return 0; 01461 } 01462 if (!element->getVisible()) 01463 { 01464 return 0; 01465 } 01466 int width = getMinWidth(element); 01467 CSGrafikElements *elements = getElements(element); 01468 01469 int verticalSpacing; 01470 int horizontalSpacing; 01471 01472 CSLayoutData *layoutData = getLayoutData(element); 01473 layoutData->getSpacing(verticalSpacing, horizontalSpacing); 01474 01475 if (!elements == 0) 01476 { 01477 int neededWidth = 0; 01478 int count = 0; 01479 CSGrafikElements::iterator iter = elements->begin(); 01480 while (iter != elements->end()) 01481 { 01482 CSGrafikElement *visitor = *iter; 01483 if (!visitor->getVisible()) 01484 { 01485 iter++; 01486 continue; 01487 } 01488 CSLayoutData *visitorLayoutData = getLayoutData(visitor); 01489 01490 int visitorWidth = visitor->getLayoutManager()->getMinimumWidth(visitor); 01491 if (count != 0) 01492 { 01493 visitorWidth += horizontalSpacing; 01494 } 01495 01496 neededWidth += visitorWidth; 01497 iter++; 01498 count++; 01499 } 01500 if (neededWidth > width) 01501 { 01502 width = neededWidth; 01503 } 01504 } 01505 width += getInsetWidth(element) + getBorderWidth(element); 01506 return width; 01507 } |
Here is the call graph for this function:
|
Implements CSLayoutManager. Definition at line 1186 of file CSLayoutManager.cpp. References CSGrafikElements, CSLayoutManager::getBorderHeight(), CSLayoutManager::getElements(), CSLayoutManager::getInsetHeight(), CSGrafikElement::getLayoutManager(), CSLayoutManager::getMinHeight(), CSLayoutManager::getMinimumHeight(), and CSGrafikElement::getVisible().
01187 { 01188 if (element == 0) 01189 { 01190 return 0; 01191 } 01192 if (!element->getVisible()) 01193 { 01194 return 0; 01195 } 01196 int height = getMinHeight(element); 01197 CSGrafikElements *elements = getElements(element); 01198 01199 if (!elements == 0) 01200 { 01201 CSGrafikElements::iterator iter = elements->begin(); 01202 while (iter != elements->end()) 01203 { 01204 int neededHeight; 01205 CSGrafikElement *visitor = *iter; 01206 neededHeight = visitor->getLayoutManager()->getMinimumHeight(visitor); 01207 01208 if (height < neededHeight) 01209 { 01210 height = neededHeight; 01211 } 01212 iter++; 01213 } 01214 } 01215 height += getInsetHeight(element) + getBorderHeight(element); 01216 return height; 01217 } |
Here is the call graph for this function:
|
Reimplemented from CSLayoutManager. Definition at line 11 of file CSLayoutManager.cpp. Referenced by getType(). |