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); if (!wxOSX) temp->SetBackgroundStyle(wxBG_STYLE_PAINT);
wxGetApp().UpdateDarkUI(temp); 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; opt_height = (double)temp->GetSize().GetHeight() / m_em_unit;
}
temp->Bind(wxEVT_KILL_FOCUS, ([this](wxEvent& e) 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() int GUI_App::get_max_font_pt_size()
{ {
const unsigned disp_count = wxDisplay::GetCount(); 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(); const wxRect display_rect = wxDisplay(i).GetGeometry();
if (display_rect.width >= 2560 && display_rect.height >= 1440) if (display_rect.width >= 2560 && display_rect.height >= 1440)
return 20; return 20;

View File

@ -1947,7 +1947,6 @@ void TabFilament::create_line_with_near_label_widget(ConfigOptionsGroupShp optgr
else else
line = optgroup->create_single_option_line(optgroup->get_option(opt_key)); 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) { line.near_label_widget = [this, optgroup_wk = ConfigOptionsGroupWkp(optgroup), opt_key, opt_index](wxWindow* parent) {
wxWindow* check_box = CheckBox::GetNewWin(parent); wxWindow* check_box = CheckBox::GetNewWin(parent);
wxGetApp().UpdateDarkUI(check_box); wxGetApp().UpdateDarkUI(check_box);

View File

@ -272,7 +272,7 @@ void ComboBox::mouseWheelMoved(wxMouseEvent &event)
{ {
event.Skip(); event.Skip();
if (drop_down) return; 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; unsigned int n = GetSelection() + delta;
if (n < GetCount()) { if (n < GetCount()) {
SetSelection((int) n); SetSelection((int) n);

View File

@ -302,7 +302,7 @@ void DropDown::render(wxDC &dc)
} }
// draw texts & icons // draw texts & icons
dc.SetTextForeground(text_color.colorForStates(states)); 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) { if (rcContent.GetBottom() < 0) {
rcContent.y += rowSize.y; rcContent.y += rowSize.y;
continue; continue;
@ -460,13 +460,14 @@ void DropDown::mouseCaptureLost(wxMouseCaptureLostEvent &event)
void DropDown::mouseMove(wxMouseEvent &event) void DropDown::mouseMove(wxMouseEvent &event)
{ {
wxPoint pt = event.GetPosition(); wxPoint pt = event.GetPosition();
int text_size = int(texts.size());
if (pressedDown) { if (pressedDown) {
wxPoint pt2 = offset + pt - dragStart; wxPoint pt2 = offset + pt - dragStart;
dragStart = pt; dragStart = pt;
if (pt2.y > 0) if (pt2.y > 0)
pt2.y = 0; pt2.y = 0;
else if (pt2.y + rowSize.y * texts.size() < GetSize().y) else if (pt2.y + rowSize.y * text_size < GetSize().y)
pt2.y = GetSize().y - rowSize.y * texts.size(); pt2.y = GetSize().y - rowSize.y * text_size;
if (pt2.y != offset.y) { if (pt2.y != offset.y) {
offset = pt2; offset = pt2;
hover_item = -1; // moved hover_item = -1; // moved
@ -476,7 +477,7 @@ void DropDown::mouseMove(wxMouseEvent &event)
} }
if (!pressedDown || hover_item >= 0) { if (!pressedDown || hover_item >= 0) {
int hover = (pt.y - offset.y) / rowSize.y; 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; if (hover == hover_item) return;
hover_item = hover; hover_item = hover;
if (hover >= 0) if (hover >= 0)
@ -489,17 +490,18 @@ void DropDown::mouseWheelMoved(wxMouseEvent &event)
{ {
auto delta = event.GetWheelRotation() > 0 ? rowSize.y : -rowSize.y; auto delta = event.GetWheelRotation() > 0 ? rowSize.y : -rowSize.y;
wxPoint pt2 = offset + wxPoint{0, delta}; wxPoint pt2 = offset + wxPoint{0, delta};
int text_size = int(texts.size());
if (pt2.y > 0) if (pt2.y > 0)
pt2.y = 0; pt2.y = 0;
else if (pt2.y + rowSize.y * texts.size() < GetSize().y) else if (pt2.y + rowSize.y * text_size < GetSize().y)
pt2.y = GetSize().y - rowSize.y * texts.size(); pt2.y = GetSize().y - rowSize.y * text_size;
if (pt2.y != offset.y) { if (pt2.y != offset.y) {
offset = pt2; offset = pt2;
} else { } else {
return; return;
} }
int hover = (event.GetPosition().y - offset.y) / rowSize.y; 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) { if (hover != hover_item) {
hover_item = hover; hover_item = hover;
if (hover >= 0) SetToolTip(texts[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, &SpinInput::onText, this);
text_ctrl->Bind(wxEVT_TEXT_ENTER, &SpinInput::onTextEnter, this); text_ctrl->Bind(wxEVT_TEXT_ENTER, &SpinInput::onTextEnter, this);
text_ctrl->Bind(wxEVT_KEY_DOWN, &SpinInput::keyPressed, 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_inc = create_button(ButtonId::btnIncrease);
button_dec = create_button(ButtonId::btnDecrease); button_dec = create_button(ButtonId::btnDecrease);
delta = 0; delta = 0;
@ -403,7 +403,7 @@ void SpinInput::onTextEnter(wxCommandEvent &event)
void SpinInput::mouseWheelMoved(wxMouseEvent &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); SetValue(val + delta);
sendSpinEvent(); sendSpinEvent();
text_ctrl->SetFocus(); 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, &SpinInputDouble::onText, this);
text_ctrl->Bind(wxEVT_TEXT_ENTER, &SpinInputDouble::onTextEnter, this); text_ctrl->Bind(wxEVT_TEXT_ENTER, &SpinInputDouble::onTextEnter, this);
text_ctrl->Bind(wxEVT_KEY_DOWN, &SpinInputDouble::keyPressed, 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_inc = create_button(ButtonId::btnIncrease);
button_dec = create_button(ButtonId::btnDecrease); button_dec = create_button(ButtonId::btnDecrease);
delta = 0; delta = 0;
@ -600,7 +600,7 @@ void SpinInputDouble::onTextEnter(wxCommandEvent &event)
void SpinInputDouble::mouseWheelMoved(wxMouseEvent &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); SetValue(val + delta);
sendSpinEvent(); sendSpinEvent();
text_ctrl->SetFocus(); text_ctrl->SetFocus();

View File

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

View File

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

View File

@ -78,7 +78,7 @@ void TextInput::Create(wxWindow * parent,
e.SetId(GetId()); e.SetId(GetId());
ProcessEventLocally(e); 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()) { if (!icon.IsEmpty()) {
this->drop_down_icon = ScalableBitmap(this, icon.ToStdString(), 16); this->drop_down_icon = ScalableBitmap(this, icon.ToStdString(), 16);
@ -86,12 +86,6 @@ void TextInput::Create(wxWindow * parent,
messureSize(); messureSize();
} }
void TextInput::SetCornerRadius(double radius)
{
this->radius = radius;
Refresh();
}
void TextInput::SetLabel(const wxString& label) void TextInput::SetLabel(const wxString& label)
{ {
wxWindow::SetLabel(label); wxWindow::SetLabel(label);

View File

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