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

split scrolling support for internal/external scrolling support

so for widgets that support their own scrolling we
throw away the intermediate scrolling widget and for widgets
that don't we retain it.

Change-Id: I12444bcf1c6c5b51469ef75f0011ce0d965ebc62
üst 1a87393f
...@@ -250,6 +250,9 @@ private: ...@@ -250,6 +250,9 @@ private:
PackingData get_window_packing_data(const Window *pWindow) const; PackingData get_window_packing_data(const Window *pWindow) const;
void set_window_packing_position(const Window *pWindow, sal_Int32 nPosition); void set_window_packing_position(const Window *pWindow, sal_Int32 nPosition);
Window* prepareWidgetOwnScrolling(Window *pParent, WinBits &rWinStyle);
void cleanupWidgetOwnScrolling(Window *pScrollParent, Window *pWindow, stringmap &rMap);
//Helpers to retrofit all the existing code to the builder //Helpers to retrofit all the existing code to the builder
static void reorderWithinParent(Window &rWindow, sal_uInt16 nNewPosition); static void reorderWithinParent(Window &rWindow, sal_uInt16 nNewPosition);
}; };
......
...@@ -702,6 +702,33 @@ bool VclBuilder::extractImage(const OString &id, stringmap &rMap) ...@@ -702,6 +702,33 @@ bool VclBuilder::extractImage(const OString &id, stringmap &rMap)
return false; return false;
} }
Window* VclBuilder::prepareWidgetOwnScrolling(Window *pParent, WinBits &rWinStyle)
{
//For Widgets that manage their own scrolling, if one appears as a child of
//a scrolling window shoehorn that scrolling settings to this widget and
//return the real parent to use
if (pParent && pParent->GetType() == WINDOW_SCROLLWINDOW)
{
WinBits nScrollBits = pParent->GetStyle();
nScrollBits &= (WB_AUTOHSCROLL|WB_HSCROLL|WB_AUTOVSCROLL|WB_VSCROLL);
rWinStyle |= nScrollBits;
pParent = pParent->GetParent();
}
return pParent;
}
void VclBuilder::cleanupWidgetOwnScrolling(Window *pScrollParent, Window *pWindow, stringmap &rMap)
{
//remove the redundant scrolling parent
sal_Int32 nWidthReq = pScrollParent->get_width_request();
rMap[OString("width-request")] = OString::valueOf(nWidthReq);
sal_Int32 nHeightReq = pScrollParent->get_height_request();
rMap[OString("height-request")] = OString::valueOf(nHeightReq);
m_pParserState->m_aRedundantParentWidgets[pScrollParent] = pWindow;
}
#ifndef DISABLE_DYNLOADING #ifndef DISABLE_DYNLOADING
extern "C" { static void SAL_CALL thisModule() {} } extern "C" { static void SAL_CALL thisModule() {} }
#endif #endif
...@@ -895,7 +922,12 @@ Window *VclBuilder::makeObject(Window *pParent, const OString &name, const OStri ...@@ -895,7 +922,12 @@ Window *VclBuilder::makeObject(Window *pParent, const OString &name, const OStri
// everything over to SvTreeViewBox // everything over to SvTreeViewBox
//d) remove the users of makeSvTreeViewBox //d) remove the users of makeSvTreeViewBox
extractModel(id, rMap); extractModel(id, rMap);
pWindow = new ListBox(pParent, WB_LEFT|WB_VCENTER|WB_3DLOOK|WB_SIMPLEMODE); WinBits nWinStyle = WB_LEFT|WB_VCENTER|WB_3DLOOK|WB_SIMPLEMODE;
//ListBox manages its own scrolling,
Window *pRealParent = prepareWidgetOwnScrolling(pParent, nWinStyle);
pWindow = new ListBox(pRealParent, nWinStyle);
if (pRealParent != pParent)
cleanupWidgetOwnScrolling(pParent, pWindow, rMap);
} }
else if (name == "GtkLabel") else if (name == "GtkLabel")
{ {
...@@ -957,32 +989,11 @@ Window *VclBuilder::makeObject(Window *pParent, const OString &name, const OStri ...@@ -957,32 +989,11 @@ Window *VclBuilder::makeObject(Window *pParent, const OString &name, const OStri
extractBuffer(id, rMap); extractBuffer(id, rMap);
WinBits nWinStyle = WB_LEFT | WB_BORDER; WinBits nWinStyle = WB_LEFT | WB_BORDER;
//VclMultiLineEdit manage their own scrolling, //VclMultiLineEdit manages its own scrolling,
//so if it appears as a child of a scrolling window Window *pRealParent = prepareWidgetOwnScrolling(pParent, nWinStyle);
//shoehorn that scrolling settings to this pWindow = new VclMultiLineEdit(pRealParent, nWinStyle);
//widget and remove the parent if (pRealParent != pParent)
Window *pScrollParent = NULL; cleanupWidgetOwnScrolling(pParent, pWindow, rMap);
if (pParent && pParent->GetType() == WINDOW_SCROLLWINDOW)
{
WinBits nScrollBits = pParent->GetStyle();
nScrollBits &= (WB_AUTOHSCROLL|WB_HSCROLL|WB_AUTOVSCROLL|WB_VSCROLL);
nWinStyle |= nScrollBits;
pScrollParent = pParent;
pParent = pParent->GetParent();
}
pWindow = new VclMultiLineEdit(pParent, nWinStyle);
if (pScrollParent)
{
sal_Int32 nWidthReq = pScrollParent->get_width_request();
rMap[OString("width-request")] = OString::valueOf(nWidthReq);
sal_Int32 nHeightReq = pScrollParent->get_height_request();
rMap[OString("height-request")] = OString::valueOf(nHeightReq);
m_pParserState->m_aRedundantParentWidgets[pScrollParent] = pWindow;
}
} }
else else
{ {
...@@ -1892,9 +1903,13 @@ void VclBuilder::applyPackingProperty(Window *pCurrent, ...@@ -1892,9 +1903,13 @@ void VclBuilder::applyPackingProperty(Window *pCurrent,
if (pCurrent->GetType() == WINDOW_SCROLLWINDOW) if (pCurrent->GetType() == WINDOW_SCROLLWINDOW)
{ {
pCurrent = m_pParserState->m_aRedundantParentWidgets[pCurrent]; std::map<Window*, Window*>::iterator aFind = m_pParserState->m_aRedundantParentWidgets.find(pCurrent);
if (aFind != m_pParserState->m_aRedundantParentWidgets.end())
{
pCurrent = aFind->second;
assert(pCurrent); assert(pCurrent);
} }
}
while (reader.nextAttribute(&nsId, &name)) while (reader.nextAttribute(&nsId, &name))
{ {
......
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