FIX: Label hyperlink style

Change-Id: Ib0935b41080de994b0b82e4c211ff7a0b9f295bc
This commit is contained in:
chunmao.guo 2022-10-19 13:35:04 +08:00 committed by Lane.Wei
parent e363966f9b
commit 5fc2acc235
2 changed files with 26 additions and 10 deletions

View file

@ -95,16 +95,19 @@ Label::Label(wxWindow *parent, wxFont const &font, wxString const &text, long st
this->font = font; this->font = font;
SetFont(font); SetFont(font);
SetBackgroundColour(StaticBox::GetParentBackgroundColor(parent)); SetBackgroundColour(StaticBox::GetParentBackgroundColor(parent));
Bind(wxEVT_ENTER_WINDOW, [this](auto &e) { }
if (GetWindowStyle() & LB_HYPERLINK) {
SetFont(this->font.Underlined()); void Label::SetLabel(const wxString& label)
Refresh(); {
} if (GetLabel() == label)
}); return;
Bind(wxEVT_LEAVE_WINDOW, [this](auto &e) { wxStaticText::SetLabel(label);
SetFont(this->font); #ifdef __WXOSX__
Refresh(); if ((GetWindowStyle() & LB_HYPERLINK)) {
}); SetLabelMarkup(label);
return;
}
#endif
} }
void Label::SetWindowStyleFlag(long style) void Label::SetWindowStyleFlag(long style)
@ -115,10 +118,21 @@ void Label::SetWindowStyleFlag(long style)
if (style & LB_HYPERLINK) { if (style & LB_HYPERLINK) {
this->color = GetForegroundColour(); this->color = GetForegroundColour();
static wxColor clr_url("#00AE42"); static wxColor clr_url("#00AE42");
SetFont(this->font.Underlined());
SetForegroundColour(clr_url); SetForegroundColour(clr_url);
SetCursor(wxCURSOR_HAND);
#ifdef __WXOSX__
SetLabelMarkup(GetLabel());
#endif
} else { } else {
SetForegroundColour(this->color); SetForegroundColour(this->color);
SetFont(this->font); SetFont(this->font);
SetCursor(wxCURSOR_ARROW);
#ifdef __WXOSX__
auto label = GetLabel();
wxStaticText::SetLabel({});
wxStaticText::SetLabel(label);
#endif
} }
Refresh(); Refresh();
} }

View file

@ -13,6 +13,8 @@ public:
Label(wxWindow *parent, wxFont const &font, wxString const &text = {}, long style = 0); Label(wxWindow *parent, wxFont const &font, wxString const &text = {}, long style = 0);
void SetLabel(const wxString& label) override;
void SetWindowStyleFlag(long style) override; void SetWindowStyleFlag(long style) override;
private: private: