Skip to content

Commit

Permalink
Minor wx upgrades
Browse files Browse the repository at this point in the history
  • Loading branch information
Blake-Madden committed Oct 18, 2024
1 parent 8a3c3cb commit acb2eaa
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 44 deletions.
15 changes: 5 additions & 10 deletions src/ui/controls/infobarex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,20 +44,15 @@ bool InfoBarEx::Create(wxWindow* parent, wxWindowID winid)
// button at the very right
wxBoxSizer* const sizer = new wxBoxSizer(wxVERTICAL);
wxBoxSizer* const firstRowSizer = new wxBoxSizer(wxHORIZONTAL);
firstRowSizer->Add(
m_icon, wxSizerFlags().CentreVertical().Border(wxALL, wxSizerFlags::GetDefaultBorder()));
firstRowSizer->Add(
m_text,
wxSizerFlags().Expand().Border(wxALL, wxSizerFlags::GetDefaultBorder()).Proportion(1));
firstRowSizer->Add(m_icon, wxSizerFlags{}.CentreVertical().Border());
firstRowSizer->Add(m_text, wxSizerFlags{ 1 }.Expand().Border());
firstRowSizer->AddStretchSpacer();
firstRowSizer->Add(closeButton, wxSizerFlags().CentreVertical().Border(
wxALL, wxSizerFlags::GetDefaultBorder()));
firstRowSizer->Add(closeButton, wxSizerFlags{}.CentreVertical().Border());

wxBoxSizer* const secondRowSizer = new wxBoxSizer(wxHORIZONTAL);
secondRowSizer->Add(m_dontShowAgainCheckbox, wxSizerFlags().CentreVertical().Border(
wxALL, wxSizerFlags::GetDefaultBorder()));
secondRowSizer->Add(m_dontShowAgainCheckbox, wxSizerFlags{}.CentreVertical().Border());

sizer->Add(firstRowSizer, wxSizerFlags().Proportion(1).Expand());
sizer->Add(firstRowSizer, wxSizerFlags{ 1 }.Expand());
sizer->Add(secondRowSizer);
sizer->Show(m_dontShowAgainCheckbox, m_includeDontShowAgain, true);

Expand Down
14 changes: 7 additions & 7 deletions src/ui/dialogs/filelistdlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace Wisteria::UI

// infobar
m_infoBar = new wxInfoBar(this);
mainSizer->Add(m_infoBar, wxSizerFlags().Expand());
mainSizer->Add(m_infoBar, wxSizerFlags{}.Expand());

const wxSizerFlags szFlags(wxSizerFlags{}.Expand().Border());

Expand All @@ -33,24 +33,24 @@ namespace Wisteria::UI
wxButton* button = new wxButton(this, wxID_OPEN, _(L"&Open File(s)..."));
button->SetBitmap(
wxArtProvider::GetBitmap(wxART_FILE_OPEN, wxART_BUTTON, FromDIP(wxSize(16, 16))));
buttonsSizer->Add(button, wxSizerFlags().Align(wxALIGN_LEFT).Expand());
buttonsSizer->Add(button, wxSizerFlags{}.Align(wxALIGN_LEFT).Expand());

#ifdef __WXMSW__
button = new wxButton(this, ID_FOLDER_OPEN, _(L"Open &Folder(s)..."));
button->SetBitmap(
wxArtProvider::GetBitmap(wxART_FOLDER_OPEN, wxART_BUTTON, FromDIP(wxSize(16, 16))));
buttonsSizer->Add(button, wxSizerFlags().Align(wxALIGN_LEFT).Expand());
buttonsSizer->Add(button, wxSizerFlags{}.Align(wxALIGN_LEFT).Expand());
#endif

button = new wxButton(this, wxID_DELETE, _(L"&Delete File(s)"));
button->SetBitmap(
wxArtProvider::GetBitmap(wxART_DELETE, wxART_BUTTON, FromDIP(wxSize(16, 16))));
buttonsSizer->Add(button, wxSizerFlags().Align(wxALIGN_LEFT).Expand());
buttonsSizer->Add(button, wxSizerFlags{}.Align(wxALIGN_LEFT).Expand());

