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

rearrange matters to get FloatingWindows working loaded from .ui

Change-Id: I099c810533c4590ee3182e1edf27e9038ed44f30
üst 2f1eed48
...@@ -39,7 +39,6 @@ class VclButtonBox; ...@@ -39,7 +39,6 @@ class VclButtonBox;
class VCL_DLLPUBLIC Dialog : public SystemWindow class VCL_DLLPUBLIC Dialog : public SystemWindow
{ {
private: private:
Window* mpDialogParent;
Dialog* mpPrevExecuteDlg; Dialog* mpPrevExecuteDlg;
DialogImpl* mpDialogImpl; DialogImpl* mpDialogImpl;
long mnMousePositioned; long mnMousePositioned;
...@@ -47,7 +46,6 @@ private: ...@@ -47,7 +46,6 @@ private:
bool mbOldSaveBack; bool mbOldSaveBack;
bool mbInClose; bool mbInClose;
bool mbModalMode; bool mbModalMode;
bool mbIsDefferedInit;
VclButtonBox* mpActionArea; VclButtonBox* mpActionArea;
VclBox* mpContentArea; VclBox* mpContentArea;
...@@ -67,8 +65,7 @@ protected: ...@@ -67,8 +65,7 @@ protected:
public: public:
SAL_DLLPRIVATE bool IsInClose() const { return mbInClose; } SAL_DLLPRIVATE bool IsInClose() const { return mbInClose; }
SAL_DLLPRIVATE void doDeferredInit(bool bResizable); virtual void doDeferredInit(bool bResizable) SAL_OVERRIDE;
SAL_DLLPRIVATE bool isDeferredInit() const { return mbIsDefferedInit; }
protected: protected:
explicit Dialog( WindowType nType ); explicit Dialog( WindowType nType );
......
...@@ -117,9 +117,10 @@ public: ...@@ -117,9 +117,10 @@ public:
SAL_DLLPRIVATE void ImplEndPopupMode( sal_uInt16 nFlags = 0, sal_uLong nFocusId = 0 ); SAL_DLLPRIVATE void ImplEndPopupMode( sal_uInt16 nFlags = 0, sal_uLong nFocusId = 0 );
SAL_DLLPRIVATE Rectangle& ImplGetItemEdgeClipRect(); SAL_DLLPRIVATE Rectangle& ImplGetItemEdgeClipRect();
SAL_DLLPRIVATE bool ImplIsInPrivatePopupMode() const { return mbInPopupMode; } SAL_DLLPRIVATE bool ImplIsInPrivatePopupMode() const { return mbInPopupMode; }
virtual void doDeferredInit(bool bResizable) SAL_OVERRIDE;
public: 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 OString& rID, const OUString& rUIXMLDescription);
explicit FloatingWindow( Window* pParent, const ResId& ); explicit FloatingWindow( Window* pParent, const ResId& );
virtual ~FloatingWindow(); virtual ~FloatingWindow();
......
...@@ -147,17 +147,19 @@ private: ...@@ -147,17 +147,19 @@ private:
bool mbDockBtn; bool mbDockBtn;
bool mbHideBtn; bool mbHideBtn;
bool mbSysChild; bool mbSysChild;
bool mbIsDefferedInit;
bool mbIsCalculatingInitialLayoutSize; bool mbIsCalculatingInitialLayoutSize;
bool mbInitialLayoutDone; bool mbInitialLayoutDone;
sal_uInt16 mnMenuBarMode; sal_uInt16 mnMenuBarMode;
sal_uInt16 mnIcon; sal_uInt16 mnIcon;
ImplData* mpImplData; ImplData* mpImplData;
Timer maLayoutTimer; Timer maLayoutTimer;
protected:
bool mbIsDefferedInit;
Window* mpDialogParent;
public: public:
using Window::ImplIsInTaskPaneList; using Window::ImplIsInTaskPaneList;
SAL_DLLPRIVATE bool ImplIsInTaskPaneList( Window* pWin ); SAL_DLLPRIVATE bool ImplIsInTaskPaneList( Window* pWin );
SAL_DLLPRIVATE bool isDeferredInit() const { return mbIsDefferedInit; }
private: private:
SAL_DLLPRIVATE void Init(); SAL_DLLPRIVATE void Init();
...@@ -168,7 +170,7 @@ private: ...@@ -168,7 +170,7 @@ private:
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 loadUI(Window* pParent, const OString& rID, const OUString& rUIXMLDescription);
void SetWindowStateData( const WindowStateData& rData ); void SetWindowStateData( const WindowStateData& rData );
...@@ -187,7 +189,6 @@ public: ...@@ -187,7 +189,6 @@ public:
virtual void Resizing( Size& rSize ); virtual void Resizing( Size& rSize );
virtual void Resize() SAL_OVERRIDE; virtual void Resize() SAL_OVERRIDE;
virtual Size GetOptimalSize() const 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; virtual void queue_resize(StateChangedType eReason = STATE_CHANGE_LAYOUT) SAL_OVERRIDE;
bool isLayoutEnabled() const; bool isLayoutEnabled() const;
void setOptimalLayoutSize(); void setOptimalLayoutSize();
...@@ -274,6 +275,8 @@ public: ...@@ -274,6 +275,8 @@ public:
const Link& GetCloseHdl() const; const Link& GetCloseHdl() const;
SAL_DLLPRIVATE bool hasPendingLayout() const { return maLayoutTimer.IsActive(); } SAL_DLLPRIVATE bool hasPendingLayout() const { return maLayoutTimer.IsActive(); }
virtual void doDeferredInit(bool bResizable);
}; };
#endif // INCLUDED_VCL_SYSWIN_HXX #endif // INCLUDED_VCL_SYSWIN_HXX
......
...@@ -70,18 +70,23 @@ int UIPreviewApp::Main() ...@@ -70,18 +70,23 @@ int UIPreviewApp::Main()
{ {
VclBuilder aBuilder(pDialog, OUString(), uifiles[0]); 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) if (!pRealDialog)
pRealDialog = pDialog; pRealDialog = pDialog;
if (pRealDialog)
{
pRealDialog->SetText(OUString("LibreOffice ui-previewer")); pRealDialog->SetText(OUString("LibreOffice ui-previewer"));
pRealDialog->SetStyle(pDialog->GetStyle()|WB_CLOSEABLE); 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(); pRealDialog->Execute();
} }
}
delete pDialog; delete pDialog;
} }
......
...@@ -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() && static_cast<Dialog*>(pParent)->isDeferredInit(); m_bToplevelHasDeferredInit = pParent && pParent->IsSystemWindow() && static_cast<SystemWindow*>(pParent)->isDeferredInit();
m_bToplevelHasDeferredProperties = m_bToplevelHasDeferredInit; m_bToplevelHasDeferredProperties = m_bToplevelHasDeferredInit;
sal_Int32 nIdx = m_sHelpRoot.lastIndexOf('.'); sal_Int32 nIdx = m_sHelpRoot.lastIndexOf('.');
...@@ -571,6 +571,18 @@ OString VclBuilder::extractCustomProperty(VclBuilder::stringmap &rMap) ...@@ -571,6 +571,18 @@ OString VclBuilder::extractCustomProperty(VclBuilder::stringmap &rMap)
namespace 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 extractResizable(VclBuilder::stringmap &rMap)
{ {
bool bResizable = true; bool bResizable = true;
...@@ -1571,6 +1583,21 @@ Window *VclBuilder::makeObject(Window *pParent, const OString &name, const OStri ...@@ -1571,6 +1583,21 @@ Window *VclBuilder::makeObject(Window *pParent, const OString &name, const OStri
return NULL; // no widget to be created 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 else
{ {
sal_Int32 nDelim = name.indexOf('-'); sal_Int32 nDelim = name.indexOf('-');
...@@ -1660,13 +1687,17 @@ Window *VclBuilder::insertObject(Window *pParent, const OString &rClass, ...@@ -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)) if (m_pParent && !isConsideredGtkPseudo(m_pParent) && !m_sID.isEmpty() && rID.equals(m_sID))
{ {
pCurrentChild = m_pParent; 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); SystemWindow *pSysWin = static_cast<SystemWindow*>(pCurrentChild);
pDialog->doDeferredInit(extractResizable(rProps)); pSysWin->doDeferredInit(extractResizable(rProps));
m_bToplevelHasDeferredInit = false; m_bToplevelHasDeferredInit = false;
} }
if (pCurrentChild->GetHelpId().isEmpty()) if (pCurrentChild->GetHelpId().isEmpty())
{ {
pCurrentChild->SetHelpId(m_sHelpRoot + m_sID); pCurrentChild->SetHelpId(m_sHelpRoot + m_sID);
......
...@@ -339,7 +339,6 @@ struct DialogImpl ...@@ -339,7 +339,6 @@ struct DialogImpl
void Dialog::ImplInitDialogData() void Dialog::ImplInitDialogData()
{ {
mpWindowImpl->mbDialog = true; mpWindowImpl->mbDialog = true;
mpDialogParent = NULL;
mpPrevExecuteDlg = NULL; mpPrevExecuteDlg = NULL;
mbInExecute = false; mbInExecute = false;
mbOldSaveBack = false; mbOldSaveBack = false;
...@@ -450,7 +449,6 @@ void Dialog::ImplInitSettings() ...@@ -450,7 +449,6 @@ void Dialog::ImplInitSettings()
Dialog::Dialog( WindowType nType ) Dialog::Dialog( WindowType nType )
: SystemWindow( nType ) : SystemWindow( nType )
, mbIsDefferedInit(false)
{ {
ImplInitDialogData(); ImplInitDialogData();
} }
...@@ -491,26 +489,21 @@ void Dialog::doDeferredInit(bool bResizable) ...@@ -491,26 +489,21 @@ void Dialog::doDeferredInit(bool bResizable)
} }
Dialog::Dialog(Window* pParent, const OString& rID, const OUString& rUIXMLDescription) Dialog::Dialog(Window* pParent, const OString& rID, const OUString& rUIXMLDescription)
: SystemWindow( WINDOW_DIALOG ) : SystemWindow(WINDOW_DIALOG)
, mbIsDefferedInit(true)
{ {
ImplInitDialogData(); ImplInitDialogData();
mpDialogParent = pParent; //will be unset in doDeferredInit loadUI(pParent, rID, rUIXMLDescription);
m_pUIBuilder = new VclBuilder(this, getUIRootDir(), rUIXMLDescription, rID);
} }
Dialog::Dialog(Window* pParent, const OString& rID, const OUString& rUIXMLDescription, WindowType nType) Dialog::Dialog(Window* pParent, const OString& rID, const OUString& rUIXMLDescription, WindowType nType)
: SystemWindow( nType ) : SystemWindow(nType)
, mbIsDefferedInit(true)
{ {
ImplInitDialogData(); ImplInitDialogData();
mpDialogParent = pParent; //will be unset in doDeferredInit loadUI(pParent, rID, rUIXMLDescription);
m_pUIBuilder = new VclBuilder(this, getUIRootDir(), rUIXMLDescription, rID);
} }
Dialog::Dialog( Window* pParent, WinBits nStyle ) Dialog::Dialog(Window* pParent, WinBits nStyle)
: SystemWindow( WINDOW_DIALOG ) : SystemWindow(WINDOW_DIALOG)
, mbIsDefferedInit(false)
{ {
ImplInitDialogData(); ImplInitDialogData();
ImplInit( pParent, nStyle ); ImplInit( pParent, nStyle );
......
...@@ -165,8 +165,21 @@ FloatingWindow::FloatingWindow( Window* pParent, const ResId& rResId ) : ...@@ -165,8 +165,21 @@ FloatingWindow::FloatingWindow( Window* pParent, const ResId& rResId ) :
} }
FloatingWindow::FloatingWindow(Window* pParent, const OString& rID, const OUString& rUIXMLDescription) 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 ) void FloatingWindow::ImplLoadRes( const ResId& rResId )
...@@ -554,6 +567,11 @@ bool FloatingWindow::Notify( NotifyEvent& rNEvt ) ...@@ -554,6 +567,11 @@ bool FloatingWindow::Notify( NotifyEvent& rNEvt )
void FloatingWindow::StateChanged( StateChangedType nType ) void FloatingWindow::StateChanged( StateChangedType nType )
{ {
if (nType == STATE_CHANGE_INITSHOW)
{
DoInitialLayout();
}
SystemWindow::StateChanged( nType ); SystemWindow::StateChanged( nType );
if ( nType == STATE_CHANGE_CONTROLBACKGROUND ) if ( nType == STATE_CHANGE_CONTROLBACKGROUND )
......
...@@ -81,6 +81,7 @@ void SystemWindow::Init() ...@@ -81,6 +81,7 @@ void SystemWindow::Init()
mbInitialLayoutDone = false; mbInitialLayoutDone = false;
mnMenuBarMode = MENUBAR_MODE_NORMAL; mnMenuBarMode = MENUBAR_MODE_NORMAL;
mnIcon = 0; mnIcon = 0;
mpDialogParent = NULL;
//To-Do, reuse maResizeTimer //To-Do, reuse maResizeTimer
maLayoutTimer.SetTimeout(50); maLayoutTimer.SetTimeout(50);
...@@ -89,14 +90,15 @@ void SystemWindow::Init() ...@@ -89,14 +90,15 @@ void SystemWindow::Init()
SystemWindow::SystemWindow(WindowType nType) SystemWindow::SystemWindow(WindowType nType)
: Window(nType) : Window(nType)
, mbIsDefferedInit(false)
{ {
Init(); Init();
} }
SystemWindow::SystemWindow(Window* pParent, const OString& rID, const OUString& rUIXMLDescription, WindowType nType) void SystemWindow::loadUI(Window* pParent, const OString& rID, const OUString& rUIXMLDescription)
: Window(pParent, nType)
{ {
Init(); mbIsDefferedInit = true;
mpDialogParent = pParent; //should be unset in doDeferredInit
m_pUIBuilder = new VclBuilder(this, getUIRootDir(), rUIXMLDescription, rID); m_pUIBuilder = new VclBuilder(this, getUIRootDir(), rUIXMLDescription, rID);
} }
...@@ -1102,14 +1104,9 @@ void SystemWindow::DoInitialLayout() ...@@ -1102,14 +1104,9 @@ void SystemWindow::DoInitialLayout()
} }
} }
void SystemWindow::StateChanged( StateChangedType nType ) void SystemWindow::doDeferredInit(bool /*bResizable*/)
{ {
Window::StateChanged(nType); SAL_WARN("vcl.layout", "SystemWindow in layout without doDeferredInit impl");
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