Kaydet (Commit) 68d75af9 authored tarafından Jan Holesovsky's avatar Jan Holesovsky

vcl: Initial NotebookBar implementation.

Re-introduced, this is still useful code to have :-)

Change-Id: I91535c13d68261f7195989ec78bd305cf572c87c
üst a22702ab
...@@ -782,7 +782,14 @@ void LayoutManager::implts_updateUIElementsVisibleState( bool bSetVisible ) ...@@ -782,7 +782,14 @@ void LayoutManager::implts_updateUIElementsVisibleState( bool bSetVisible )
if ( pSysWindow ) if ( pSysWindow )
{ {
if ( bSetVisible ) if ( bSetVisible )
{
pSysWindow->SetMenuBar(pMenuBar); pSysWindow->SetMenuBar(pMenuBar);
if (getenv("LO_USE_NOTEBOOKBAR"))
{
pSysWindow->CreateNotebookBar("vcl/ui/notebookbar.ui", m_xFrame);
pSysWindow->SetMenuBarMode(MenuBarMode::Hide);
}
}
else else
pSysWindow->SetMenuBar( nullptr ); pSysWindow->SetMenuBar( nullptr );
} }
......
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
class ModalDialog; class ModalDialog;
class MenuBar; class MenuBar;
class NotebookBarWindow;
class TaskPaneList; class TaskPaneList;
class VclContainer; class VclContainer;
...@@ -237,6 +238,8 @@ public: ...@@ -237,6 +238,8 @@ public:
MenuBar* GetMenuBar() const { return mpMenuBar; } MenuBar* GetMenuBar() const { return mpMenuBar; }
void SetMenuBarMode( MenuBarMode nMode ); void SetMenuBarMode( MenuBarMode nMode );
void CreateNotebookBar(const OUString& rUIXMLDescription, const css::uno::Reference<css::frame::XFrame>& rFrame);
TaskPaneList* GetTaskPaneList(); TaskPaneList* GetTaskPaneList();
void GetWindowStateData( WindowStateData& rData ) const; void GetWindowStateData( WindowStateData& rData ) const;
......
...@@ -181,6 +181,7 @@ $(eval $(call gb_Library_add_exception_objects,vcl,\ ...@@ -181,6 +181,7 @@ $(eval $(call gb_Library_add_exception_objects,vcl,\
vcl/source/window/mouse \ vcl/source/window/mouse \
vcl/source/window/mouseevent \ vcl/source/window/mouseevent \
vcl/source/window/msgbox \ vcl/source/window/msgbox \
vcl/source/window/notebookbarwindow \
vcl/source/window/popupmenuwindow \ vcl/source/window/popupmenuwindow \
vcl/source/window/printdlg \ vcl/source/window/printdlg \
vcl/source/window/scrwnd \ vcl/source/window/scrwnd \
......
...@@ -13,6 +13,7 @@ $(eval $(call gb_UIConfig_add_uifiles,vcl,\ ...@@ -13,6 +13,7 @@ $(eval $(call gb_UIConfig_add_uifiles,vcl,\
vcl/uiconfig/ui/cupspassworddialog \ vcl/uiconfig/ui/cupspassworddialog \
vcl/uiconfig/ui/errornocontentdialog \ vcl/uiconfig/ui/errornocontentdialog \
vcl/uiconfig/ui/errornoprinterdialog \ vcl/uiconfig/ui/errornoprinterdialog \
vcl/uiconfig/ui/notebookbar \
vcl/uiconfig/ui/printdialog \ vcl/uiconfig/ui/printdialog \
vcl/uiconfig/ui/printerdevicepage \ vcl/uiconfig/ui/printerdevicepage \
vcl/uiconfig/ui/printerpaperpage \ vcl/uiconfig/ui/printerpaperpage \
......
...@@ -22,8 +22,11 @@ ...@@ -22,8 +22,11 @@
#include <vcl/window.hxx> #include <vcl/window.hxx>
#include <com/sun/star/frame/XFrame.hpp>
class ImplBorderWindowView; class ImplBorderWindowView;
enum class DrawButtonFlags; enum class DrawButtonFlags;
class NotebookBarWindow;
#define BORDERWINDOW_STYLE_OVERLAP ((sal_uInt16)0x0001) #define BORDERWINDOW_STYLE_OVERLAP ((sal_uInt16)0x0001)
#define BORDERWINDOW_STYLE_BORDER ((sal_uInt16)0x0002) #define BORDERWINDOW_STYLE_BORDER ((sal_uInt16)0x0002)
...@@ -85,6 +88,7 @@ class ImplBorderWindow : public vcl::Window ...@@ -85,6 +88,7 @@ class ImplBorderWindow : public vcl::Window
private: private:
ImplBorderWindowView* mpBorderView; ImplBorderWindowView* mpBorderView;
VclPtr<vcl::Window> mpMenuBarWindow; VclPtr<vcl::Window> mpMenuBarWindow;
VclPtr<NotebookBarWindow> mpNotebookBarWindow;
long mnMinWidth; long mnMinWidth;
long mnMinHeight; long mnMinHeight;
long mnMaxWidth; long mnMaxWidth;
...@@ -158,6 +162,8 @@ public: ...@@ -158,6 +162,8 @@ public:
void SetMenuBarWindow( vcl::Window* pWindow ); void SetMenuBarWindow( vcl::Window* pWindow );
void SetMenuBarMode( bool bHide ); void SetMenuBarMode( bool bHide );
void SetNotebookBarWindow(const OUString& rUIXMLDescription, const css::uno::Reference<css::frame::XFrame>& rFrame);
void SetMinOutputSize( long nWidth, long nHeight ) void SetMinOutputSize( long nWidth, long nHeight )
{ mnMinWidth = nWidth; mnMinHeight = nHeight; } { mnMinWidth = nWidth; mnMinHeight = nHeight; }
void SetMaxOutputSize( long nWidth, long nHeight ) void SetMaxOutputSize( long nWidth, long nHeight )
......
...@@ -36,6 +36,8 @@ ...@@ -36,6 +36,8 @@
#include <vcl/metric.hxx> #include <vcl/metric.hxx>
#include <vcl/settings.hxx> #include <vcl/settings.hxx>
#include "notebookbarwindow.hxx"
using namespace ::com::sun::star::uno; using namespace ::com::sun::star::uno;
// useful caption height for title bar buttons // useful caption height for title bar buttons
...@@ -1832,6 +1834,7 @@ void ImplBorderWindow::dispose() ...@@ -1832,6 +1834,7 @@ void ImplBorderWindow::dispose()
delete mpBorderView; delete mpBorderView;
mpBorderView = nullptr; mpBorderView = nullptr;
mpMenuBarWindow.clear(); mpMenuBarWindow.clear();
mpNotebookBarWindow.disposeAndClear();
vcl::Window::dispose(); vcl::Window::dispose();
} }
...@@ -1912,12 +1915,14 @@ void ImplBorderWindow::Resize() ...@@ -1912,12 +1915,14 @@ void ImplBorderWindow::Resize()
{ {
vcl::Window* pClientWindow = ImplGetClientWindow(); vcl::Window* pClientWindow = ImplGetClientWindow();
if ( mpMenuBarWindow ) sal_Int32 nLeftBorder;
sal_Int32 nTopBorder;
sal_Int32 nRightBorder;
sal_Int32 nBottomBorder;
mpBorderView->GetBorder( nLeftBorder, nTopBorder, nRightBorder, nBottomBorder );
if (mpMenuBarWindow)
{ {
sal_Int32 nLeftBorder;
sal_Int32 nTopBorder;
sal_Int32 nRightBorder;
sal_Int32 nBottomBorder;
long nMenuHeight = mpMenuBarWindow->GetSizePixel().Height(); long nMenuHeight = mpMenuBarWindow->GetSizePixel().Height();
if ( mbMenuHide ) if ( mbMenuHide )
{ {
...@@ -1930,11 +1935,22 @@ void ImplBorderWindow::Resize() ...@@ -1930,11 +1935,22 @@ void ImplBorderWindow::Resize()
if ( !nMenuHeight ) if ( !nMenuHeight )
nMenuHeight = mnOrgMenuHeight; nMenuHeight = mnOrgMenuHeight;
} }
mpBorderView->GetBorder( nLeftBorder, nTopBorder, nRightBorder, nBottomBorder ); mpMenuBarWindow->setPosSizePixel(
mpMenuBarWindow->setPosSizePixel( nLeftBorder, nLeftBorder, nTopBorder,
nTopBorder, aSize.Width()-nLeftBorder-nRightBorder,
aSize.Width()-nLeftBorder-nRightBorder, nMenuHeight);
nMenuHeight);
// shift the notebookbar down accordingly
nTopBorder += nMenuHeight;
}
if (mpNotebookBarWindow)
{
long nNotebookBarHeight = mpNotebookBarWindow->GetSizePixel().Height();
mpNotebookBarWindow->setPosSizePixel(
nLeftBorder, nTopBorder,
aSize.Width() - nLeftBorder - nRightBorder,
nNotebookBarHeight);
} }
GetBorder( pClientWindow->mpWindowImpl->mnLeftBorder, pClientWindow->mpWindowImpl->mnTopBorder, GetBorder( pClientWindow->mpWindowImpl->mnLeftBorder, pClientWindow->mpWindowImpl->mnTopBorder,
...@@ -2161,12 +2177,23 @@ void ImplBorderWindow::SetMenuBarMode( bool bHide ) ...@@ -2161,12 +2177,23 @@ void ImplBorderWindow::SetMenuBarMode( bool bHide )
UpdateMenuHeight(); UpdateMenuHeight();
} }
void ImplBorderWindow::SetNotebookBarWindow(const OUString& rUIXMLDescription, const css::uno::Reference<css::frame::XFrame>& rFrame)
{
mpNotebookBarWindow.reset(new NotebookBarWindow(this, "NotebookBar", rUIXMLDescription, rFrame));
Resize();
mpNotebookBarWindow->Show();
}
void ImplBorderWindow::GetBorder( sal_Int32& rLeftBorder, sal_Int32& rTopBorder, void ImplBorderWindow::GetBorder( sal_Int32& rLeftBorder, sal_Int32& rTopBorder,
sal_Int32& rRightBorder, sal_Int32& rBottomBorder ) const sal_Int32& rRightBorder, sal_Int32& rBottomBorder ) const
{ {
mpBorderView->GetBorder( rLeftBorder, rTopBorder, rRightBorder, rBottomBorder ); mpBorderView->GetBorder(rLeftBorder, rTopBorder, rRightBorder, rBottomBorder);
if ( mpMenuBarWindow && !mbMenuHide )
if (mpMenuBarWindow && !mbMenuHide)
rTopBorder += mpMenuBarWindow->GetSizePixel().Height(); rTopBorder += mpMenuBarWindow->GetSizePixel().Height();
if (mpNotebookBarWindow)
rTopBorder += mpNotebookBarWindow->GetSizePixel().Height();
} }
long ImplBorderWindow::CalcTitleWidth() const long ImplBorderWindow::CalcTitleWidth() const
......
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#include "notebookbarwindow.hxx"
#include <vcl/layout.hxx>
NotebookBarWindow::NotebookBarWindow(Window* pParent, const OString& rID, const OUString& rUIXMLDescription, const css::uno::Reference<css::frame::XFrame> &rFrame)
: Control(pParent)
{
SetStyle(GetStyle() | WB_DIALOGCONTROL);
m_pUIBuilder = new VclBuilder(this, getUIRootDir(), rUIXMLDescription, rID, rFrame);
}
NotebookBarWindow::~NotebookBarWindow()
{
disposeOnce();
}
void NotebookBarWindow::dispose()
{
disposeBuilder();
Control::dispose();
}
Size NotebookBarWindow::GetOptimalSize() const
{
if (isLayoutEnabled(this))
return VclContainer::getLayoutRequisition(*GetWindow(GetWindowType::FirstChild));
return Control::GetOptimalSize();
}
void NotebookBarWindow::setPosSizePixel(long nX, long nY, long nWidth, long nHeight, PosSizeFlags nFlags)
{
bool bCanHandleSmallerWidth = false;
bool bCanHandleSmallerHeight = false;
bool bIsLayoutEnabled = isLayoutEnabled(this);
Window *pChild = GetWindow(GetWindowType::FirstChild);
if (bIsLayoutEnabled && pChild->GetType() == WINDOW_SCROLLWINDOW)
{
WinBits nStyle = pChild->GetStyle();
if (nStyle & (WB_AUTOHSCROLL | WB_HSCROLL))
bCanHandleSmallerWidth = true;
if (nStyle & (WB_AUTOVSCROLL | WB_VSCROLL))
bCanHandleSmallerHeight = true;
}
Size aSize(GetOptimalSize());
if (!bCanHandleSmallerWidth)
nWidth = std::max(nWidth, aSize.Width());
if (!bCanHandleSmallerHeight)
nHeight = std::max(nHeight, aSize.Height());
Control::setPosSizePixel(nX, nY, nWidth, nHeight, nFlags);
if (bIsLayoutEnabled && (nFlags & PosSizeFlags::Size))
VclContainer::setLayoutAllocation(*pChild, Point(0, 0), Size(nWidth, nHeight));
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#ifndef VCL_SOURCE_WINDOW_NOTEBOOKBARWINDOW_HXX
#define VCL_SOURCE_WINDOW_NOTEBOOKBARWINDOW_HXX
#include "menuwindow.hxx"
#include <vcl/builder.hxx>
#include <vcl/ctrl.hxx>
/// This implements Widget Layout-based notebook-like menu bar.
class NotebookBarWindow : public Control, public VclBuilderContainer
{
public:
NotebookBarWindow(Window* pParent, const OString& rID, const OUString& rUIXMLDescription, const css::uno::Reference<css::frame::XFrame> &rFrame);
virtual ~NotebookBarWindow();
virtual void dispose() SAL_OVERRIDE;
virtual Size GetOptimalSize() const SAL_OVERRIDE;
virtual void setPosSizePixel(long nX, long nY, long nWidth, long nHeight, PosSizeFlags nFlags = PosSizeFlags::All) SAL_OVERRIDE;
};
#endif // VCL_SOURCE_WINDOW_NOTEBOOKBARWINDOW_HXX
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -39,6 +39,8 @@ ...@@ -39,6 +39,8 @@
#include <brdwin.hxx> #include <brdwin.hxx>
#include <window.h> #include <window.h>
#include "notebookbarwindow.hxx"
using namespace ::com::sun::star::uno; using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::lang; using namespace ::com::sun::star::lang;
...@@ -967,6 +969,11 @@ void SystemWindow::SetMenuBar(MenuBar* pMenuBar) ...@@ -967,6 +969,11 @@ void SystemWindow::SetMenuBar(MenuBar* pMenuBar)
} }
} }
void SystemWindow::CreateNotebookBar(const OUString& rUIXMLDescription, const css::uno::Reference<css::frame::XFrame>& rFrame)
{
static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow.get())->SetNotebookBarWindow(rUIXMLDescription, rFrame);
}
void SystemWindow::SetMenuBarMode( MenuBarMode nMode ) void SystemWindow::SetMenuBarMode( MenuBarMode nMode )
{ {
if ( mnMenuBarMode != nMode ) if ( mnMenuBarMode != nMode )
......
This diff is collapsed.
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