button = new wxButton(this, wxID_REFRESH, _(L"&Refresh List"));
button->SetBitmap(
wxArtProvider::GetBitmap(wxART_REDO, wxART_BUTTON, FromDIP(wxSize(16, 16))));
buttonsSizer->Add(button, wxSizerFlags().Align(wxALIGN_LEFT).Expand());
buttonsSizer->Add(button, wxSizerFlags{}.Align(wxALIGN_LEFT).Expand());

fileListSizer->Add(buttonsSizer);

Expand All @@ -67,14 +67,14 @@ namespace Wisteria::UI
m_listCtrl->EnableFileDeletion();
m_listCtrl->SetVirtualDataProvider(m_fileData);
m_listCtrl->SetVirtualDataSize(1, 3);
fileListSizer->Add(m_listCtrl, wxSizerFlags(1).Expand());
fileListSizer->Add(m_listCtrl, wxSizerFlags{ 1 }.Expand());

// file information
wxBoxSizer* fileInfoSizer = new wxBoxSizer(wxVERTICAL);
m_thumbnail = new Wisteria::UI::Thumbnail(
this, wxNullBitmap, Wisteria::ClickMode::FullSizeViewable, false, wxID_ANY,
wxDefaultPosition, FromDIP(wxSize(256, 256)));
fileInfoSizer->Add(m_thumbnail, wxSizerFlags().Border(wxDirection::wxALL,
fileInfoSizer->Add(m_thumbnail, wxSizerFlags{}.Border(wxDirection::wxALL,
wxSizerFlags::GetDefaultBorder()));

fileInfoSizer->AddStretchSpacer();
Expand Down
2 changes: 1 addition & 1 deletion src/ui/dialogs/functionbrowserdlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ namespace Wisteria::UI

m_funcBrowserControl =
new FunctionBrowserCtrl(this, editor, wxID_ANY, firstWindowCaption, secondWindowCaption);
mainSizer->Add(m_funcBrowserControl, wxSizerFlags(1).Expand());
mainSizer->Add(m_funcBrowserControl, wxSizerFlags{ 1 }.Expand());

// Close and Insert buttons
mainSizer->Add(CreateSeparatedButtonSizer(wxOK | wxCANCEL | wxHELP),
Expand Down
2 changes: 1 addition & 1 deletion src/ui/dialogs/graphdlg.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ namespace Wisteria::UI

mainSizer->Add(
new wxStaticLine(this),
wxSizerFlags().Expand().Border(wxRIGHT | wxLEFT, wxSizerFlags::GetDefaultBorder()));
wxSizerFlags{}.Expand().Border(wxRIGHT | wxLEFT, wxSizerFlags::GetDefaultBorder()));
wxBoxSizer* buttonSizer = new wxBoxSizer(wxHORIZONTAL);
{
wxButton* button = new wxButton(this, wxID_PRINT);
Expand Down
38 changes: 17 additions & 21 deletions src/ui/dialogs/gridexportdlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,87 +98,83 @@ void GridExportDlg::CreateControls()
wxBoxSizer* mainSizer = new wxBoxSizer(wxVERTICAL);

wxBoxSizer* optionsSizer = new wxBoxSizer(wxVERTICAL);
mainSizer->Add(optionsSizer, wxSizerFlags(1).Border(wxALL, wxSizerFlags::GetDefaultBorder()));
mainSizer->Add(optionsSizer, wxSizerFlags{ 1 }.Border());

wxCheckBox* columnHeaderCheck = new wxCheckBox(
this, wxID_ANY, _(L"&Include column headers"), wxDefaultPosition, wxDefaultSize,
wxCHK_2STATE, wxGenericValidator(&m_options.m_includeColumnHeaders));
optionsSizer->Add(columnHeaderCheck,
wxSizerFlags().Border(wxALL, wxSizerFlags::GetDefaultBorder()));
optionsSizer->Add(columnHeaderCheck, wxSizerFlags{}.Border());

optionsSizer->Add(new wxRadioButton(this, ControlIDs::ID_EXPORT_ALL_OPTION,
_(L"&Export all rows"), wxDefaultPosition, wxDefaultSize,
wxRB_GROUP, wxGenericValidator(&m_options.m_exportAll)),
wxSizerFlags().Border(wxALL, wxSizerFlags::GetDefaultBorder()));
wxSizerFlags{}.Border());

optionsSizer->Add(new wxRadioButton(this, ControlIDs::ID_EXPORT_SELECTED_OPTION,
_(L"Export &selected rows"), wxDefaultPosition,
wxDefaultSize, 0,
wxGenericValidator(&m_options.m_exportSelected)),
wxSizerFlags().Border(wxALL, wxSizerFlags::GetDefaultBorder()));
wxSizerFlags{}.Border());

optionsSizer->Add(new wxRadioButton(this, ControlIDs::ID_EXPORT_RANGE_OPTION,
_(L"Export a &range of rows"), wxDefaultPosition,
wxDefaultSize, 0,
wxGenericValidator(&m_options.m_exportRange)),
wxSizerFlags().Border(wxALL, wxSizerFlags::GetDefaultBorder()));
wxSizerFlags{}.Border());

