diff options
author | Caolán McNamara <caolanm@redhat.com> | 2020-08-28 10:29:55 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2020-08-28 20:15:45 +0200 |
commit | 3fc63a7463149685b04c676968a82bc00a48a9af (patch) | |
tree | 730a8219e3617b3fd6773dab0a961265945cf9b7 /dbaccess/source/ui/tabledesign | |
parent | bde1637b30570ee82fd8f3f72d1f6f4012914fc0 (diff) |
weld OTableBorderWindow
Change-Id: I8008d9ea1e1c5418c960ec9c80b55602a11f15f6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/101552
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'dbaccess/source/ui/tabledesign')
-rw-r--r-- | dbaccess/source/ui/tabledesign/TEditControl.cxx | 9 | ||||
-rw-r--r-- | dbaccess/source/ui/tabledesign/TEditControl.hxx | 5 | ||||
-rw-r--r-- | dbaccess/source/ui/tabledesign/TableDesignView.cxx | 119 | ||||
-rw-r--r-- | dbaccess/source/ui/tabledesign/TableFieldDescWin.cxx | 27 | ||||
-rw-r--r-- | dbaccess/source/ui/tabledesign/TableFieldDescWin.hxx | 10 |
5 files changed, 55 insertions, 115 deletions
diff --git a/dbaccess/source/ui/tabledesign/TEditControl.cxx b/dbaccess/source/ui/tabledesign/TEditControl.cxx index 6dbb9327877a..4d42125dd241 100644 --- a/dbaccess/source/ui/tabledesign/TEditControl.cxx +++ b/dbaccess/source/ui/tabledesign/TEditControl.cxx @@ -125,8 +125,9 @@ void OTableEditorCtrl::Init() RowInserted(0, m_pRowList->size()); } -OTableEditorCtrl::OTableEditorCtrl(vcl::Window* pWindow) +OTableEditorCtrl::OTableEditorCtrl(vcl::Window* pWindow, OTableDesignView* pView) :OTableRowView(pWindow) + ,m_pView(pView) ,pNameCell(nullptr) ,pTypeCell(nullptr) ,pHelpTextCell(nullptr) @@ -142,7 +143,6 @@ OTableEditorCtrl::OTableEditorCtrl(vcl::Window* pWindow) ,bReadOnly(true) ,m_aInvalidate(this) { - SetHelpId(HID_TABDESIGN_BACKGROUND); GetDataWindow().SetHelpId(HID_CTL_TABLEEDIT); @@ -273,7 +273,8 @@ void OTableEditorCtrl::dispose() pTypeCell.disposeAndClear(); pDescrCell.disposeAndClear(); pHelpTextCell.disposeAndClear(); - pDescrWin.clear(); + pDescrWin = nullptr; + m_pView.clear(); OTableRowView::dispose(); } @@ -1640,7 +1641,7 @@ void OTableEditorCtrl::SwitchType( const TOTypeInfoSP& _pType ) OTableDesignView* OTableEditorCtrl::GetView() const { - return static_cast<OTableDesignView*>(GetParent()->GetParent()); + return m_pView; } void OTableEditorCtrl::DeactivateCell(bool bUpdate) diff --git a/dbaccess/source/ui/tabledesign/TEditControl.hxx b/dbaccess/source/ui/tabledesign/TEditControl.hxx index b216cb518d55..d858555ce0d6 100644 --- a/dbaccess/source/ui/tabledesign/TEditControl.hxx +++ b/dbaccess/source/ui/tabledesign/TEditControl.hxx @@ -44,11 +44,12 @@ namespace dbaui std::vector< std::shared_ptr<OTableRow> >* m_pRowList; + VclPtr<OTableDesignView> m_pView; VclPtr<OSQLNameEditControl> pNameCell; VclPtr<::svt::ListBoxControl> pTypeCell; VclPtr<::svt::EditControl> pHelpTextCell; VclPtr<::svt::EditControl> pDescrCell; - VclPtr<OTableFieldDescWin> pDescrWin; // properties of one column + OTableFieldDescWin* pDescrWin; // properties of one column std::shared_ptr<OTableRow> pActRow; @@ -116,7 +117,7 @@ namespace dbaui bool IsPrimaryKey(); public: - explicit OTableEditorCtrl(vcl::Window* pParentWin); + explicit OTableEditorCtrl(vcl::Window* pParentWin, OTableDesignView* pView); virtual ~OTableEditorCtrl() override; virtual void dispose() override; virtual bool CursorMoving(long nNewRow, sal_uInt16 nNewCol) override; diff --git a/dbaccess/source/ui/tabledesign/TableDesignView.cxx b/dbaccess/source/ui/tabledesign/TableDesignView.cxx index 3f15dfba10cb..ae32e9706302 100644 --- a/dbaccess/source/ui/tabledesign/TableDesignView.cxx +++ b/dbaccess/source/ui/tabledesign/TableDesignView.cxx @@ -25,6 +25,7 @@ #include "TableFieldDescWin.hxx" #include <TableRow.hxx> #include <i18nlangtag/languagetag.hxx> +#include <toolkit/helper/vclunohelper.hxx> #include <unotools/syslocale.hxx> #include <vcl/settings.hxx> #include <memory> @@ -36,23 +37,21 @@ using namespace ::com::sun::star::datatransfer::clipboard; using namespace ::com::sun::star::lang; using namespace ::com::sun::star::beans; -OTableBorderWindow::OTableBorderWindow(OTableDesignView* pParent) : Window(pParent,WB_BORDER) - ,m_aHorzSplitter( VclPtr<Splitter>::Create(this) ) +OTableBorderWindow::OTableBorderWindow(OTableDesignView* pParent) + : InterimItemWindow(pParent, "dbaccess/ui/tableborderwindow.ui", "TableBorderWindow", false) + , m_xHorzSplitter(m_xBuilder->weld_paned("splitter")) + , m_xEditorParent(m_xBuilder->weld_container("editor")) + , m_xEditorParentWin(m_xEditorParent->CreateChildFrame()) + , m_xEditorCtrl(VclPtr<OTableEditorCtrl>::Create(VCLUnoHelper::GetWindow(m_xEditorParentWin), pParent)) + , m_xFieldDescParent(m_xBuilder->weld_container("fielddesc")) + , m_xFieldDescWin(new OTableFieldDescWin(m_xFieldDescParent.get(), pParent)) { + SetStyle(GetStyle() | WB_DIALOGCONTROL); - ImplInitSettings(); - // create children - m_pEditorCtrl = VclPtr<OTableEditorCtrl>::Create( this); - m_pFieldDescWin = VclPtr<OTableFieldDescWin>::Create(this, pParent); - - m_pFieldDescWin->SetHelpId(HID_TAB_DESIGN_DESCWIN); + m_xFieldDescWin->SetHelpId(HID_TAB_DESIGN_DESCWIN); // set depending windows and controls - m_pEditorCtrl->SetDescrWin(m_pFieldDescWin); - - // set up splitter - m_aHorzSplitter->SetSplitHdl( LINK(this, OTableBorderWindow, SplitHdl) ); - m_aHorzSplitter->Show(); + m_xEditorCtrl->SetDescrWin(m_xFieldDescWin.get()); } OTableBorderWindow::~OTableBorderWindow() @@ -63,93 +62,45 @@ OTableBorderWindow::~OTableBorderWindow() void OTableBorderWindow::dispose() { // destroy children - // ::dbaui::notifySystemWindow(this,m_pFieldDescWin,::comphelper::mem_fun(&TaskPaneList::RemoveWindow)); - m_pEditorCtrl->Hide(); - m_pFieldDescWin->Hide(); - m_pEditorCtrl.disposeAndClear(); - m_pFieldDescWin.disposeAndClear(); - m_aHorzSplitter.disposeAndClear(); - vcl::Window::dispose(); + m_xEditorCtrl.disposeAndClear(); + m_xEditorParentWin->dispose(); + m_xEditorParentWin.clear(); + m_xEditorParent.reset(); + m_xFieldDescWin.reset(); + m_xFieldDescParent.reset(); + m_xHorzSplitter.reset(); + InterimItemWindow::dispose(); } -void OTableBorderWindow::Resize() +void OTableBorderWindow::IdleResize() { - const long nSplitterHeight(3); - // dimensions of parent window - Size aOutputSize( GetOutputSize() ); - long nOutputWidth = aOutputSize.Width(); - long nOutputHeight = aOutputSize.Height(); - long nSplitPos = m_aHorzSplitter->GetSplitPosPixel(); + auto nOutputHeight = GetSizePixel().Height(); + auto nOldSplitPos = m_xHorzSplitter->get_position(); + auto nSplitPos = nOldSplitPos; // shift range of the splitter is the middle third of the output - long nDragPosY = nOutputHeight/3; - long nDragSizeHeight = nOutputHeight/3; - m_aHorzSplitter->SetDragRectPixel( tools::Rectangle(Point(0,nDragPosY), Size(nOutputWidth,nDragSizeHeight) ), this ); - if( (nSplitPos < nDragPosY) || (nSplitPos > (nDragPosY+nDragSizeHeight)) ) - nSplitPos = nDragPosY+nDragSizeHeight-5; + auto nDragPosY = nOutputHeight/3; + auto nDragSizeHeight = nOutputHeight/3; + if (nSplitPos < nDragPosY || nSplitPos > nDragPosY + nDragSizeHeight) + nSplitPos = nDragPosY + nDragSizeHeight; // set splitter - m_aHorzSplitter->SetPosSizePixel( Point( 0, nSplitPos ), Size(nOutputWidth, nSplitterHeight)); - m_aHorzSplitter->SetSplitPosPixel( nSplitPos ); + m_xHorzSplitter->set_position(nSplitPos); - // set window - m_pEditorCtrl->SetPosSizePixel( Point(0, 0), Size(nOutputWidth , nSplitPos) ); + InterimItemWindow::IdleResize(); - m_pFieldDescWin->SetPosSizePixel( Point(0, nSplitPos+nSplitterHeight), - Size(nOutputWidth, nOutputHeight-nSplitPos-nSplitterHeight) ); -} - -IMPL_LINK( OTableBorderWindow, SplitHdl, Splitter*, pSplit, void ) -{ - if(pSplit == m_aHorzSplitter.get()) - { - m_aHorzSplitter->SetPosPixel( Point( m_aHorzSplitter->GetPosPixel().X(),m_aHorzSplitter->GetSplitPosPixel() ) ); - Resize(); - } -} - -void OTableBorderWindow::ImplInitSettings() -{ - const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings(); - - // FIXME RenderContext - - vcl::Font aFont = rStyleSettings.GetAppFont(); - if ( IsControlFont() ) - aFont.Merge( GetControlFont() ); - SetPointFont(*this, aFont); - - Color aTextColor = rStyleSettings.GetButtonTextColor(); - if ( IsControlForeground() ) - aTextColor = GetControlForeground(); - SetTextColor( aTextColor ); - - if( IsControlBackground() ) - SetBackground( GetControlBackground() ); - else - SetBackground( rStyleSettings.GetFaceColor() ); -} - -void OTableBorderWindow::DataChanged( const DataChangedEvent& rDCEvt ) -{ - Window::DataChanged( rDCEvt ); - - if ( (rDCEvt.GetType() == DataChangedEventType::SETTINGS) && - (rDCEvt.GetFlags() & AllSettingsFlags::STYLE) ) - { - ImplInitSettings(); - Invalidate(); - } + if (nOldSplitPos != nSplitPos) + m_xHorzSplitter->set_position(nSplitPos); } void OTableBorderWindow::GetFocus() { - Window::GetFocus(); + InterimItemWindow::GetFocus(); // forward the focus to the current cell of the editor control - if (m_pEditorCtrl) - m_pEditorCtrl->GrabFocus(); + if (m_xEditorCtrl) + m_xEditorCtrl->GrabFocus(); } OTableDesignView::OTableDesignView( vcl::Window* pParent, diff --git a/dbaccess/source/ui/tabledesign/TableFieldDescWin.cxx b/dbaccess/source/ui/tabledesign/TableFieldDescWin.cxx index b85bc2e74a9d..af7dfd6168b7 100644 --- a/dbaccess/source/ui/tabledesign/TableFieldDescWin.cxx +++ b/dbaccess/source/ui/tabledesign/TableFieldDescWin.cxx @@ -29,8 +29,8 @@ using namespace dbaui; -OTableFieldDescWin::OTableFieldDescWin(vcl::Window* pParent, OTableDesignView* pView) - : InterimItemWindow(pParent, "dbaccess/ui/fielddescpanel.ui", "FieldDescPanel") +OTableFieldDescWin::OTableFieldDescWin(weld::Container* pParent, OTableDesignView* pView) + : OChildWindow(pParent, "dbaccess/ui/fielddescpanel.ui", "FieldDescPanel") , m_xHelpBar(new OTableDesignHelpBar(m_xBuilder->weld_text_view("textview"))) , m_xBox(m_xBuilder->weld_container("box")) , m_xFieldControl(new OTableFieldControl(m_xBox.get(), m_xHelpBar.get(), pView)) @@ -46,19 +46,13 @@ OTableFieldDescWin::OTableFieldDescWin(vcl::Window* pParent, OTableDesignView* p m_xFieldControl->connect_focus_in(LINK(this, OTableFieldDescWin, FieldFocusIn)); } -OTableFieldDescWin::~OTableFieldDescWin() +bool OTableFieldDescWin::HasChildPathFocus() const { - disposeOnce(); + return m_xFieldControl->HasChildPathFocus() || m_xHelpBar->HasFocus(); } -void OTableFieldDescWin::dispose() +OTableFieldDescWin::~OTableFieldDescWin() { - // destroy children - m_xFieldControl.reset(); - m_xBox.reset(); - m_xHeader.reset(); - m_xHelpBar.reset(); - InterimItemWindow::dispose(); } void OTableFieldDescWin::Init() @@ -129,16 +123,9 @@ void OTableFieldDescWin::paste() getActiveChild()->paste(); } -void OTableFieldDescWin::GetFocus() -{ - if ( getGenPage() ) - getGenPage()->GetFocus(); -} - -void OTableFieldDescWin::LoseFocus() +void OTableFieldDescWin::GrabFocus() { - if ( getGenPage() ) - getGenPage()->LoseFocus(); + m_xFieldControl->GrabFocus(); } IMPL_LINK(OTableFieldDescWin, HelpFocusIn, weld::Widget&, rWidget, void) diff --git a/dbaccess/source/ui/tabledesign/TableFieldDescWin.hxx b/dbaccess/source/ui/tabledesign/TableFieldDescWin.hxx index d25c5c61b60b..7d7fbbe5d9b1 100644 --- a/dbaccess/source/ui/tabledesign/TableFieldDescWin.hxx +++ b/dbaccess/source/ui/tabledesign/TableFieldDescWin.hxx @@ -21,6 +21,7 @@ #include <vcl/InterimItemWindow.hxx> #include <IClipBoardTest.hxx> +#include <ChildWindow.hxx> #include "TableFieldControl.hxx" namespace dbaui @@ -29,7 +30,7 @@ namespace dbaui class OTableDesignView; class OFieldDescription; - class OTableFieldDescWin final : public InterimItemWindow + class OTableFieldDescWin final : public OChildWindow , public IClipboardTest { enum ChildFocusState @@ -53,9 +54,8 @@ namespace dbaui DECL_LINK(FieldFocusIn, weld::Widget&, void); public: - explicit OTableFieldDescWin(vcl::Window* pParent, OTableDesignView* pView); + explicit OTableFieldDescWin(weld::Container* pParent, OTableDesignView* pView); virtual ~OTableFieldDescWin() override; - virtual void dispose() override; void Init(); @@ -69,8 +69,8 @@ namespace dbaui OUString BoolStringPersistent(const OUString& rUIString) const { return m_xFieldControl->BoolStringPersistent(rUIString); } OUString BoolStringUI(const OUString& rPersistentString) const { return m_xFieldControl->BoolStringUI(rPersistentString); } - virtual void GetFocus() override; - virtual void LoseFocus() override; + virtual bool HasChildPathFocus() const override; + virtual void GrabFocus() override; // IClipboardTest virtual bool isCutAllowed() override; |