WxButton - mouse hover & border size
Posted: Sun Jul 28, 2019 10:06 am
Hello Everyone!,
How do I add the mouse hover effect to the Wxbutton and change the border size? and I went through https://docs.wxwidgets.org/trunk/classw ... 43a8d21563
there is something called "void wxAnyButton::SetBitmapCurrent(const wxBitmap & bitmap)" for mouse hover, but I don't know how to use it and where to add it.
I'm using Windows 7, Wxsmith, Code blocks and I'm new to Wxwidgets please help me.
here is my main.cpp
How do I add the mouse hover effect to the Wxbutton and change the border size? and I went through https://docs.wxwidgets.org/trunk/classw ... 43a8d21563
there is something called "void wxAnyButton::SetBitmapCurrent(const wxBitmap & bitmap)" for mouse hover, but I don't know how to use it and where to add it.
I'm using Windows 7, Wxsmith, Code blocks and I'm new to Wxwidgets please help me.
here is my main.cpp
Code: Select all
#include "_Main.h"
#include <wx/msgdlg.h>
//(*InternalHeaders(_Frame)
#include <wx/font.h>
#include <wx/intl.h>
#include <wx/settings.h>
#include <wx/string.h>
//*)
//helper functions
enum wxbuildinfoformat {
short_f, long_f };
wxString wxbuildinfo(wxbuildinfoformat format)
{
wxString wxbuild(wxVERSION_STRING);
if (format == long_f )
{
#if defined(__WXMSW__)
wxbuild << _T("-Windows");
#elif defined(__UNIX__)
wxbuild << _T("-Linux");
#endif
#if wxUSE_UNICODE
wxbuild << _T("-Unicode build");
#else
wxbuild << _T("-ANSI build");
#endif // wxUSE_UNICODE
}
return wxbuild;
}
//(*IdInit(_Frame)
const long _Frame::ID_STATICTEXT1 = wxNewId();
const long _Frame::ID_STATICTEXT2 = wxNewId();
const long _Frame::ID_TEXTCTRL1 = wxNewId();
const long _Frame::ID_STATICTEXT3 = wxNewId();
const long _Frame::ID_TEXTCTRL2 = wxNewId();
const long _Frame::ID_BUTTON1 = wxNewId();
//*)
BEGIN_EVENT_TABLE(_Frame,wxFrame)
//(*EventTable(_Frame)
//*)
END_EVENT_TABLE()
_Frame::_Frame(wxWindow* parent,wxWindowID id)
{
//(*Initialize(_Frame)
wxBoxSizer* BoxSizer2;
wxBoxSizer* BoxSizer3;
Create(parent, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_STYLE, _T("wxID_ANY"));
SetClientSize(wxSize(385,392));
SetMinSize(wxSize(-1,-1));
SetMaxSize(wxSize(-1,-1));
SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_MENUTEXT));
BoxSizer1 = new wxBoxSizer(wxVERTICAL);
StaticText1 = new wxStaticText(this, ID_STATICTEXT1, _("LOGIN"), wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT1"));
StaticText1->SetForegroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW));
wxFont StaticText1Font(36,wxFONTFAMILY_SWISS,wxFONTSTYLE_NORMAL,wxFONTWEIGHT_BOLD,false,_T("Calibri"),wxFONTENCODING_DEFAULT);
StaticText1->SetFont(StaticText1Font);
BoxSizer1->Add(StaticText1, 0, wxALIGN_CENTER_HORIZONTAL, 5);
BoxSizer1->Add(10,60,0, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
BoxSizer2 = new wxBoxSizer(wxHORIZONTAL);
StaticText2 = new wxStaticText(this, ID_STATICTEXT2, _("Username"), wxDefaultPosition, wxSize(70,20), 0, _T("ID_STATICTEXT2"));
StaticText2->SetForegroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW));
wxFont StaticText2Font(12,wxFONTFAMILY_SWISS,wxFONTSTYLE_NORMAL,wxFONTWEIGHT_BOLD,false,_T("Calibri"),wxFONTENCODING_DEFAULT);
StaticText2->SetFont(StaticText2Font);
BoxSizer2->Add(StaticText2, 0, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
BoxSizer2->Add(25,10,0, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
TextCtrl1 = new wxTextCtrl(this, ID_TEXTCTRL1, wxEmptyString, wxPoint(-1,-1), wxSize(250,20), wxSIMPLE_BORDER, wxDefaultValidator, _T("ID_TEXTCTRL1"));
TextCtrl1->SetForegroundColour(wxColour(255,255,255));
TextCtrl1->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT));
wxFont TextCtrl1Font(12,wxFONTFAMILY_SWISS,wxFONTSTYLE_NORMAL,wxFONTWEIGHT_NORMAL,false,_T("Calibri"),wxFONTENCODING_DEFAULT);
TextCtrl1->SetFont(TextCtrl1Font);
BoxSizer2->Add(TextCtrl1, 0, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
BoxSizer1->Add(BoxSizer2, 0, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
BoxSizer1->Add(20,1,0, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
BoxSizer3 = new wxBoxSizer(wxHORIZONTAL);
StaticText3 = new wxStaticText(this, ID_STATICTEXT3, _("Password"), wxDefaultPosition, wxSize(70,20), 0, _T("ID_STATICTEXT3"));
StaticText3->SetForegroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW));
wxFont StaticText3Font(12,wxFONTFAMILY_SWISS,wxFONTSTYLE_NORMAL,wxFONTWEIGHT_BOLD,false,_T("Calibri"),wxFONTENCODING_DEFAULT);
StaticText3->SetFont(StaticText3Font);
BoxSizer3->Add(StaticText3, 0, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
BoxSizer3->Add(25,10,0, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
TextCtrl2 = new wxTextCtrl(this, ID_TEXTCTRL2, wxEmptyString, wxDefaultPosition, wxSize(250,20), wxTE_PASSWORD|wxSIMPLE_BORDER, wxDefaultValidator, _T("ID_TEXTCTRL2"));
TextCtrl2->SetForegroundColour(wxColour(255,255,255));
TextCtrl2->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT));
wxFont TextCtrl2Font(12,wxFONTFAMILY_SWISS,wxFONTSTYLE_NORMAL,wxFONTWEIGHT_NORMAL,false,_T("Calibri"),wxFONTENCODING_DEFAULT);
TextCtrl2->SetFont(TextCtrl2Font);
BoxSizer3->Add(TextCtrl2, 0, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
BoxSizer1->Add(BoxSizer3, 0, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
BoxSizer1->Add(10,60,0, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
Button1 = new wxButton(this, ID_BUTTON1, _("Sign in"), wxDefaultPosition, wxSize(260,25), wxNO_BORDER, wxDefaultValidator, _T("ID_BUTTON1"));
Button1->SetBackgroundColour(wxColour(0,128,255));
wxFont Button1Font(12,wxFONTFAMILY_SWISS,wxFONTSTYLE_NORMAL,wxFONTWEIGHT_BOLD,false,_T("Calibri"),wxFONTENCODING_DEFAULT);
Button1->SetFont(Button1Font);
BoxSizer1->Add(Button1, 0, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
BoxSizer1->Add(20,30,0, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
SetSizer(BoxSizer1);
SetSizer(BoxSizer1);
Layout();
Center();
//*)
}
_Frame::~_Frame()
{
//(*Destroy(_Frame)
//*)
}
void _Frame::OnQuit(wxCommandEvent& event)
{
Close();
}
void _Frame::OnAbout(wxCommandEvent& event)
{
wxString msg = wxbuildinfo(long_f);
wxMessageBox(msg, _("Welcome to..."));
}