#include <CSLayoutManager.h>
Inheritance diagram for CSLayoutManagerBorder:
Definition at line 197 of file CSLayoutManager.h.
Public Member Functions | |
virtual std::string | getType () |
CSLayoutManagerBorder () | |
virtual | ~CSLayoutManagerBorder () |
virtual int | getMinimumWidth (CSGrafikElement *element) |
virtual int | getMinimumHeight (CSGrafikElement *element) |
Static Public Attributes | |
const char * | CLASS = "CSLayoutManagerBorder" |
Protected Member Functions | |
virtual void | layoutElements () |
|
Definition at line 205 of file CSLayoutManager.h.
00205 {} |
|
Definition at line 206 of file CSLayoutManager.h.
00206 {} |
|
total width and height of screen are ten units center width and height take 6 units north, south -> height take 2 units north, south -> width take 10 units east, west -> width take 2 units east, west -> height take 6 units if one border is missing center is always extended first north and south is extend each other if center is missing north and south are equal east and west are equal CSPanel* panelNV = new CSPanel(200,200); l = CSLayoutData(POSITION_NORTH); l.setStretchedHorizontal(true); mDesktop->addElement(panelNV, l); CSPanel* panelSV = new CSPanel(200,200); l = CSLayoutData(POSITION_SOUTH); l.setStretchedHorizontal(true); mDesktop->addElement(panelSV, l); CSPanel* panelEV = new CSPanel(200,200); l = CSLayoutData(POSITION_EAST); l.setStretchedVertical(true); mDesktop->addElement(panelEV, l); CSPanel* panelWV = new CSPanel(200,200); l = CSLayoutData(POSITION_WEST); l.setStretchedVertical(true); mDesktop->addElement(panelWV, l); Reimplemented from CSLayoutManager. Definition at line 361 of file CSLayoutManager.cpp. References CSGrafikElements, CSLayoutData::getCenteredHorizontal(), CSLayoutData::getCenteredVertical(), CSLayoutManager::getElements(), CSGrafikElement::getHeight(), CSLayoutManager::getHostingElement(), CSLayoutManager::getLayoutData(), CSGrafikElement::getLayoutManager(), CSLayoutManager::getMinimumHeight(), CSLayoutManager::getMinimumWidth(), CSLayoutData::getPackedHorizontal(), CSLayoutData::getPackedVertical(), CSLayoutData::getPosition(), CSLayoutData::getStretchedHorizontal(), CSLayoutData::getStretchedVertical(), CSLayoutManager::getViewportHeight(), CSLayoutManager::getViewportWidth(), CSGrafikElement::getVisible(), CSGrafikElement::getWidth(), POSITION_CENTER, POSITION_EAST, POSITION_NORTH, POSITION_SOUTH, POSITION_WEST, and CSLayoutManager::setLayout().
00362 { 00363 CSGrafikElement *host = getHostingElement(); 00364 if (host == 0) 00365 { 00366 return; 00367 } 00368 00369 CSLayoutData *hostLayoutData = getLayoutData(host); 00370 00371 CSGrafikElements *elements = getElements(host); 00372 CSGrafikElements::iterator iter = elements->begin(); 00373 CSGrafikElement *north = 0; 00374 CSGrafikElement *south = 0; 00375 CSGrafikElement *east = 0; 00376 CSGrafikElement *west = 0; 00377 CSGrafikElement *center = 0; 00378 00379 while (iter != elements->end()) 00380 { 00381 CSGrafikElement *visitor = *iter; 00382 if (!visitor->getVisible()) 00383 { 00384 iter++; 00385 continue; 00386 } 00387 CSLayoutData *visitorLayoutData = getLayoutData(visitor); 00388 // now, lay it out 00389 switch (visitorLayoutData->getPosition()) 00390 { 00391 case POSITION_NORTH: 00392 { 00393 north = visitor; 00394 break; 00395 } 00396 case POSITION_SOUTH: 00397 { 00398 south = visitor; 00399 break; 00400 } 00401 case POSITION_EAST: 00402 { 00403 east = visitor; 00404 break; 00405 } 00406 case POSITION_WEST: 00407 { 00408 west = visitor; 00409 break; 00410 } 00411 case POSITION_CENTER: 00412 { 00413 center = visitor; 00414 break; 00415 } 00416 default: 00417 { 00418 break; 00419 } 00420 } 00421 iter++; 00422 } 00423 int sizeNorthW = 10; 00424 int sizeSouthW = 10; 00425 int sizeEastW = 2; 00426 int sizeWestW = 2; 00427 int sizeCenterW = 6; 00428 00429 int sizeNorthH = 2; 00430 int sizeSouthH = 2; 00431 int sizeEastH = 6; 00432 int sizeWestH = 6; 00433 int sizeCenterH = 6; 00434 00435 if ((center == 0) && (east == 0) && (west == 0)) 00436 { 00437 if (north) 00438 { 00439 sizeNorthH += sizeCenterH/2; 00440 } 00441 else 00442 { 00443 if (south) 00444 { 00445 sizeSouthH += sizeCenterH/2; 00446 } 00447 } 00448 if (south) 00449 { 00450 sizeSouthH += sizeCenterH/2; 00451 } 00452 else 00453 { 00454 if (north) 00455 { 00456 sizeNorthH += sizeCenterH/2; 00457 } 00458 } 00459 sizeCenterH = 0; 00460 } 00461 if (north == 0) 00462 { 00463 if (center) 00464 { 00465 sizeCenterH += sizeNorthH; 00466 } 00467 else 00468 { 00469 if (south) 00470 { 00471 sizeSouthH += sizeNorthH; 00472 } 00473 } 00474 sizeEastH += sizeNorthH; 00475 sizeWestH += sizeNorthH; 00476 sizeNorthH = 0; 00477 } 00478 if (south == 0) 00479 { 00480 if (center) 00481 { 00482 sizeCenterH += sizeSouthH; 00483 } 00484 else 00485 { 00486 if (north) 00487 { 00488 sizeNorthH += sizeSouthH; 00489 } 00490 } 00491 sizeEastH += sizeSouthH; 00492 sizeWestH += sizeSouthH; 00493 sizeSouthH = 0; 00494 } 00495 if (center == 0) 00496 { 00497 sizeEastW += sizeCenterW/2; 00498 sizeWestW += sizeCenterW/2; 00499 sizeCenterW = 0; 00500 } 00501 if (east == 0) 00502 { 00503 if (center) 00504 { 00505 sizeCenterW += sizeEastW; 00506 } 00507 else 00508 { 00509 sizeWestW += sizeEastW; 00510 } 00511 sizeEastW = 0; 00512 } 00513 if (west == 0) 00514 { 00515 if (center) 00516 { 00517 sizeCenterW += sizeWestW; 00518 } 00519 else 00520 { 00521 if (east) 00522 { 00523 sizeEastW += sizeWestW; 00524 } 00525 } 00526 sizeWestW = 0; 00527 } 00528 int width = getViewportWidth(host); 00529 int height = getViewportHeight(host); 00530 00531 int centerStartY = 0; 00532 int centerEndY = height; 00533 int centerStartX = 0; 00534 int centerEndX = width; 00535 00536 if (north) 00537 { 00538 CSLayoutData *layoutData = getLayoutData(north); 00539 int x = 0; 00540 int y = 0; 00541 int w = north->getWidth(); 00542 int h = north->getHeight(); 00543 00544 if (layoutData->getStretchedHorizontal()) 00545 { 00546 w = (width * sizeNorthW)/10; 00547 } 00548 else if (layoutData->getPackedHorizontal()) 00549 { 00550 w = north->getLayoutManager()->getMinimumWidth(north); 00551 } 00552 else 00553 { 00554 if (layoutData->getCenteredHorizontal()) 00555 { 00556 x = (((width * sizeNorthW)/10) / 2) - w/2; 00557 if (x < 0) 00558 { 00559 x = 0; 00560 } 00561 } 00562 } 00563 if (layoutData->getStretchedVertical()) 00564 { 00565 h = (height * sizeNorthH)/10; 00566 } 00567 else if (layoutData->getPackedVertical()) 00568 { 00569 h = north->getLayoutManager()->getMinimumHeight(north); 00570 } 00571 if (layoutData->getCenteredVertical()) 00572 { 00573 y = (((height * sizeNorthH)/10)/2) - h/2; 00574 if (y < 0) 00575 { 00576 y = 0; 00577 } 00578 } 00579 setLayout(north, x, y, w, h); 00580 centerStartY = y + h; 00581 } 00582 if (south) 00583 { 00584 CSLayoutData *layoutData = getLayoutData(south); 00585 int x = 0; 00586 int y = height - south->getHeight(); 00587 if (y < 0) 00588 { 00589 y = 0; 00590 } 00591 int w = south->getWidth(); 00592 int h = south->getHeight(); 00593 00594 if (layoutData->getStretchedHorizontal()) 00595 { 00596 w = (width * sizeSouthW)/10; 00597 } 00598 else 00599 { 00600 if (layoutData->getCenteredHorizontal()) 00601 { 00602 x = (((width * sizeSouthW)/10) / 2) - w/2; 00603 if (x < 0) 00604 { 00605 x = 0; 00606 } 00607 } 00608 } 00609 if (layoutData->getStretchedVertical()) 00610 { 00611 h = (height * sizeSouthH)/10; 00612 y = height - h; 00613 if (y < 0) 00614 { 00615 y = 0; 00616 } 00617 } 00618 else 00619 { 00620 if (layoutData->getPackedVertical()) 00621 { 00622 h = south->getLayoutManager()->getMinimumHeight(south); 00623 } 00624 if (layoutData->getCenteredVertical()) 00625 { 00626 y = 0; 00627 y += (height * sizeNorthH)/10; 00628 y += (height * sizeCenterH)/10; 00629 y += (((height * sizeSouthH)/10)/2); 00630 y -= h/2; 00631 if (y + h > height) 00632 { 00633 y = height - h; 00634 } 00635 if (y < 0) 00636 { 00637 y = 0; 00638 } 00639 } 00640 } 00641 setLayout(south, x, y, w , h); 00642 centerEndY = y; 00643 } 00644 00645 int westEndHorizontal = 0; 00646 if (west) 00647 { 00648 CSLayoutData *layoutData = getLayoutData(west); 00649 int x = 0; 00650 int y = centerStartY; 00651 int w = west->getWidth(); 00652 int h = west->getHeight(); 00653 00654 if (layoutData->getStretchedHorizontal()) 00655 { 00656 w = (width * sizeWestW)/10; 00657 } 00658 else 00659 { 00660 if (layoutData->getPackedHorizontal()) 00661 { 00662 w = west->getLayoutManager()->getMinimumWidth(west); 00663 } 00664 if (layoutData->getCenteredHorizontal()) 00665 { 00666 x = (((width * sizeWestW)/10) / 2) - w/2; 00667 if (x <0) 00668 { 00669 x = 0; 00670 } 00671 } 00672 } 00673 if (layoutData->getStretchedVertical()) 00674 { 00675 h = centerEndY - centerStartY; 00676 } 00677 else 00678 { 00679 if (layoutData->getCenteredVertical()) 00680 { 00681 y = (((height * sizeWestH)/10)/2) - h/2 + ((height * sizeNorthH)/10); 00682 if (y < 0) 00683 { 00684 x = 0; 00685 } 00686 } 00687 } 00688 00689 setLayout(west, x, y, w , h); 00690 centerStartX = x + w; 00691 } 00692 00693 if (east) 00694 { 00695 CSLayoutData *layoutData = getLayoutData(east); 00696 int x = width - east->getWidth(); 00697 if (x < 0) 00698 { 00699 x = 0; 00700 } 00701 int y = centerStartY; 00702 int w = east->getWidth(); 00703 int h = east->getHeight(); 00704 if (layoutData->getStretchedHorizontal()) 00705 { 00706 w = (width * sizeEastW)/10; 00707 } 00708 else 00709 { 00710 if (layoutData->getPackedHorizontal()) 00711 { 00712 w = east->getLayoutManager()->getMinimumWidth(east); 00713 } 00714 if (layoutData->getCenteredHorizontal()) 00715 { 00716 x = (((width * sizeEastW)/10) / 2) - w/2 + ((width * sizeWestW)/10) + ((width * sizeCenterW)/10); 00717 if (x > width - w) 00718 { 00719 x = width - w; 00720 } 00721 if (x < 0) 00722 { 00723 x = 0; 00724 } 00725 } 00726 } 00727 if (layoutData->getStretchedVertical()) 00728 { 00729 h = centerEndY - centerStartY; 00730 } 00731 else 00732 { 00733 if (layoutData->getCenteredVertical()) 00734 { 00735 y = (((height * sizeEastH)/10)/2) - h/2 + ((height * sizeNorthH)/10); 00736 if (y < 0) 00737 { 00738 y = 0; 00739 } 00740 } 00741 } 00742 setLayout(east, x, y, w , h); 00743 centerEndX = x; 00744 } 00745 00746 if (center) 00747 { 00748 CSLayoutData *layoutData = getLayoutData(center); 00749 int x = centerStartX; 00750 int y = centerStartY; 00751 int w = center->getWidth(); 00752 int h = center->getHeight(); 00753 if (layoutData->getStretchedHorizontal()) 00754 { 00755 w = centerEndX - centerStartX; 00756 } 00757 else 00758 { 00759 if (layoutData->getPackedHorizontal()) 00760 { 00761 w = center->getLayoutManager()->getMinimumWidth(center); 00762 } 00763 if (layoutData->getCenteredHorizontal()) 00764 { 00765 x += ((centerEndX - centerStartX) / 2) - w/2; 00766 } 00767 } 00768 if (layoutData->getStretchedVertical()) 00769 { 00770 h = centerEndY - centerStartY; 00771 } 00772 else 00773 { 00774 if (layoutData->getPackedVertical()) 00775 { 00776 h = center->getLayoutManager()->getMinimumHeight(center); 00777 } 00778 if (layoutData->getCenteredVertical()) 00779 { 00780 y += ((centerEndY - centerStartY) / 2) - h/2; 00781 } 00782 } 00783 setLayout(center, x, y, w , h); 00784 } 00785 } |
Here is the call graph for this function:
|
Reimplemented from CSLayoutManager. Definition at line 204 of file CSLayoutManager.h. References CLASS.
00204 {return (std::string) CLASS;} |
|
Implements CSLayoutManager. Definition at line 1603 of file CSLayoutManager.cpp. References CSGrafikElements, CSLayoutManager::getBorderWidth(), CSLayoutManager::getElements(), CSLayoutManager::getInsetWidth(), CSLayoutManager::getLayoutData(), CSGrafikElement::getLayoutManager(), CSLayoutManager::getMinimumWidth(), CSLayoutManager::getMinWidth(), CSLayoutData::getPosition(), CSLayoutData::getSpacing(), CSGrafikElement::getVisible(), POSITION_CENTER, POSITION_EAST, POSITION_NORTH, POSITION_SOUTH, and POSITION_WEST.
01604 { 01605 if (element == 0) 01606 { 01607 return 0; 01608 } 01609 if (!element->getVisible()) 01610 { 01611 return 0; 01612 } 01613 int width = getMinWidth(element); 01614 CSGrafikElements *elements = getElements(element); 01615 CSGrafikElements::iterator iter = elements->begin(); 01616 01617 CSGrafikElement *north = 0; 01618 CSGrafikElement *south = 0; 01619 CSGrafikElement *east = 0; 01620 CSGrafikElement *west = 0; 01621 CSGrafikElement *center = 0; 01622 01623 while (iter != elements->end()) 01624 { 01625 CSGrafikElement *visitor = *iter; 01626 if (!visitor->getVisible()) 01627 { 01628 iter++; 01629 continue; 01630 } 01631 CSLayoutData *visitorLayoutData = getLayoutData(visitor); 01632 switch (visitorLayoutData->getPosition()) 01633 { 01634 case POSITION_NORTH: 01635 { 01636 north = visitor; 01637 break; 01638 } 01639 case POSITION_SOUTH: 01640 { 01641 south = visitor; 01642 break; 01643 } 01644 case POSITION_EAST: 01645 { 01646 east = visitor; 01647 break; 01648 } 01649 case POSITION_WEST: 01650 { 01651 west = visitor; 01652 break; 01653 } 01654 case POSITION_CENTER: 01655 { 01656 center = visitor; 01657 break; 01658 } 01659 default: 01660 { 01661 break; 01662 } 01663 } 01664 iter++; 01665 } 01666 01667 int verticalSpacing; 01668 int horizontalSpacing; 01669 01670 01671 CSLayoutData *layoutData = getLayoutData(element); 01672 layoutData->getSpacing(verticalSpacing, horizontalSpacing); 01673 01674 int neededWidth = 0; 01675 int centralWidth = 0; 01676 int maxWidth = 0; 01677 int northWidth = 0; 01678 int southWidth = 0; 01679 01680 if ((west) && (center) && (east)) 01681 { 01682 centralWidth += horizontalSpacing; 01683 centralWidth += horizontalSpacing; 01684 } 01685 else if ((west) && (center)) 01686 { 01687 centralWidth += horizontalSpacing; 01688 } 01689 else if ((center) && (east)) 01690 { 01691 centralWidth += horizontalSpacing; 01692 } 01693 else if ((west) && (east)) 01694 { 01695 centralWidth += horizontalSpacing; 01696 } 01697 if (west) 01698 { 01699 centralWidth += west->getLayoutManager()->getMinimumWidth(west); 01700 } 01701 if (center) 01702 { 01703 centralWidth += center->getLayoutManager()->getMinimumWidth(center); 01704 } 01705 if (east) 01706 { 01707 centralWidth += east->getLayoutManager()->getMinimumWidth(east); 01708 } 01709 01710 if (north) 01711 { 01712 northWidth += north->getLayoutManager()->getMinimumWidth(north); 01713 } 01714 if (south) 01715 { 01716 southWidth += south->getLayoutManager()->getMinimumWidth(south); 01717 } 01718 01719 maxWidth = centralWidth; 01720 if (northWidth >maxWidth) 01721 { 01722 maxWidth = northWidth; 01723 } 01724 if (southWidth >maxWidth) 01725 { 01726 maxWidth = southWidth; 01727 } 01728 01729 if (maxWidth > width) 01730 { 01731 width = maxWidth; 01732 } 01733 01734 width += getInsetWidth(element) + getBorderWidth(element); 01735 return width; 01736 } |
Here is the call graph for this function:
|
Implements CSLayoutManager. Definition at line 1318 of file CSLayoutManager.cpp. References CSGrafikElements, CSLayoutManager::getBorderHeight(), CSLayoutManager::getElements(), CSLayoutManager::getInsetHeight(), CSLayoutManager::getLayoutData(), CSGrafikElement::getLayoutManager(), CSLayoutManager::getMinHeight(), CSLayoutManager::getMinimumHeight(), CSLayoutData::getPosition(), CSLayoutData::getSpacing(), CSGrafikElement::getVisible(), POSITION_CENTER, POSITION_EAST, POSITION_NORTH, POSITION_SOUTH, and POSITION_WEST.
01319 { 01320 if (element == 0) 01321 { 01322 return 0; 01323 } 01324 if (!element->getVisible()) 01325 { 01326 return 0; 01327 } 01328 int height = getMinHeight(element); 01329 CSGrafikElements *elements = getElements(element); 01330 CSGrafikElements::iterator iter = elements->begin(); 01331 01332 CSGrafikElement *north = 0; 01333 CSGrafikElement *south = 0; 01334 CSGrafikElement *east = 0; 01335 CSGrafikElement *west = 0; 01336 CSGrafikElement *center = 0; 01337 01338 while (iter != elements->end()) 01339 { 01340 CSGrafikElement *visitor = *iter; 01341 if (!visitor->getVisible()) 01342 { 01343 iter++; 01344 continue; 01345 } 01346 CSLayoutData *visitorLayoutData = getLayoutData(visitor); 01347 switch (visitorLayoutData->getPosition()) 01348 { 01349 case POSITION_NORTH: 01350 { 01351 north = visitor; 01352 break; 01353 } 01354 case POSITION_SOUTH: 01355 { 01356 south = visitor; 01357 break; 01358 } 01359 case POSITION_EAST: 01360 { 01361 east = visitor; 01362 break; 01363 } 01364 case POSITION_WEST: 01365 { 01366 west = visitor; 01367 break; 01368 } 01369 case POSITION_CENTER: 01370 { 01371 center = visitor; 01372 break; 01373 } 01374 default: 01375 { 01376 break; 01377 } 01378 } 01379 iter++; 01380 } 01381 01382 int verticalSpacing; 01383 int horizontalSpacing; 01384 CSLayoutData *layoutData = getLayoutData(element); 01385 layoutData->getSpacing(verticalSpacing, horizontalSpacing); 01386 01387 int neededHeight = 0; 01388 if ((north) && ((center) || (east) || (west)) && (south)) 01389 { 01390 neededHeight += verticalSpacing; 01391 neededHeight += verticalSpacing; 01392 } 01393 else if ((north) && ((center) || (east) || (west))) 01394 { 01395 neededHeight += verticalSpacing; 01396 } 01397 else if (((center) || (east) || (west)) && (south)) 01398 { 01399 neededHeight += verticalSpacing; 01400 } 01401 else if ((north) && (south)) 01402 { 01403 neededHeight += verticalSpacing; 01404 } 01405 01406 if (north) 01407 { 01408 neededHeight += north->getLayoutManager()->getMinimumHeight(north); 01409 } 01410 if ((center) || (east) || (west)) 01411 { 01412 int maxHeight = 0; 01413 int centerHeight = 0; 01414 int eastHeight = 0; 01415 int westHeight = 0; 01416 01417 if (center) 01418 { 01419 centerHeight = center->getLayoutManager()->getMinimumHeight(center); 01420 } 01421 if (east) 01422 { 01423 eastHeight = east->getLayoutManager()->getMinimumHeight(east); 01424 } 01425 if (west) 01426 { 01427 westHeight = west->getLayoutManager()->getMinimumHeight(west); 01428 } 01429 01430 maxHeight = centerHeight; 01431 if (eastHeight>maxHeight) 01432 { 01433 maxHeight = eastHeight; 01434 } 01435 if (westHeight>maxHeight) 01436 { 01437 maxHeight = westHeight; 01438 } 01439 01440 neededHeight += maxHeight; 01441 } 01442 if (south) 01443 { 01444 neededHeight += south->getLayoutManager()->getMinimumHeight(south); 01445 } 01446 01447 if (neededHeight > height) 01448 { 01449 height = neededHeight; 01450 } 01451 01452 height += getInsetHeight(element) + getBorderHeight(element); 01453 return height; 01454 } |
Here is the call graph for this function:
|
Reimplemented from CSLayoutManager. Definition at line 13 of file CSLayoutManager.cpp. Referenced by getType(). |