m_rangeBoxSizer = new wxStaticBoxSizer(wxVERTICAL, this, _(L"Range:"));
optionsSizer->Add(m_rangeBoxSizer,
wxSizerFlags(1).Expand().Border(wxALL, wxSizerFlags::GetDefaultBorder()));
optionsSizer->Add(m_rangeBoxSizer, wxSizerFlags{ 1 }.Expand().Border());

wxFlexGridSizer* rangeOptionsSizer = new wxFlexGridSizer(2, 4, 5, 5);
m_rangeBoxSizer->Add(rangeOptionsSizer,
wxSizerFlags(1).Expand().Border(wxALL, wxSizerFlags::GetDefaultBorder()));
m_rangeBoxSizer->Add(rangeOptionsSizer, wxSizerFlags{ 1 }.Expand().Border());

// row options
rangeOptionsSizer->Add(
new wxStaticText(m_rangeBoxSizer->GetStaticBox(), ID_ROWS_FROM_LABEL, _(L"Rows: from")),
wxSizerFlags().CenterVertical());
wxSizerFlags{}.CenterVertical());

auto fromRowSpinCtrl =
new wxSpinCtrl(m_rangeBoxSizer->GetStaticBox(), ControlIDs::ID_ROWS_FROM_SPIN, L"1",
wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 1, m_options.m_toRow, 1);
fromRowSpinCtrl->SetValidator(wxGenericValidator(&m_options.m_fromRow));
rangeOptionsSizer->Add(fromRowSpinCtrl, wxSizerFlags().Expand());
rangeOptionsSizer->Add(fromRowSpinCtrl, wxSizerFlags{}.Expand());

rangeOptionsSizer->Add(
new wxStaticText(m_rangeBoxSizer->GetStaticBox(), ID_ROWS_TO_LABEL, _(L"to")),
wxSizerFlags().CenterVertical());
wxSizerFlags{}.CenterVertical());

auto toRowSpinCtrl =
new wxSpinCtrl(m_rangeBoxSizer->GetStaticBox(), ControlIDs::ID_ROWS_TO_SPIN, L"1",
wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 1, m_options.m_toRow, 1);
toRowSpinCtrl->SetValidator(wxGenericValidator(&m_options.m_toRow));
rangeOptionsSizer->Add(toRowSpinCtrl, wxSizerFlags().Expand());
rangeOptionsSizer->Add(toRowSpinCtrl, wxSizerFlags{}.Expand());

// column options
rangeOptionsSizer->Add(
new wxStaticText(m_rangeBoxSizer->GetStaticBox(), wxID_STATIC, _(L"Columns: from")),
wxSizerFlags().CenterVertical());
wxSizerFlags{}.CenterVertical());

