diff options
author | Caolán McNamara <caolanm@redhat.com> | 2012-10-10 21:30:15 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2012-10-11 09:21:42 +0100 |
commit | e38d9aa925c85efb924666c55dd2533c7d34788b (patch) | |
tree | 7a1efaf3ff40615ab7f8579cdd7ebf782c85926d /vcl | |
parent | e70cec4a4264987720f9b42a72a13fa1f84fde6d (diff) |
add a stub ScrolledWindow to store scroll properties
e.g. VclMultiLineEdit manages its own scrolling, so just
store that info in a dummy ScrolledWindow for now and
set the scroll window settings onto the VCLMultiLineEdit
if it has a scrolledwindow parent
Change-Id: I8f7282e1348aa4e9ff77cce384dcc367b17bd3b0
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/inc/vcl/builder.hxx | 1 | ||||
-rw-r--r-- | vcl/inc/vcl/window.hxx | 3 | ||||
-rw-r--r-- | vcl/source/window/builder.cxx | 62 | ||||
-rw-r--r-- | vcl/source/window/window.cxx | 5 | ||||
-rw-r--r-- | vcl/source/window/window2.cxx | 36 |
5 files changed, 100 insertions, 7 deletions
diff --git a/vcl/inc/vcl/builder.hxx b/vcl/inc/vcl/builder.hxx index 83b1139b9eee..ef3e85c07472 100644 --- a/vcl/inc/vcl/builder.hxx +++ b/vcl/inc/vcl/builder.hxx @@ -156,6 +156,7 @@ public: return static_cast<T*>(w); } OString get_by_window(const Window *pWindow) const; + void delete_by_window(const Window *pWindow); //for the purposes of retrofitting this to the existing code //look up sID, clone its properties into replacement and //splice replacement into the tree instead of it, without diff --git a/vcl/inc/vcl/window.hxx b/vcl/inc/vcl/window.hxx index 80ce5fd13914..5b83760ee6cd 100644 --- a/vcl/inc/vcl/window.hxx +++ b/vcl/inc/vcl/window.hxx @@ -595,6 +595,9 @@ protected: */ SAL_DLLPRIVATE void queue_resize(); + sal_Int32 get_height_request() const; + sal_Int32 get_width_request() const; + // FIXME: this is a hack to workaround missing layout functionality SAL_DLLPRIVATE void ImplAdjustNWFSizes(); public: diff --git a/vcl/source/window/builder.cxx b/vcl/source/window/builder.cxx index 40c0b71c9cf6..5b6028060996 100644 --- a/vcl/source/window/builder.cxx +++ b/vcl/source/window/builder.cxx @@ -504,6 +504,21 @@ bool VclBuilder::extractImage(const OString &id, stringmap &rMap) return false; } +//This doesn't actually do anything yet, so hide it down here in builder.cxx as +//merely a temporary storage for scrolling information for vcl controls which +//actually manage their own scrolling. If you want to put something inside +//a scrolled window that doesn't handle its own scrolling, then you +//need to implement this fully and move into a top-level header +class VclScrolledWindow : public Window +{ +public: + VclScrolledWindow(Window *pParent) + : Window(WINDOW_SCROLLWINDOW) + { + ImplInit(pParent, WB_HIDE, NULL); + } +}; + #ifndef DISABLE_DYNLOADING extern "C" { static void SAL_CALL thisModule() {} } #endif @@ -690,6 +705,10 @@ Window *VclBuilder::makeObject(Window *pParent, const OString &name, const OStri else pWindow = new ScrollBar(pParent, WB_HORZ); } + else if (name == "GtkScrolledWindow") + { + pWindow = new VclScrolledWindow(pParent); + } else if (name == "GtkEntry") { pWindow = new Edit(pParent, WB_LEFT|WB_VCENTER|WB_BORDER|WB_3DLOOK); @@ -700,7 +719,30 @@ Window *VclBuilder::makeObject(Window *pParent, const OString &name, const OStri else if (name == "GtkDrawingArea") pWindow = new Window(pParent); else if (name == "GtkTextView") - pWindow = new VCLMultiLineEdit(pParent); + { + WinBits nWinStyle = WB_LEFT | WB_BORDER; + //VCLMultiLineEdit manage their own scrolling, + //so if it appears as a child of a scrolling window + //shoehorn that scrolling settings to this + //widget and remove the parent + if (pParent && pParent->GetType() == WINDOW_SCROLLWINDOW) + { + WinBits nScrollBits = pParent->GetStyle(); + nScrollBits &= (WB_AUTOHSCROLL|WB_HSCROLL|WB_AUTOVSCROLL|WB_VSCROLL); + nWinStyle |= nScrollBits; + + Window *pScrollParent = pParent; + pParent = pParent->GetParent(); + + 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); + + delete_by_window(pScrollParent); + } + pWindow = new VCLMultiLineEdit(pParent, nWinStyle); + } else { sal_Int32 nDelim = name.indexOf(':'); @@ -747,7 +789,7 @@ 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) + bool isConsideredGtkPseudo(Window *pWindow) { return pWindow->GetType() == WINDOW_TABPAGE; } @@ -757,7 +799,7 @@ Window *VclBuilder::insertObject(Window *pParent, const OString &rClass, const O { Window *pCurrentChild = NULL; - if (m_pParent && !isConsideredPseudo(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; //toplevels default to resizable @@ -1419,6 +1461,20 @@ void VclBuilder::delete_by_name(OString sID) } } +void VclBuilder::delete_by_window(const Window *pWindow) +{ + for (std::vector<WinAndId>::iterator aI = m_aChildren.begin(), + aEnd = m_aChildren.end(); aI != aEnd; ++aI) + { + if (aI->m_pWindow == pWindow) + { + delete aI->m_pWindow; + m_aChildren.erase(aI); + break; + } + } +} + OString VclBuilder::get_by_window(const Window *pWindow) const { for (std::vector<WinAndId>::const_iterator aI = m_aChildren.begin(), diff --git a/vcl/source/window/window.cxx b/vcl/source/window/window.cxx index 7d21da6a3a99..9efcedf9ac92 100644 --- a/vcl/source/window/window.cxx +++ b/vcl/source/window/window.cxx @@ -8885,7 +8885,10 @@ sal_uInt16 Window::GetAccessibleRole() const case WINDOW_HELPTEXTWINDOW: nRole = accessibility::AccessibleRole::TOOL_TIP; break; - case WINDOW_RULER: nRole = accessibility::AccessibleRole::RULER; break; + case WINDOW_RULER: nRole = accessibility::AccessibleRole::RULER; break; + + case WINDOW_SCROLLWINDOW: nRole = accessibility::AccessibleRole::SCROLL_PANE; break; + case WINDOW_WINDOW: case WINDOW_CONTROL: case WINDOW_BORDERWINDOW: diff --git a/vcl/source/window/window2.cxx b/vcl/source/window/window2.cxx index 5bd02d99b531..4c0b3309cc10 100644 --- a/vcl/source/window/window2.cxx +++ b/vcl/source/window/window2.cxx @@ -2037,6 +2037,26 @@ bool Window::set_property(const rtl::OString &rKey, const rtl::OString &rValue) set_margin_top(rValue.toInt32()); else if (rKey.equalsL(RTL_CONSTASCII_STRINGPARAM("margin-bottom"))) set_margin_bottom(rValue.toInt32()); + else if (rKey.equalsL(RTL_CONSTASCII_STRINGPARAM("hscrollbar-policy"))) + { + WinBits nBits = GetStyle(); + nBits &= ~(WB_AUTOHSCROLL|WB_HSCROLL); + if (rValue == "always") + nBits |= WB_HSCROLL; + else if (rValue == "automatic") + nBits |= WB_AUTOHSCROLL; + SetStyle(nBits); + } + else if (rKey.equalsL(RTL_CONSTASCII_STRINGPARAM("vscrollbar-policy"))) + { + WinBits nBits = GetStyle(); + nBits &= ~(WB_AUTOVSCROLL|WB_VSCROLL); + if (rValue == "always") + nBits |= WB_VSCROLL; + else if (rValue == "automatic") + nBits |= WB_AUTOVSCROLL; + SetStyle(nBits); + } else { SAL_INFO("vcl.layout", "unhandled property: " << rKey.getStr()); @@ -2073,9 +2093,7 @@ void Window::set_width_request(sal_Int32 nWidthRequest) Size Window::get_preferred_size() const { - WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl : mpWindowImpl; - - Size aRet(pWindowImpl->mnWidthRequest, pWindowImpl->mnHeightRequest); + Size aRet(get_width_request(), get_height_request()); if (aRet.Width() == -1 || aRet.Height() == -1) { Size aOptimal = GetOptimalSize(WINDOWSIZE_PREFERRED); @@ -2291,4 +2309,16 @@ sal_Int32 Window::get_margin_bottom() const return pWindowImpl->mnMarginBottom; } +sal_Int32 Window::get_height_request() const +{ + WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl : mpWindowImpl; + return pWindowImpl->mnHeightRequest; +} + +sal_Int32 Window::get_width_request() const +{ + WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl : mpWindowImpl; + return pWindowImpl->mnWidthRequest; +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |