2012-08-17 07:29:20 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
|
|
|
/*
|
|
|
|
* This file is part of the LibreOffice project.
|
|
|
|
*
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
*
|
|
|
|
* This file incorporates work covered by the following license notice:
|
|
|
|
*
|
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed
|
|
|
|
* with this work for additional information regarding copyright
|
|
|
|
* ownership. The ASF licenses this file to you under the Apache
|
|
|
|
* License, Version 2.0 (the "License"); you may not use this file
|
|
|
|
* except in compliance with the License. You may obtain a copy of
|
|
|
|
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "layout.hxx"
|
|
|
|
|
|
|
|
#include "bastypes.hxx"
|
|
|
|
|
|
|
|
#include <boost/make_shared.hpp>
|
|
|
|
|
|
|
|
namespace basctl
|
|
|
|
{
|
|
|
|
|
|
|
|
namespace
|
|
|
|
{
|
|
|
|
// the thickness of the splitting lines
|
2012-09-07 10:31:53 +02:00
|
|
|
static long const nSplitThickness = 3;
|
2012-08-17 07:29:20 +02:00
|
|
|
} // namespace
|
|
|
|
|
|
|
|
// ctor for derived classes
|
Basic IDE: namespace basctl
Now all names in basctl are in namespace 'basctl'.
There were lots of names that included the word 'Basic' or 'BasicIDE' in
it, e.g. BasicIDEData, BasicDocumentEntry, BasicTreeListBox,
BasicIDEModule, IDEBaseWindow etc. This information is now stored in the
namespace name, so the names could be shortened: basctl::DocumentEntry,
basctl::TreeListBox, basctl::Module, basctl::BaseWindow etc.
Some other minor changes:
* LibInfos, LibInfoItem, LibInfoKey ->
LibInfos, LibInfos::Item, LibInfos::Key
* The header guards are now uniformly BASCTL_FILENAME_HXX, instead of
e.g. _FILENAME_HXX, which is undefined behaviour because of the '_'.
* namespace BasicIDE, BasicIDEGlobals, basicide -> namespace basctl
* BASICIDE_TYPE_MODULE, ... -> basctl::TYPE_MODULE, ...
Change-Id: I2a9b493562d0d8a2510d569798fbe9e1161b7c9b
Reviewed-on: https://gerrit.libreoffice.org/501
Reviewed-by: Andras Timar <atimar@suse.com>
Tested-by: Andras Timar <atimar@suse.com>
2012-08-25 12:43:27 +02:00
|
|
|
// pParent: the parent window (Shell)
|
2012-08-17 07:29:20 +02:00
|
|
|
Layout::Layout (Window* pParent) :
|
|
|
|
Window(pParent, WB_CLIPCHILDREN),
|
|
|
|
pChild(0),
|
|
|
|
bFirstSize(true),
|
|
|
|
aLeftSide(this, SplittedSide::Left),
|
|
|
|
aBottomSide(this, SplittedSide::Bottom)
|
|
|
|
{
|
|
|
|
SetBackground(GetSettings().GetStyleSettings().GetWindowColor());
|
|
|
|
|
|
|
|
Font aFont = GetFont();
|
|
|
|
Size aSz = aFont.GetSize();
|
|
|
|
aSz.Height() *= 1.5;
|
|
|
|
aFont.SetSize(aSz);
|
|
|
|
aFont.SetWeight(WEIGHT_BOLD);
|
|
|
|
aFont.SetColor(GetSettings().GetStyleSettings().GetWindowTextColor());
|
|
|
|
SetFont(aFont);
|
|
|
|
}
|
|
|
|
|
|
|
|
// virtual dtor
|
|
|
|
Layout::~Layout()
|
|
|
|
{ }
|
|
|
|
|
2012-09-05 19:41:42 +02:00
|
|
|
// removes a docking window
|
|
|
|
void Layout::Remove (DockingWindow* pWin)
|
|
|
|
{
|
|
|
|
aLeftSide.Remove(pWin);
|
|
|
|
aBottomSide.Remove(pWin);
|
|
|
|
}
|
|
|
|
|
2012-08-17 07:29:20 +02:00
|
|
|
// called by Window when resized
|
|
|
|
void Layout::Resize()
|
|
|
|
{
|
|
|
|
if (IsVisible())
|
|
|
|
ArrangeWindows();
|
|
|
|
}
|
|
|
|
|
|
|
|
// ArrangeWindows() -- arranges the child windows
|
|
|
|
void Layout::ArrangeWindows ()
|
|
|
|
{
|
2012-09-05 19:41:42 +02:00
|
|
|
// prevent recursion via OnFirstSize() -> Add() -> ArrangeWindows()
|
2012-09-07 10:01:42 +02:00
|
|
|
static bool bInArrangeWindows = false;
|
|
|
|
if (bInArrangeWindows)
|
2012-09-05 19:41:42 +02:00
|
|
|
return;
|
2012-09-07 10:01:42 +02:00
|
|
|
bInArrangeWindows = true;
|
2012-09-05 19:41:42 +02:00
|
|
|
|
2012-09-07 10:01:42 +02:00
|
|
|
Size const aSize = GetOutputSizePixel();
|
2012-09-07 10:31:53 +02:00
|
|
|
long const nWidth = aSize.Width(), nHeight = aSize.Height();
|
2012-09-07 10:01:42 +02:00
|
|
|
if (nWidth && nHeight) // non-empty size
|
2012-08-17 07:29:20 +02:00
|
|
|
{
|
2012-09-07 10:01:42 +02:00
|
|
|
// On first call the derived classes initializes the sizes of the
|
|
|
|
// docking windows. This cannot be done at construction because
|
|
|
|
// the Layout has empty size at that point.
|
|
|
|
if (bFirstSize)
|
|
|
|
{
|
|
|
|
bFirstSize = false;
|
|
|
|
this->OnFirstSize(nWidth, nHeight); // virtual
|
|
|
|
}
|
2012-08-17 07:29:20 +02:00
|
|
|
|
2012-09-07 10:01:42 +02:00
|
|
|
// sides
|
|
|
|
aBottomSide.ArrangeIn(Rectangle(Point(0, 0), aSize));
|
|
|
|
aLeftSide.ArrangeIn(Rectangle(Point(0, 0), Size(nWidth, nHeight - aBottomSide.GetSize())));
|
|
|
|
// child in the middle
|
|
|
|
pChild->SetPosSizePixel(
|
|
|
|
Point(aLeftSide.GetSize(), 0),
|
|
|
|
Size(nWidth - aLeftSide.GetSize(), nHeight - aBottomSide.GetSize())
|
|
|
|
);
|
|
|
|
}
|
2012-09-05 19:41:42 +02:00
|
|
|
|
2012-09-07 10:01:42 +02:00
|
|
|
bInArrangeWindows = false;
|
2012-08-17 07:29:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void Layout::DockaWindow (DockingWindow*)
|
|
|
|
{
|
|
|
|
ArrangeWindows();
|
|
|
|
}
|
|
|
|
|
Basic IDE: namespace basctl
Now all names in basctl are in namespace 'basctl'.
There were lots of names that included the word 'Basic' or 'BasicIDE' in
it, e.g. BasicIDEData, BasicDocumentEntry, BasicTreeListBox,
BasicIDEModule, IDEBaseWindow etc. This information is now stored in the
namespace name, so the names could be shortened: basctl::DocumentEntry,
basctl::TreeListBox, basctl::Module, basctl::BaseWindow etc.
Some other minor changes:
* LibInfos, LibInfoItem, LibInfoKey ->
LibInfos, LibInfos::Item, LibInfos::Key
* The header guards are now uniformly BASCTL_FILENAME_HXX, instead of
e.g. _FILENAME_HXX, which is undefined behaviour because of the '_'.
* namespace BasicIDE, BasicIDEGlobals, basicide -> namespace basctl
* BASICIDE_TYPE_MODULE, ... -> basctl::TYPE_MODULE, ...
Change-Id: I2a9b493562d0d8a2510d569798fbe9e1161b7c9b
Reviewed-on: https://gerrit.libreoffice.org/501
Reviewed-by: Andras Timar <atimar@suse.com>
Tested-by: Andras Timar <atimar@suse.com>
2012-08-25 12:43:27 +02:00
|
|
|
void Layout::Activating (BaseWindow& rWindow)
|
2012-08-17 07:29:20 +02:00
|
|
|
{
|
|
|
|
// first activation
|
Basic IDE: namespace basctl
Now all names in basctl are in namespace 'basctl'.
There were lots of names that included the word 'Basic' or 'BasicIDE' in
it, e.g. BasicIDEData, BasicDocumentEntry, BasicTreeListBox,
BasicIDEModule, IDEBaseWindow etc. This information is now stored in the
namespace name, so the names could be shortened: basctl::DocumentEntry,
basctl::TreeListBox, basctl::Module, basctl::BaseWindow etc.
Some other minor changes:
* LibInfos, LibInfoItem, LibInfoKey ->
LibInfos, LibInfos::Item, LibInfos::Key
* The header guards are now uniformly BASCTL_FILENAME_HXX, instead of
e.g. _FILENAME_HXX, which is undefined behaviour because of the '_'.
* namespace BasicIDE, BasicIDEGlobals, basicide -> namespace basctl
* BASICIDE_TYPE_MODULE, ... -> basctl::TYPE_MODULE, ...
Change-Id: I2a9b493562d0d8a2510d569798fbe9e1161b7c9b
Reviewed-on: https://gerrit.libreoffice.org/501
Reviewed-by: Andras Timar <atimar@suse.com>
Tested-by: Andras Timar <atimar@suse.com>
2012-08-25 12:43:27 +02:00
|
|
|
pChild = &rWindow;
|
2012-08-17 07:29:20 +02:00
|
|
|
ArrangeWindows();
|
|
|
|
Show();
|
|
|
|
pChild->Activating();
|
|
|
|
}
|
|
|
|
|
|
|
|
void Layout::Deactivating ()
|
|
|
|
{
|
|
|
|
if (pChild)
|
|
|
|
pChild->Deactivating();
|
|
|
|
Hide();
|
|
|
|
pChild = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// virtual
|
|
|
|
void Layout::DataChanged (DataChangedEvent const& rDCEvt)
|
|
|
|
{
|
|
|
|
Window::DataChanged(rDCEvt);
|
|
|
|
if (rDCEvt.GetType() == DATACHANGED_SETTINGS && (rDCEvt.GetFlags() & SETTINGS_STYLE))
|
|
|
|
{
|
|
|
|
bool bInvalidate = false;
|
|
|
|
Color aColor = GetSettings().GetStyleSettings().GetWindowColor();
|
2013-01-12 06:39:31 +01:00
|
|
|
const AllSettings* pOldSettings = rDCEvt.GetOldSettings();
|
|
|
|
if (!pOldSettings || aColor != pOldSettings->GetStyleSettings().GetWindowColor())
|
2012-08-17 07:29:20 +02:00
|
|
|
{
|
|
|
|
SetBackground(Wallpaper(aColor));
|
|
|
|
bInvalidate = true;
|
|
|
|
}
|
|
|
|
aColor = GetSettings().GetStyleSettings().GetWindowTextColor();
|
2013-01-12 06:39:31 +01:00
|
|
|
if (!pOldSettings || aColor != pOldSettings->GetStyleSettings().GetWindowTextColor())
|
2012-08-17 07:29:20 +02:00
|
|
|
{
|
|
|
|
Font aFont(GetFont());
|
|
|
|
aFont.SetColor(aColor);
|
|
|
|
SetFont(aFont);
|
|
|
|
bInvalidate = true;
|
|
|
|
}
|
|
|
|
if (bInvalidate)
|
|
|
|
Invalidate();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// SplittedSide
|
|
|
|
// ============
|
|
|
|
//
|
|
|
|
|
|
|
|
// ctor
|
|
|
|
Layout::SplittedSide::SplittedSide (Layout* pParent, Side eSide) :
|
|
|
|
rLayout(*pParent),
|
|
|
|
bVertical(eSide == Left || eSide == Right),
|
|
|
|
bLower(eSide == Left || eSide == Top),
|
|
|
|
nSize(0),
|
|
|
|
aSplitter(pParent, bVertical ? WB_HSCROLL : WB_VSCROLL)
|
|
|
|
{
|
|
|
|
InitSplitter(aSplitter);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Add() -- adds a new window to the side (after construction)
|
Basic IDE: namespace basctl
Now all names in basctl are in namespace 'basctl'.
There were lots of names that included the word 'Basic' or 'BasicIDE' in
it, e.g. BasicIDEData, BasicDocumentEntry, BasicTreeListBox,
BasicIDEModule, IDEBaseWindow etc. This information is now stored in the
namespace name, so the names could be shortened: basctl::DocumentEntry,
basctl::TreeListBox, basctl::Module, basctl::BaseWindow etc.
Some other minor changes:
* LibInfos, LibInfoItem, LibInfoKey ->
LibInfos, LibInfos::Item, LibInfos::Key
* The header guards are now uniformly BASCTL_FILENAME_HXX, instead of
e.g. _FILENAME_HXX, which is undefined behaviour because of the '_'.
* namespace BasicIDE, BasicIDEGlobals, basicide -> namespace basctl
* BASICIDE_TYPE_MODULE, ... -> basctl::TYPE_MODULE, ...
Change-Id: I2a9b493562d0d8a2510d569798fbe9e1161b7c9b
Reviewed-on: https://gerrit.libreoffice.org/501
Reviewed-by: Andras Timar <atimar@suse.com>
Tested-by: Andras Timar <atimar@suse.com>
2012-08-25 12:43:27 +02:00
|
|
|
void Layout::SplittedSide::Add (DockingWindow* pWin, Size const& rSize)
|
2012-08-17 07:29:20 +02:00
|
|
|
{
|
2012-09-07 10:31:53 +02:00
|
|
|
long const nSize1 = (bVertical ? rSize.Width() : rSize.Height()) + nSplitThickness;
|
|
|
|
long const nSize2 = bVertical ? rSize.Height() : rSize.Width();
|
2012-08-17 07:29:20 +02:00
|
|
|
// nSize
|
|
|
|
if (nSize1 > nSize)
|
|
|
|
nSize = nSize1;
|
|
|
|
// window
|
2012-09-07 10:01:42 +02:00
|
|
|
Item aItem;
|
|
|
|
aItem.pWin = pWin;
|
|
|
|
aItem.nStartPos = vItems.empty() ? 0 : vItems.back().nEndPos + nSplitThickness;
|
|
|
|
aItem.nEndPos = aItem.nStartPos + nSize2;
|
|
|
|
// splitter
|
|
|
|
if (!vItems.empty())
|
2012-08-17 07:29:20 +02:00
|
|
|
{
|
2012-09-07 10:01:42 +02:00
|
|
|
aItem.pSplit = boost::make_shared<Splitter>(&rLayout, bVertical ? WB_VSCROLL : WB_HSCROLL);
|
|
|
|
aItem.pSplit->SetSplitPosPixel(aItem.nStartPos - nSplitThickness);
|
|
|
|
InitSplitter(*aItem.pSplit);
|
2012-08-17 07:29:20 +02:00
|
|
|
}
|
2012-09-07 10:01:42 +02:00
|
|
|
vItems.push_back(aItem);
|
2012-09-05 19:41:42 +02:00
|
|
|
// refresh
|
|
|
|
rLayout.ArrangeWindows();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Remove() -- removes a window from the side (if contains)
|
|
|
|
void Layout::SplittedSide::Remove (DockingWindow* pWin)
|
|
|
|
{
|
|
|
|
// contains?
|
2012-09-07 10:01:42 +02:00
|
|
|
unsigned iWin;
|
|
|
|
for (iWin = 0; iWin != vItems.size(); ++iWin)
|
|
|
|
if (vItems[iWin].pWin == pWin)
|
|
|
|
break;
|
|
|
|
if (iWin == vItems.size())
|
2012-09-05 19:41:42 +02:00
|
|
|
return;
|
|
|
|
// remove
|
2012-09-07 10:01:42 +02:00
|
|
|
vItems.erase(vItems.begin() + iWin);
|
|
|
|
// if that was the first one, remove the first splitter line
|
|
|
|
if (iWin == 0 && !vItems.empty())
|
|
|
|
vItems.front().pSplit.reset();
|
2012-08-17 07:29:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// creating a Point or a Size object
|
|
|
|
// The coordinate order depends on bVertical (reversed if true).
|
2012-09-07 10:31:53 +02:00
|
|
|
inline Size Layout::SplittedSide::MakeSize (long A, long B) const
|
2012-08-17 07:29:20 +02:00
|
|
|
{
|
|
|
|
return bVertical ? Size(B, A) : Size(A, B);
|
|
|
|
}
|
2012-09-07 10:31:53 +02:00
|
|
|
inline Point Layout::SplittedSide::MakePoint (long A, long B) const
|
2012-08-17 07:29:20 +02:00
|
|
|
{
|
|
|
|
return bVertical ? Point(B, A) : Point(A, B);
|
|
|
|
}
|
|
|
|
|
2012-09-07 10:01:42 +02:00
|
|
|
// IsDocking() -- is this window currently docking in the strip?
|
|
|
|
bool Layout::SplittedSide::IsDocking (DockingWindow const& rWin)
|
|
|
|
{
|
|
|
|
return rWin.IsVisible() && !rWin.IsFloatingMode();
|
|
|
|
}
|
|
|
|
|
2012-08-17 07:29:20 +02:00
|
|
|
// IsEmpty() -- are there no windows docked in this strip?
|
|
|
|
bool Layout::SplittedSide::IsEmpty () const
|
|
|
|
{
|
2012-09-07 10:01:42 +02:00
|
|
|
for (unsigned i = 0; i != vItems.size(); ++i)
|
|
|
|
if (IsDocking(*vItems[i].pWin))
|
2012-08-17 07:29:20 +02:00
|
|
|
return false;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// GetSize() -- returns the width or height of the strip (depending on the direction)
|
2012-09-07 10:31:53 +02:00
|
|
|
long Layout::SplittedSide::GetSize () const
|
2012-08-17 07:29:20 +02:00
|
|
|
{
|
|
|
|
return IsEmpty() ? 0 : nSize;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Arrange() -- arranges the docking windows
|
|
|
|
// rRect: the available space
|
|
|
|
void Layout::SplittedSide::ArrangeIn (Rectangle const& rRect)
|
|
|
|
{
|
|
|
|
// saving the rectangle
|
|
|
|
aRect = rRect;
|
|
|
|
|
|
|
|
// the length of the side
|
2012-09-07 10:31:53 +02:00
|
|
|
long const nLength = bVertical ? aRect.GetSize().Height() : aRect.GetSize().Width();
|
|
|
|
long const nOtherSize = bVertical ? aRect.GetSize().Width() : aRect.GetSize().Height();
|
2012-08-17 07:29:20 +02:00
|
|
|
// bVertical ? horizontal pozition : vertical pozition
|
2012-09-07 10:31:53 +02:00
|
|
|
long const nPos1 = (bVertical ? aRect.Left() : aRect.Top()) +
|
2012-08-17 07:29:20 +02:00
|
|
|
(bLower ? 0 : nOtherSize - (nSize - nSplitThickness));
|
|
|
|
// bVertical ? vertical position : horizontal position
|
2012-09-07 10:31:53 +02:00
|
|
|
long const nPos2 = bVertical ? aRect.Top() : aRect.Left();
|
2012-08-17 07:29:20 +02:00
|
|
|
|
|
|
|
// main line
|
2012-09-07 10:01:42 +02:00
|
|
|
bool const bEmpty = IsEmpty();
|
|
|
|
// shown if any of the windows is docked
|
|
|
|
if (!bEmpty)
|
2012-08-17 07:29:20 +02:00
|
|
|
{
|
2012-09-07 10:01:42 +02:00
|
|
|
aSplitter.Show();
|
|
|
|
// split position
|
|
|
|
aSplitter.SetSplitPosPixel((bLower ? nSize : nPos1) - nSplitThickness);
|
|
|
|
// the actual position and size
|
|
|
|
aSplitter.SetPosSizePixel(
|
|
|
|
MakePoint(nPos2, aSplitter.GetSplitPosPixel()),
|
|
|
|
MakeSize(nLength, nSplitThickness)
|
|
|
|
);
|
|
|
|
// dragging rectangle
|
|
|
|
aSplitter.SetDragRectPixel(aRect);
|
2012-08-17 07:29:20 +02:00
|
|
|
}
|
2012-09-07 10:01:42 +02:00
|
|
|
else
|
|
|
|
aSplitter.Hide();
|
2012-08-17 07:29:20 +02:00
|
|
|
|
|
|
|
// positioning separator lines and windows
|
2012-09-07 10:01:42 +02:00
|
|
|
bool bPrevDocking = false; // is the previous window docked?
|
2012-09-07 10:31:53 +02:00
|
|
|
long nStartPos = 0; // window position in the strip
|
2012-09-07 11:47:21 +02:00
|
|
|
unsigned iLastWin = vItems.size(); // index of last docking window in the strip
|
|
|
|
|
2012-09-07 10:01:42 +02:00
|
|
|
for (unsigned i = 0; i != vItems.size(); ++i)
|
2012-08-17 07:29:20 +02:00
|
|
|
{
|
|
|
|
// window
|
2012-09-07 10:01:42 +02:00
|
|
|
DockingWindow& rWin = *vItems[i].pWin;
|
|
|
|
bool const bDocking = IsDocking(rWin);
|
|
|
|
if (bDocking)
|
|
|
|
iLastWin = i;
|
|
|
|
// sizing window
|
2012-08-17 07:29:20 +02:00
|
|
|
rWin.ResizeIfDocking(
|
2012-09-07 10:01:42 +02:00
|
|
|
MakePoint(nPos2 + nStartPos, nPos1),
|
|
|
|
MakeSize(vItems[i].nEndPos - nStartPos, nSize - nSplitThickness)
|
2012-08-17 07:29:20 +02:00
|
|
|
);
|
|
|
|
// splitting line before the window
|
|
|
|
if (i > 0)
|
|
|
|
{
|
2012-09-07 10:01:42 +02:00
|
|
|
Splitter& rSplit = *vItems[i].pSplit;
|
2012-08-17 07:29:20 +02:00
|
|
|
// If neither of two adjacent windows are docked,
|
|
|
|
// the splitting line is hidden.
|
2012-09-07 10:01:42 +02:00
|
|
|
// If this window is docking but the previous isn't,
|
|
|
|
// then the splitting line is also hidden, because this window
|
|
|
|
// will occupy the space of the previous.
|
|
|
|
if (bPrevDocking)
|
2012-08-17 07:29:20 +02:00
|
|
|
{
|
|
|
|
rSplit.Show();
|
2012-09-07 11:47:21 +02:00
|
|
|
// the actual position and size of the line
|
2012-08-17 07:29:20 +02:00
|
|
|
rSplit.SetPosSizePixel(
|
2012-09-07 10:01:42 +02:00
|
|
|
MakePoint(nPos2 + nStartPos - nSplitThickness, nPos1),
|
2012-08-17 07:29:20 +02:00
|
|
|
MakeSize(nSplitThickness, nSize - nSplitThickness)
|
|
|
|
);
|
|
|
|
// the dragging rectangle
|
|
|
|
rSplit.SetDragRectPixel(Rectangle(
|
2012-09-07 10:01:42 +02:00
|
|
|
MakePoint(nPos2, nPos1),
|
2012-08-17 07:29:20 +02:00
|
|
|
MakeSize(nLength, nSize - nSplitThickness)
|
|
|
|
));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
rSplit.Hide();
|
|
|
|
}
|
|
|
|
// next
|
2012-09-07 10:01:42 +02:00
|
|
|
bPrevDocking = bDocking;
|
|
|
|
if (bDocking)
|
|
|
|
nStartPos = vItems[i].nEndPos + nSplitThickness;
|
|
|
|
// We only set nStartPos if this window is docking, because otherwise
|
|
|
|
// the next window will occupy also the space of this window.
|
2012-08-17 07:29:20 +02:00
|
|
|
}
|
|
|
|
|
2012-09-07 10:01:42 +02:00
|
|
|
// filling the remaining space with the last docking window
|
|
|
|
if (!bEmpty && vItems[iLastWin].nEndPos != nLength)
|
|
|
|
{
|
|
|
|
Item& rItem = vItems[iLastWin];
|
|
|
|
Size aSize = rItem.pWin->GetDockingSize();
|
|
|
|
(bVertical ? aSize.Height() : aSize.Width()) += nLength - rItem.nEndPos;
|
|
|
|
rItem.pWin->ResizeIfDocking(aSize);
|
|
|
|
// and hiding the split line after the window
|
|
|
|
if (iLastWin < vItems.size() - 1)
|
|
|
|
vItems[iLastWin + 1].pSplit->Hide();
|
|
|
|
}
|
2012-08-17 07:29:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
IMPL_LINK(Layout::SplittedSide, SplitHdl, Splitter*, pSplitter)
|
|
|
|
{
|
|
|
|
// checking margins
|
|
|
|
CheckMarginsFor(pSplitter);
|
2012-09-07 10:01:42 +02:00
|
|
|
// changing stored sizes
|
2012-08-17 07:29:20 +02:00
|
|
|
if (pSplitter == &aSplitter)
|
|
|
|
{
|
2012-09-07 10:01:42 +02:00
|
|
|
// nSize
|
2012-08-17 07:29:20 +02:00
|
|
|
if (bLower)
|
|
|
|
nSize = pSplitter->GetSplitPosPixel();
|
|
|
|
else
|
|
|
|
nSize = (bVertical ? aRect.Right() : aRect.Bottom()) + 1 - pSplitter->GetSplitPosPixel();
|
|
|
|
}
|
2012-09-07 10:01:42 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
// Item::nStartPos, Item::nLength
|
|
|
|
for (unsigned i = 1; i < vItems.size(); ++i)
|
|
|
|
{
|
|
|
|
if (vItems[i].pSplit.get() == pSplitter)
|
|
|
|
{
|
|
|
|
// before the line
|
|
|
|
vItems[i - 1].nEndPos = pSplitter->GetSplitPosPixel();
|
|
|
|
// after the line
|
|
|
|
vItems[i].nStartPos = pSplitter->GetSplitPosPixel() + nSplitThickness;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-08-17 07:29:20 +02:00
|
|
|
// arranging windows
|
|
|
|
rLayout.ArrangeWindows();
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Layout::SplittedSide::CheckMarginsFor (Splitter* pSplitter)
|
|
|
|
{
|
|
|
|
// The splitter line cannot be closer to the edges than nMargin pixels.
|
2012-09-07 10:31:53 +02:00
|
|
|
static long const nMargin = 16;
|
2012-08-17 07:29:20 +02:00
|
|
|
// Checking margins:
|
2012-09-07 10:31:53 +02:00
|
|
|
if (long const nLength = pSplitter->IsHorizontal() ?
|
2012-08-17 07:29:20 +02:00
|
|
|
aRect.GetWidth() : aRect.GetHeight()
|
|
|
|
) {
|
|
|
|
// bounds
|
2012-09-07 10:31:53 +02:00
|
|
|
long const nLower = (pSplitter->IsHorizontal() ? aRect.Left() : aRect.Top()) + nMargin;
|
|
|
|
long const nUpper = nLower + nLength - 2*nMargin;
|
2012-08-17 07:29:20 +02:00
|
|
|
// split position
|
2012-09-07 10:31:53 +02:00
|
|
|
long const nPos = pSplitter->GetSplitPosPixel();
|
2012-08-17 07:29:20 +02:00
|
|
|
// checking bounds
|
|
|
|
if (nPos < nLower)
|
|
|
|
pSplitter->SetSplitPosPixel(nLower);
|
|
|
|
if (nPos > nUpper)
|
|
|
|
pSplitter->SetSplitPosPixel(nUpper);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Layout::SplittedSide::InitSplitter (Splitter& rSplitter)
|
|
|
|
{
|
|
|
|
// link
|
|
|
|
rSplitter.SetSplitHdl(LINK(this, SplittedSide, SplitHdl));
|
|
|
|
// color
|
|
|
|
Color aColor = rLayout.GetSettings().GetStyleSettings().GetShadowColor();
|
|
|
|
rSplitter.SetLineColor(aColor);
|
|
|
|
rSplitter.SetFillColor(aColor);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
} // namespace basctl
|
|
|
|
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|