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

CSWindow.cpp

Go to the documentation of this file.
00001 #ifdef WIN32
00002 #pragma warning(disable : 4786 )
00003 #endif
00004 
00005 #include "CSWindow.h"
00006 #include "CSScrollbar.h"
00007 #include "CSIcon.h"
00008 #include "CSLAF.h"
00009 #include "CSPanel.h"
00010 #include "CSDesktop.h"
00011 #include "CSMessage.h"
00012 #include "CSFont.h"
00013 
00014 const char *CSWindow::CLASS = "CSWindow";
00015 //! \todo correct picture window, so it works again!
00016 CSWindow::CSWindow(CSPicture *picture) : CSGrafikElement(0,0)
00017 {
00018     static char *functionName="CSWindow";
00019     LOG_ENTER 
00020     if (picture)
00021     {
00022         mPicture = picture;
00023         init(mPicture->getMaxY(), mPicture->getMaxX());
00024         initWindow();
00025         setArea(0);
00026     }
00027     else
00028     {
00029         mPicture =0;
00030         initWindow();
00031     }
00032     mIsSizeable = true;
00033     LOG_EXIT
00034 }
00035 
00036 CSWindow::CSWindow(int height, int width, bool hasTitle) : CSGrafikElement(height,width), mCloseButton(0)
00037 {
00038     static char *functionName="CSWindow";
00039     LOG_ENTER 
00040     mHasTitle = hasTitle;
00041     mIsSizeable = mHasTitle;
00042     mPicture = 0;
00043     initWindow();
00044     LOG_EXIT
00045 }
00046 
00047 CSWindow::~CSWindow()
00048 {
00049     static char *functionName="~CSWindow";
00050     LOG_ENTER 
00051     // all elements are deleted by parent!
00052     LOG_EXIT
00053 }
00054 
00055 void CSWindow::initWindow()
00056 {
00057     static char *functionName="initWindow";
00058     LOG_ENTER 
00059     mActive = true;
00060     mDragging = false;
00061     mSizing = false;
00062     mCursorChange = false;
00063     mCloseButton = 0;
00064     mTitleIcon = 0;
00065     mTitleBar = 0;
00066     mDragStartX = 0;
00067     mDragStartY = 0;
00068     mVerticalDisplayStart = -1;
00069     mVerticalDisplayEnd = -1;
00070     mVerticalDisplayLength = 0;
00071     mHorizontalDisplayStart = -1;
00072     mHorizontalDisplayEnd = -1;
00073     mHorizontalDisplayLength = 0;
00074     mVerticalScrollbar = 0;
00075     mHorizontalScrollbar = 0;
00076     mMinHeightInPixel = 0;
00077     mMinWidthInPixel = 0;
00078     mHorizontalDisplaySet = false;
00079     mVerticalDisplaySet = false;
00080 
00081     mTitle = "Window";
00082     MESSAGE_WINDOW_CLOSE.setSubtype(WINDOW_CLOSE_MESSAGE);
00083     mCloseable = true;
00084     setVisible(false);
00085 
00086     mNorth = 0;
00087     mWest = 0;
00088     mSouth = 0;
00089     mEast = 0;
00090     mCenter = 0;
00091     setMainLayoutManager(new CSLayoutManagerBorder());
00092 
00093     mNorth = new CSPanel();
00094     mNorth->setLayoutManager(new CSLayoutManagerStackVertical());
00095     mWest = new CSPanel();
00096     mWest->setLayoutManager(new CSLayoutManagerStackHorizontal());
00097     mSouth = new CSPanel();
00098     mSouth->setLayoutManager(new CSLayoutManagerStackVertical());
00099     mEast = new CSPanel();
00100     mEast->setLayoutManager(new CSLayoutManagerStackHorizontal());
00101     mCenter = new CSPanel();
00102     
00103     CSLayoutData layout = CSLayoutData(POSITION_NORTH);
00104     layout.setSpacing(0,0);
00105 
00106     layout.setStretchedHorizontal(true);
00107     layout.setPackedVertical(true);
00108     mNorth->setLayoutData(layout);
00109     addMainElement(mNorth);
00110 
00111     layout.setPosition(POSITION_SOUTH);
00112     mSouth->setLayoutData(layout);
00113     addMainElement(mSouth);
00114     
00115     layout.setPosition(POSITION_CENTER);
00116     layout.setStretchedVertical(true);
00117     mCenter->setLayoutData(layout);
00118     addMainElement(mCenter);
00119     setMainElement(mCenter);
00120     
00121     layout.setPackedHorizontal(true);
00122     layout.setPosition(POSITION_WEST);
00123     mWest->setLayoutData(layout);
00124     addMainElement(mWest);
00125     
00126     layout.setPosition(POSITION_EAST);
00127     mEast->setLayoutData(layout);
00128     addMainElement(mEast);
00129 
00130     rebuildElement();
00131     LOG_EXIT
00132 }
00133 
00134 void CSWindow::addElementNorth(CSGrafikElement *element)
00135 {
00136     mNorth->addElement(element);
00137 }
00138 
00139 void CSWindow::addElementSouth(CSGrafikElement *element)
00140 {
00141     mSouth->addElement(element);
00142 }
00143 
00144 void CSWindow::addElementEast(CSGrafikElement *element)
00145 {
00146     mEast->addElement(element);
00147 }
00148 
00149 void CSWindow::addElementWest(CSGrafikElement *element)
00150 {
00151     mWest->addElement(element);
00152 }
00153 
00154 void CSWindow::paint(SDL_Surface *destination, SDL_Rect *parentViewport)
00155 {
00156     static char *functionName="paint";
00157     if (isPictureWindow())
00158     {
00159         mPicture->display(getX() + parentViewport->x, getY() + parentViewport->y);
00160     }
00161     paintChildren(destination, parentViewport);
00162 }
00163 
00164 bool CSWindow::isTransparent(int x, int y, SDL_Rect *parentViewport)
00165 {
00166     static char *functionName="isTransparent";
00167     if (mPicture == 0)
00168     {
00169         return false;
00170     }
00171 
00172     bool b = mPicture->isTransparent(x+parentViewport->x, y+parentViewport->y);
00173     return b;
00174 }
00175 
00176 void CSWindow::addLeftIcon(CSIcon *icon)
00177 {
00178     static char *functionName="addLeftIcon";
00179     LOG_ENTER 
00180 
00181     if (mTitleIcon)
00182     {
00183         mLeftIcons.pop_back();
00184     }
00185     mLeftIcons.push_back(icon);
00186     if (mTitleIcon)
00187     {
00188         mLeftIcons.push_back(mTitleIcon);
00189     }
00190     layoutChanged();
00191     LOG_EXIT
00192 }
00193 
00194 void CSWindow::reactOnMessage(CSMessage *message)
00195 {
00196     reactOnMessageWindow(message);
00197 }
00198 
00199 void CSWindow::reactOnMessageWindow(CSMessage *message)
00200 {
00201     static char *functionName="reactOnMessage";
00202     if (message->mIsHandled)
00203     {
00204         if (message->getType() == GUI_MESSAGE)
00205         {
00206             GuiMessage *gm = (GuiMessage *) message;
00207             switch (message->getSubtype())
00208             {
00209                 case MOUSE_BUTTON_RELEASED_MESSAGE:
00210                 {
00211                     mDragging = false;
00212                     if (mCursorChange)
00213                     {
00214                         cursorDefault();
00215                         mSizing = false;
00216                         mCursorChange = false;
00217                     }
00218                     break;
00219                 }
00220             }
00221         }
00222         reactOnMessageGrafikElement(message);
00223         return;
00224     }
00225     switch (message->getType())
00226     {
00227         case GUI_MESSAGE:
00228         {
00229             GuiMessage *gm = (GuiMessage *) message;
00230             if (message->getSubtype() ==  MOUSE_MOTION_LOST_MESSAGE)
00231             {
00232                 mDragging = false;
00233             }
00234             if (message->getSubtype() ==  MOUSE_MOTION_MESSAGE)
00235             {
00236                 if (mDragging)
00237                 {
00238                     int deltaX = gm->screenX - mDragStartX;
00239                     int deltaY = gm->screenY - mDragStartY;
00240                     if (mSizing)
00241                     {
00242                         int height = getHeight() + deltaY;
00243                         int width = getWidth() + deltaX;
00244                 
00245                         if (height < 100)  height = 100;
00246                         if (width < 100)  width = 100; 
00247                         
00248                         setHeight(height);
00249                         setWidth(width);
00250                     }
00251                     else
00252                     {
00253                         setPosition(getX()+deltaX, getY()+deltaY);
00254                     }
00255                     mDragStartX = gm->screenX;
00256                     mDragStartY = gm->screenY;
00257                 }
00258                 else
00259                 {
00260                     int x = gm->receiverX;
00261                     int y = gm->receiverY;
00262                     if (mIsSizeable)
00263                     {
00264                         if ((x > getWidth()-mSizingOffset) && (y > getHeight()-mSizingOffset))
00265                         {
00266                             if (!mCursorChange)
00267                             {
00268                                 cursorSizing();
00269                                 mSizing = true;
00270                                 mCursorChange = true;
00271                             }
00272                         }
00273                         else
00274                         {
00275                             if (mCursorChange)
00276                             {
00277                                 cursorDefault();
00278                                 mSizing = false;
00279                                 mCursorChange = false;
00280                             }
00281                         }
00282                     }
00283                 }
00284             }
00285 
00286             if (gm->receiver != this)
00287             {
00288                 if (gm->getSubtype() == SCROLLBAR_POSITION_CHANGED_MESSAGE)
00289                 {
00290                     if (gm->sender == mVerticalScrollbar)
00291                     {
00292                         mVerticalDisplayStart = gm->start;
00293                         mVerticalDisplayEnd = gm->end;
00294                         mVerticalDisplaySet = true;
00295                         mCenter->setViewportOffset(mHorizontalDisplayStart, mVerticalDisplayStart);
00296                     }
00297                     else if (gm->sender == mHorizontalScrollbar)
00298                     {
00299                         mHorizontalDisplayStart = gm->start;
00300                         mHorizontalDisplayEnd = gm->end;
00301                         mHorizontalDisplaySet = true;
00302                         mCenter->setViewportOffset(mHorizontalDisplayStart, mVerticalDisplayStart);
00303                     }
00304                     gm->mIsHandled = true;
00305                 }
00306                 switch (message->getSubtype())
00307                 {
00308                     case MOUSE_BUTTON_RELEASED_MESSAGE:
00309                     {
00310                         mDragging = false;
00311                         break;
00312                     }
00313                     case MOUSE_BUTTON_PRESSED_MESSAGE:
00314                     {
00315                         if (!mHasTitle)
00316                         {
00317                             break;
00318                         }
00319                         int tx = gm->receiverX;
00320                         int ty = gm->receiverY;
00321 
00322                         if (isChild(gm->receiver))
00323                         {
00324                             mDragging = true;
00325                             mDragStartX = gm->screenX;
00326                             mDragStartY = gm->screenY;
00327                             gm->mIsHandled = true;
00328                             mParent->toFront(this);
00329                         }   
00330                         break;
00331                     }
00332                     case BUTTON_PRESSED_MESSAGE:
00333                     {
00334                         if (gm->actionId == CLOSE_ACTION_ID)
00335                         {
00336                             CSGrafikElement *parent = getParent();
00337                             if (parent) 
00338                             {
00339                                 setVisible(false);
00340                             }
00341                             gm->mIsHandled = true;
00342                         }
00343                         break;
00344                     }
00345                 }
00346             }
00347             else // receiver == this
00348             {
00349                 switch (message->getSubtype())
00350                 {
00351                     case MOUSE_BUTTON_PRESSED_MESSAGE:
00352                     {
00353                         if (!mHasTitle)
00354                         {
00355                             break;
00356                         }
00357                         if (mSizing)
00358                         {
00359                             mDragging = true;
00360                             mDragStartX = gm->screenX;
00361                             mDragStartY = gm->screenY;
00362                             gm->mIsHandled = true;
00363                             mParent->toFront(this);
00364                         }   
00365                         break;
00366                     }
00367                     case MOUSE_BUTTON_RELEASED_MESSAGE:
00368                     {
00369                         mDragging = false;
00370                         break;
00371                     }
00372                 }
00373             }                       
00374         }
00375     }
00376     reactOnMessageGrafikElement(message);
00377 }
00378 
00379 void CSWindow::rebuildElementWindow() 
00380 {
00381     static char *functionName="rebuildElementWindow";
00382     LOG_ENTER 
00383 
00384     CSLAF *laf = CSLAF::getCurrentLAF();
00385     mSizingOffset = laf->getWindowSizingOffset();
00386 
00387     // Button & Icon must be deleted befor TitleBar, for titleBar will delete them anyway! 
00388     if (mCloseButton) 
00389     {
00390         mCloseButton->removeMessageListener(this);
00391         delete (mCloseButton);
00392         mCloseButton = 0;
00393     }
00394     if (mTitleIcon)
00395     {
00396         mLeftIcons.pop_back();
00397         mTitleIcon->removeMessageListener(this);
00398         delete (mTitleIcon);
00399         mTitleIcon = 0;
00400     }
00401 
00402     if (mHasTitle)
00403     {
00404         if (mTitleBar)
00405         {
00406             mNorth->removeElement(mTitleBar);
00407             mTitleBar->removeMessageListener(this);
00408             delete (mTitleBar);
00409             mTitleBar = 0;
00410         }
00411         mTitleBar = new CSBar(TYPE_HORIZONTAL);
00412         mTitleBar->setGUIType("Title");
00413         mTitleBar->addMessageListener(this, GUI_MESSAGE);
00414         mNorth->addElement(mTitleBar);
00415     }
00416 
00417     if (mTitleBar)
00418     { 
00419         mTitleBar->removeAllElements(); 
00420     }
00421 
00422     if (mHasTitle)
00423     {   
00424         mCloseButton = new CSButton(laf->getIcon(LAF_ICON_TYPE_CLOSE));
00425         mCloseButton->setVisible(mCloseable);
00426         mCloseButton->setTooltipText("Button to hide a window...");
00427         mCloseButton->addMessageListener(this, GUI_MESSAGE);
00428         
00429         mTitleIcon = CSTextIcon::buildIcon(mTitle);
00430         mTitleIcon->setVisible(true);
00431         mTitleIcon->addMessageListener(this, GUI_MESSAGE);
00432         mTitleIcon->setBorderState(0);
00433         mLeftIcons.push_back(mTitleIcon);
00434 
00435         CSIcons::iterator iter = mLeftIcons.begin();
00436         CSLayoutData layoutData(POSITION_WEST);
00437         layoutData.setStretchedVertical(false);
00438         layoutData.setPackedVertical(true);
00439         layoutData.setPackedHorizontal(true);
00440         layoutData.setCenteredVertical(true);
00441 
00442         CSIcon* loopIcon = 0;
00443         while (iter != mLeftIcons.end())
00444         {
00445             CSIcon* loopIcon = *iter;
00446             loopIcon->setBorderState(0);
00447             loopIcon->addMessageListener(this, GUI_MESSAGE); // doesn't matter if readded, that is handled by message listerner internally
00448             loopIcon->setLayoutData(layoutData);
00449             mTitleBar->addElement(loopIcon);
00450             iter++;
00451         }
00452         if (mCloseable)
00453         {
00454             layoutData.setPosition(POSITION_EAST);
00455             mCloseButton->setLayoutData(layoutData);
00456             mTitleBar->addElement(mCloseButton);
00457             mCloseButton->setActionId(CLOSE_ACTION_ID);
00458         }
00459     }
00460     if (mHorizontalScrollbar != 0) 
00461     {
00462         mHorizontalScrollbar->removeMessageListener(this);
00463         removeElement(mHorizontalScrollbar);
00464         delete(mHorizontalScrollbar);
00465         mHorizontalScrollbar = 0;
00466     }
00467     mHorizontalScrollbar = new CSScrollbar(TYPE_HORIZONTAL);
00468     mHorizontalScrollbar->addMessageListener(this, GUI_MESSAGE);
00469     addElementSouth(mHorizontalScrollbar);
00470     
00471     if (mVerticalScrollbar != 0)
00472     {
00473         mVerticalScrollbar->removeMessageListener(this);
00474         removeElement(mVerticalScrollbar);
00475         delete (mVerticalScrollbar);
00476         mVerticalScrollbar = 0;
00477     }
00478     mVerticalScrollbar = new CSScrollbar(TYPE_VERTICAL);
00479     mVerticalScrollbar->addMessageListener(this, GUI_MESSAGE);
00480     addElementEast(mVerticalScrollbar);
00481     
00482     LOG_EXIT
00483 }
00484 
00485 // returns whether a scrollbar was added!
00486 // /TODO auch für andere Layouts
00487 // only successfull on Center = XY Layout & Border
00488 bool CSWindow::initHorizontalScrollbar()
00489 {
00490     mMinHeightInPixel = 0;
00491     mMinWidthInPixel = 0;
00492     int minHeight = 0;
00493     int minWidth = 0;
00494     if ((mCenter->getLayoutManager()->getType().compare(CSLayoutManagerXY.CLASS) != 0) && (mCenter->getLayoutManager()->getType().compare(CSLayoutManagerBorder.CLASS) != 0))
00495     {
00496         mHorizontalScrollbar->setVisible(false);
00497         return false;
00498     }
00499         
00500     getCenterMinSize(minWidth, minHeight);
00501 
00502     // setting the complete size of the to be displayed are (in pixel)
00503     mHorizontalScrollbar->setStart(0);
00504     mHorizontalScrollbar->setEnd(minWidth);
00505 
00506     int xAdd = 1; // adding 1 pixel per scroll unit!
00507 
00508     mHorizontalDisplayLength = (mCenter->getViewportWidth()) / xAdd;    // maximal displayable "items" (scrollable entities) in viewport (without scrolling)
00509     mHorizontalDisplayEnd = mHorizontalDisplayStart + mHorizontalDisplayLength;
00510     
00511     // if the position is already set we don't want to change it
00512     // it upsets the user, if upon resizing
00513     // the position of the scrollbar resets
00514     if (!mHorizontalDisplaySet)
00515     {
00516         mHorizontalDisplayStart = 0;
00517     }
00518     else
00519     {
00520         if (mHorizontalDisplayStart + mHorizontalDisplayLength >minWidth)
00521         {
00522             mHorizontalDisplayStart = minWidth - mHorizontalDisplayLength;
00523             if (mHorizontalDisplayStart < 0)
00524             {
00525                 mHorizontalDisplayStart = 0;
00526             }
00527         }
00528     }
00529     
00530     mHorizontalScrollbar->setDisplayStart(mHorizontalDisplayStart);
00531     mHorizontalScrollbar->setDisplayEnd(mHorizontalDisplayEnd);
00532     mHorizontalScrollbar->setDisplayLength(mHorizontalDisplayLength);
00533 
00534     // if the viewport is to small - add the scollbar
00535     // if not - the above was all not really neccessary
00536     if (mHorizontalDisplayLength < minWidth)
00537     {
00538         // reset an recount the size, since we also got now the size of the scrollbar!
00539         mMinHeightInPixel = 0;
00540         mMinWidthInPixel = 0;
00541         getCenterMinSize(minWidth, minHeight);
00542         mHorizontalScrollbar->setEnd(minWidth);
00543         mHorizontalScrollbar->setVisible(true);
00544         return true;
00545     }
00546     else
00547     {
00548         mHorizontalScrollbar->setVisible(false);
00549     }
00550     return false;
00551 }
00552 
00553 // returns whether a scrollbar was added!
00554 // /TODO auch für andere Layouts
00555 // only successfull on Center = XY Layout && Border
00556 // exactly the same as above - just switch horizontal an vertical arround!
00557 bool CSWindow::initVerticalScrollbar()
00558 {
00559     mMinHeightInPixel = 0;
00560     mMinWidthInPixel = 0;
00561     int minHeight = 0;
00562     int minWidth = 0;
00563     if ((mCenter->getLayoutManager()->getType().compare(CSLayoutManagerXY.CLASS) != 0) && (mCenter->getLayoutManager()->getType().compare(CSLayoutManagerBorder.CLASS) != 0))
00564     {
00565         mVerticalScrollbar->setVisible(false);
00566         return false;
00567     }
00568 
00569     getCenterMinSize(minWidth, minHeight);
00570     
00571     mVerticalScrollbar->setStart(0);
00572     mVerticalScrollbar->setEnd(minHeight);
00573 
00574     int yAdd = 1; // adding 1 pixel per scroll unit!
00575     mVerticalDisplayLength = (mCenter->getViewportHeight()) / yAdd; // maximal displayable "items" (scrollable entities) in viewport (without scrolling)
00576     mVerticalDisplayEnd = mVerticalDisplayStart + mVerticalDisplayLength;
00577 
00578     if (!mVerticalDisplaySet)
00579     {
00580         mVerticalDisplayStart = 0;
00581     }
00582     else
00583     {
00584         if (mVerticalDisplayStart + mVerticalDisplayLength >minHeight)
00585         {
00586             mVerticalDisplayStart = minHeight - mVerticalDisplayLength;
00587             if (mVerticalDisplayStart < 0)
00588             {
00589                 mVerticalDisplayStart = 0;
00590             }
00591         }
00592     }
00593 
00594     mVerticalScrollbar->setDisplayStart(mVerticalDisplayStart);
00595     mVerticalScrollbar->setDisplayEnd(mVerticalDisplayEnd);
00596     mVerticalScrollbar->setDisplayLength(mVerticalDisplayLength);
00597 
00598     if (mVerticalDisplayLength < minHeight)
00599     {
00600         // reset an recount the size, since we also got now the size of the scrollbar!
00601         mMinHeightInPixel = 0;
00602         mMinWidthInPixel = 0;
00603         getCenterMinSize(minWidth, minHeight);
00604         mVerticalScrollbar->setEnd(minHeight);
00605         mVerticalScrollbar->setVisible(true);
00606         return true;
00607     }
00608     else
00609     {
00610         mVerticalScrollbar->setVisible(false);
00611     }
00612     return false;
00613 }
00614 
00615 // /TODO auch für andere Layouts
00616 // only available for XY Layout! && Border layout
00617 void CSWindow::getCenterMinSize(int &minWidth, int &minHeight)
00618 {
00619     int height = 0;
00620     int width = 0;
00621     if (mCenter->getLayoutManager()->getType().compare(CSLayoutManagerXY.CLASS) == 0)   
00622     {
00623         CSGrafikElements::iterator iter = mCenter->getElements()->begin();
00624         while (iter != mCenter->getElements()->end())
00625         {
00626             CSGrafikElement *visitor = *iter;
00627             if (!visitor->getVisible())
00628             {
00629                 iter++;
00630                 continue;
00631             }
00632             CSLayoutData visitorLayoutData = visitor->getLayoutData();
00633 
00634             int h = visitorLayoutData.getY() + visitor->getHeight();
00635             int w = visitorLayoutData.getX() + visitor->getWidth();
00636             if ( h > height)
00637             {
00638                 height = h;
00639             }
00640             if ( w > width)
00641             {
00642                 width = w;
00643             }
00644             iter++;
00645         }
00646         minHeight = height;
00647         minWidth = width;
00648     }
00649 
00650     else if (mCenter->getLayoutManager()->getType().compare(CSLayoutManagerBorder.CLASS) == 0)  
00651     {
00652         CSGrafikElements::iterator iter = mCenter->getElements()->begin();
00653         while (iter != mCenter->getElements()->end())
00654         {
00655             CSGrafikElement *visitor = *iter;
00656             if (!visitor->getVisible())
00657             {
00658                 iter++;
00659                 continue;
00660             }
00661             CSLayoutData visitorLayoutData = visitor->getLayoutData();
00662 
00663             int h = visitorLayoutData.getY() + visitor->getHeight();
00664             int w = visitorLayoutData.getX() + visitor->getWidth();
00665             if ( h > height)
00666             {
00667                 height = h;
00668             }
00669             if ( w > width)
00670             {
00671                 width = w;
00672             }
00673             iter++;
00674         }
00675         minHeight = height;
00676         minWidth = width;
00677     }
00678 }
00679 
00680 void CSWindow::setVerticalDisplayStart(int y)
00681 {
00682     mVerticalDisplayStart = y;
00683     mVerticalScrollbar->setDisplayStart(mVerticalDisplayStart);
00684 
00685     mVerticalDisplayEnd = mVerticalDisplayStart + mVerticalDisplayLength;
00686     mVerticalScrollbar->setDisplayEnd(mVerticalDisplayEnd);
00687 
00688     mCenter->setViewportOffset(mHorizontalDisplayStart, mVerticalDisplayStart);
00689 }
00690 
00691 void CSWindow::setHorizontalDisplayStart(int x)
00692 {
00693     mHorizontalDisplayStart = x;
00694     mHorizontalScrollbar->setDisplayStart(mHorizontalDisplayStart);
00695 
00696     mHorizontalDisplayEnd = mHorizontalDisplayStart + mHorizontalDisplayLength;
00697     mHorizontalScrollbar->setDisplayEnd(mHorizontalDisplayEnd);
00698     mCenter->setViewportOffset(mHorizontalDisplayStart, mVerticalDisplayStart);
00699 }
00700 
00701 
00702 void CSWindow::layoutSetupWindow()
00703 {
00704     static char *functionName="layoutSetupWindow";
00705     LOG_ENTER 
00706     CSLAF *laf = CSLAF::getCurrentLAF();
00707 
00708     // the size of the viewport changes if a scrollbar is added -> every size might change...
00709     // looks like ping pong - but is a must :-(
00710     bool tester = initVerticalScrollbar();
00711     if (initHorizontalScrollbar())
00712     {
00713         if (initVerticalScrollbar())
00714         {
00715             initHorizontalScrollbar();
00716         }
00717     }
00718 
00719     // correct scrollbars
00720     if (mVerticalDisplayEnd > mCenter->getLayoutManager()->getMinimumHeight(mCenter))
00721     {
00722         mVerticalDisplayEnd = mCenter->getLayoutManager()->getMinimumHeight(mCenter);
00723         mVerticalDisplayStart = mVerticalDisplayEnd - mVerticalDisplayLength;
00724         if (mVerticalDisplayStart < 0)
00725         {
00726             mVerticalDisplayStart = 0;
00727         }
00728         mVerticalScrollbar->setDisplayStart(mVerticalDisplayStart);
00729         mVerticalScrollbar->setDisplayEnd(mVerticalDisplayEnd);
00730         mCenter->setViewportOffset(mHorizontalDisplayStart, mVerticalDisplayStart);
00731     }
00732 
00733     if (mHorizontalDisplayEnd > mCenter->getLayoutManager()->getMinimumWidth(mCenter))
00734     {
00735         mHorizontalDisplayEnd = mCenter->getLayoutManager()->getMinimumWidth(mCenter);
00736         mHorizontalDisplayStart = mHorizontalDisplayEnd - mHorizontalDisplayLength;
00737         if (mHorizontalDisplayStart < 0)
00738         {
00739             mHorizontalDisplayStart = 0;
00740         }
00741         mHorizontalScrollbar->setDisplayStart(mHorizontalDisplayStart);
00742         mHorizontalScrollbar->setDisplayEnd(mHorizontalDisplayEnd);
00743         mCenter->setViewportOffset(mHorizontalDisplayStart, mVerticalDisplayStart);
00744     }
00745 //printf("Height: %i, min: %i, dispend: %i\n", mCenter->getHeight(), mCenter->getLayoutManager()->getMinimumHeight(mCenter), mVerticalDisplayEnd);
00746     // correct viewport offsets
00747     LOG_EXIT
00748 }
00749 
00750 
00751 
00752 

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