diff options
author | Caolán McNamara <caolanm@redhat.com> | 2018-04-29 15:27:31 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2018-04-30 10:01:00 +0200 |
commit | a0329f7c60b457405058404dececd4d8479ef1d5 (patch) | |
tree | 5da019b41a0b610ae7e40c44f3c13573a7d0df91 /starmath | |
parent | d0f7b12359082b7dd7c07cfa57e0394dfe325c36 (diff) |
weld SmSymbolDialog
Change-Id: I163a309fdf79e3eeadeb15b2a1c042666def339f
Reviewed-on: https://gerrit.libreoffice.org/53633
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'starmath')
-rw-r--r-- | starmath/inc/dialog.hxx | 110 | ||||
-rw-r--r-- | starmath/source/dialog.cxx | 350 | ||||
-rw-r--r-- | starmath/source/view.cxx | 3 | ||||
-rw-r--r-- | starmath/uiconfig/smath/ui/catalogdialog.ui | 88 |
4 files changed, 240 insertions, 311 deletions
diff --git a/starmath/inc/dialog.hxx b/starmath/inc/dialog.hxx index 3a63fb264f7a..e2a66edba2c7 100644 --- a/starmath/inc/dialog.hxx +++ b/starmath/inc/dialog.hxx @@ -258,91 +258,70 @@ public: /**************************************************************************/ -class SmShowSymbolSetWindow : public Control +class SmShowSymbolSet { - VclPtr<ScrollBar> m_pVScrollBar; + Size m_aSize; + Size m_aOldSize; SymbolPtrVec_t aSymbolSet; - Link<SmShowSymbolSetWindow&,void> aSelectHdlLink; - Link<SmShowSymbolSetWindow&,void> aDblClickHdlLink; + Link<SmShowSymbolSet&,void> aSelectHdlLink; + Link<SmShowSymbolSet&,void> aDblClickHdlLink; long nLen; long nRows, nColumns; long nXOffset, nYOffset; sal_uInt16 nSelectSymbol; + std::unique_ptr<weld::DrawingArea> m_xDrawingArea; + std::unique_ptr<weld::ScrolledWindow> m_xScrolledWindow; void SetScrollBarRange(); Point OffsetPoint(const Point &rPoint) const; - virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle&) override; - virtual void MouseButtonDown(const MouseEvent& rMEvt) override; - virtual void KeyInput(const KeyEvent& rKEvt) override; - virtual void Resize() override; - virtual Size GetOptimalSize() const override; + DECL_LINK(DoPaint, weld::DrawingArea::draw_args, void); + DECL_LINK(DoMouseButtonDown, const MouseEvent& rMEvt, void); + DECL_LINK(DoKeyDown, const KeyEvent& rKEvt, bool); + DECL_LINK(DoResize, const Size& rSize, void); + DECL_LINK(ScrollHdl, weld::ScrolledWindow&, void); - DECL_LINK( ScrollHdl, ScrollBar*, void ); public: - SmShowSymbolSetWindow(vcl::Window *pParent, WinBits nStyle); - virtual ~SmShowSymbolSetWindow() override; - virtual void dispose() override; - void setScrollbar(ScrollBar *pVScrollBar); - void calccols(); + SmShowSymbolSet(weld::DrawingArea* pDrawingArea, weld::ScrolledWindow* pScrolledWindow); + void calccols(vcl::RenderContext& rRenderContext); void SelectSymbol(sal_uInt16 nSymbol); sal_uInt16 GetSelectSymbol() const { return nSelectSymbol; } void SetSymbolSet(const SymbolPtrVec_t& rSymbolSet); - void SetSelectHdl(const Link<SmShowSymbolSetWindow&,void>& rLink) { aSelectHdlLink = rLink; } - void SetDblClickHdl(const Link<SmShowSymbolSetWindow&,void>& rLink) { aDblClickHdlLink = rLink; } + void SetSelectHdl(const Link<SmShowSymbolSet&,void>& rLink) { aSelectHdlLink = rLink; } + void SetDblClickHdl(const Link<SmShowSymbolSet&,void>& rLink) { aDblClickHdlLink = rLink; } }; -class SmShowSymbolSet : public VclHBox +class SmShowSymbol { - VclPtr<SmShowSymbolSetWindow> aSymbolWindow; - VclPtr<ScrollBar> aVScrollBar; - -public: - SmShowSymbolSet(vcl::Window *pParent); - virtual ~SmShowSymbolSet() override; - virtual void dispose() override; - - void SetSymbolSet(const SymbolPtrVec_t& rSymbolSet) { aSymbolWindow->SetSymbolSet(rSymbolSet); } - - void SelectSymbol(sal_uInt16 nSymbol) { aSymbolWindow->SelectSymbol(nSymbol); } - sal_uInt16 GetSelectSymbol() const { return aSymbolWindow->GetSelectSymbol(); } - - void SetSelectHdl(const Link<SmShowSymbolSetWindow&,void>& rLink) { aSymbolWindow->SetSelectHdl(rLink); } - void SetDblClickHdl(const Link<SmShowSymbolSetWindow&,void>& rLink) { aSymbolWindow->SetDblClickHdl(rLink); } -}; - +private: + Size m_aSize; + vcl::Font m_aFont; + OUString m_aText; + std::unique_ptr<weld::DrawingArea> m_xDrawingArea; -class SmShowSymbol : public Control -{ Link<SmShowSymbol&,void> aDblClickHdlLink; - virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle&) override; - virtual void ApplySettings(vcl::RenderContext& rRenderContext) override; - virtual void MouseButtonDown(const MouseEvent& rMEvt) override; - virtual void Resize() override; + DECL_LINK(DoPaint, weld::DrawingArea::draw_args, void); + DECL_LINK(DoMouseButtonDown, const MouseEvent& rMEvt, void); + DECL_LINK(DoResize, const Size& rSize, void); void setFontSize(vcl::Font &rFont) const; public: - SmShowSymbol(vcl::Window *pParent, WinBits nStyle) - : Control(pParent, nStyle) - { - } + SmShowSymbol(weld::DrawingArea* pDrawingArea); + + void SetText(const OUString& rText) { m_aText = rText; } + const OUString& GetText() const { return m_aText; } + + void SetFont(const vcl::Font& rFont) { m_aFont = rFont; } + const vcl::Font& GetFont() const { return m_aFont; } void SetSymbol(const SmSym *pSymbol); void SetDblClickHdl(const Link<SmShowSymbol&,void> &rLink) { aDblClickHdlLink = rLink; } }; - -class SmSymbolDialog : public ModalDialog +class SmSymbolDialog : public weld::GenericDialogController { - VclPtr<ListBox> m_pSymbolSets; - VclPtr<SmShowSymbolSet> m_pSymbolSetDisplay; - VclPtr<FixedText> m_pSymbolName; - VclPtr<SmShowSymbol> m_pSymbolDisplay; - VclPtr<PushButton> m_pGetBtn; - VclPtr<PushButton> m_pEditBtn; - SmViewShell &rViewSh; SmSymbolManager &rSymbolMgr; @@ -351,30 +330,33 @@ class SmSymbolDialog : public ModalDialog VclPtr<OutputDevice> pFontListDev; - DECL_LINK(SymbolSetChangeHdl, ListBox&, void); - DECL_LINK(SymbolChangeHdl, SmShowSymbolSetWindow&, void); + std::unique_ptr<weld::ComboBoxText> m_xSymbolSets; + std::unique_ptr<SmShowSymbolSet> m_xSymbolSetDisplay; + std::unique_ptr<weld::Label> m_xSymbolName; + std::unique_ptr<SmShowSymbol> m_xSymbolDisplay; + std::unique_ptr<weld::Button> m_xGetBtn; + std::unique_ptr<weld::Button> m_xEditBtn; + + DECL_LINK(SymbolSetChangeHdl, weld::ComboBoxText&, void); + DECL_LINK(SymbolChangeHdl, SmShowSymbolSet&, void); DECL_LINK(SymbolDblClickHdl, SmShowSymbol&, void); - DECL_LINK(SymbolDblClickHdl2, SmShowSymbolSetWindow&, void); - DECL_LINK(EditClickHdl, Button*, void); - DECL_LINK(GetClickHdl, Button*, void); + DECL_LINK(SymbolDblClickHdl2, SmShowSymbolSet&, void); + DECL_LINK(EditClickHdl, weld::Button&, void); + DECL_LINK(GetClickHdl, weld::Button&, void); void SymbolDblClickHdl(); void FillSymbolSets(); const SmSym *GetSymbol() const; - virtual void DataChanged( const DataChangedEvent& rDCEvt ) override; - public: - SmSymbolDialog(vcl::Window * pParent, OutputDevice *pFntListDevice, + SmSymbolDialog(weld::Window* pParent, OutputDevice *pFntListDevice, SmSymbolManager &rSymbolMgr, SmViewShell &rViewShell); virtual ~SmSymbolDialog() override; - virtual void dispose() override; bool SelectSymbolSet(const OUString &rSymbolSetName); void SelectSymbol(sal_uInt16 nSymbolPos); }; - class SmShowChar { private: diff --git a/starmath/source/dialog.cxx b/starmath/source/dialog.cxx index b9bc57f9530d..7713cd475b05 100644 --- a/starmath/source/dialog.cxx +++ b/starmath/source/dialog.cxx @@ -958,36 +958,41 @@ void SmAlignDialog::WriteTo(SmFormat &rFormat) const rFormat.RequestApplyChanges(); } -SmShowSymbolSetWindow::SmShowSymbolSetWindow(vcl::Window *pParent, WinBits nStyle) - : Control(pParent, nStyle) - , m_pVScrollBar(nullptr) - , nLen(0) +SmShowSymbolSet::SmShowSymbolSet(weld::DrawingArea* pDrawingArea, weld::ScrolledWindow* pScrolledWindow) + : nLen(0) , nRows(0) , nColumns(0) , nXOffset(0) , nYOffset(0) , nSelectSymbol(SYMBOL_NONE) + , m_xDrawingArea(pDrawingArea) + , m_xScrolledWindow(pScrolledWindow) { + m_xDrawingArea->connect_size_allocate(LINK(this, SmShowSymbolSet, DoResize)); + m_xDrawingArea->connect_draw(LINK(this, SmShowSymbolSet, DoPaint)); + m_xDrawingArea->connect_mouse_press(LINK(this, SmShowSymbolSet, DoMouseButtonDown)); + m_xDrawingArea->connect_key_press(LINK(this, SmShowSymbolSet, DoKeyDown)); + m_xScrolledWindow->set_user_managed_scrolling(); + m_xScrolledWindow->connect_vadjustment_changed(LINK(this, SmShowSymbolSet, ScrollHdl)); + m_xDrawingArea->set_size_request(m_xDrawingArea->get_approximate_digit_width() * 27, + m_xDrawingArea->get_text_height() * 9); } -SmShowSymbolSetWindow::~SmShowSymbolSetWindow() +Point SmShowSymbolSet::OffsetPoint(const Point &rPoint) const { - disposeOnce(); + return Point(rPoint.X() + nXOffset, rPoint.Y() + nYOffset); } -void SmShowSymbolSetWindow::dispose() +IMPL_LINK(SmShowSymbolSet, DoPaint, weld::DrawingArea::draw_args, aPayload, void) { - m_pVScrollBar.clear(); - Control::dispose(); -} + vcl::RenderContext& rRenderContext = aPayload.first; -Point SmShowSymbolSetWindow::OffsetPoint(const Point &rPoint) const -{ - return Point(rPoint.X() + nXOffset, rPoint.Y() + nYOffset); -} + if (m_aSize != m_aOldSize) + { + calccols(rRenderContext); + m_aOldSize = m_aSize; + } -void SmShowSymbolSetWindow::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle&) -{ Color aBackgroundColor; Color aTextColor; lclGetSettingColors(aBackgroundColor, aTextColor); @@ -1000,7 +1005,7 @@ void SmShowSymbolSetWindow::Paint(vcl::RenderContext& rRenderContext, const tool // set MapUnit for which 'nLen' has been calculated rRenderContext.SetMapMode(MapMode(MapUnit::MapPixel)); - sal_uInt16 v = sal::static_int_cast< sal_uInt16 >(m_pVScrollBar->GetThumbPos() * nColumns); + sal_uInt16 v = sal::static_int_cast< sal_uInt16 >(m_xScrolledWindow->vadjustment_get_value() * nColumns); size_t nSymbols = aSymbolSet.size(); Color aTxtColor(rRenderContext.GetTextColor()); @@ -1033,17 +1038,16 @@ void SmShowSymbolSetWindow::Paint(vcl::RenderContext& rRenderContext, const tool Point aPoint(((nSelectSymbol - v) % nColumns) * nLen, ((nSelectSymbol - v) / nColumns) * nLen); - Invert(tools::Rectangle(OffsetPoint(aPoint), Size(nLen, nLen))); + rRenderContext.Invert(tools::Rectangle(OffsetPoint(aPoint), Size(nLen, nLen))); } rRenderContext.Pop(); } - -void SmShowSymbolSetWindow::MouseButtonDown(const MouseEvent& rMEvt) +IMPL_LINK(SmShowSymbolSet, DoMouseButtonDown, const MouseEvent&, rMEvt, void) { - GrabFocus(); + m_xDrawingArea->grab_focus(); Size aOutputSize(nColumns * nLen, nRows * nLen); aOutputSize.AdjustWidth(nXOffset ); @@ -1055,7 +1059,7 @@ void SmShowSymbolSetWindow::MouseButtonDown(const MouseEvent& rMEvt) if (rMEvt.IsLeft() && tools::Rectangle(Point(0, 0), aOutputSize).IsInside(rMEvt.GetPosPixel())) { long nPos = (aPoint.Y() / nLen) * nColumns + (aPoint.X() / nLen) + - m_pVScrollBar->GetThumbPos() * nColumns; + m_xScrolledWindow->vadjustment_get_value() * nColumns; SelectSymbol( sal::static_int_cast< sal_uInt16 >(nPos) ); aSelectHdlLink.Call(*this); @@ -1065,8 +1069,7 @@ void SmShowSymbolSetWindow::MouseButtonDown(const MouseEvent& rMEvt) } } - -void SmShowSymbolSetWindow::KeyInput(const KeyEvent& rKEvt) +IMPL_LINK(SmShowSymbolSet, DoKeyDown, const KeyEvent&, rKEvt, bool) { sal_uInt16 n = nSelectSymbol; @@ -1082,10 +1085,8 @@ void SmShowSymbolSetWindow::KeyInput(const KeyEvent& rKEvt) case KEY_END: n = static_cast< sal_uInt16 >(aSymbolSet.size() - 1); break; case KEY_PAGEUP: n -= nColumns * nRows; break; case KEY_PAGEDOWN: n += nColumns * nRows; break; - default: - Control::KeyInput(rKEvt); - return; + return false; } } else @@ -1095,58 +1096,25 @@ void SmShowSymbolSetWindow::KeyInput(const KeyEvent& rKEvt) n = nSelectSymbol; // adjust scrollbar - if ((n < sal::static_int_cast<sal_uInt16>(m_pVScrollBar->GetThumbPos() * nColumns)) || - (n >= sal::static_int_cast<sal_uInt16>((m_pVScrollBar->GetThumbPos() + nRows) * nColumns))) + if ((n < sal::static_int_cast<sal_uInt16>(m_xScrolledWindow->vadjustment_get_value() * nColumns)) || + (n >= sal::static_int_cast<sal_uInt16>((m_xScrolledWindow->vadjustment_get_value() + nRows) * nColumns))) { - m_pVScrollBar->SetThumbPos(n / nColumns); - Invalidate(); - Update(); + m_xScrolledWindow->vadjustment_set_value(n / nColumns); + m_xDrawingArea->queue_draw(); } SelectSymbol(n); aSelectHdlLink.Call(*this); -} - -void SmShowSymbolSetWindow::setScrollbar(ScrollBar *pVScrollBar) -{ - m_pVScrollBar = pVScrollBar; - m_pVScrollBar->Enable(false); - m_pVScrollBar->Show(); - m_pVScrollBar->SetScrollHdl(LINK(this, SmShowSymbolSetWindow, ScrollHdl)); -} -SmShowSymbolSet::SmShowSymbolSet(vcl::Window *pParent) - : VclHBox(pParent, false, 6) - , aSymbolWindow(VclPtr<SmShowSymbolSetWindow>::Create(this, WB_TABSTOP)) - , aVScrollBar(VclPtr<ScrollBar>::Create(this, WinBits(WB_VSCROLL))) -{ - aSymbolWindow->set_hexpand(true); - aSymbolWindow->set_vexpand(true); - aSymbolWindow->setScrollbar(aVScrollBar.get()); - aSymbolWindow->calccols(); - aSymbolWindow->Show(); -} - -SmShowSymbolSet::~SmShowSymbolSet() -{ - disposeOnce(); -} - -void SmShowSymbolSet::dispose() -{ - aSymbolWindow.disposeAndClear(); - aVScrollBar.disposeAndClear(); - VclHBox::dispose(); + return true; } -VCL_BUILDER_FACTORY(SmShowSymbolSet) - -void SmShowSymbolSetWindow::calccols() +void SmShowSymbolSet::calccols(vcl::RenderContext& rRenderContext) { // Height of 16pt in pixels (matching 'aOutputSize') - nLen = LogicToPixel(Size(0, 16), MapMode(MapUnit::MapPoint)).Height(); + nLen = rRenderContext.LogicToPixel(Size(0, 16), MapMode(MapUnit::MapPoint)).Height(); - Size aOutputSize = GetOutputSizePixel(); + Size aOutputSize = m_aSize; nColumns = aOutputSize.Width() / nLen; nRows = aOutputSize.Height() / nLen; @@ -1159,43 +1127,29 @@ void SmShowSymbolSetWindow::calccols() SetScrollBarRange(); } -Size SmShowSymbolSetWindow::GetOptimalSize() const -{ - vcl::Window *pParent = GetParent(); - return Size(pParent->approximate_char_width() * 24, pParent->GetTextHeight() * 8); -} - -void SmShowSymbolSetWindow::SetSymbolSet(const SymbolPtrVec_t& rSymbolSet) +void SmShowSymbolSet::SetSymbolSet(const SymbolPtrVec_t& rSymbolSet) { aSymbolSet = rSymbolSet; - - SetScrollBarRange(); + m_xDrawingArea->queue_draw(); } -void SmShowSymbolSetWindow::SetScrollBarRange() +void SmShowSymbolSet::SetScrollBarRange() { - if (aSymbolSet.size() > static_cast<size_t>(nColumns * nRows)) - { - m_pVScrollBar->SetRange(Range(0, ((aSymbolSet.size() + (nColumns - 1)) / nColumns) - nRows)); - m_pVScrollBar->Enable(); - } - else - { - m_pVScrollBar->SetRange(Range(0,0)); - m_pVScrollBar->Enable (false); - } - - Invalidate(); + const int nLastRow = (aSymbolSet.size() - 1 + nColumns) / nColumns; + m_xScrolledWindow->vadjustment_configure(m_xScrolledWindow->vadjustment_get_value(), 0, nLastRow, 1, nRows - 1, nRows); + m_xDrawingArea->queue_draw(); } -void SmShowSymbolSetWindow::SelectSymbol(sal_uInt16 nSymbol) +void SmShowSymbolSet::SelectSymbol(sal_uInt16 nSymbol) { - int v = static_cast<int>(m_pVScrollBar->GetThumbPos() * nColumns); + int v = m_xScrolledWindow->vadjustment_get_value() * nColumns; - if (nSelectSymbol != SYMBOL_NONE) - Invalidate(tools::Rectangle(OffsetPoint(Point(((nSelectSymbol - v) % nColumns) * nLen, - ((nSelectSymbol - v) / nColumns) * nLen)), - Size(nLen, nLen))); + if (nSelectSymbol != SYMBOL_NONE && nColumns) + { + Point aPoint(OffsetPoint(Point(((nSelectSymbol - v) % nColumns) * nLen, + ((nSelectSymbol - v) / nColumns) * nLen))); + m_xDrawingArea->queue_draw_area(aPoint.X(), aPoint.Y(), nLen, nLen); + } if (nSymbol < aSymbolSet.size()) nSelectSymbol = nSymbol; @@ -1203,53 +1157,61 @@ void SmShowSymbolSetWindow::SelectSymbol(sal_uInt16 nSymbol) if (aSymbolSet.empty()) nSelectSymbol = SYMBOL_NONE; - if (nSelectSymbol != SYMBOL_NONE) - Invalidate(tools::Rectangle(OffsetPoint(Point(((nSelectSymbol - v) % nColumns) * nLen, - ((nSelectSymbol - v) / nColumns) * nLen)), - Size(nLen, nLen))); + if (nSelectSymbol != SYMBOL_NONE && nColumns) + { + Point aPoint(OffsetPoint(Point(((nSelectSymbol - v) % nColumns) * nLen, + ((nSelectSymbol - v) / nColumns) * nLen))); + m_xDrawingArea->queue_draw_area(aPoint.X(), aPoint.Y(), nLen, nLen); + } - Update(); + if (!nColumns) + m_xDrawingArea->queue_draw(); } -void SmShowSymbolSetWindow::Resize() +IMPL_LINK(SmShowSymbolSet, DoResize, const Size&, rSize, void) { - Control::Resize(); - calccols(); + m_aSize = rSize; + m_xDrawingArea->queue_draw(); } -IMPL_LINK( SmShowSymbolSetWindow, ScrollHdl, ScrollBar*, /*pScrollBar*/, void) +IMPL_LINK_NOARG(SmShowSymbolSet, ScrollHdl, weld::ScrolledWindow&, void) { - Invalidate(); + m_xDrawingArea->queue_draw(); } -VCL_BUILDER_FACTORY_CONSTRUCTOR(SmShowSymbol, 0) - -void SmShowSymbol::Resize() +IMPL_LINK(SmShowSymbol, DoResize, const Size&, rSize, void) { - Control::Resize(); - Invalidate(); + m_aSize = rSize; + m_xDrawingArea->queue_draw(); } -void SmShowSymbol::ApplySettings(vcl::RenderContext& /*rRenderContext*/ ) +SmShowSymbol::SmShowSymbol(weld::DrawingArea* pDrawingArea) + : m_xDrawingArea(pDrawingArea) { + m_xDrawingArea->connect_size_allocate(LINK(this, SmShowSymbol, DoResize)); + m_xDrawingArea->connect_draw(LINK(this, SmShowSymbol, DoPaint)); + m_xDrawingArea->connect_mouse_press(LINK(this, SmShowSymbol, DoMouseButtonDown)); + m_xDrawingArea->set_size_request(m_xDrawingArea->get_approximate_digit_width() * 27, + m_xDrawingArea->get_text_height() * 9); } void SmShowSymbol::setFontSize(vcl::Font &rFont) const { - rFont.SetFontSize(Size(0, GetOutputSize().Height() - GetOutputSize().Height() / 3)); + rFont.SetFontSize(Size(0, m_aSize.Height() - m_aSize.Height() / 3)); } -void SmShowSymbol::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle &rRect) +IMPL_LINK(SmShowSymbol, DoPaint, weld::DrawingArea::draw_args, aPayload, void) { - Control::Paint(rRenderContext, rRect); + vcl::RenderContext& rRenderContext = aPayload.first; Color aBackgroundColor; Color aTextColor; lclGetSettingColors(aBackgroundColor, aTextColor); - SetBackground(Wallpaper(aBackgroundColor)); - SetTextColor(aTextColor); + rRenderContext.SetBackground(Wallpaper(aBackgroundColor)); + rRenderContext.SetTextColor(aTextColor); + rRenderContext.Erase(); - vcl::Font aFont(rRenderContext.GetFont()); + vcl::Font aFont(GetFont()); setFontSize(aFont); rRenderContext.SetFont(aFont); @@ -1260,20 +1222,17 @@ void SmShowSymbol::Paint(vcl::RenderContext& rRenderContext, const tools::Rectan (rRenderContext.GetOutputSize().Height() * 7 / 10)), rText); } -void SmShowSymbol::MouseButtonDown(const MouseEvent& rMEvt) +IMPL_LINK(SmShowSymbol, DoMouseButtonDown, const MouseEvent&, rMEvt, void) { if (rMEvt.GetClicks() > 1) aDblClickHdlLink.Call(*this); - else - Control::MouseButtonDown (rMEvt); } void SmShowSymbol::SetSymbol(const SmSym *pSymbol) { if (pSymbol) { - vcl::Font aFont (pSymbol->GetFace()); - setFontSize(aFont); + vcl::Font aFont(pSymbol->GetFace()); aFont.SetAlignment(ALIGN_BASELINE); SetFont(aFont); @@ -1282,70 +1241,65 @@ void SmShowSymbol::SetSymbol(const SmSym *pSymbol) SetText( aText ); } - // 'Invalidate' fills the background with the background color. - // If a NULL pointer has been passed that's already enough to clear the display - Invalidate(); + m_xDrawingArea->queue_draw(); } - void SmSymbolDialog::FillSymbolSets() // populate the entries of possible SymbolsSets in the dialog with // current values of the SymbolSet manager but selects none of those { - m_pSymbolSets->Clear(); - m_pSymbolSets->SetNoSelection(); + m_xSymbolSets->clear(); + m_xSymbolSets->set_active(-1); std::set< OUString > aSybolSetNames( rSymbolMgr.GetSymbolSetNames() ); std::set< OUString >::const_iterator aIt( aSybolSetNames.begin() ); for ( ; aIt != aSybolSetNames.end(); ++aIt) - m_pSymbolSets->InsertEntry( *aIt ); + m_xSymbolSets->append_text(*aIt); } - -IMPL_LINK_NOARG( SmSymbolDialog, SymbolSetChangeHdl, ListBox&, void ) +IMPL_LINK_NOARG( SmSymbolDialog, SymbolSetChangeHdl, weld::ComboBoxText&, void ) { - SelectSymbolSet(m_pSymbolSets->GetSelectedEntry()); + SelectSymbolSet(m_xSymbolSets->get_active_text()); } - -IMPL_LINK_NOARG( SmSymbolDialog, SymbolChangeHdl, SmShowSymbolSetWindow&, void ) +IMPL_LINK_NOARG( SmSymbolDialog, SymbolChangeHdl, SmShowSymbolSet&, void ) { - SelectSymbol(m_pSymbolSetDisplay->GetSelectSymbol()); + SelectSymbol(m_xSymbolSetDisplay->GetSelectSymbol()); } -IMPL_LINK_NOARG(SmSymbolDialog, EditClickHdl, Button*, void) +IMPL_LINK_NOARG(SmSymbolDialog, EditClickHdl, weld::Button&, void) { - SmSymDefineDialog aDialog(GetFrameWeld(), pFontListDev, rSymbolMgr); + SmSymDefineDialog aDialog(m_xDialog.get(), pFontListDev, rSymbolMgr); // set current symbol and SymbolSet for the new dialog - const OUString aSymSetName (m_pSymbolSets->GetSelectedEntry()), - aSymName (m_pSymbolName->GetText()); + const OUString aSymSetName (m_xSymbolSets->get_active_text()), + aSymName (m_xSymbolName->get_label()); aDialog.SelectOldSymbolSet(aSymSetName); aDialog.SelectOldSymbol(aSymName); aDialog.SelectSymbolSet(aSymSetName); aDialog.SelectSymbol(aSymName); // remember old SymbolSet - OUString aOldSymbolSet (m_pSymbolSets->GetSelectedEntry()); + OUString aOldSymbolSet (m_xSymbolSets->get_active_text()); - sal_uInt16 nSymPos = m_pSymbolSetDisplay->GetSelectSymbol(); + sal_uInt16 nSymPos = m_xSymbolSetDisplay->GetSelectSymbol(); // adapt dialog to data of the SymbolSet manager, which might have changed - if (aDialog.execute() == RET_OK && rSymbolMgr.IsModified()) + if (aDialog.execute() == RET_OK && rSymbolMgr.IsModified()) { rSymbolMgr.Save(); FillSymbolSets(); } // if the old SymbolSet doesn't exist anymore, go to the first one SymbolSet (if one exists) - if (!SelectSymbolSet(aOldSymbolSet) && m_pSymbolSets->GetEntryCount() > 0) - SelectSymbolSet(m_pSymbolSets->GetEntry(0)); + if (!SelectSymbolSet(aOldSymbolSet) && m_xSymbolSets->get_count() > 0) + SelectSymbolSet(m_xSymbolSets->get_text(0)); else { // just update display of current symbol set assert(aSymSetName == aSymSetName); //unexpected change in symbol set name aSymbolSet = rSymbolMgr.GetSymbolSet( aSymbolSetName ); - m_pSymbolSetDisplay->SetSymbolSet( aSymbolSet ); + m_xSymbolSetDisplay->SetSymbolSet( aSymbolSet ); } if (nSymPos >= aSymbolSet.size()) @@ -1353,23 +1307,23 @@ IMPL_LINK_NOARG(SmSymbolDialog, EditClickHdl, Button*, void) SelectSymbol( nSymPos ); } - -IMPL_LINK_NOARG( SmSymbolDialog, SymbolDblClickHdl2, SmShowSymbolSetWindow&, void ) +IMPL_LINK_NOARG( SmSymbolDialog, SymbolDblClickHdl2, SmShowSymbolSet&, void ) { SymbolDblClickHdl(); } + IMPL_LINK_NOARG( SmSymbolDialog, SymbolDblClickHdl, SmShowSymbol&, void ) { SymbolDblClickHdl(); } + void SmSymbolDialog::SymbolDblClickHdl() { - GetClickHdl(m_pGetBtn); - EndDialog(RET_OK); + GetClickHdl(*m_xGetBtn); + m_xDialog->response(RET_OK); } - -IMPL_LINK_NOARG( SmSymbolDialog, GetClickHdl, Button*, void ) +IMPL_LINK_NOARG(SmSymbolDialog, GetClickHdl, weld::Button&, void) { const SmSym *pSym = GetSymbol(); if (pSym) @@ -1382,81 +1336,49 @@ IMPL_LINK_NOARG( SmSymbolDialog, GetClickHdl, Button*, void ) } } - -SmSymbolDialog::SmSymbolDialog(vcl::Window *pParent, OutputDevice *pFntListDevice, - SmSymbolManager &rMgr, SmViewShell &rViewShell) - : ModalDialog(pParent, "CatalogDialog", - "modules/smath/ui/catalogdialog.ui") - - , - - rViewSh (rViewShell), - rSymbolMgr (rMgr), - pFontListDev (pFntListDevice) +SmSymbolDialog::SmSymbolDialog(weld::Window *pParent, OutputDevice *pFntListDevice, + SmSymbolManager &rMgr, SmViewShell &rViewShell) + : GenericDialogController(pParent, "modules/smath/ui/catalogdialog.ui", "CatalogDialog") + , rViewSh(rViewShell) + , rSymbolMgr(rMgr) + , pFontListDev(pFntListDevice) + , m_xSymbolSets(m_xBuilder->weld_combo_box_text("symbolset")) + , m_xSymbolSetDisplay(new SmShowSymbolSet(m_xBuilder->weld_drawing_area("symbolsetdisplay"), m_xBuilder->weld_scrolled_window("scrolledwindow"))) + , m_xSymbolName(m_xBuilder->weld_label("symbolname")) + , m_xSymbolDisplay(new SmShowSymbol(m_xBuilder->weld_drawing_area("preview"))) + , m_xGetBtn(m_xBuilder->weld_button("ok")) + , m_xEditBtn(m_xBuilder->weld_button("edit")) { - get(m_pSymbolSets, "symbolset"); - m_pSymbolSets->SetStyle(m_pSymbolSets->GetStyle()|WB_SORT); - get(m_pSymbolName, "symbolname"); - get(m_pGetBtn, "ok"); - get(m_pEditBtn, "edit"); - get(m_pSymbolSetDisplay, "symbolsetdisplay"); - get(m_pSymbolDisplay, "preview"); + m_xSymbolSets->make_sorted(); aSymbolSetName.clear(); aSymbolSet.clear(); FillSymbolSets(); - if (m_pSymbolSets->GetEntryCount() > 0) - SelectSymbolSet(m_pSymbolSets->GetEntry(0)); - - // preview like controls should have a 2D look - m_pSymbolDisplay->SetBorderStyle( WindowBorderStyle::MONO ); + if (m_xSymbolSets->get_count() > 0) + SelectSymbolSet(m_xSymbolSets->get_text(0)); - m_pSymbolSets->SetSelectHdl(LINK(this, SmSymbolDialog, SymbolSetChangeHdl)); - m_pSymbolSetDisplay->SetSelectHdl(LINK(this, SmSymbolDialog, SymbolChangeHdl)); - m_pSymbolSetDisplay->SetDblClickHdl(LINK(this, SmSymbolDialog, SymbolDblClickHdl2)); - m_pSymbolDisplay->SetDblClickHdl(LINK(this, SmSymbolDialog, SymbolDblClickHdl)); - m_pEditBtn->SetClickHdl(LINK(this, SmSymbolDialog, EditClickHdl)); - m_pGetBtn->SetClickHdl(LINK(this, SmSymbolDialog, GetClickHdl)); + m_xSymbolSets->connect_changed(LINK(this, SmSymbolDialog, SymbolSetChangeHdl)); + m_xSymbolSetDisplay->SetSelectHdl(LINK(this, SmSymbolDialog, SymbolChangeHdl)); + m_xSymbolSetDisplay->SetDblClickHdl(LINK(this, SmSymbolDialog, SymbolDblClickHdl2)); + m_xSymbolDisplay->SetDblClickHdl(LINK(this, SmSymbolDialog, SymbolDblClickHdl)); + m_xEditBtn->connect_clicked(LINK(this, SmSymbolDialog, EditClickHdl)); + m_xGetBtn->connect_clicked(LINK(this, SmSymbolDialog, GetClickHdl)); } SmSymbolDialog::~SmSymbolDialog() { - disposeOnce(); -} - -void SmSymbolDialog::dispose() -{ - m_pSymbolSets.clear(); - m_pSymbolSetDisplay.clear(); - m_pSymbolName.clear(); - m_pSymbolDisplay.clear(); - m_pGetBtn.clear(); - m_pEditBtn.clear(); - pFontListDev.clear(); - ModalDialog::dispose(); -} - -void SmSymbolDialog::DataChanged( const DataChangedEvent& rDCEvt ) -{ - if (rDCEvt.GetType() == DataChangedEventType::SETTINGS && (rDCEvt.GetFlags() & AllSettingsFlags::STYLE)) - { - m_pSymbolDisplay->Invalidate(); - m_pSymbolSetDisplay->Invalidate(); - } - - ModalDialog::DataChanged( rDCEvt ); } bool SmSymbolDialog::SelectSymbolSet(const OUString &rSymbolSetName) { bool bRet = false; - sal_Int32 nPos = m_pSymbolSets->GetEntryPos(rSymbolSetName); + sal_Int32 nPos = m_xSymbolSets->find_text(rSymbolSetName); aSymbolSetName.clear(); aSymbolSet.clear(); - if (nPos != LISTBOX_ENTRY_NOTFOUND) + if (nPos != -1) { - m_pSymbolSets->SelectEntryPos(nPos); + m_xSymbolSets->set_active(nPos); aSymbolSetName = rSymbolSetName; aSymbolSet = rSymbolMgr.GetSymbolSet( aSymbolSetName ); @@ -1468,14 +1390,14 @@ bool SmSymbolDialog::SelectSymbolSet(const OUString &rSymbolSetName) return pSym1->GetCharacter() < pSym2->GetCharacter(); } ); - m_pSymbolSetDisplay->SetSymbolSet( aSymbolSet ); + m_xSymbolSetDisplay->SetSymbolSet( aSymbolSet ); if (!aSymbolSet.empty()) SelectSymbol(0); bRet = true; } else - m_pSymbolSets->SetNoSelection(); + m_xSymbolSets->set_active(-1); return bRet; } @@ -1486,14 +1408,14 @@ void SmSymbolDialog::SelectSymbol(sal_uInt16 nSymbolNo) if (!aSymbolSetName.isEmpty() && nSymbolNo < static_cast< sal_uInt16 >(aSymbolSet.size())) pSym = aSymbolSet[ nSymbolNo ]; - m_pSymbolSetDisplay->SelectSymbol(nSymbolNo); - m_pSymbolDisplay->SetSymbol(pSym); - m_pSymbolName->SetText(pSym ? pSym->GetName() : OUString()); + m_xSymbolSetDisplay->SelectSymbol(nSymbolNo); + m_xSymbolDisplay->SetSymbol(pSym); + m_xSymbolName->set_label(pSym ? pSym->GetName() : OUString()); } const SmSym* SmSymbolDialog::GetSymbol() const { - sal_uInt16 nSymbolNo = m_pSymbolSetDisplay->GetSelectSymbol(); + sal_uInt16 nSymbolNo = m_xSymbolSetDisplay->GetSelectSymbol(); bool bValid = !aSymbolSetName.isEmpty() && nSymbolNo < static_cast< sal_uInt16 >(aSymbolSet.size()); return bValid ? aSymbolSet[ nSymbolNo ] : nullptr; } diff --git a/starmath/source/view.cxx b/starmath/source/view.cxx index 5850194c3468..346ea88400f3 100644 --- a/starmath/source/view.cxx +++ b/starmath/source/view.cxx @@ -1798,7 +1798,8 @@ void SmViewShell::Execute(SfxRequest& rReq) SAL_WARN_IF( !pDev, "starmath", "device for font list missing" ); SmModule *pp = SM_MOD(); - ScopedVclPtrInstance<SmSymbolDialog>( nullptr, pDev, pp->GetSymbolManager(), *this )->Execute(); + SmSymbolDialog aDialog(pWin ? pWin->GetFrameWeld() : nullptr, pDev, pp->GetSymbolManager(), *this); + aDialog.run(); } break; } diff --git a/starmath/uiconfig/smath/ui/catalogdialog.ui b/starmath/uiconfig/smath/ui/catalogdialog.ui index c4010b41b1e5..407dab1aa29c 100644 --- a/starmath/uiconfig/smath/ui/catalogdialog.ui +++ b/starmath/uiconfig/smath/ui/catalogdialog.ui @@ -2,13 +2,13 @@ <!-- Generated with glade 3.20.4 --> <interface domain="sm"> <requires lib="gtk+" version="3.18"/> - <requires lib="LibreOffice" version="1.0"/> <object class="GtkDialog" id="CatalogDialog"> <property name="can_focus">False</property> <property name="border_width">6</property> <property name="title" translatable="yes" context="catalogdialog|CatalogDialog">Symbols</property> - <property name="resizable">False</property> <property name="modal">True</property> + <property name="default_width">0</property> + <property name="default_height">0</property> <property name="type_hint">dialog</property> <child internal-child="vbox"> <object class="GtkBox" id="dialog-vbox5"> @@ -95,6 +95,7 @@ <property name="vexpand">True</property> <property name="row_spacing">6</property> <property name="column_spacing">12</property> + <property name="column_homogeneous">True</property> <child> <object class="GtkLabel" id="label1"> <property name="visible">True</property> @@ -120,39 +121,78 @@ </packing> </child> <child> - <object class="smlo-SmShowSymbolSet" id="symbolsetdisplay"> + <object class="GtkLabel" id="symbolname"> <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">True</property> - <property name="hexpand">True</property> - <property name="vexpand">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes" context="catalogdialog|symbolname">Unknown</property> </object> <packing> <property name="left_attach">0</property> - <property name="top_attach">2</property> + <property name="top_attach">3</property> </packing> </child> <child> - <object class="smlo-SmShowSymbol" id="preview:border"> + <object class="GtkScrolledWindow" id="scrolledwindow"> <property name="visible">True</property> - <property name="can_focus">False</property> + <property name="can_focus">True</property> <property name="hexpand">True</property> <property name="vexpand">True</property> + <property name="vscrollbar_policy">always</property> + <property name="shadow_type">in</property> + <child> + <object class="GtkViewport"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="hexpand">True</property> + <property name="vexpand">True</property> + <child> + <object class="GtkDrawingArea" id="symbolsetdisplay"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <property name="events">GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK | GDK_STRUCTURE_MASK</property> + <property name="hexpand">True</property> + <property name="vexpand">True</property> + </object> + </child> + </object> + </child> </object> <packing> - <property name="left_attach">1</property> + <property name="left_attach">0</property> <property name="top_attach">2</property> </packing> </child> <child> - <object class="GtkLabel" id="symbolname"> + <object class="GtkScrolledWindow"> <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="label" translatable="yes" context="catalogdialog|symbolname">Unknown</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="vscrollbar_policy">never</property> + <property name="shadow_type">in</property> + <child> + <object class="GtkViewport"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="hexpand">True</property> + <property name="vexpand">True</property> + <child> + <object class="GtkDrawingArea" id="preview"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="events">GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_STRUCTURE_MASK</property> + <property name="hexpand">True</property> + <property name="vexpand">True</property> + </object> + </child> + </object> + </child> </object> <packing> - <property name="left_attach">0</property> - <property name="top_attach">3</property> + <property name="left_attach">1</property> + <property name="top_attach">2</property> </packing> </child> <child> @@ -174,7 +214,6 @@ </object> </child> <action-widgets> - <action-widget response="0">edit</action-widget> <action-widget response="-5">ok</action-widget> <action-widget response="-7">close</action-widget> <action-widget response="-11">help</action-widget> @@ -183,19 +222,4 @@ <placeholder/> </child> </object> - <object class="GtkSizeGroup" id="sizegroup1"> - <property name="mode">vertical</property> - <widgets> - <widget name="preview:border"/> - <widget name="symbolsetdisplay"/> - </widgets> - </object> - <object class="GtkSizeGroup" id="sizegroup2"> - <widgets> - <widget name="preview:border"/> - <widget name="symbolsetdisplay"/> - <widget name="symbolset"/> - </widgets> - </object> - <object class="GtkListStore" id="liststore1"/> </interface> |