auto fromColumnSpinCtrl =
new wxSpinCtrl(m_rangeBoxSizer->GetStaticBox(), wxID_ANY, L"1", wxDefaultPosition,
wxDefaultSize, wxSP_ARROW_KEYS, 1, m_options.m_toColumn, 1);
fromColumnSpinCtrl->SetValidator(wxGenericValidator(&m_options.m_fromColumn));
rangeOptionsSizer->Add(fromColumnSpinCtrl, wxSizerFlags().Expand());
rangeOptionsSizer->Add(fromColumnSpinCtrl, wxSizerFlags{}.Expand());

rangeOptionsSizer->Add(new wxStaticText(m_rangeBoxSizer->GetStaticBox(), wxID_STATIC, _(L"to")),
wxSizerFlags().CenterVertical());
wxSizerFlags{}.CenterVertical());

auto toColumnSpinCtrl =
new wxSpinCtrl(m_rangeBoxSizer->GetStaticBox(), wxID_ANY, L"1", wxDefaultPosition,
wxDefaultSize, wxSP_ARROW_KEYS, 1, m_options.m_toColumn, 1);
toColumnSpinCtrl->SetValidator(wxGenericValidator(&m_options.m_toColumn));
rangeOptionsSizer->Add(toColumnSpinCtrl, wxSizerFlags().Expand());
rangeOptionsSizer->Add(toColumnSpinCtrl, wxSizerFlags{}.Expand());

if (m_exportFormat == GridExportFormat::ExportHtml)
{
m_paginateCheckBox = new wxCheckBox(
this, wxID_ANY, _(L"&Paginate using printer settings"), wxDefaultPosition,
wxDefaultSize, wxCHK_2STATE, wxGenericValidator(&m_options.m_pageUsingPrinterSettings));
optionsSizer->Add(m_paginateCheckBox,
wxSizerFlags().Border(wxALL, wxSizerFlags::GetDefaultBorder()));
optionsSizer->Add(m_paginateCheckBox, wxSizerFlags{}.Border());
}

m_rangeBoxSizer->GetStaticBox()->Enable(false);
Expand All @@ -188,7 +184,7 @@ void GridExportDlg::CreateControls()
}

mainSizer->Add(CreateSeparatedButtonSizer(wxOK | wxCANCEL | wxHELP),
wxSizerFlags().Expand().Border(wxALL, wxSizerFlags::GetDefaultBorder()));
wxSizerFlags{}.Expand().Border());

SetSizerAndFit(mainSizer);
}
9 changes: 5 additions & 4 deletions src/ui/dialogs/opacitydlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ void OpacityDlg::CreateControls()
assert(m_image.IsOk());
if (m_image.IsOk())
{
const wxSize scaledSize = FromDIP(wxSize(300, 300));
const wxSize scaledSize = FromDIP(wxSize{ 300, 300 });
const std::pair<double, double> thumbSize = geometry::downscaled_size(
std::make_pair(m_image.GetWidth(), m_image.GetHeight()),
std::make_pair(scaledSize.GetWidth(), scaledSize.GetHeight()));
Expand All @@ -57,13 +57,14 @@ void OpacityDlg::CreateControls()
m_thumb->SetOpacity(static_cast<uint8_t>(GetOpacity()));
m_thumb->SetMinSize(wxSize(thumbSize.first, thumbSize.second));

mainSizer->Add(m_thumb, wxSizerFlags(1).Expand());
mainSizer->Add(m_thumb, wxSizerFlags{ 1 }.Expand());
}

mainSizer->Add(new wxSlider(this, wxID_ANY, m_opacity, 0, 255, wxDefaultPosition, wxDefaultSize,
mainSizer->Add(new wxSlider(this, wxID_ANY, m_opacity, wxALPHA_TRANSPARENT, wxALPHA_OPAQUE,
wxDefaultPosition, wxDefaultSize,
wxSL_HORIZONTAL | wxSL_LABELS | wxSL_AUTOTICKS,
wxGenericValidator(&m_opacity)),
wxSizerFlags(0).Expand().Border(wxALL, wxSizerFlags::GetDefaultBorder()));
wxSizerFlags{}.Expand().Border());

mainSizer->Add(CreateSeparatedButtonSizer(wxOK | wxCANCEL), wxSizerFlags{}.Expand().Border());

Expand Down

0 comments on commit acb2eaa

Please sign in to comment.