rearrange matters to get FloatingWindows working loaded from .ui
Change-Id: I099c810533c4590ee3182e1edf27e9038ed44f30
This commit is contained in:
@@ -39,7 +39,6 @@ class VclButtonBox;
|
||||
class VCL_DLLPUBLIC Dialog : public SystemWindow
|
||||
{
|
||||
private:
|
||||
Window* mpDialogParent;
|
||||
Dialog* mpPrevExecuteDlg;
|
||||
DialogImpl* mpDialogImpl;
|
||||
long mnMousePositioned;
|
||||
@@ -47,7 +46,6 @@ private:
|
||||
bool mbOldSaveBack;
|
||||
bool mbInClose;
|
||||
bool mbModalMode;
|
||||
bool mbIsDefferedInit;
|
||||
|
||||
VclButtonBox* mpActionArea;
|
||||
VclBox* mpContentArea;
|
||||
@@ -67,8 +65,7 @@ protected:
|
||||
|
||||
public:
|
||||
SAL_DLLPRIVATE bool IsInClose() const { return mbInClose; }
|
||||
SAL_DLLPRIVATE void doDeferredInit(bool bResizable);
|
||||
SAL_DLLPRIVATE bool isDeferredInit() const { return mbIsDefferedInit; }
|
||||
virtual void doDeferredInit(bool bResizable) SAL_OVERRIDE;
|
||||
|
||||
protected:
|
||||
explicit Dialog( WindowType nType );
|
||||
|
@@ -117,9 +117,10 @@ public:
|
||||
SAL_DLLPRIVATE void ImplEndPopupMode( sal_uInt16 nFlags = 0, sal_uLong nFocusId = 0 );
|
||||
SAL_DLLPRIVATE Rectangle& ImplGetItemEdgeClipRect();
|
||||
SAL_DLLPRIVATE bool ImplIsInPrivatePopupMode() const { return mbInPopupMode; }
|
||||
virtual void doDeferredInit(bool bResizable) SAL_OVERRIDE;
|
||||
|
||||
public:
|
||||
explicit FloatingWindow( Window* pParent, WinBits nStyle = WB_STDFLOATWIN );
|
||||
explicit FloatingWindow(Window* pParent, WinBits nStyle = WB_STDFLOATWIN);
|
||||
explicit FloatingWindow(Window* pParent, const OString& rID, const OUString& rUIXMLDescription);
|
||||
explicit FloatingWindow( Window* pParent, const ResId& );
|
||||
virtual ~FloatingWindow();
|
||||
@@ -131,7 +132,7 @@ public:
|
||||
virtual void PopupModeEnd();
|
||||
|
||||
void SetTitleType( sal_uInt16 nTitle );
|
||||
sal_uInt16 GetTitleType() const { return mnTitle; }
|
||||
sal_uInt16 GetTitleType() const { return mnTitle; }
|
||||
|
||||
void StartPopupMode( const Rectangle& rRect, sal_uLong nFlags = 0 );
|
||||
void StartPopupMode( ToolBox* pBox, sal_uLong nFlags = 0 );
|
||||
|
@@ -147,17 +147,19 @@ private:
|
||||
bool mbDockBtn;
|
||||
bool mbHideBtn;
|
||||
bool mbSysChild;
|
||||
bool mbIsDefferedInit;
|
||||
bool mbIsCalculatingInitialLayoutSize;
|
||||
bool mbInitialLayoutDone;
|
||||
sal_uInt16 mnMenuBarMode;
|
||||
sal_uInt16 mnIcon;
|
||||
ImplData* mpImplData;
|
||||
Timer maLayoutTimer;
|
||||
|
||||
protected:
|
||||
bool mbIsDefferedInit;
|
||||
Window* mpDialogParent;
|
||||
public:
|
||||
using Window::ImplIsInTaskPaneList;
|
||||
SAL_DLLPRIVATE bool ImplIsInTaskPaneList( Window* pWin );
|
||||
SAL_DLLPRIVATE bool isDeferredInit() const { return mbIsDefferedInit; }
|
||||
|
||||
private:
|
||||
SAL_DLLPRIVATE void Init();
|
||||
@@ -168,7 +170,7 @@ private:
|
||||
protected:
|
||||
// Single argument ctors shall be explicit.
|
||||
explicit SystemWindow(WindowType nType);
|
||||
explicit SystemWindow(Window* pParent, const OString& rID, const OUString& rUIXMLDescription, WindowType nType);
|
||||
void loadUI(Window* pParent, const OString& rID, const OUString& rUIXMLDescription);
|
||||
|
||||
void SetWindowStateData( const WindowStateData& rData );
|
||||
|
||||
@@ -187,7 +189,6 @@ public:
|
||||
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();
|
||||
@@ -274,6 +275,8 @@ public:
|
||||
const Link& GetCloseHdl() const;
|
||||
|
||||
SAL_DLLPRIVATE bool hasPendingLayout() const { return maLayoutTimer.IsActive(); }
|
||||
|
||||
virtual void doDeferredInit(bool bResizable);
|
||||
};
|
||||
|
||||
#endif // INCLUDED_VCL_SYSWIN_HXX
|
||||
|
@@ -70,17 +70,22 @@ int UIPreviewApp::Main()
|
||||
|
||||
{
|
||||
VclBuilder aBuilder(pDialog, OUString(), uifiles[0]);
|
||||
Dialog *pRealDialog = dynamic_cast<Dialog*>(aBuilder.get_widget_root());
|
||||
Window *pRoot = aBuilder.get_widget_root();
|
||||
Dialog *pRealDialog = dynamic_cast<Dialog*>(pRoot);
|
||||
|
||||
if (!pRealDialog)
|
||||
pRealDialog = pDialog;
|
||||
|
||||
if (pRealDialog)
|
||||
{
|
||||
pRealDialog->SetText(OUString("LibreOffice ui-previewer"));
|
||||
pRealDialog->SetStyle(pDialog->GetStyle()|WB_CLOSEABLE);
|
||||
pRealDialog->Execute();
|
||||
}
|
||||
pRealDialog->SetText(OUString("LibreOffice ui-previewer"));
|
||||
pRealDialog->SetStyle(pDialog->GetStyle()|WB_CLOSEABLE);
|
||||
/*
|
||||
Force a new STATE_CHANGE_INITSHOW for the edge case where pRoot
|
||||
is not a dialog or contents of a dialog, but instead a visible floating window
|
||||
which may have had initshow already done before it was given children
|
||||
*/
|
||||
pRoot->Hide();
|
||||
pRoot->Show();
|
||||
pRealDialog->Execute();
|
||||
}
|
||||
|
||||
delete pDialog;
|
||||
|
@@ -176,7 +176,7 @@ VclBuilder::VclBuilder(Window *pParent, const OUString& sUIDir, const OUString&
|
||||
, m_pParserState(new ParserState)
|
||||
, m_xFrame(rFrame)
|
||||
{
|
||||
m_bToplevelHasDeferredInit = pParent && pParent->IsDialog() && static_cast<Dialog*>(pParent)->isDeferredInit();
|
||||
m_bToplevelHasDeferredInit = pParent && pParent->IsSystemWindow() && static_cast<SystemWindow*>(pParent)->isDeferredInit();
|
||||
m_bToplevelHasDeferredProperties = m_bToplevelHasDeferredInit;
|
||||
|
||||
sal_Int32 nIdx = m_sHelpRoot.lastIndexOf('.');
|
||||
@@ -571,6 +571,18 @@ OString VclBuilder::extractCustomProperty(VclBuilder::stringmap &rMap)
|
||||
|
||||
namespace
|
||||
{
|
||||
OString extractTypeHint(VclBuilder::stringmap &rMap)
|
||||
{
|
||||
OString sRet("normal");
|
||||
VclBuilder::stringmap::iterator aFind = rMap.find(OString("type-hint"));
|
||||
if (aFind != rMap.end())
|
||||
{
|
||||
sRet = aFind->second;
|
||||
rMap.erase(aFind);
|
||||
}
|
||||
return sRet;
|
||||
}
|
||||
|
||||
bool extractResizable(VclBuilder::stringmap &rMap)
|
||||
{
|
||||
bool bResizable = true;
|
||||
@@ -1571,6 +1583,21 @@ Window *VclBuilder::makeObject(Window *pParent, const OString &name, const OStri
|
||||
return NULL; // no widget to be created
|
||||
}
|
||||
}
|
||||
else if (name == "GtkWindow")
|
||||
{
|
||||
WinBits nBits = WB_SYSTEMWINDOW|WB_MOVEABLE|WB_3DLOOK|WB_CLOSEABLE|WB_HIDE;
|
||||
if (extractResizable(rMap))
|
||||
nBits |= WB_SIZEABLE;
|
||||
OString sType(extractTypeHint(rMap));
|
||||
if (sType == "utility")
|
||||
{
|
||||
pWindow = new FloatingWindow(pParent, nBits);
|
||||
}
|
||||
else
|
||||
{
|
||||
SAL_WARN("vcl.layout", "no mapping yet for GtkWindow of type " << sType.getStr() << " yet");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
sal_Int32 nDelim = name.indexOf('-');
|
||||
@@ -1660,13 +1687,17 @@ Window *VclBuilder::insertObject(Window *pParent, const OString &rClass,
|
||||
if (m_pParent && !isConsideredGtkPseudo(m_pParent) && !m_sID.isEmpty() && rID.equals(m_sID))
|
||||
{
|
||||
pCurrentChild = m_pParent;
|
||||
//toplevels default to resizable
|
||||
if (pCurrentChild->IsDialog())
|
||||
|
||||
//toplevels default to resizable and apparently you can't change them
|
||||
//afterwards, so we need to wait until now before we can truly
|
||||
//initialize the dialog.
|
||||
if (pParent->IsSystemWindow())
|
||||
{
|
||||
Dialog *pDialog = static_cast<Dialog*>(pCurrentChild);
|
||||
pDialog->doDeferredInit(extractResizable(rProps));
|
||||
SystemWindow *pSysWin = static_cast<SystemWindow*>(pCurrentChild);
|
||||
pSysWin->doDeferredInit(extractResizable(rProps));
|
||||
m_bToplevelHasDeferredInit = false;
|
||||
}
|
||||
|
||||
if (pCurrentChild->GetHelpId().isEmpty())
|
||||
{
|
||||
pCurrentChild->SetHelpId(m_sHelpRoot + m_sID);
|
||||
|
@@ -339,7 +339,6 @@ struct DialogImpl
|
||||
void Dialog::ImplInitDialogData()
|
||||
{
|
||||
mpWindowImpl->mbDialog = true;
|
||||
mpDialogParent = NULL;
|
||||
mpPrevExecuteDlg = NULL;
|
||||
mbInExecute = false;
|
||||
mbOldSaveBack = false;
|
||||
@@ -450,7 +449,6 @@ void Dialog::ImplInitSettings()
|
||||
|
||||
Dialog::Dialog( WindowType nType )
|
||||
: SystemWindow( nType )
|
||||
, mbIsDefferedInit(false)
|
||||
{
|
||||
ImplInitDialogData();
|
||||
}
|
||||
@@ -491,26 +489,21 @@ void Dialog::doDeferredInit(bool bResizable)
|
||||
}
|
||||
|
||||
Dialog::Dialog(Window* pParent, const OString& rID, const OUString& rUIXMLDescription)
|
||||
: SystemWindow( WINDOW_DIALOG )
|
||||
, mbIsDefferedInit(true)
|
||||
: SystemWindow(WINDOW_DIALOG)
|
||||
{
|
||||
ImplInitDialogData();
|
||||
mpDialogParent = pParent; //will be unset in doDeferredInit
|
||||
m_pUIBuilder = new VclBuilder(this, getUIRootDir(), rUIXMLDescription, rID);
|
||||
loadUI(pParent, rID, rUIXMLDescription);
|
||||
}
|
||||
|
||||
Dialog::Dialog(Window* pParent, const OString& rID, const OUString& rUIXMLDescription, WindowType nType)
|
||||
: SystemWindow( nType )
|
||||
, mbIsDefferedInit(true)
|
||||
: SystemWindow(nType)
|
||||
{
|
||||
ImplInitDialogData();
|
||||
mpDialogParent = pParent; //will be unset in doDeferredInit
|
||||
m_pUIBuilder = new VclBuilder(this, getUIRootDir(), rUIXMLDescription, rID);
|
||||
loadUI(pParent, rID, rUIXMLDescription);
|
||||
}
|
||||
|
||||
Dialog::Dialog( Window* pParent, WinBits nStyle )
|
||||
: SystemWindow( WINDOW_DIALOG )
|
||||
, mbIsDefferedInit(false)
|
||||
Dialog::Dialog(Window* pParent, WinBits nStyle)
|
||||
: SystemWindow(WINDOW_DIALOG)
|
||||
{
|
||||
ImplInitDialogData();
|
||||
ImplInit( pParent, nStyle );
|
||||
|
@@ -165,8 +165,21 @@ FloatingWindow::FloatingWindow( Window* pParent, const ResId& rResId ) :
|
||||
}
|
||||
|
||||
FloatingWindow::FloatingWindow(Window* pParent, const OString& rID, const OUString& rUIXMLDescription)
|
||||
: SystemWindow(pParent, rID, rUIXMLDescription, WINDOW_FLOATINGWINDOW)
|
||||
: SystemWindow(WINDOW_FLOATINGWINDOW)
|
||||
{
|
||||
loadUI(pParent, rID, rUIXMLDescription);
|
||||
}
|
||||
|
||||
//Find the real parent stashed in mpDialogParent.
|
||||
void FloatingWindow::doDeferredInit(bool bResizable)
|
||||
{
|
||||
WinBits nBits = WB_MOVEABLE|WB_3DLOOK;
|
||||
if (bResizable)
|
||||
nBits |= WB_SIZEABLE;
|
||||
Window *pParent = mpDialogParent;
|
||||
mpDialogParent = NULL;
|
||||
ImplInit(pParent, nBits);
|
||||
mbIsDefferedInit = false;
|
||||
}
|
||||
|
||||
void FloatingWindow::ImplLoadRes( const ResId& rResId )
|
||||
@@ -554,6 +567,11 @@ bool FloatingWindow::Notify( NotifyEvent& rNEvt )
|
||||
|
||||
void FloatingWindow::StateChanged( StateChangedType nType )
|
||||
{
|
||||
if (nType == STATE_CHANGE_INITSHOW)
|
||||
{
|
||||
DoInitialLayout();
|
||||
}
|
||||
|
||||
SystemWindow::StateChanged( nType );
|
||||
|
||||
if ( nType == STATE_CHANGE_CONTROLBACKGROUND )
|
||||
|
@@ -81,6 +81,7 @@ void SystemWindow::Init()
|
||||
mbInitialLayoutDone = false;
|
||||
mnMenuBarMode = MENUBAR_MODE_NORMAL;
|
||||
mnIcon = 0;
|
||||
mpDialogParent = NULL;
|
||||
|
||||
//To-Do, reuse maResizeTimer
|
||||
maLayoutTimer.SetTimeout(50);
|
||||
@@ -89,14 +90,15 @@ void SystemWindow::Init()
|
||||
|
||||
SystemWindow::SystemWindow(WindowType nType)
|
||||
: Window(nType)
|
||||
, mbIsDefferedInit(false)
|
||||
{
|
||||
Init();
|
||||
}
|
||||
|
||||
SystemWindow::SystemWindow(Window* pParent, const OString& rID, const OUString& rUIXMLDescription, WindowType nType)
|
||||
: Window(pParent, nType)
|
||||
void SystemWindow::loadUI(Window* pParent, const OString& rID, const OUString& rUIXMLDescription)
|
||||
{
|
||||
Init();
|
||||
mbIsDefferedInit = true;
|
||||
mpDialogParent = pParent; //should be unset in doDeferredInit
|
||||
m_pUIBuilder = new VclBuilder(this, getUIRootDir(), rUIXMLDescription, rID);
|
||||
}
|
||||
|
||||
@@ -1102,14 +1104,9 @@ void SystemWindow::DoInitialLayout()
|
||||
}
|
||||
}
|
||||
|
||||
void SystemWindow::StateChanged( StateChangedType nType )
|
||||
void SystemWindow::doDeferredInit(bool /*bResizable*/)
|
||||
{
|
||||
Window::StateChanged(nType);
|
||||
|
||||
if (nType == STATE_CHANGE_INITSHOW && !mbInitialLayoutDone)
|
||||
{
|
||||
DoInitialLayout();
|
||||
}
|
||||
SAL_WARN("vcl.layout", "SystemWindow in layout without doDeferredInit impl");
|
||||
}
|
||||
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||
|
Reference in New Issue
Block a user