[Libreoffice-commits] .: Branch 'feature/cmclayout' - 5 commits - vcl/inc vcl/source
Caolán McNamara
caolan at kemper.freedesktop.org
Wed Jun 13 08:33:40 PDT 2012
vcl/inc/vcl/builder.hxx | 17 +++++++++++
vcl/inc/vcl/dialog.hxx | 9 ++----
vcl/inc/vcl/tabpage.hxx | 5 ++-
vcl/source/control/button.cxx | 12 ++++----
vcl/source/control/edit.cxx | 2 -
vcl/source/control/field.cxx | 4 +-
vcl/source/control/fixed.cxx | 4 +-
vcl/source/control/lstbox.cxx | 9 +++---
vcl/source/uipreviewer/previewer.cxx | 27 ++++++++++--------
vcl/source/window/builder.cxx | 16 +++++++++-
vcl/source/window/dialog.cxx | 52 +++++++++++++++++++++++------------
vcl/source/window/tabpage.cxx | 8 ++++-
vcl/source/window/window.cxx | 10 ++++++
13 files changed, 122 insertions(+), 53 deletions(-)
New commits:
commit 56e5c3d5a28b775541f7b045e0796ce798115aa1
Author: Caolán McNamara <caolanm at redhat.com>
Date: Wed Jun 13 16:31:45 2012 +0100
classic vcl resources use the "height" of a combobox to set the dropdown size
so, pick an arbitrary large number of lines for the dropdown
diff --git a/vcl/source/control/lstbox.cxx b/vcl/source/control/lstbox.cxx
index ecc21a8..e08ae21 100644
--- a/vcl/source/control/lstbox.cxx
+++ b/vcl/source/control/lstbox.cxx
@@ -95,8 +95,8 @@ void ListBox::take_properties(Window &rOther)
ListBox &rOtherListBox = static_cast<ListBox&>(rOther);
mnDDHeight = rOtherListBox.mnDDHeight;
mnSaveValue = rOtherListBox.mnSaveValue;
- mbDDAutoSize = rOtherListBox.mbDDAutoSize;
- mnLineCount = rOtherListBox.mnLineCount;
+ EnableAutoSize(rOtherListBox.mbDDAutoSize);
+ SetDropDownLineCount(rOtherListBox.GetDropDownLineCount());
mpImplLB->take_properties(*rOtherListBox.mpImplLB);
if (mpImplWin && rOtherListBox.mpImplWin)
mpImplWin->take_properties(*rOtherListBox.mpImplWin);
diff --git a/vcl/source/window/builder.cxx b/vcl/source/window/builder.cxx
index e8aa15e..144f613 100644
--- a/vcl/source/window/builder.cxx
+++ b/vcl/source/window/builder.cxx
@@ -247,7 +247,9 @@ Window *VclBuilder::makeObject(Window *pParent, const rtl::OString &name, const
else if (name.equalsL(RTL_CONSTASCII_STRINGPARAM("GtkComboBox")))
{
extractModel(id, rMap);
- pWindow = new ListBox(pParent, WB_LEFT|WB_DROPDOWN|WB_VCENTER|WB_3DLOOK);
+ ListBox *pListBox = new ListBox(pParent, WB_LEFT|WB_DROPDOWN|WB_VCENTER|WB_3DLOOK);
+ pListBox->SetDropDownLineCount(64); //arbitrary
+ pWindow = pListBox;
}
else if (name.equalsL(RTL_CONSTASCII_STRINGPARAM("GtkTreeView")))
{
commit 471e38f406505608893e4bb08e80fbd1454c39e3
Author: Caolán McNamara <caolanm at redhat.com>
Date: Wed Jun 13 14:51:06 2012 +0100
allow bare Windows to be replaceable too (GtkDrawingArea)
diff --git a/vcl/source/window/window.cxx b/vcl/source/window/window.cxx
index d4c8a4a..033eb6e 100644
--- a/vcl/source/window/window.cxx
+++ b/vcl/source/window/window.cxx
@@ -4194,8 +4194,11 @@ Window::Window( Window* pParent, WinBits nStyle )
// -----------------------------------------------------------------------
Window::Window( Window* pParent, const ResId& rResId )
+ : mpWindowImpl(NULL)
{
DBG_CTOR( Window, ImplDbgCheckWindow );
+ if (VclBuilderContainer::replace_buildable(pParent, rResId.GetId(), *this))
+ return;
ImplInitWindowData( WINDOW_WINDOW );
rResId.SetRT( RSC_WINDOW );
@@ -9692,7 +9695,6 @@ uno::Any Window::getWidgetAnyProperty(const rtl::OString &rString) const
Size Window::get_preferred_size() const
{
Size aRet(mpWindowImpl->mnWidthRequest, mpWindowImpl->mnHeightRequest);
- fprintf(stderr, "numbers are %d %d\n", aRet.Width(), aRet.Height());
if (aRet.Width() == -1 || aRet.Height() == -1)
{
Size aOptimal = GetOptimalSize(WINDOWSIZE_PREFERRED);
@@ -9706,6 +9708,12 @@ Size Window::get_preferred_size() const
void Window::take_properties(Window &rOther)
{
+ if (!mpWindowImpl)
+ {
+ ImplInitWindowData(WINDOW_WINDOW);
+ ImplInit(rOther.GetParent(), rOther.GetStyle(), NULL);
+ }
+
WindowImpl *pWindowImpl = rOther.mpWindowImpl;
if (!mpWindowImpl->mpRealParent)
ImplInit(pWindowImpl->mpRealParent, rOther.GetStyle(), NULL);
commit ced0f198b9c21398a4fbfe4175e1a628be886788
Author: Caolán McNamara <caolanm at redhat.com>
Date: Wed Jun 13 14:25:07 2012 +0100
mpImplWin only exists for dropdown ListBoxes
diff --git a/vcl/source/control/lstbox.cxx b/vcl/source/control/lstbox.cxx
index e790869..ecc21a8 100644
--- a/vcl/source/control/lstbox.cxx
+++ b/vcl/source/control/lstbox.cxx
@@ -98,7 +98,8 @@ void ListBox::take_properties(Window &rOther)
mbDDAutoSize = rOtherListBox.mbDDAutoSize;
mnLineCount = rOtherListBox.mnLineCount;
mpImplLB->take_properties(*rOtherListBox.mpImplLB);
- mpImplWin->take_properties(*rOtherListBox.mpImplWin);
+ if (mpImplWin && rOtherListBox.mpImplWin)
+ mpImplWin->take_properties(*rOtherListBox.mpImplWin);
}
// -----------------------------------------------------------------------
commit 4fb2bb4938f071a862d1d580c1c93e53de1adb17
Author: Caolán McNamara <caolanm at redhat.com>
Date: Wed Jun 13 14:24:01 2012 +0100
allow TabPages to load .ui files for retrofitting
when presented with a resource id let tabpages
find .ui files that can override that
diff --git a/vcl/inc/vcl/builder.hxx b/vcl/inc/vcl/builder.hxx
index b44cb3f..d62d126 100644
--- a/vcl/inc/vcl/builder.hxx
+++ b/vcl/inc/vcl/builder.hxx
@@ -127,6 +127,23 @@ private:
static void reorderWithinParent(Window &rWindow, sal_uInt16 nNewPosition);
};
+
+//allows retro fitting existing dialogs/tabpages that load a resource
+//to load a .ui file instead
+
+class ResId;
+
+class VCL_DLLPUBLIC VclBuilderContainer
+{
+protected:
+ VclBuilder *m_pUIBuilder;
+public:
+ VclBuilderContainer();
+ static VclBuilder* overrideResourceWithUIXML(Window *pWindow, const ResId& rResId);
+ static bool replace_buildable(Window *pParent, sal_Int32 nID, Window &rReplacement);
+};
+
+
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/inc/vcl/dialog.hxx b/vcl/inc/vcl/dialog.hxx
index e447e13..2d7928f 100644
--- a/vcl/inc/vcl/dialog.hxx
+++ b/vcl/inc/vcl/dialog.hxx
@@ -31,6 +31,7 @@
#include <vcl/sv.h>
#include <vcl/dllapi.h>
+#include <vcl/builder.hxx>
#include <vcl/syswin.hxx>
#include <vcl/timer.hxx>
@@ -44,7 +45,9 @@
struct DialogImpl;
class VclBuilder;
-class VCL_DLLPUBLIC Dialog : public SystemWindow
+class VCL_DLLPUBLIC Dialog
+ : public SystemWindow
+ , public VclBuilderContainer
{
private:
Window* mpDialogParent;
@@ -75,8 +78,6 @@ protected:
SAL_DLLPRIVATE void ImplDialogRes( const ResId& rResId );
SAL_DLLPRIVATE WinBits init(Window *pParent, const ResId& rResId);
- VclBuilder *m_pUIBuilder;
-
public:
SAL_DLLPRIVATE sal_Bool IsInClose() const { return mbInClose; }
SAL_DLLPRIVATE bool hasPendingLayout() const { return maLayoutTimer.IsActive(); }
@@ -144,8 +145,6 @@ public:
sal_Bool IsModalInputMode() const { return mbModalMode; }
void GrabFocusToFirstControl();
-
- static bool replace_buildable(Window *pParent, sal_Int32 nID, Window &rReplacement);
};
// ------------------
diff --git a/vcl/inc/vcl/tabpage.hxx b/vcl/inc/vcl/tabpage.hxx
index 5edf199..fd8d470 100644
--- a/vcl/inc/vcl/tabpage.hxx
+++ b/vcl/inc/vcl/tabpage.hxx
@@ -31,13 +31,16 @@
#include <vcl/sv.h>
#include <vcl/dllapi.h>
+#include <vcl/builder.hxx>
#include <vcl/window.hxx>
// -----------
// - TabPage -
// -----------
-class VCL_DLLPUBLIC TabPage : public Window
+class VCL_DLLPUBLIC TabPage
+ : public Window
+ , public VclBuilderContainer
{
private:
using Window::ImplInit;
diff --git a/vcl/source/control/button.cxx b/vcl/source/control/button.cxx
index 4e81d71..21afb3b 100644
--- a/vcl/source/control/button.cxx
+++ b/vcl/source/control/button.cxx
@@ -1207,7 +1207,7 @@ PushButton::PushButton( Window* pParent, WinBits nStyle ) :
PushButton::PushButton( Window* pParent, const ResId& rResId ) :
Button( WINDOW_PUSHBUTTON )
{
- if (Dialog::replace_buildable(pParent, rResId.GetId(), *this))
+ if (VclBuilderContainer::replace_buildable(pParent, rResId.GetId(), *this))
return;
ImplInitPushButtonData();
@@ -1762,7 +1762,7 @@ OKButton::OKButton( Window* pParent, WinBits nStyle ) :
OKButton::OKButton( Window* pParent, const ResId& rResId ) :
PushButton( WINDOW_OKBUTTON )
{
- if (Dialog::replace_buildable(pParent, rResId.GetId(), *this))
+ if (VclBuilderContainer::replace_buildable(pParent, rResId.GetId(), *this))
return;
rResId.SetRT( RSC_OKBUTTON );
@@ -1839,7 +1839,7 @@ CancelButton::CancelButton( Window* pParent, WinBits nStyle ) :
CancelButton::CancelButton( Window* pParent, const ResId& rResId ) :
PushButton( WINDOW_CANCELBUTTON )
{
- if (Dialog::replace_buildable(pParent, rResId.GetId(), *this))
+ if (VclBuilderContainer::replace_buildable(pParent, rResId.GetId(), *this))
return;
rResId.SetRT( RSC_CANCELBUTTON );
@@ -1916,7 +1916,7 @@ HelpButton::HelpButton( Window* pParent, WinBits nStyle ) :
HelpButton::HelpButton( Window* pParent, const ResId& rResId ) :
PushButton( WINDOW_HELPBUTTON )
{
- if (Dialog::replace_buildable(pParent, rResId.GetId(), *this))
+ if (VclBuilderContainer::replace_buildable(pParent, rResId.GetId(), *this))
return;
rResId.SetRT( RSC_HELPBUTTON );
@@ -2475,7 +2475,7 @@ RadioButton::RadioButton( Window* pParent, WinBits nStyle ) :
RadioButton::RadioButton( Window* pParent, const ResId& rResId ) :
Button( WINDOW_RADIOBUTTON )
{
- if (Dialog::replace_buildable(pParent, rResId.GetId(), *this))
+ if (VclBuilderContainer::replace_buildable(pParent, rResId.GetId(), *this))
return;
ImplInitRadioButtonData();
@@ -3445,7 +3445,7 @@ CheckBox::CheckBox( Window* pParent, WinBits nStyle ) :
CheckBox::CheckBox( Window* pParent, const ResId& rResId ) :
Button( WINDOW_CHECKBOX )
{
- if (Dialog::replace_buildable(pParent, rResId.GetId(), *this))
+ if (VclBuilderContainer::replace_buildable(pParent, rResId.GetId(), *this))
return;
ImplInitCheckBoxData();
diff --git a/vcl/source/control/edit.cxx b/vcl/source/control/edit.cxx
index 5eda75f..e064219 100644
--- a/vcl/source/control/edit.cxx
+++ b/vcl/source/control/edit.cxx
@@ -205,7 +205,7 @@ Edit::Edit( Window* pParent, WinBits nStyle ) :
Edit::Edit( Window* pParent, const ResId& rResId ) :
Control( WINDOW_EDIT )
{
- if (Dialog::replace_buildable(pParent, rResId.GetId(), *this))
+ if (VclBuilderContainer::replace_buildable(pParent, rResId.GetId(), *this))
return;
ImplInitEditData();
diff --git a/vcl/source/control/field.cxx b/vcl/source/control/field.cxx
index c908b7b..a5b720d 100644
--- a/vcl/source/control/field.cxx
+++ b/vcl/source/control/field.cxx
@@ -789,7 +789,7 @@ NumericField::NumericField( Window* pParent, WinBits nWinStyle ) :
NumericField::NumericField( Window* pParent, const ResId& rResId ) :
SpinField( WINDOW_NUMERICFIELD )
{
- if (Dialog::replace_buildable(pParent, rResId.GetId(), *this))
+ if (VclBuilderContainer::replace_buildable(pParent, rResId.GetId(), *this))
{
SetField( this );
return;
@@ -1662,7 +1662,7 @@ MetricField::MetricField( Window* pParent, WinBits nWinStyle ) :
MetricField::MetricField( Window* pParent, const ResId& rResId ) :
SpinField( WINDOW_METRICFIELD )
{
- if (Dialog::replace_buildable(pParent, rResId.GetId(), *this))
+ if (VclBuilderContainer::replace_buildable(pParent, rResId.GetId(), *this))
return;
rResId.SetRT( RSC_METRICFIELD );
diff --git a/vcl/source/control/fixed.cxx b/vcl/source/control/fixed.cxx
index 474ee71..117580c 100644
--- a/vcl/source/control/fixed.cxx
+++ b/vcl/source/control/fixed.cxx
@@ -165,7 +165,7 @@ FixedText::FixedText( Window* pParent, WinBits nStyle ) :
FixedText::FixedText( Window* pParent, const ResId& rResId ) :
Control( WINDOW_FIXEDTEXT )
{
- if (Dialog::replace_buildable(pParent, rResId.GetId(), *this))
+ if (VclBuilderContainer::replace_buildable(pParent, rResId.GetId(), *this))
return;
rResId.SetRT( RSC_TEXT );
@@ -592,7 +592,7 @@ FixedLine::FixedLine( Window* pParent, WinBits nStyle ) :
FixedLine::FixedLine( Window* pParent, const ResId& rResId ) :
Control( WINDOW_FIXEDLINE )
{
- if (Dialog::replace_buildable(pParent, rResId.GetId(), *this))
+ if (VclBuilderContainer::replace_buildable(pParent, rResId.GetId(), *this))
return;
rResId.SetRT( RSC_FIXEDLINE );
diff --git a/vcl/source/control/lstbox.cxx b/vcl/source/control/lstbox.cxx
index fe7f35b..e790869 100644
--- a/vcl/source/control/lstbox.cxx
+++ b/vcl/source/control/lstbox.cxx
@@ -68,7 +68,7 @@ ListBox::ListBox( Window* pParent, WinBits nStyle ) : Control( WINDOW_LISTBOX )
ListBox::ListBox( Window* pParent, const ResId& rResId ) :
Control( WINDOW_LISTBOX )
{
- if (Dialog::replace_buildable(pParent, rResId.GetId(), *this))
+ if (VclBuilderContainer::replace_buildable(pParent, rResId.GetId(), *this))
return;
ImplInitListBoxData();
diff --git a/vcl/source/window/builder.cxx b/vcl/source/window/builder.cxx
index 2f8e5d2..e8aa15e 100644
--- a/vcl/source/window/builder.cxx
+++ b/vcl/source/window/builder.cxx
@@ -272,11 +272,21 @@ Window *VclBuilder::makeObject(Window *pParent, const rtl::OString &name, const
return pWindow;
}
+namespace
+{
+ //return true for window types which exist in vcl but are not themselves
+ //represented in the .ui format, i.e. only their children exist.
+ bool isConsideredPseudo(Window *pWindow)
+ {
+ return pWindow->GetType() == WINDOW_TABPAGE;
+ }
+}
+
Window *VclBuilder::insertObject(Window *pParent, const rtl::OString &rClass, const rtl::OString &rID, stringmap &rMap)
{
Window *pCurrentChild = NULL;
- if (!m_sID.isEmpty() && rID.equals(m_sID))
+ if (m_pParent && !isConsideredPseudo(m_pParent) && !m_sID.isEmpty() && rID.equals(m_sID))
{
pCurrentChild = m_pParent;
//toplevels default to resizable
diff --git a/vcl/source/window/dialog.cxx b/vcl/source/window/dialog.cxx
index 3a1caa9..1a2e1ec 100644
--- a/vcl/source/window/dialog.cxx
+++ b/vcl/source/window/dialog.cxx
@@ -354,7 +354,6 @@ void Dialog::ImplInitDialogData()
mnMousePositioned = 0;
m_nBorderWidth = 0;
mpDialogImpl = new DialogImpl;
- m_pUIBuilder = NULL;
//To-Do, reuse maResizeTimer
maLayoutTimer.SetTimeout(50);
@@ -557,12 +556,8 @@ Dialog::Dialog( Window* pParent, const ResId& rResId ) :
init(pParent, rResId);
}
-WinBits Dialog::init(Window *pParent, const ResId& rResId)
+VclBuilder* VclBuilderContainer::overrideResourceWithUIXML(Window *pWindow, const ResId& rResId)
{
- WinBits nStyle = ImplInitRes( rResId );
-
- ImplInit( pParent, nStyle );
-
sal_Int32 nUIid = static_cast<sal_Int32>(rResId.GetId());
rtl::OUString sPath = rtl::OUStringBuffer(getUIRootDir()).
append(rResId.GetResMgr()->getPrefixName()).
@@ -574,12 +569,21 @@ WinBits Dialog::init(Window *pParent, const ResId& rResId)
osl::File aUIFile(sPath);
osl::File::RC error = aUIFile.open(osl_File_OpenFlag_Read);
+ //good, use the preferred GtkBuilder xml
if (error == osl::File::E_None)
- {
- //good, use the preferred GtkBuilder xml
- m_pUIBuilder = new VclBuilder(this, sPath, rtl::OString::valueOf(nUIid));
- }
- else
+ return new VclBuilder(pWindow, sPath, rtl::OString::valueOf(nUIid));
+ return NULL;
+}
+
+WinBits Dialog::init(Window *pParent, const ResId& rResId)
+{
+ WinBits nStyle = ImplInitRes( rResId );
+
+ ImplInit( pParent, nStyle );
+
+ m_pUIBuilder = overrideResourceWithUIXML(this, rResId);
+
+ if (!m_pUIBuilder)
{
//fallback to using the binary resource file
ImplLoadRes( rResId );
@@ -1267,14 +1271,21 @@ bool Dialog::set_property(const rtl::OString &rKey, const rtl::OString &rValue)
return true;
}
-bool Dialog::replace_buildable(Window *pParent, sal_Int32 nID, Window &rReplacement)
+VclBuilderContainer::VclBuilderContainer()
+ : m_pUIBuilder(NULL)
+{
+}
+
+bool VclBuilderContainer::replace_buildable(Window *pParent, sal_Int32 nID, Window &rReplacement)
{
if (!pParent)
return false;
- if (!pParent->IsDialog())
+
+ VclBuilderContainer *pBuilderContainer = dynamic_cast<VclBuilderContainer*>(pParent);
+ if (!pBuilderContainer)
return false;
- Dialog *pDialog = static_cast<Dialog*>(pParent);
- VclBuilder *pUIBuilder = pDialog->m_pUIBuilder;
+
+ VclBuilder *pUIBuilder = pBuilderContainer->m_pUIBuilder;
if (!pUIBuilder)
return false;
bool bFound = pUIBuilder->replace(rtl::OString::valueOf(nID), rReplacement);
@@ -1283,8 +1294,15 @@ bool Dialog::replace_buildable(Window *pParent, sal_Int32 nID, Window &rReplacem
fprintf(stderr, "%d %p not found, hiding\n", nID, &rReplacement);
//move "missing" elements into the action area (just to have
//a known container as an owner) and hide it
- VclButtonBox* pActionArea = getActionArea(pDialog);
- rReplacement.ImplInit(pActionArea, 0, NULL);
+ Window* pArbitraryParent;
+ if (pParent->IsDialog())
+ {
+ Dialog *pDialog = static_cast<Dialog*>(pParent);
+ pArbitraryParent = getActionArea(pDialog);
+ }
+ else
+ pArbitraryParent = pParent->GetWindow(WINDOW_FIRSTCHILD);
+ rReplacement.ImplInit(pArbitraryParent, 0, NULL);
rReplacement.Hide();
}
else
diff --git a/vcl/source/window/tabpage.cxx b/vcl/source/window/tabpage.cxx
index cdeb565..b39ba02 100644
--- a/vcl/source/window/tabpage.cxx
+++ b/vcl/source/window/tabpage.cxx
@@ -99,7 +99,13 @@ TabPage::TabPage( Window* pParent, const ResId& rResId ) :
WinBits nStyle = ImplInitRes( rResId );
ImplInit( pParent, nStyle );
- ImplLoadRes( rResId );
+ m_pUIBuilder = overrideResourceWithUIXML(this, rResId);
+
+ if (!m_pUIBuilder)
+ {
+ //fallback to using the binary resource file
+ ImplLoadRes( rResId );
+ }
if ( !(nStyle & WB_HIDE) )
Show();
commit 9d76655faab45c102b4041775c6c7bae2d674844
Author: Caolán McNamara <caolanm at redhat.com>
Date: Wed Jun 13 13:46:34 2012 +0100
allow previewing trees without toplevel windows
diff --git a/vcl/source/uipreviewer/previewer.cxx b/vcl/source/uipreviewer/previewer.cxx
index c1f787b..5a09974 100644
--- a/vcl/source/uipreviewer/previewer.cxx
+++ b/vcl/source/uipreviewer/previewer.cxx
@@ -78,19 +78,24 @@ int UIPreviewApp::Main()
try
{
- VclBuilder aBuilder(NULL, uifiles[0]);
- Window *pWindow = aBuilder.get_widget_root();
- Dialog *pDialog = dynamic_cast<Dialog*>(pWindow);
- if (pDialog)
- {
- pDialog->SetText(rtl::OUString("LibreOffice ui-previewer"));
- pDialog->SetStyle(pDialog->GetStyle()|WB_CLOSEABLE);
- pDialog->Execute();
- }
- else
+ Dialog *pDialog = new Dialog(NULL, WB_STDDIALOG);
+
{
- fprintf(stderr, "to-do: no toplevel dialog, make one\n");
+ VclBuilder aBuilder(pDialog, uifiles[0]);
+ Dialog *pRealDialog = dynamic_cast<Dialog*>(aBuilder.get_widget_root());
+
+ if (!pRealDialog)
+ pRealDialog = pDialog;
+
+ if (pRealDialog)
+ {
+ pRealDialog->SetText(rtl::OUString("LibreOffice ui-previewer"));
+ pRealDialog->SetStyle(pDialog->GetStyle()|WB_CLOSEABLE);
+ pRealDialog->Execute();
+ }
}
+
+ delete pDialog;
}
catch (const uno::Exception &e)
{
More information about the Libreoffice-commits
mailing list