summaryrefslogtreecommitdiff
path: root/basctl
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2018-09-19 09:52:19 +0100
committerCaolán McNamara <caolanm@redhat.com>2018-09-20 09:55:43 +0200
commit3f73733f7df6393be773e66e445eb0a86e9a9377 (patch)
tree5e053b87acd9db800c38a9c3a212efc86cff04f6 /basctl
parent495412c74f52957dd3941970bf34928d069e0dc3 (diff)
weld BreakPointDialog
Change-Id: Icecef8b0b939c5d87bdf1bb781731df8fc4419b5 Reviewed-on: https://gerrit.libreoffice.org/60756 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'basctl')
-rw-r--r--basctl/source/basicide/baside2.cxx6
-rw-r--r--basctl/source/basicide/baside2b.cxx10
-rw-r--r--basctl/source/basicide/brkdlg.cxx175
-rw-r--r--basctl/source/basicide/brkdlg.hxx33
-rw-r--r--basctl/uiconfig/basicide/ui/managebreakpoints.ui87
5 files changed, 180 insertions, 131 deletions
diff --git a/basctl/source/basicide/baside2.cxx b/basctl/source/basicide/baside2.cxx
index 7518a7b4a67e..a10f1b9ba34b 100644
--- a/basctl/source/basicide/baside2.cxx
+++ b/basctl/source/basicide/baside2.cxx
@@ -588,16 +588,14 @@ void ModulWindow::BasicToggleBreakPointEnabled()
}
}
-
void ModulWindow::ManageBreakPoints()
{
BreakPointWindow& rBrkWin = GetBreakPointWindow();
- ScopedVclPtrInstance< BreakPointDialog > aBrkDlg( &rBrkWin, GetBreakPoints() );
- aBrkDlg->Execute();
+ BreakPointDialog aBrkDlg(rBrkWin.GetFrameWeld(), GetBreakPoints());
+ aBrkDlg.run();
rBrkWin.Invalidate();
}
-
bool ModulWindow::BasicErrorHdl( StarBASIC const * pBasic )
{
GetShell()->GetViewFrame()->ToTop();
diff --git a/basctl/source/basicide/baside2b.cxx b/basctl/source/basicide/baside2b.cxx
index bcd09142536c..f2ccbc6e3812 100644
--- a/basctl/source/basicide/baside2b.cxx
+++ b/basctl/source/basicide/baside2b.cxx
@@ -1469,9 +1469,9 @@ void BreakPointWindow::Command( const CommandEvent& rCEvt )
}
else if (sCommand == "properties")
{
- ScopedVclPtrInstance<BreakPointDialog> aBrkDlg(this, GetBreakPoints());
- aBrkDlg->SetCurrentBreakPoint( *pBrk );
- aBrkDlg->Execute();
+ BreakPointDialog aBrkDlg(GetFrameWeld(), GetBreakPoints());
+ aBrkDlg.SetCurrentBreakPoint( *pBrk );
+ aBrkDlg.run();
Invalidate();
}
}
@@ -1481,8 +1481,8 @@ void BreakPointWindow::Command( const CommandEvent& rCEvt )
OString sCommand = xBrkListMenu->GetItemIdent(xBrkListMenu->Execute(this, aPos));
if (sCommand == "manage")
{
- ScopedVclPtrInstance< BreakPointDialog > aBrkDlg( this, GetBreakPoints() );
- aBrkDlg->Execute();
+ BreakPointDialog aBrkDlg(GetFrameWeld(), GetBreakPoints());
+ aBrkDlg.run();
Invalidate();
}
}
diff --git a/basctl/source/basicide/brkdlg.cxx b/basctl/source/basicide/brkdlg.cxx
index 53be6215bd78..fb34de153aa8 100644
--- a/basctl/source/basicide/brkdlg.cxx
+++ b/basctl/source/basicide/brkdlg.cxx
@@ -61,46 +61,45 @@ bool lcl_ParseText(OUString const &rText, size_t& rLineNr )
} // namespace
-BreakPointDialog::BreakPointDialog( vcl::Window* pParent, BreakPointList& rBrkPntList )
- : ModalDialog(pParent, "ManageBreakpointsDialog",
- "modules/BasicIDE/ui/managebreakpoints.ui")
+BreakPointDialog::BreakPointDialog(weld::Window* pParent, BreakPointList& rBrkPntList)
+ : GenericDialogController(pParent, "modules/BasicIDE/ui/managebreakpoints.ui", "ManageBreakpointsDialog")
, m_rOriginalBreakPointList(rBrkPntList)
, m_aModifiedBreakPointList(rBrkPntList)
+ , m_xComboBox(m_xBuilder->weld_entry_tree_view("entriesgrid", "entries", "entrieslist"))
+ , m_xOKButton(m_xBuilder->weld_button("ok"))
+ , m_xNewButton(m_xBuilder->weld_button("new"))
+ , m_xDelButton(m_xBuilder->weld_button("delete"))
+ , m_xCheckBox(m_xBuilder->weld_check_button("active"))
+ , m_xNumericField(m_xBuilder->weld_spin_button("pass-nospin"))
{
- get(m_pComboBox, "entries");
- m_pComboBox->set_height_request(m_pComboBox->GetTextHeight() * 12);
- m_pComboBox->set_width_request(m_pComboBox->approximate_char_width() * 32);
- get(m_pOKButton, "ok");
- get(m_pNewButton, "new");
- get(m_pDelButton, "delete");
- get(m_pCheckBox, "active");
- get(m_pNumericField, "pass-nospin");
-
- m_pComboBox->SetUpdateMode(false);
+ m_xComboBox->set_size_request(m_xComboBox->get_approximate_digit_width() * 20, -1);
+ m_xComboBox->set_height_request_by_rows(12);
+
+ m_xComboBox->freeze();
for ( size_t i = 0, n = m_aModifiedBreakPointList.size(); i < n; ++i )
{
BreakPoint& rBrk = m_aModifiedBreakPointList.at( i );
OUString aEntryStr( "# " + OUString::number(rBrk.nLine) );
- m_pComboBox->InsertEntry( aEntryStr );
+ m_xComboBox->append_text(aEntryStr);
}
- m_pComboBox->SetUpdateMode(true);
+ m_xComboBox->thaw();
+
+ m_xOKButton->connect_clicked(LINK(this, BreakPointDialog, ButtonHdl));
+ m_xNewButton->connect_clicked(LINK(this, BreakPointDialog, ButtonHdl));
+ m_xDelButton->connect_clicked(LINK(this, BreakPointDialog, ButtonHdl));
- m_pOKButton->SetClickHdl( LINK( this, BreakPointDialog, ButtonHdl ) );
- m_pNewButton->SetClickHdl( LINK( this, BreakPointDialog, ButtonHdl ) );
- m_pDelButton->SetClickHdl( LINK( this, BreakPointDialog, ButtonHdl ) );
+ m_xCheckBox->connect_toggled(LINK(this, BreakPointDialog, CheckBoxHdl));
+ m_xComboBox->connect_changed(LINK(this, BreakPointDialog, EditModifyHdl));
+ m_xComboBox->connect_row_activated(LINK(this, BreakPointDialog, TreeModifyHdl));
+ m_xComboBox->grab_focus();
- m_pCheckBox->SetClickHdl( LINK( this, BreakPointDialog, CheckBoxHdl ) );
- m_pComboBox->SetSelectHdl( LINK( this, BreakPointDialog, ComboBoxHighlightHdl ) );
- m_pComboBox->SetModifyHdl( LINK( this, BreakPointDialog, EditModifyHdl ) );
- m_pComboBox->GrabFocus();
+ m_xNumericField->set_range(0, 0x7FFFFFFF);
+ m_xNumericField->set_increments(1, 10);
+ m_xNumericField->connect_value_changed(LINK(this, BreakPointDialog, FieldModifyHdl));
- m_pNumericField->SetMin( 0 );
- m_pNumericField->SetMax( 0x7FFFFFFF );
- m_pNumericField->SetSpinSize( 1 );
- m_pNumericField->SetStrictFormat(true);
- m_pNumericField->SetModifyHdl( LINK( this, BreakPointDialog, EditModifyHdl ) );
+ if (m_xComboBox->get_count())
+ m_xComboBox->set_active(0);
- m_pComboBox->SetText( m_pComboBox->GetEntry( 0 ) );
if (m_aModifiedBreakPointList.size())
UpdateFields( m_aModifiedBreakPointList.at( 0 ) );
@@ -109,24 +108,12 @@ BreakPointDialog::BreakPointDialog( vcl::Window* pParent, BreakPointList& rBrkPn
BreakPointDialog::~BreakPointDialog()
{
- disposeOnce();
-}
-
-void BreakPointDialog::dispose()
-{
- m_pComboBox.clear();
- m_pOKButton.clear();
- m_pNewButton.clear();
- m_pDelButton.clear();
- m_pNumericField.clear();
- m_pCheckBox.clear();
- ModalDialog::dispose();
}
void BreakPointDialog::SetCurrentBreakPoint( BreakPoint const & rBrk )
{
OUString aStr( "# " + OUString::number(rBrk.nLine) );
- m_pComboBox->SetText( aStr );
+ m_xComboBox->set_entry_text(aStr);
UpdateFields( rBrk );
}
@@ -136,111 +123,115 @@ void BreakPointDialog::CheckButtons()
// number that is not already present in the combo box list; otherwise
// "OK" and "Delete" buttons are enabled:
size_t nLine;
- if (lcl_ParseText(m_pComboBox->GetText(), nLine)
+ if (lcl_ParseText(m_xComboBox->get_active_text(), nLine)
&& m_aModifiedBreakPointList.FindBreakPoint(nLine) == nullptr)
{
- m_pNewButton->Enable();
- m_pOKButton->Disable();
- m_pDelButton->Disable();
+ m_xNewButton->set_sensitive(true);
+ m_xOKButton->set_sensitive(false);
+ m_xDelButton->set_sensitive(false);
+ m_xDelButton->set_has_default(false);
+ m_xNewButton->set_has_default(true);
}
else
{
- m_pNewButton->Disable();
- m_pOKButton->Enable();
- m_pDelButton->Enable();
+ m_xNewButton->set_sensitive(false);
+ m_xOKButton->set_sensitive(true);
+ m_xDelButton->set_sensitive(true);
+ m_xNewButton->set_has_default(false);
+ m_xDelButton->set_has_default(true);
}
}
-IMPL_LINK( BreakPointDialog, CheckBoxHdl, Button *, pButton, void )
+IMPL_LINK(BreakPointDialog, CheckBoxHdl, weld::ToggleButton&, rButton, void)
{
- ::CheckBox * pChkBx = static_cast<::CheckBox*>(pButton);
BreakPoint* pBrk = GetSelectedBreakPoint();
if (pBrk)
- pBrk->bEnabled = pChkBx->IsChecked();
+ pBrk->bEnabled = rButton.get_active();
}
-IMPL_LINK( BreakPointDialog, ComboBoxHighlightHdl, ComboBox&, rBox, void )
+IMPL_LINK(BreakPointDialog, EditModifyHdl, weld::ComboBox&, rBox, void)
{
- m_pNewButton->Disable();
- m_pOKButton->Enable();
- m_pDelButton->Enable();
+ CheckButtons();
- sal_Int32 nEntry = rBox.GetEntryPos( rBox.GetText() );
+ int nEntry = rBox.find_text(rBox.get_active_text());
+ if (nEntry == -1)
+ return;
BreakPoint& rBrk = m_aModifiedBreakPointList.at( nEntry );
UpdateFields( rBrk );
}
-
-IMPL_LINK( BreakPointDialog, EditModifyHdl, Edit&, rEdit, void )
+IMPL_LINK(BreakPointDialog, FieldModifyHdl, weld::SpinButton&, rEdit, void)
{
- if (&rEdit == m_pComboBox)
- CheckButtons();
- else if (&rEdit == m_pNumericField)
- {
- BreakPoint* pBrk = GetSelectedBreakPoint();
- if (pBrk)
- pBrk->nStopAfter = rEdit.GetText().toInt32();
- }
+ BreakPoint* pBrk = GetSelectedBreakPoint();
+ if (pBrk)
+ pBrk->nStopAfter = rEdit.get_value();
}
+IMPL_LINK_NOARG(BreakPointDialog, TreeModifyHdl, weld::TreeView&, void)
+{
+ if (!m_xDelButton->get_sensitive())
+ return;
+ ButtonHdl(*m_xDelButton);
+}
-IMPL_LINK( BreakPointDialog, ButtonHdl, Button *, pButton, void )
+IMPL_LINK(BreakPointDialog, ButtonHdl, weld::Button&, rButton, void)
{
- if (pButton == m_pOKButton)
+ if (&rButton == m_xOKButton.get())
{
m_rOriginalBreakPointList.transfer(m_aModifiedBreakPointList);
- EndDialog( 1 );
+ m_xDialog->response(RET_OK);
}
- else if (pButton == m_pNewButton)
+ else if (&rButton == m_xNewButton.get())
{
// keep checkbox in mind!
- OUString aText( m_pComboBox->GetText() );
+ OUString aText(m_xComboBox->get_active_text());
size_t nLine;
bool bValid = lcl_ParseText( aText, nLine );
if ( bValid )
{
BreakPoint aBrk( nLine );
- aBrk.bEnabled = m_pCheckBox->IsChecked();
- aBrk.nStopAfter = static_cast<size_t>(m_pNumericField->GetValue());
+ aBrk.bEnabled = m_xCheckBox->get_active();
+ aBrk.nStopAfter = static_cast<size_t>(m_xNumericField->get_value());
m_aModifiedBreakPointList.InsertSorted( aBrk );
OUString aEntryStr( "# " + OUString::number(aBrk.nLine) );
- m_pComboBox->InsertEntry( aEntryStr );
+ m_xComboBox->append_text(aEntryStr);
if (SfxDispatcher* pDispatcher = GetDispatcher())
pDispatcher->Execute( SID_BASICIDE_BRKPNTSCHANGED );
}
else
{
- m_pComboBox->SetText( aText );
- m_pComboBox->GrabFocus();
+ m_xComboBox->set_active_text(aText);
+ m_xComboBox->grab_focus();
}
CheckButtons();
}
- else if (pButton == m_pDelButton)
+ else if (&rButton == m_xDelButton.get())
{
- sal_Int32 nEntry = m_pComboBox->GetEntryPos( m_pComboBox->GetText() );
- m_aModifiedBreakPointList.remove( nEntry );
- m_pComboBox->RemoveEntryAt(nEntry);
- if ( nEntry && nEntry >= m_pComboBox->GetEntryCount() )
- nEntry--;
- m_pComboBox->SetText( m_pComboBox->GetEntry( nEntry ) );
- if (SfxDispatcher* pDispatcher = GetDispatcher())
- pDispatcher->Execute( SID_BASICIDE_BRKPNTSCHANGED );
- CheckButtons();
+ int nEntry = m_xComboBox->find_text(m_xComboBox->get_active_text());
+ if (nEntry != -1)
+ {
+ m_aModifiedBreakPointList.remove(nEntry);
+ m_xComboBox->remove(nEntry);
+ if (nEntry && nEntry >= m_xComboBox->get_count())
+ nEntry--;
+ m_xComboBox->set_active_text(m_xComboBox->get_text(nEntry));
+ if (SfxDispatcher* pDispatcher = GetDispatcher())
+ pDispatcher->Execute( SID_BASICIDE_BRKPNTSCHANGED );
+ CheckButtons();
+ }
}
}
-
void BreakPointDialog::UpdateFields( BreakPoint const & rBrk )
{
- m_pCheckBox->Check( rBrk.bEnabled );
- m_pNumericField->SetValue( rBrk.nStopAfter );
+ m_xCheckBox->set_active(rBrk.bEnabled);
+ m_xNumericField->set_value(rBrk.nStopAfter);
}
-
BreakPoint* BreakPointDialog::GetSelectedBreakPoint()
{
- sal_Int32 nEntry = m_pComboBox->GetEntryPos( m_pComboBox->GetText() );
- if (nEntry == LISTBOX_ENTRY_NOTFOUND)
+ int nEntry = m_xComboBox->find_text(m_xComboBox->get_active_text());
+ if (nEntry == -1)
return nullptr;
return &m_aModifiedBreakPointList.at( nEntry );
}
diff --git a/basctl/source/basicide/brkdlg.hxx b/basctl/source/basicide/brkdlg.hxx
index f4cd8f684f94..48b91cf8a6e6 100644
--- a/basctl/source/basicide/brkdlg.hxx
+++ b/basctl/source/basicide/brkdlg.hxx
@@ -20,39 +20,36 @@
#ifndef INCLUDED_BASCTL_SOURCE_BASICIDE_BRKDLG_HXX
#define INCLUDED_BASCTL_SOURCE_BASICIDE_BRKDLG_HXX
-#include <vcl/dialog.hxx>
-
-#include <vcl/button.hxx>
-#include <vcl/field.hxx>
+#include <vcl/weld.hxx>
namespace basctl
{
-class BreakPointDialog final : public ModalDialog
+class BreakPointDialog final : public weld::GenericDialogController
{
- VclPtr<ComboBox> m_pComboBox;
- VclPtr<OKButton> m_pOKButton;
- VclPtr<PushButton> m_pNewButton;
- VclPtr<PushButton> m_pDelButton;
- VclPtr<CheckBox> m_pCheckBox;
- VclPtr<NumericField> m_pNumericField;
-
BreakPointList & m_rOriginalBreakPointList;
BreakPointList m_aModifiedBreakPointList;
+ std::unique_ptr<weld::EntryTreeView> m_xComboBox;
+ std::unique_ptr<weld::Button> m_xOKButton;
+ std::unique_ptr<weld::Button> m_xNewButton;
+ std::unique_ptr<weld::Button> m_xDelButton;
+ std::unique_ptr<weld::CheckButton> m_xCheckBox;
+ std::unique_ptr<weld::SpinButton> m_xNumericField;
+
void CheckButtons();
- DECL_LINK( CheckBoxHdl, Button*, void );
- DECL_LINK( ComboBoxHighlightHdl, ComboBox&, void );
- DECL_LINK( EditModifyHdl, Edit&, void );
- DECL_LINK( ButtonHdl, Button*, void );
+ DECL_LINK(CheckBoxHdl, weld::ToggleButton&, void);
+ DECL_LINK(EditModifyHdl, weld::ComboBox&, void);
+ DECL_LINK(FieldModifyHdl, weld::SpinButton&, void);
+ DECL_LINK(ButtonHdl, weld::Button&, void);
+ DECL_LINK(TreeModifyHdl, weld::TreeView&, void);
void UpdateFields( BreakPoint const & rBrk );
BreakPoint* GetSelectedBreakPoint();
public:
- BreakPointDialog( vcl::Window* pParent, BreakPointList& rBrkList );
+ BreakPointDialog(weld::Window* pParent, BreakPointList& rBrkList);
virtual ~BreakPointDialog() override;
- virtual void dispose() override;
void SetCurrentBreakPoint( BreakPoint const & rBrk );
};
diff --git a/basctl/uiconfig/basicide/ui/managebreakpoints.ui b/basctl/uiconfig/basicide/ui/managebreakpoints.ui
index 42f939905957..ba7ca5bb2e00 100644
--- a/basctl/uiconfig/basicide/ui/managebreakpoints.ui
+++ b/basctl/uiconfig/basicide/ui/managebreakpoints.ui
@@ -1,13 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.18.3 -->
+<!-- Generated with glade 3.22.1 -->
<interface domain="basctl">
<requires lib="gtk+" version="3.18"/>
- <requires lib="LibreOffice" version="1.0"/>
+ <object class="GtkListStore" id="liststore1">
+ <columns>
+ <!-- column-name text -->
+ <column type="gchararray"/>
+ <!-- column-name id -->
+ <column type="gchararray"/>
+ </columns>
+ </object>
+ <object class="GtkEntryCompletion" id="entrycompletion1">
+ <property name="model">liststore1</property>
+ <property name="text_column">0</property>
+ <property name="inline_completion">True</property>
+ <property name="popup_completion">False</property>
+ <property name="popup_set_width">False</property>
+ <property name="popup_single_match">False</property>
+ </object>
<object class="GtkDialog" id="ManageBreakpointsDialog">
<property name="can_focus">False</property>
<property name="border_width">6</property>
<property name="title" translatable="yes" context="managebreakpoints|ManageBreakpointsDialog">Manage Breakpoints</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>
+ <placeholder/>
+ </child>
<child internal-child="vbox">
<object class="GtkBox" id="dialog-vbox1">
<property name="can_focus">False</property>
@@ -23,7 +44,6 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="can_default">True</property>
- <property name="has_default">True</property>
<property name="receives_default">True</property>
<property name="use_stock">True</property>
</object>
@@ -39,7 +59,6 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="can_default">True</property>
- <property name="has_default">True</property>
<property name="receives_default">True</property>
<property name="use_stock">True</property>
</object>
@@ -55,7 +74,6 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="can_default">True</property>
- <property name="has_default">True</property>
<property name="receives_default">True</property>
<property name="use_stock">True</property>
</object>
@@ -140,19 +158,63 @@
</packing>
</child>
<child>
- <object class="VclComboBoxText" id="entries">
+ <object class="GtkGrid" id="entriesgrid">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
- <property name="has_entry">True</property>
- <property name="dropdown">False</property>
- <child internal-child="entry">
- <object class="GtkEntry" id="comboboxtext-entry">
+ <property name="row_spacing">3</property>
+ <child>
+ <object class="GtkScrolledWindow">
+ <property name="visible">True</property>
<property name="can_focus">False</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
+ <property name="shadow_type">in</property>
+ <child>
+ <object class="GtkTreeView" id="entrieslist">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="hexpand">True</property>
+ <property name="vexpand">True</property>
+ <property name="model">liststore1</property>
+ <property name="headers_visible">False</property>
+ <property name="headers_clickable">False</property>
+ <property name="search_column">0</property>
+ <property name="show_expanders">False</property>
+ <child internal-child="selection">
+ <object class="GtkTreeSelection" id="treeview-selection1"/>
+ </child>
+ <child>
+ <object class="GtkTreeViewColumn" id="treeviewcolumn1">
+ <child>
+ <object class="GtkCellRendererText" id="cellrenderertext1"/>
+ <attributes>
+ <attribute name="text">0</attribute>
+ </attributes>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkEntry" id="entries">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="hexpand">True</property>
+ <property name="activates_default">True</property>
+ <property name="completion">entrycompletion1</property>
</object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">0</property>
+ </packing>
</child>
</object>
<packing>
@@ -169,6 +231,7 @@
<object class="GtkSpinButton" id="pass-nospin">
<property name="visible">True</property>
<property name="can_focus">True</property>
+ <property name="activates_default">True</property>
</object>
<packing>
<property name="left_attach">1</property>
@@ -218,8 +281,8 @@
</object>
</child>
<action-widgets>
- <action-widget response="0">new</action-widget>
- <action-widget response="0">delete</action-widget>
+ <action-widget response="101">new</action-widget>
+ <action-widget response="102">delete</action-widget>
<action-widget response="-5">ok</action-widget>
<action-widget response="-6">cancel</action-widget>
</action-widgets>