Kaydet (Commit) e8fb8613 authored tarafından Caolán McNamara's avatar Caolán McNamara

move layout from dialog to systemwindow

*distant sounds of hammering in basement*

so we can get Floating Windows layout aware
as well without duplicate of dialog layout logic

Change-Id: I063375f2f7d4e5c3bfbfedf55649078d4dbe4139
üst 0d5cc8ce
...@@ -22,7 +22,6 @@ ...@@ -22,7 +22,6 @@
#include <tools/solar.h> #include <tools/solar.h>
#include <vcl/dllapi.h> #include <vcl/dllapi.h>
#include <vcl/builder.hxx>
#include <vcl/syswin.hxx> #include <vcl/syswin.hxx>
#include <vcl/timer.hxx> #include <vcl/timer.hxx>
...@@ -36,11 +35,8 @@ ...@@ -36,11 +35,8 @@
struct DialogImpl; struct DialogImpl;
class VclBox; class VclBox;
class VclButtonBox; class VclButtonBox;
class VclContainer;
class VCL_DLLPUBLIC Dialog class VCL_DLLPUBLIC Dialog : public SystemWindow
: public SystemWindow
, public VclBuilderContainer
{ {
private: private:
Window* mpDialogParent; Window* mpDialogParent;
...@@ -52,8 +48,7 @@ private: ...@@ -52,8 +48,7 @@ private:
bool mbInClose; bool mbInClose;
bool mbModalMode; bool mbModalMode;
bool mbIsDefferedInit; bool mbIsDefferedInit;
bool mbIsCalculatingInitialLayoutSize;
Timer maLayoutTimer;
VclButtonBox* mpActionArea; VclButtonBox* mpActionArea;
VclBox* mpContentArea; VclBox* mpContentArea;
...@@ -65,16 +60,13 @@ private: ...@@ -65,16 +60,13 @@ private:
SAL_DLLPRIVATE Dialog & operator= (const Dialog &); SAL_DLLPRIVATE Dialog & operator= (const Dialog &);
DECL_DLLPRIVATE_LINK( ImplAsyncCloseHdl, void* ); DECL_DLLPRIVATE_LINK( ImplAsyncCloseHdl, void* );
DECL_DLLPRIVATE_LINK( ImplHandleLayoutTimerHdl, void* );
protected: protected:
using Window::ImplInit; using Window::ImplInit;
SAL_DLLPRIVATE void ImplInit( Window* pParent, WinBits nStyle ); SAL_DLLPRIVATE void ImplInit( Window* pParent, WinBits nStyle );
SAL_DLLPRIVATE void setPosSizeOnContainee(Size aSize, VclContainer &rBox);
public: public:
SAL_DLLPRIVATE bool IsInClose() const { return mbInClose; } SAL_DLLPRIVATE bool IsInClose() const { return mbInClose; }
SAL_DLLPRIVATE bool hasPendingLayout() const { return maLayoutTimer.IsActive(); }
SAL_DLLPRIVATE void doDeferredInit(bool bResizable); SAL_DLLPRIVATE void doDeferredInit(bool bResizable);
SAL_DLLPRIVATE bool isDeferredInit() const { return mbIsDefferedInit; } SAL_DLLPRIVATE bool isDeferredInit() const { return mbIsDefferedInit; }
...@@ -82,6 +74,7 @@ protected: ...@@ -82,6 +74,7 @@ protected:
explicit Dialog( WindowType nType ); explicit Dialog( WindowType nType );
explicit Dialog( Window* pParent, const OString& rID, const OUString& rUIXMLDescription, WindowType nType ); explicit Dialog( Window* pParent, const OString& rID, const OUString& rUIXMLDescription, WindowType nType );
virtual void Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize, sal_uLong nFlags ) SAL_OVERRIDE; virtual void Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize, sal_uLong nFlags ) SAL_OVERRIDE;
virtual void settingOptimalLayoutSize(VclBox *pBox) SAL_OVERRIDE;
protected: protected:
friend class VclBuilder; friend class VclBuilder;
...@@ -97,11 +90,6 @@ public: ...@@ -97,11 +90,6 @@ public:
virtual void StateChanged( StateChangedType nStateChange ) SAL_OVERRIDE; virtual void StateChanged( StateChangedType nStateChange ) SAL_OVERRIDE;
virtual void DataChanged( const DataChangedEvent& rDCEvt ) SAL_OVERRIDE; virtual void DataChanged( const DataChangedEvent& rDCEvt ) SAL_OVERRIDE;
virtual Size GetOptimalSize() const SAL_OVERRIDE;
virtual void Resize() SAL_OVERRIDE;
bool isLayoutEnabled() const;
void setOptimalLayoutSize();
bool isCalculatingInitialLayoutSize() const { return mbIsCalculatingInitialLayoutSize; }
virtual void queue_resize(StateChangedType eReason = STATE_CHANGE_LAYOUT) SAL_OVERRIDE; virtual void queue_resize(StateChangedType eReason = STATE_CHANGE_LAYOUT) SAL_OVERRIDE;
virtual bool set_property(const OString &rKey, const OString &rValue) SAL_OVERRIDE; virtual bool set_property(const OString &rKey, const OString &rValue) SAL_OVERRIDE;
VclButtonBox* get_action_area() { return mpActionArea;} VclButtonBox* get_action_area() { return mpActionArea;}
...@@ -112,10 +100,6 @@ public: ...@@ -112,10 +100,6 @@ public:
virtual short Execute(); virtual short Execute();
bool IsInExecute() const { return mbInExecute; } bool IsInExecute() const { return mbInExecute; }
virtual void SetText( const OUString& rStr ) SAL_OVERRIDE;
virtual OUString GetText() const SAL_OVERRIDE;
// Dialog::Execute replacement API // Dialog::Execute replacement API
public: public:
// Link impl: DECL_LINK( MyEndDialogHdl, Dialog* ); <= param is dialog just ended // Link impl: DECL_LINK( MyEndDialogHdl, Dialog* ); <= param is dialog just ended
......
...@@ -22,16 +22,16 @@ ...@@ -22,16 +22,16 @@
#include <tools/solar.h> #include <tools/solar.h>
#include <vcl/dllapi.h> #include <vcl/dllapi.h>
#include <vcl/builder.hxx>
#include <vcl/window.hxx> #include <vcl/window.hxx>
class ModalDialog; class ModalDialog;
class MenuBar; class MenuBar;
class TaskPaneList; class TaskPaneList;
class VclContainer;
class VclBox;
// - Icon-Types - // - Icon-Types -
#define ICON_LO_DEFAULT 1 #define ICON_LO_DEFAULT 1
#define ICON_TEXT_DOCUMENT 2 #define ICON_TEXT_DOCUMENT 2
#define ICON_TEXT_TEMPLATE 3 #define ICON_TEXT_TEMPLATE 3
...@@ -128,12 +128,10 @@ public: ...@@ -128,12 +128,10 @@ public:
#define TITLE_BUTTON_HIDE ((sal_uInt16)2) #define TITLE_BUTTON_HIDE ((sal_uInt16)2)
#define TITLE_BUTTON_MENU ((sal_uInt16)4) #define TITLE_BUTTON_MENU ((sal_uInt16)4)
// - SystemWindow - // - SystemWindow -
class VCL_DLLPUBLIC SystemWindow
: public Window
, public VclBuilderContainer
class VCL_DLLPUBLIC SystemWindow : public Window
{ {
friend class WorkWindow; friend class WorkWindow;
class ImplData; class ImplData;
...@@ -149,23 +147,34 @@ private: ...@@ -149,23 +147,34 @@ private:
bool mbDockBtn; bool mbDockBtn;
bool mbHideBtn; bool mbHideBtn;
bool mbSysChild; bool mbSysChild;
sal_uInt16 mnMenuBarMode; bool mbIsDefferedInit;
sal_uInt16 mnIcon; bool mbIsCalculatingInitialLayoutSize;
bool mbInitialLayoutDone;
sal_uInt16 mnMenuBarMode;
sal_uInt16 mnIcon;
ImplData* mpImplData; ImplData* mpImplData;
Timer maLayoutTimer;
public: public:
using Window::ImplIsInTaskPaneList; using Window::ImplIsInTaskPaneList;
SAL_DLLPRIVATE bool ImplIsInTaskPaneList( Window* pWin ); SAL_DLLPRIVATE bool ImplIsInTaskPaneList( Window* pWin );
private: private:
SAL_DLLPRIVATE void Init();
SAL_DLLPRIVATE void ImplMoveToScreen( long& io_rX, long& io_rY, long i_nWidth, long i_nHeight, Window* i_pConfigureWin ); SAL_DLLPRIVATE void ImplMoveToScreen( long& io_rX, long& io_rY, long i_nWidth, long i_nHeight, Window* i_pConfigureWin );
SAL_DLLPRIVATE void setPosSizeOnContainee(Size aSize, VclContainer &rBox);
DECL_DLLPRIVATE_LINK( ImplHandleLayoutTimerHdl, void* );
protected: protected:
// Single argument ctors shall be explicit. // Single argument ctors shall be explicit.
explicit SystemWindow( WindowType nType ); explicit SystemWindow(WindowType nType);
explicit SystemWindow(Window* pParent, const OString& rID, const OUString& rUIXMLDescription, WindowType nType);
void SetWindowStateData( const WindowStateData& rData );
void SetWindowStateData( const WindowStateData& rData ); virtual void settingOptimalLayoutSize(VclBox *pBox);
SAL_DLLPRIVATE void DoInitialLayout();
public: public:
virtual ~SystemWindow(); virtual ~SystemWindow();
virtual bool Notify( NotifyEvent& rNEvt ) SAL_OVERRIDE; virtual bool Notify( NotifyEvent& rNEvt ) SAL_OVERRIDE;
...@@ -176,6 +185,13 @@ public: ...@@ -176,6 +185,13 @@ public:
virtual void Pin(); virtual void Pin();
virtual void Roll(); virtual void Roll();
virtual void Resizing( Size& rSize ); virtual void Resizing( Size& rSize );
virtual void Resize() SAL_OVERRIDE;
virtual Size GetOptimalSize() const SAL_OVERRIDE;
virtual void StateChanged(StateChangedType nStateChange) SAL_OVERRIDE;
virtual void queue_resize(StateChangedType eReason = STATE_CHANGE_LAYOUT) SAL_OVERRIDE;
bool isLayoutEnabled() const;
void setOptimalLayoutSize();
bool isCalculatingInitialLayoutSize() const { return mbIsCalculatingInitialLayoutSize; }
void SetIcon( sal_uInt16 nIcon ); void SetIcon( sal_uInt16 nIcon );
sal_uInt16 GetIcon() const { return mnIcon; } sal_uInt16 GetIcon() const { return mnIcon; }
...@@ -205,16 +221,19 @@ public: ...@@ -205,16 +221,19 @@ public:
const Size& GetMaxOutputSizePixel() const; const Size& GetMaxOutputSizePixel() const;
void SetWindowState(const OString& rStr); void SetWindowState(const OString& rStr);
OString GetWindowState(sal_uLong nMask = WINDOWSTATE_MASK_ALL) const; OString GetWindowState(sal_uLong nMask = WINDOWSTATE_MASK_ALL) const;
void SetMenuBar( MenuBar* pMenuBar ); void SetMenuBar( MenuBar* pMenuBar );
MenuBar* GetMenuBar() const { return mpMenuBar; } MenuBar* GetMenuBar() const { return mpMenuBar; }
void SetMenuBarMode( sal_uInt16 nMode ); void SetMenuBarMode( sal_uInt16 nMode );
sal_uInt16 GetMenuBarMode() const { return mnMenuBarMode; } sal_uInt16 GetMenuBarMode() const { return mnMenuBarMode; }
TaskPaneList* GetTaskPaneList(); TaskPaneList* GetTaskPaneList();
void GetWindowStateData( WindowStateData& rData ) const; void GetWindowStateData( WindowStateData& rData ) const;
virtual void SetText( const OUString& rStr ) SAL_OVERRIDE;
virtual OUString GetText() const SAL_OVERRIDE;
/** /**
Returns the screen number the window is on Returns the screen number the window is on
...@@ -253,6 +272,8 @@ public: ...@@ -253,6 +272,8 @@ public:
void SetCloseHdl(const Link& rLink); void SetCloseHdl(const Link& rLink);
const Link& GetCloseHdl() const; const Link& GetCloseHdl() const;
SAL_DLLPRIVATE bool hasPendingLayout() const { return maLayoutTimer.IsActive(); }
}; };
#endif // INCLUDED_VCL_SYSWIN_HXX #endif // INCLUDED_VCL_SYSWIN_HXX
......
...@@ -176,7 +176,7 @@ VclBuilder::VclBuilder(Window *pParent, const OUString& sUIDir, const OUString& ...@@ -176,7 +176,7 @@ VclBuilder::VclBuilder(Window *pParent, const OUString& sUIDir, const OUString&
, m_pParserState(new ParserState) , m_pParserState(new ParserState)
, m_xFrame(rFrame) , m_xFrame(rFrame)
{ {
m_bToplevelHasDeferredInit = pParent && pParent->IsDialog() && ((Dialog*)pParent)->isDeferredInit(); m_bToplevelHasDeferredInit = pParent && pParent->IsDialog() && static_cast<Dialog*>(pParent)->isDeferredInit();
m_bToplevelHasDeferredProperties = m_bToplevelHasDeferredInit; m_bToplevelHasDeferredProperties = m_bToplevelHasDeferredInit;
sal_Int32 nIdx = m_sHelpRoot.lastIndexOf('.'); sal_Int32 nIdx = m_sHelpRoot.lastIndexOf('.');
...@@ -1663,7 +1663,7 @@ Window *VclBuilder::insertObject(Window *pParent, const OString &rClass, ...@@ -1663,7 +1663,7 @@ Window *VclBuilder::insertObject(Window *pParent, const OString &rClass,
//toplevels default to resizable //toplevels default to resizable
if (pCurrentChild->IsDialog()) if (pCurrentChild->IsDialog())
{ {
Dialog *pDialog = (Dialog*)pCurrentChild; Dialog *pDialog = static_cast<Dialog*>(pCurrentChild);
pDialog->doDeferredInit(extractResizable(rProps)); pDialog->doDeferredInit(extractResizable(rProps));
m_bToplevelHasDeferredInit = false; m_bToplevelHasDeferredInit = false;
} }
......
...@@ -347,13 +347,8 @@ void Dialog::ImplInitDialogData() ...@@ -347,13 +347,8 @@ void Dialog::ImplInitDialogData()
mbModalMode = false; mbModalMode = false;
mpContentArea = NULL; mpContentArea = NULL;
mpActionArea = NULL; mpActionArea = NULL;
mbIsCalculatingInitialLayoutSize = false;
mnMousePositioned = 0; mnMousePositioned = 0;
mpDialogImpl = new DialogImpl; mpDialogImpl = new DialogImpl;
//To-Do, reuse maResizeTimer
maLayoutTimer.SetTimeout(50);
maLayoutTimer.SetTimeoutHdl( LINK( this, Dialog, ImplHandleLayoutTimerHdl ) );
} }
void Dialog::ImplInit( Window* pParent, WinBits nStyle ) void Dialog::ImplInit( Window* pParent, WinBits nStyle )
...@@ -531,9 +526,24 @@ void Dialog::set_content_area(VclBox* pContentArea) ...@@ -531,9 +526,24 @@ void Dialog::set_content_area(VclBox* pContentArea)
mpContentArea = pContentArea; mpContentArea = pContentArea;
} }
void Dialog::settingOptimalLayoutSize(VclBox *pBox)
{
const DialogStyle& rDialogStyle =
GetSettings().GetStyleSettings().GetDialogStyle();
pBox->set_border_width(rDialogStyle.content_area_border);
pBox->set_spacing(pBox->get_spacing() +
rDialogStyle.content_area_spacing);
VclButtonBox *pActionArea = getActionArea(this);
if (pActionArea)
{
pActionArea->set_border_width(rDialogStyle.action_area_border);
pActionArea->set_spacing(rDialogStyle.button_spacing);
}
}
Dialog::~Dialog() Dialog::~Dialog()
{ {
maLayoutTimer.Stop();
delete mpDialogImpl; delete mpDialogImpl;
mpDialogImpl = NULL; mpDialogImpl = NULL;
} }
...@@ -614,54 +624,14 @@ Size bestmaxFrameSizeForScreenSize(const Size &rScreenSize) ...@@ -614,54 +624,14 @@ Size bestmaxFrameSizeForScreenSize(const Size &rScreenSize)
return Size(w, h); return Size(w, h);
} }
void Dialog::setOptimalLayoutSize()
{
maLayoutTimer.Stop();
//resize dialog to fit requisition on initial show
VclBox *pBox = static_cast<VclBox*>(GetWindow(WINDOW_FIRSTCHILD));
const DialogStyle& rDialogStyle =
GetSettings().GetStyleSettings().GetDialogStyle();
pBox->set_border_width(rDialogStyle.content_area_border);
pBox->set_spacing(pBox->get_spacing() +
rDialogStyle.content_area_spacing);
VclButtonBox *pActionArea = getActionArea(this);
if (pActionArea)
{
pActionArea->set_border_width(rDialogStyle.action_area_border);
pActionArea->set_spacing(rDialogStyle.button_spacing);
}
Size aSize = get_preferred_size();
Size aMax(bestmaxFrameSizeForScreenSize(GetDesktopRectPixel().GetSize()));
aSize.Width() = std::min(aMax.Width(), aSize.Width());
aSize.Height() = std::min(aMax.Height(), aSize.Height());
SetMinOutputSizePixel(aSize);
SetSizePixel(aSize);
setPosSizeOnContainee(aSize, *pBox);
}
void Dialog::StateChanged( StateChangedType nType ) void Dialog::StateChanged( StateChangedType nType )
{ {
SystemWindow::StateChanged( nType ); if (nType == STATE_CHANGE_INITSHOW)
if ( nType == STATE_CHANGE_INITSHOW )
{ {
if ( GetSettings().GetStyleSettings().GetAutoMnemonic() ) if ( GetSettings().GetStyleSettings().GetAutoMnemonic() )
ImplWindowAutoMnemonic( this ); ImplWindowAutoMnemonic( this );
if (isLayoutEnabled()) DoInitialLayout();
{
mbIsCalculatingInitialLayoutSize = true;
setDeferredProperties();
setOptimalLayoutSize();
mbIsCalculatingInitialLayoutSize = false;
}
if ( !HasChildPathFocus() || HasFocus() ) if ( !HasChildPathFocus() || HasFocus() )
GrabFocusToFirstControl(); GrabFocusToFirstControl();
...@@ -676,7 +646,10 @@ void Dialog::StateChanged( StateChangedType nType ) ...@@ -676,7 +646,10 @@ void Dialog::StateChanged( StateChangedType nType )
ImplMouseAutoPos( this ); ImplMouseAutoPos( this );
} }
else if ( nType == STATE_CHANGE_CONTROLBACKGROUND )
SystemWindow::StateChanged( nType );
if (nType == STATE_CHANGE_CONTROLBACKGROUND)
{ {
ImplInitSettings(); ImplInitSettings();
Invalidate(); Invalidate();
...@@ -1166,75 +1139,11 @@ void Dialog::Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize, sal ...@@ -1166,75 +1139,11 @@ void Dialog::Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize, sal
pDev->Pop(); pDev->Pop();
} }
bool Dialog::isLayoutEnabled() const void Dialog::queue_resize(StateChangedType eReason)
{
//pre dtor called, and single child is a container => we're layout enabled
return mpDialogImpl && ::isLayoutEnabled(this);
}
Size Dialog::GetOptimalSize() const
{
if (!isLayoutEnabled())
return SystemWindow::GetOptimalSize();
Size aSize = VclContainer::getLayoutRequisition(*GetWindow(WINDOW_FIRSTCHILD));
sal_Int32 nBorderWidth = get_border_width();
aSize.Height() += mpWindowImpl->mnLeftBorder + mpWindowImpl->mnRightBorder
+ 2*nBorderWidth;
aSize.Width() += mpWindowImpl->mnTopBorder + mpWindowImpl->mnBottomBorder
+ 2*nBorderWidth;
return Window::CalcWindowSize(aSize);
}
void Dialog::setPosSizeOnContainee(Size aSize, VclContainer &rBox)
{
sal_Int32 nBorderWidth = get_border_width();
aSize.Width() -= mpWindowImpl->mnLeftBorder + mpWindowImpl->mnRightBorder
+ 2 * nBorderWidth;
aSize.Height() -= mpWindowImpl->mnTopBorder + mpWindowImpl->mnBottomBorder
+ 2 * nBorderWidth;
Point aPos(mpWindowImpl->mnLeftBorder + nBorderWidth,
mpWindowImpl->mnTopBorder + nBorderWidth);
VclContainer::setLayoutAllocation(rBox, aPos, aSize);
}
IMPL_LINK( Dialog, ImplHandleLayoutTimerHdl, void*, EMPTYARG )
{ {
if (!isLayoutEnabled())
{
SAL_WARN("vcl.layout", "Dialog has become non-layout because extra children have been added directly to it.");
return 0;
}
VclBox *pBox = static_cast<VclBox*>(GetWindow(WINDOW_FIRSTCHILD));
assert(pBox);
setPosSizeOnContainee(GetSizePixel(), *pBox);
return 0;
}
void Dialog::queue_resize(StateChangedType /*eReason*/)
{
if (hasPendingLayout() || isCalculatingInitialLayoutSize())
return;
if (IsInClose()) if (IsInClose())
return; return;
if (!isLayoutEnabled()) SystemWindow::queue_resize(eReason);
return;
WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl : mpWindowImpl;
pWindowImpl->mnOptimalWidthCache = -1;
pWindowImpl->mnOptimalHeightCache = -1;
maLayoutTimer.Start();
}
void Dialog::Resize()
{
queue_resize();
} }
bool Dialog::set_property(const OString &rKey, const OString &rValue) bool Dialog::set_property(const OString &rKey, const OString &rValue)
...@@ -1246,18 +1155,6 @@ bool Dialog::set_property(const OString &rKey, const OString &rValue) ...@@ -1246,18 +1155,6 @@ bool Dialog::set_property(const OString &rKey, const OString &rValue)
return true; return true;
} }
void Dialog::SetText(const OUString& rStr)
{
setDeferredProperties();
SystemWindow::SetText(rStr);
}
OUString Dialog::GetText() const
{
const_cast<Dialog*>(this)->setDeferredProperties();
return SystemWindow::GetText();
}
VclBuilderContainer::VclBuilderContainer() VclBuilderContainer::VclBuilderContainer()
: m_pUIBuilder(NULL) : m_pUIBuilder(NULL)
{ {
......
...@@ -284,7 +284,7 @@ void Window::ImplPostPaint() ...@@ -284,7 +284,7 @@ void Window::ImplPostPaint()
IMPL_LINK_NOARG(Window, ImplHandlePaintHdl) IMPL_LINK_NOARG(Window, ImplHandlePaintHdl)
{ {
// save paint events until layout is done // save paint events until layout is done
if (!ImplDoTiledRendering() && IsDialog() && static_cast<const Dialog*>(this)->hasPendingLayout()) if (!ImplDoTiledRendering() && IsSystemWindow() && static_cast<const SystemWindow*>(this)->hasPendingLayout())
{ {
mpWindowImpl->mpFrameData->maPaintTimer.Start(); mpWindowImpl->mpFrameData->maPaintTimer.Start();
return 0; return 0;
......
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#include <tools/debug.hxx> #include <tools/debug.hxx>
#include <vcl/layout.hxx>
#include <vcl/svapp.hxx> #include <vcl/svapp.hxx>
#include <vcl/menu.hxx> #include <vcl/menu.hxx>
#include <vcl/event.hxx> #include <vcl/event.hxx>
...@@ -60,12 +61,10 @@ SystemWindow::ImplData::ImplData() ...@@ -60,12 +61,10 @@ SystemWindow::ImplData::ImplData()
SystemWindow::ImplData::~ImplData() SystemWindow::ImplData::~ImplData()
{ {
if( mpTaskPaneList ) delete mpTaskPaneList;
delete mpTaskPaneList;
} }
SystemWindow::SystemWindow( WindowType nType ) : void SystemWindow::Init()
Window( nType )
{ {
mpImplData = new ImplData; mpImplData = new ImplData;
mpWindowImpl->mbSysWin = true; mpWindowImpl->mbSysWin = true;
...@@ -78,12 +77,32 @@ SystemWindow::SystemWindow( WindowType nType ) : ...@@ -78,12 +77,32 @@ SystemWindow::SystemWindow( WindowType nType ) :
mbDockBtn = false; mbDockBtn = false;
mbHideBtn = false; mbHideBtn = false;
mbSysChild = false; mbSysChild = false;
mbIsCalculatingInitialLayoutSize = false;
mbInitialLayoutDone = false;
mnMenuBarMode = MENUBAR_MODE_NORMAL; mnMenuBarMode = MENUBAR_MODE_NORMAL;
mnIcon = 0; mnIcon = 0;
//To-Do, reuse maResizeTimer
maLayoutTimer.SetTimeout(50);
maLayoutTimer.SetTimeoutHdl( LINK( this, SystemWindow, ImplHandleLayoutTimerHdl ) );
}
SystemWindow::SystemWindow(WindowType nType)
: Window(nType)
{
Init();
}
SystemWindow::SystemWindow(Window* pParent, const OString& rID, const OUString& rUIXMLDescription, WindowType nType)
: Window(pParent, nType)
{
Init();
m_pUIBuilder = new VclBuilder(this, getUIRootDir(), rUIXMLDescription, rID);
} }
SystemWindow::~SystemWindow() SystemWindow::~SystemWindow()
{ {
maLayoutTimer.Stop();
delete mpImplData; delete mpImplData;
mpImplData = NULL; mpImplData = NULL;
} }
...@@ -965,4 +984,132 @@ const Link& SystemWindow::GetCloseHdl() const ...@@ -965,4 +984,132 @@ const Link& SystemWindow::GetCloseHdl() const
return mpImplData->maCloseHdl; return mpImplData->maCloseHdl;
} }
void SystemWindow::queue_resize(StateChangedType /*eReason*/)
{
if (hasPendingLayout() || isCalculatingInitialLayoutSize())
return;
if (!isLayoutEnabled())
return;
WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl : mpWindowImpl;
pWindowImpl->mnOptimalWidthCache = -1;
pWindowImpl->mnOptimalHeightCache = -1;
maLayoutTimer.Start();
}
void SystemWindow::Resize()
{
queue_resize();
}
bool SystemWindow::isLayoutEnabled() const
{
//pre dtor called, and single child is a container => we're layout enabled
return mpImplData && ::isLayoutEnabled(this);
}
Size SystemWindow::GetOptimalSize() const
{
if (!isLayoutEnabled())
return Window::GetOptimalSize();
Size aSize = VclContainer::getLayoutRequisition(*GetWindow(WINDOW_FIRSTCHILD));
sal_Int32 nBorderWidth = get_border_width();
aSize.Height() += mpWindowImpl->mnLeftBorder + mpWindowImpl->mnRightBorder
+ 2*nBorderWidth;
aSize.Width() += mpWindowImpl->mnTopBorder + mpWindowImpl->mnBottomBorder
+ 2*nBorderWidth;
return Window::CalcWindowSize(aSize);
}
void SystemWindow::setPosSizeOnContainee(Size aSize, VclContainer &rBox)
{
sal_Int32 nBorderWidth = get_border_width();
aSize.Width() -= mpWindowImpl->mnLeftBorder + mpWindowImpl->mnRightBorder
+ 2 * nBorderWidth;
aSize.Height() -= mpWindowImpl->mnTopBorder + mpWindowImpl->mnBottomBorder
+ 2 * nBorderWidth;
Point aPos(mpWindowImpl->mnLeftBorder + nBorderWidth,
mpWindowImpl->mnTopBorder + nBorderWidth);
VclContainer::setLayoutAllocation(rBox, aPos, aSize);
}
IMPL_LINK( SystemWindow, ImplHandleLayoutTimerHdl, void*, EMPTYARG )
{
if (!isLayoutEnabled())
{
SAL_WARN("vcl.layout", "SystemWindow has become non-layout because extra children have been added directly to it.");
return 0;
}
VclBox *pBox = static_cast<VclBox*>(GetWindow(WINDOW_FIRSTCHILD));
assert(pBox);
setPosSizeOnContainee(GetSizePixel(), *pBox);
return 0;
}
void SystemWindow::SetText(const OUString& rStr)
{
setDeferredProperties();
Window::SetText(rStr);
}
OUString SystemWindow::GetText() const
{
const_cast<SystemWindow*>(this)->setDeferredProperties();
return Window::GetText();
}
void SystemWindow::settingOptimalLayoutSize(VclBox* /*pBox*/)
{
}
void SystemWindow::setOptimalLayoutSize()
{
maLayoutTimer.Stop();
//resize SystemWindow to fit requisition on initial show
VclBox *pBox = static_cast<VclBox*>(GetWindow(WINDOW_FIRSTCHILD));
settingOptimalLayoutSize(pBox);
Size aSize = get_preferred_size();
Size aMax(bestmaxFrameSizeForScreenSize(GetDesktopRectPixel().GetSize()));
aSize.Width() = std::min(aMax.Width(), aSize.Width());
aSize.Height() = std::min(aMax.Height(), aSize.Height());
SetMinOutputSizePixel(aSize);
SetSizePixel(aSize);
setPosSizeOnContainee(aSize, *pBox);
}
void SystemWindow::DoInitialLayout()
{
if (isLayoutEnabled())
{
mbIsCalculatingInitialLayoutSize = true;
setDeferredProperties();
setOptimalLayoutSize();
mbIsCalculatingInitialLayoutSize = false;
mbInitialLayoutDone = true;
}
}
void SystemWindow::StateChanged( StateChangedType nType )
{
Window::StateChanged(nType);
if (nType == STATE_CHANGE_INITSHOW && !mbInitialLayoutDone)
{
DoInitialLayout();
}
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment