dbaccess/UIConfig_dbaccess.mk | 1 dbaccess/source/ui/control/FieldDescControl.cxx | 2 dbaccess/source/ui/inc/TableDesignHelpBar.hxx | 15 +---- dbaccess/source/ui/tabledesign/TableDesignHelpBar.cxx | 52 +++++------------- dbaccess/source/ui/tabledesign/TableFieldDescWin.cxx | 29 ++++------ dbaccess/uiconfig/ui/designhelpbox.ui | 38 +++++++++++++ include/vcl/weld.hxx | 1 7 files changed, 74 insertions(+), 64 deletions(-)
New commits: commit 33e0f4c8f1a38ed06508eb0754c7b6fe9cc9f2c8 Author: Caolán McNamara <caol...@redhat.com> AuthorDate: Thu Jul 23 16:03:09 2020 +0100 Commit: Caolán McNamara <caol...@redhat.com> CommitDate: Thu Jul 23 22:10:15 2020 +0200 weld OTableDesignHelpBar Change-Id: If77b9e180791909998cb8536439bcc6ea6d4137b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/99331 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caol...@redhat.com> diff --git a/dbaccess/UIConfig_dbaccess.mk b/dbaccess/UIConfig_dbaccess.mk index eed1ba41a531..25f840ec5494 100644 --- a/dbaccess/UIConfig_dbaccess.mk +++ b/dbaccess/UIConfig_dbaccess.mk @@ -28,6 +28,7 @@ $(eval $(call gb_UIConfig_add_uifiles,dbaccess, \ dbaccess/uiconfig/ui/dbwizspreadsheetpage \ dbaccess/uiconfig/ui/dbwiztextpage \ dbaccess/uiconfig/ui/deleteallrowsdialog \ + dbaccess/uiconfig/ui/designhelpbox \ dbaccess/uiconfig/ui/designsavemodifieddialog \ dbaccess/uiconfig/ui/directsqldialog \ dbaccess/uiconfig/ui/emptypage \ diff --git a/dbaccess/source/ui/control/FieldDescControl.cxx b/dbaccess/source/ui/control/FieldDescControl.cxx index 578574d933a5..eaa34b34fafa 100644 --- a/dbaccess/source/ui/control/FieldDescControl.cxx +++ b/dbaccess/source/ui/control/FieldDescControl.cxx @@ -732,6 +732,8 @@ void OFieldDescControl::DisplayData(OFieldDescription* pFieldDescr ) pActFieldDescr = pFieldDescr; if(!pFieldDescr) { + if (pHelp) + pHelp->SetHelpText( OUString() ); DeactivateAggregate( tpDefault ); DeactivateAggregate( tpRequired ); DeactivateAggregate( tpTextLen ); diff --git a/dbaccess/source/ui/inc/TableDesignHelpBar.hxx b/dbaccess/source/ui/inc/TableDesignHelpBar.hxx index 87118362511b..a6d32dd1ae51 100644 --- a/dbaccess/source/ui/inc/TableDesignHelpBar.hxx +++ b/dbaccess/source/ui/inc/TableDesignHelpBar.hxx @@ -19,22 +19,15 @@ #ifndef INCLUDED_DBACCESS_SOURCE_UI_INC_TABLEDESIGNHELPBAR_HXX #define INCLUDED_DBACCESS_SOURCE_UI_INC_TABLEDESIGNHELPBAR_HXX -#include <vcl/tabpage.hxx> #include "IClipBoardTest.hxx" - -class VclMultiLineEdit; +#include <vcl/InterimItemWindow.hxx> namespace dbaui { - // Deriving from TabPage is a trick to notice changes - // of the system colors - class OTableDesignHelpBar : public TabPage, public IClipboardTest + class OTableDesignHelpBar final : public InterimItemWindow, public IClipboardTest { private: - VclPtr<VclMultiLineEdit> m_pTextWin; - - protected: - virtual void Resize() override; + std::unique_ptr<weld::TextView> m_xTextWin; public: OTableDesignHelpBar( vcl::Window* pParent ); @@ -43,8 +36,6 @@ namespace dbaui void SetHelpText( const OUString& rText ); - virtual bool PreNotify( NotifyEvent& rNEvt ) override; - // IClipboardTest virtual bool isCutAllowed() override; virtual bool isCopyAllowed() override; diff --git a/dbaccess/source/ui/tabledesign/TableDesignHelpBar.cxx b/dbaccess/source/ui/tabledesign/TableDesignHelpBar.cxx index 3d73ff0e6170..5d9069b3451c 100644 --- a/dbaccess/source/ui/tabledesign/TableDesignHelpBar.cxx +++ b/dbaccess/source/ui/tabledesign/TableDesignHelpBar.cxx @@ -20,19 +20,15 @@ #include <TableDesignHelpBar.hxx> #include <vcl/event.hxx> #include <vcl/settings.hxx> -#include <vcl/vclmedit.hxx> #include <helpids.h> using namespace dbaui; -#define STANDARD_MARGIN 6 -OTableDesignHelpBar::OTableDesignHelpBar( vcl::Window* pParent ) : - TabPage( pParent, WB_3DLOOK ) + +OTableDesignHelpBar::OTableDesignHelpBar(vcl::Window* pParent) + : InterimItemWindow(pParent, "dbaccess/ui/designhelpbox.ui", "DesignHelpBox") + , m_xTextWin(m_xBuilder->weld_text_view("textview")) { - m_pTextWin = VclPtr<VclMultiLineEdit>::Create( this, WB_VSCROLL | WB_LEFT | WB_BORDER | WB_NOTABSTOP | WB_READONLY); - m_pTextWin->SetHelpId(HID_TABLE_DESIGN_HELP_WINDOW); - m_pTextWin->SetReadOnly(); - m_pTextWin->SetControlBackground( GetSettings().GetStyleSettings().GetFaceColor() ); - m_pTextWin->Show(); + m_xTextWin->set_help_id(HID_TABLE_DESIGN_HELP_WINDOW); } OTableDesignHelpBar::~OTableDesignHelpBar() @@ -42,40 +38,21 @@ OTableDesignHelpBar::~OTableDesignHelpBar() void OTableDesignHelpBar::dispose() { - m_pTextWin.disposeAndClear(); - TabPage::dispose(); + m_xTextWin.reset(); + InterimItemWindow::dispose(); } void OTableDesignHelpBar::SetHelpText( const OUString& rText ) { - if(m_pTextWin) - m_pTextWin->SetText( rText ); - Invalidate(); -} - -void OTableDesignHelpBar::Resize() -{ - // parent window dimensions - Size aOutputSize( GetOutputSizePixel() ); - - // adapt the TextWin - if(m_pTextWin) - m_pTextWin->SetPosSizePixel( Point(STANDARD_MARGIN+1, STANDARD_MARGIN+1), - Size(aOutputSize.Width()-(2*STANDARD_MARGIN)-2, - aOutputSize.Height()-(2*STANDARD_MARGIN)-2) ); - -} - -bool OTableDesignHelpBar::PreNotify( NotifyEvent& rNEvt ) -{ - if (rNEvt.GetType() == MouseNotifyEvent::LOSEFOCUS) - SetHelpText(OUString()); - return TabPage::PreNotify(rNEvt); + if (!m_xTextWin) + return; + m_xTextWin->set_text(rText); } bool OTableDesignHelpBar::isCopyAllowed() { - return m_pTextWin && !m_pTextWin->GetSelected().isEmpty(); + int mStartPos, nEndPos; + return m_xTextWin && m_xTextWin->get_selection_bounds(mStartPos, nEndPos); } bool OTableDesignHelpBar::isCutAllowed() @@ -94,8 +71,9 @@ void OTableDesignHelpBar::cut() void OTableDesignHelpBar::copy() { - if ( m_pTextWin ) - m_pTextWin->Copy(); + if (!m_xTextWin) + return; + m_xTextWin->copy_clipboard(); } void OTableDesignHelpBar::paste() diff --git a/dbaccess/source/ui/tabledesign/TableFieldDescWin.cxx b/dbaccess/source/ui/tabledesign/TableFieldDescWin.cxx index 9507507949e1..cdcd932a2f74 100644 --- a/dbaccess/source/ui/tabledesign/TableFieldDescWin.cxx +++ b/dbaccess/source/ui/tabledesign/TableFieldDescWin.cxx @@ -28,7 +28,6 @@ #include <helpids.h> #include <core_resource.hxx> -#define STANDARD_MARGIN 6 #define DETAILS_HEADER_HEIGHT 25 #define CONTROL_SPACING_X 18 // 6 #define CONTROL_SPACING_Y 5 @@ -111,9 +110,9 @@ void OTableFieldDescWin::Paint(vcl::RenderContext& rRenderContext, const tools:: rRenderContext.DrawLine(Point(0,0), Point(GetSizePixel().Width(), 0)); // 3D-line for the separation of the header - rRenderContext.DrawLine(Point(3, DETAILS_HEADER_HEIGHT), Point(GetSizePixel().Width() - 6, DETAILS_HEADER_HEIGHT)); - rRenderContext.SetLineColor(rStyleSettings.GetShadowColor()); rRenderContext.DrawLine(Point(3, DETAILS_HEADER_HEIGHT - 1), Point(GetSizePixel().Width() - 6, DETAILS_HEADER_HEIGHT - 1)); + rRenderContext.SetLineColor(rStyleSettings.GetShadowColor()); + rRenderContext.DrawLine(Point(3, DETAILS_HEADER_HEIGHT - 2), Point(GetSizePixel().Width() - 6, DETAILS_HEADER_HEIGHT - 2)); } void OTableFieldDescWin::Resize() @@ -131,10 +130,10 @@ void OTableFieldDescWin::Resize() long nPageWidth, nPageHeight; // do both fit next to each other (margin + page + margin + help)? - if (STANDARD_MARGIN + DETAILS_OPT_PAGE_WIDTH + STANDARD_MARGIN + DETAILS_MIN_HELP_WIDTH <= nOutputWidth) + if (DETAILS_OPT_PAGE_WIDTH + DETAILS_MIN_HELP_WIDTH <= nOutputWidth) { // yes -> then we wonder if can give the help its optimum width nHelpWidth = DETAILS_OPT_HELP_WIDTH; - nPageWidth = nOutputWidth - nHelpWidth - STANDARD_MARGIN - STANDARD_MARGIN; + nPageWidth = nOutputWidth - nHelpWidth; if (nPageWidth < DETAILS_OPT_PAGE_WIDTH) { // rather resize the help from its optimal width to its minimum width long nTransfer = DETAILS_OPT_PAGE_WIDTH - nPageWidth; @@ -143,16 +142,16 @@ void OTableFieldDescWin::Resize() } nHelpX = nOutputWidth - nHelpWidth; // the heights are simple in that case... - nHelpY = DETAILS_HEADER_HEIGHT + 1; + nHelpY = DETAILS_HEADER_HEIGHT; nHelpHeight = nOutputHeight - nHelpY; - nPageHeight = nOutputHeight - STANDARD_MARGIN - DETAILS_HEADER_HEIGHT - STANDARD_MARGIN; + nPageHeight = nOutputHeight - DETAILS_HEADER_HEIGHT; } else { // doesn't work next to each other, thus below each other (margin + header + page + help) - if (STANDARD_MARGIN + DETAILS_HEADER_HEIGHT + DETAILS_OPT_PAGE_HEIGHT + DETAILS_MIN_HELP_HEIGHT <= nOutputHeight) + if (DETAILS_HEADER_HEIGHT + DETAILS_OPT_PAGE_HEIGHT + DETAILS_MIN_HELP_HEIGHT <= nOutputHeight) { // it's at least enough, to fit both below each other (page optimal, help minimal) nHelpHeight = DETAILS_OPT_HELP_HEIGHT; - nPageHeight = nOutputHeight - nHelpHeight - DETAILS_HEADER_HEIGHT - STANDARD_MARGIN; + nPageHeight = nOutputHeight - nHelpHeight - DETAILS_HEADER_HEIGHT; if (nPageHeight < DETAILS_OPT_PAGE_HEIGHT) { // like above: page optimal, help gets whatever is left (which is bigger/equal to its minimum) long nTransfer = DETAILS_OPT_PAGE_HEIGHT - nPageHeight; @@ -163,20 +162,20 @@ void OTableFieldDescWin::Resize() // and across the entire width nHelpX = 0; // without margin, since the HelpCtrl has its own one nHelpWidth = nOutputWidth; // dito - nPageWidth = nOutputWidth - STANDARD_MARGIN - STANDARD_MARGIN; + nPageWidth = nOutputWidth; } else { // unfortunately that's not even enough, to show page at its optimum and help with minimum width nHelpX = nHelpY = nHelpWidth = nHelpHeight = 0; // thus no help window - nPageWidth = nOutputWidth - STANDARD_MARGIN - STANDARD_MARGIN; - nPageHeight = nOutputHeight - STANDARD_MARGIN - DETAILS_HEADER_HEIGHT - STANDARD_MARGIN; + nPageWidth = nOutputWidth; + nPageHeight = nOutputHeight - DETAILS_HEADER_HEIGHT; } } - m_pHeader->SetPosSizePixel( Point(0, STANDARD_MARGIN), Size(nOutputWidth, 15) ); + m_pHeader->SetPosSizePixel( Point(0, 0), Size(nOutputWidth, 15) ); - getGenPage()->SetPosSizePixel(Point ( STANDARD_MARGIN, - STANDARD_MARGIN + DETAILS_HEADER_HEIGHT + getGenPage()->SetPosSizePixel(Point ( 0, + DETAILS_HEADER_HEIGHT ), Size ( nPageWidth, nPageHeight diff --git a/dbaccess/uiconfig/ui/designhelpbox.ui b/dbaccess/uiconfig/ui/designhelpbox.ui new file mode 100644 index 000000000000..e5791e4b931e --- /dev/null +++ b/dbaccess/uiconfig/ui/designhelpbox.ui @@ -0,0 +1,38 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- Generated with glade 3.36.0 --> +<interface domain="dba"> + <requires lib="gtk+" version="3.18"/> + <object class="GtkBox" id="DesignHelpBox"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="hexpand">True</property> + <property name="vexpand">True</property> + <property name="border_width">6</property> + <property name="spacing">6</property> + <child> + <object class="GtkScrolledWindow"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="hexpand">True</property> + <property name="vexpand">True</property> + <property name="hscrollbar_policy">never</property> + <property name="shadow_type">in</property> + <child> + <object class="GtkTextView" id="textview"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="hexpand">True</property> + <property name="vexpand">True</property> + <property name="editable">False</property> + <property name="wrap_mode">word</property> + </object> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + </object> +</interface> diff --git a/include/vcl/weld.hxx b/include/vcl/weld.hxx index 802e1ae7f138..660c7feb2a57 100644 --- a/include/vcl/weld.hxx +++ b/include/vcl/weld.hxx @@ -1945,6 +1945,7 @@ public: virtual OUString get_text() const = 0; // if nStartPos or nEndPos is -1 the max available text pos will be used virtual void select_region(int nStartPos, int nEndPos) = 0; + // returns true if the selection has nonzero length virtual bool get_selection_bounds(int& rStartPos, int& rEndPos) = 0; virtual void replace_selection(const OUString& rText) = 0; virtual void set_editable(bool bEditable) = 0; _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits