Fixed some warnings

This commit is contained in:
YuSanka 2023-10-19 15:40:14 +02:00
parent fc64b01e3f
commit 6274f24e93
10 changed files with 41 additions and 48 deletions

View File

@ -899,8 +899,9 @@ void SpinCtrl::BUILD() {
if (!wxOSX) temp->SetBackgroundStyle(wxBG_STYLE_PAINT);
wxGetApp().UpdateDarkUI(temp);
if (m_opt.height < 0 && parent_is_custom_ctrl)
if (m_opt.height < 0 && parent_is_custom_ctrl) {
opt_height = (double)temp->GetSize().GetHeight() / m_em_unit;
}
temp->Bind(wxEVT_KILL_FOCUS, ([this](wxEvent& e)
{

View File

@ -1680,7 +1680,7 @@ void GUI_App::SetWindowVariantForButton(wxButton* btn)
int GUI_App::get_max_font_pt_size()
{
const unsigned disp_count = wxDisplay::GetCount();
for (int i = 0; i < disp_count; i++) {
for (unsigned i = 0; i < disp_count; i++) {
const wxRect display_rect = wxDisplay(i).GetGeometry();
if (display_rect.width >= 2560 && display_rect.height >= 1440)
return 20;

View File

@ -1947,23 +1947,22 @@ void TabFilament::create_line_with_near_label_widget(ConfigOptionsGroupShp optgr
else
line = optgroup->create_single_option_line(optgroup->get_option(opt_key));
line.near_label_widget = [this, optgroup_wk = ConfigOptionsGroupWkp(optgroup), opt_key, opt_index](wxWindow* parent) {
wxWindow* check_box = CheckBox::GetNewWin(parent);
wxGetApp().UpdateDarkUI(check_box);
line.near_label_widget = [this, optgroup_wk = ConfigOptionsGroupWkp(optgroup), opt_key, opt_index](wxWindow* parent) {
wxWindow* check_box = CheckBox::GetNewWin(parent);
wxGetApp().UpdateDarkUI(check_box);
check_box->Bind(wxEVT_CHECKBOX, [optgroup_wk, opt_key, opt_index](wxCommandEvent& evt) {
const bool is_checked = evt.IsChecked();
if (auto optgroup_sh = optgroup_wk.lock(); optgroup_sh) {
if (Field *field = optgroup_sh->get_fieldc(opt_key, opt_index); field != nullptr) {
field->toggle(is_checked);
if (is_checked)
field->set_last_meaningful_value();
else
field->set_na_value();
}
check_box->Bind(wxEVT_CHECKBOX, [optgroup_wk, opt_key, opt_index](wxCommandEvent& evt) {
const bool is_checked = evt.IsChecked();
if (auto optgroup_sh = optgroup_wk.lock(); optgroup_sh) {
if (Field *field = optgroup_sh->get_fieldc(opt_key, opt_index); field != nullptr) {
field->toggle(is_checked);
if (is_checked)
field->set_last_meaningful_value();
else
field->set_na_value();
}
});
}
});
m_overrides_options[opt_key] = check_box;
return check_box;

View File

@ -272,7 +272,7 @@ void ComboBox::mouseWheelMoved(wxMouseEvent &event)
{
event.Skip();
if (drop_down) return;
auto delta = (event.GetWheelRotation() < 0 == event.IsWheelInverted()) ? -1 : 1;
auto delta = ((event.GetWheelRotation() < 0) == event.IsWheelInverted()) ? -1 : 1;
unsigned int n = GetSelection() + delta;
if (n < GetCount()) {
SetSelection((int) n);

View File

@ -302,7 +302,7 @@ void DropDown::render(wxDC &dc)
}
// draw texts & icons
dc.SetTextForeground(text_color.colorForStates(states));
for (int i = 0; i < texts.size(); ++i) {
for (size_t i = 0; i < texts.size(); ++i) {
if (rcContent.GetBottom() < 0) {
rcContent.y += rowSize.y;
continue;
@ -460,13 +460,14 @@ void DropDown::mouseCaptureLost(wxMouseCaptureLostEvent &event)
void DropDown::mouseMove(wxMouseEvent &event)
{
wxPoint pt = event.GetPosition();
int text_size = int(texts.size());
if (pressedDown) {
wxPoint pt2 = offset + pt - dragStart;
dragStart = pt;
if (pt2.y > 0)
pt2.y = 0;
else if (pt2.y + rowSize.y * texts.size() < GetSize().y)
pt2.y = GetSize().y - rowSize.y * texts.size();
else if (pt2.y + rowSize.y * text_size < GetSize().y)
pt2.y = GetSize().y - rowSize.y * text_size;
if (pt2.y != offset.y) {
offset = pt2;
hover_item = -1; // moved
@ -476,7 +477,7 @@ void DropDown::mouseMove(wxMouseEvent &event)
}
if (!pressedDown || hover_item >= 0) {
int hover = (pt.y - offset.y) / rowSize.y;
if (hover >= (int) texts.size()) hover = -1;
if (hover >= text_size) hover = -1;
if (hover == hover_item) return;
hover_item = hover;
if (hover >= 0)
@ -489,17 +490,18 @@ void DropDown::mouseWheelMoved(wxMouseEvent &event)
{
auto delta = event.GetWheelRotation() > 0 ? rowSize.y : -rowSize.y;
wxPoint pt2 = offset + wxPoint{0, delta};
int text_size = int(texts.size());
if (pt2.y > 0)
pt2.y = 0;
else if (pt2.y + rowSize.y * texts.size() < GetSize().y)
pt2.y = GetSize().y - rowSize.y * texts.size();
else if (pt2.y + rowSize.y * text_size < GetSize().y)
pt2.y = GetSize().y - rowSize.y * text_size;
if (pt2.y != offset.y) {
offset = pt2;
} else {
return;
}
int hover = (event.GetPosition().y - offset.y) / rowSize.y;
if (hover >= (int) texts.size()) hover = -1;
if (hover >= text_size) hover = -1;
if (hover != hover_item) {
hover_item = hover;
if (hover >= 0) SetToolTip(texts[hover]);

View File

@ -297,7 +297,7 @@ void SpinInput::Create(wxWindow *parent,
text_ctrl->Bind(wxEVT_TEXT, &SpinInput::onText, this);
text_ctrl->Bind(wxEVT_TEXT_ENTER, &SpinInput::onTextEnter, this);
text_ctrl->Bind(wxEVT_KEY_DOWN, &SpinInput::keyPressed, this);
text_ctrl->Bind(wxEVT_RIGHT_DOWN, [this](auto &e) {}); // disable context menu
text_ctrl->Bind(wxEVT_RIGHT_DOWN, [](auto &e) {}); // disable context menu
button_inc = create_button(ButtonId::btnIncrease);
button_dec = create_button(ButtonId::btnDecrease);
delta = 0;
@ -403,7 +403,7 @@ void SpinInput::onTextEnter(wxCommandEvent &event)
void SpinInput::mouseWheelMoved(wxMouseEvent &event)
{
auto delta = (event.GetWheelRotation() < 0 == event.IsWheelInverted()) ? 1 : -1;
auto delta = ((event.GetWheelRotation() < 0) == event.IsWheelInverted()) ? 1 : -1;
SetValue(val + delta);
sendSpinEvent();
text_ctrl->SetFocus();
@ -473,7 +473,7 @@ void SpinInputDouble::Create(wxWindow *parent,
text_ctrl->Bind(wxEVT_TEXT, &SpinInputDouble::onText, this);
text_ctrl->Bind(wxEVT_TEXT_ENTER, &SpinInputDouble::onTextEnter, this);
text_ctrl->Bind(wxEVT_KEY_DOWN, &SpinInputDouble::keyPressed, this);
text_ctrl->Bind(wxEVT_RIGHT_DOWN, [this](auto &e) {}); // disable context menu
text_ctrl->Bind(wxEVT_RIGHT_DOWN, [](auto &e) {}); // disable context menu
button_inc = create_button(ButtonId::btnIncrease);
button_dec = create_button(ButtonId::btnDecrease);
delta = 0;
@ -600,7 +600,7 @@ void SpinInputDouble::onTextEnter(wxCommandEvent &event)
void SpinInputDouble::mouseWheelMoved(wxMouseEvent &event)
{
auto delta = (event.GetWheelRotation() < 0 == event.IsWheelInverted()) ? inc : -inc;
auto delta = ((event.GetWheelRotation() < 0) == event.IsWheelInverted()) ? inc : -inc;
SetValue(val + delta);
sendSpinEvent();
text_ctrl->SetFocus();

View File

@ -22,7 +22,7 @@ void StateColor::append(unsigned long color, int states)
{
if ((color & 0xff000000) == 0)
color |= 0xff000000;
wxColour cl; cl.SetRGBA(color & 0xff00ff00 | ((color & 0xff) << 16) | ((color >> 16) & 0xff));
wxColour cl; cl.SetRGBA((color & 0xff00ff00) | ((color & 0xff) << 16) | ((color >> 16) & 0xff));
append(cl, states);
}
@ -49,7 +49,7 @@ wxColour StateColor::defaultColor() {
wxColour StateColor::colorForStates(int states)
{
bool focused = takeFocusedAsHovered_ && (states & Focused);
for (int i = 0; i < statesList_.size(); ++i) {
for (size_t i = 0; i < statesList_.size(); ++i) {
int s = statesList_[i];
int on = s & 0xffff;
int off = s >> 16;
@ -69,18 +69,18 @@ wxColour StateColor::colorForStates(int states)
int StateColor::colorIndexForStates(int states)
{
for (int i = 0; i < statesList_.size(); ++i) {
for (size_t i = 0; i < statesList_.size(); ++i) {
int s = statesList_[i];
int on = s & 0xffff;
int off = s >> 16;
if ((on & states) == on && (off & ~states) == off) { return i; }
if ((on & states) == on && (off & ~states) == off) { return int(i); }
}
return -1;
}
bool StateColor::setColorForStates(wxColour const &color, int states)
{
for (int i = 0; i < statesList_.size(); ++i) {
for (size_t i = 0; i < statesList_.size(); ++i) {
if (statesList_[i] == states) {
colors_[i] = color;
return true;

View File

@ -52,7 +52,7 @@ void StateHandler::update_binds()
int diff = bind_states ^ bind_states_;
State states[] = {Enabled, Checked, Focused, Hovered, Pressed};
wxEventType events[] = {EVT_ENABLE_CHANGED, wxEVT_CHECKBOX, wxEVT_SET_FOCUS, wxEVT_ENTER_WINDOW, wxEVT_LEFT_DOWN};
wxEventType events2[] = {{0}, {0}, wxEVT_KILL_FOCUS, wxEVT_LEAVE_WINDOW, wxEVT_LEFT_UP};
wxEventType events2[] = {0, 0, wxEVT_KILL_FOCUS, wxEVT_LEAVE_WINDOW, wxEVT_LEFT_UP};
for (int i = 0; i < 5; ++i) {
int s = states[i];
if (diff & s) {
@ -82,7 +82,7 @@ void StateHandler::changed(wxEvent &event)
{
event.Skip();
wxEventType events[] = {EVT_ENABLE_CHANGED, wxEVT_CHECKBOX, wxEVT_SET_FOCUS, wxEVT_ENTER_WINDOW, wxEVT_LEFT_DOWN};
wxEventType events2[] = {{0}, {0}, wxEVT_KILL_FOCUS, wxEVT_LEAVE_WINDOW, wxEVT_LEFT_UP};
wxEventType events2[] = { 0, 0, wxEVT_KILL_FOCUS, wxEVT_LEAVE_WINDOW, wxEVT_LEFT_UP};
int old = states_;
// some events are from another window (ex: text_ctrl of TextInput), save state in states2_ to avoid conflicts
for (int i = 0; i < 5; ++i) {

View File

@ -78,7 +78,7 @@ void TextInput::Create(wxWindow * parent,
e.SetId(GetId());
ProcessEventLocally(e);
});
text_ctrl->Bind(wxEVT_RIGHT_DOWN, [this](auto &e) {}); // disable context menu
text_ctrl->Bind(wxEVT_RIGHT_DOWN, [](auto &e) {}); // disable context menu
if (!icon.IsEmpty()) {
this->drop_down_icon = ScalableBitmap(this, icon.ToStdString(), 16);
@ -86,12 +86,6 @@ void TextInput::Create(wxWindow * parent,
messureSize();
}
void TextInput::SetCornerRadius(double radius)
{
this->radius = radius;
Refresh();
}
void TextInput::SetLabel(const wxString& label)
{
wxWindow::SetLabel(label);

View File

@ -37,9 +37,7 @@ public:
const wxSize & size = wxDefaultSize,
long style = 0);
void SetCornerRadius(double radius);
void SetLabel(const wxString& label);
void SetLabel(const wxString& label) wxOVERRIDE;
void SetIcon(const wxBitmapBundle& icon);
@ -76,8 +74,7 @@ public:
protected:
virtual void OnEdit() {}
virtual void DoSetSize(
int x, int y, int width, int height, int sizeFlags = wxSIZE_AUTO);
void DoSetSize(int x, int y, int width, int height, int sizeFlags = wxSIZE_AUTO) wxOVERRIDE;
void DoSetToolTipText(wxString const &tip) override;