Why are my wxButtons always flat
Why are my wxButtons always flat
My wxButtons never have raised borders nor do they change when clicked on. I just have grey rectangles.
My typical wxSmith generated code is:
AXIAL0 = new wxButton(MainSeite, ID_BUTTON2, _("Axial=0"), wxPoint(90,420), wxSize(150,30), 0, wxDefaultValidator, _T("ID_BUTTON2"));
AXIAL0->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_SCROLLBAR));
I am using Windows 10 and wxWidgets 3.1.1 or Raspian Linux and WxWidgets 3.0.4.
What do I do wrong?
My typical wxSmith generated code is:
AXIAL0 = new wxButton(MainSeite, ID_BUTTON2, _("Axial=0"), wxPoint(90,420), wxSize(150,30), 0, wxDefaultValidator, _T("ID_BUTTON2"));
AXIAL0->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_SCROLLBAR));
I am using Windows 10 and wxWidgets 3.1.1 or Raspian Linux and WxWidgets 3.0.4.
What do I do wrong?
Re: Why are my wxButtons always flat
This is what you are doing wrong.
By setting a custom background color you lose the native look (any gradient / 3D effect that native drawing had). Just don't do it.
Re: Why are my wxButtons always flat
Sorry,
but I made a new button TEST without setting the background color and it is just as flat.
wxSmith code:
TEST = new wxButton(ExtSeite, ID_BUTTON14, _("Test"), wxPoint(700,500), wxDefaultSize, 0, wxDefaultValidator, _T("ID_BUTTON14"));
BoxSizer1->Add(ExtSeite, 1, wxALL|wxEXPAND, 5);
Additionaly I entered the sample code from the book "GUI Programming with wxWidgets" page 86:
wxButton* button = new wxButton(ExtSeite, wxID_OK, wxT("OK"),wxPoint(10,10), wxDefaultSize);
This button is also flat. What else can I do?
but I made a new button TEST without setting the background color and it is just as flat.
wxSmith code:
TEST = new wxButton(ExtSeite, ID_BUTTON14, _("Test"), wxPoint(700,500), wxDefaultSize, 0, wxDefaultValidator, _T("ID_BUTTON14"));
BoxSizer1->Add(ExtSeite, 1, wxALL|wxEXPAND, 5);
Additionaly I entered the sample code from the book "GUI Programming with wxWidgets" page 86:
wxButton* button = new wxButton(ExtSeite, wxID_OK, wxT("OK"),wxPoint(10,10), wxDefaultSize);
This button is also flat. What else can I do?
Re: Why are my wxButtons always flat
Hi,
Which platform? Which wx version?
Do you use any non-default theme?
Do you see the flat button inside the wxSmith or when you actually executing your code?
Thank you.
Which platform? Which wx version?
Do you use any non-default theme?
Do you see the flat button inside the wxSmith or when you actually executing your code?
Thank you.
Re: Why are my wxButtons always flat
To answer your questions:
I am using Windows 10 and wxWidgets 3.1.3 or Raspian Linux and WxWidgets 3.0.4. Codeblocks 17.12 and wxSmith.
My buttons are flat inside wxSmith and with my executed code.
Sorry, I don't know what a theme is and certainly don't use a non-default theme.
Below is the code of one of my Notebook pages. The entire constructor is generated by wxSmith. The reset wxButtons is flat.
I am using Windows 10 and wxWidgets 3.1.3 or Raspian Linux and WxWidgets 3.0.4. Codeblocks 17.12 and wxSmith.
My buttons are flat inside wxSmith and with my executed code.
Sorry, I don't know what a theme is and certainly don't use a non-default theme.
Below is the code of one of my Notebook pages. The entire constructor is generated by wxSmith. The reset wxButtons is flat.
Code: Select all
#include "wx_pch.h"
#include "DiaPanel.h"
#include "GlobalData.h"
#include "SpiPanel.h"
#ifndef WX_PRECOMP
//(*InternalHeadersPCH(DiaPanel)
#include <wx/intl.h>
#include <wx/string.h>
//*)
#endif
//(*InternalHeaders(DiaPanel)
#include <wx/settings.h>
//*)
//(*IdInit(DiaPanel)
const long DiaPanel::ID_BUTTON_RESET = wxNewId();
const long DiaPanel::ID_PANEL1 = wxNewId();
//*)
//========================================================== global data
extern GlobalData Dat;
BEGIN_EVENT_TABLE(DiaPanel,wxPanel)
//(*EventTable(DiaPanel)
//*)
END_EVENT_TABLE()
DiaPanel::DiaPanel(wxWindow* parent,wxWindowID id,const wxPoint& pos,const wxSize& size)
{
//(*Initialize(DiaPanel)
wxBoxSizer* BoxSizer1;
Create(parent, id, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL, _T("id"));
SetBackgroundColour(wxColour(240,238,224));
BoxSizer1 = new wxBoxSizer(wxHORIZONTAL);
DiaSeite = new wxPanel(this, ID_PANEL1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL, _T("ID_PANEL1"));
DiaSeite->SetBackgroundColour(wxColour(240,238,224));
RESET = new wxButton(DiaSeite, ID_BUTTON_RESET, _("Reset"), wxPoint(450,100), wxSize(150,30), 0, wxDefaultValidator, _T("ID_BUTTON_RESET"));
RESET->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_SCROLLBAR));
BoxSizer1->Add(DiaSeite, 1, wxALL|wxEXPAND, 5);
SetSizer(BoxSizer1);
BoxSizer1->Fit(this);
BoxSizer1->SetSizeHints(this);
Connect(ID_BUTTON_RESET,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&DiaPanel::OnRESETClick);
DiaSeite->Connect(wxEVT_PAINT,(wxObjectEventFunction)&DiaPanel::OnDiaSeitePaint,0,this);
//*)
}
DiaPanel::~DiaPanel()
{
//(*Destroy(DiaPanel)
//*)
}
void DiaPanel::PeriodicUpdate() // update page
{
//------------------------------------------------------ repaint display
DiaSeite->Refresh(true);
}
#define Dia_X 10
#define Dia_Y 20
#define Dia_DY 23
#define Dia_Pitch_X 0
#define Dia_Pitch_Y 300
void DiaPanel::OnDiaSeitePaint(wxPaintEvent& event)
{
Dat.Page = PitchPage;
wxPaintDC dc(DiaSeite);
wxString TextBuf;
dc.SetTextForeground(*wxBLACK); // Set the text foreground to black
dc.SetTextBackground(*wxWHITE); // Set the text background to white
wxFont MyBigFont(30,wxFONTFAMILY_TELETYPE,wxNORMAL,wxBOLD,false);
wxFont MyMidFont(20,wxFONTFAMILY_TELETYPE,wxNORMAL,wxBOLD,false);
dc.SetPen(*wxBLACK_PEN);
//---------------------------------------------------- test data
dc.DrawLine(0,570,1320,570);
dc.DrawLine(1320,0,1320,570);
//---------------------------------------------------- explanations
int TempY =Dia_Y;
dc.DrawText("Pitch measurement" ,Dia_X,TempY);TempY+=Dia_DY;
dc.DrawText("Complete lathe pitch selection" ,Dia_X,TempY);TempY+=Dia_DY;
dc.DrawText("Make sure the saddle has enough space for 20 turns" ,Dia_X,TempY);TempY+=Dia_DY;
dc.DrawText("Set lathe to low speed and engage lock nut" ,Dia_X,TempY);TempY+=Dia_DY;
dc.DrawText("Click Reset to clear pitch data" ,Dia_X,TempY);TempY+=Dia_DY;
dc.DrawText("Switch lathe on and wait for pitch readings to update",Dia_X,TempY);TempY+=Dia_DY;
//------------------------------------------------------------------------------------------------ pitch
dc.SetFont(MyBigFont);
if(Dat.fPitch>0.1) TextBuf.Printf("%8.2f mm/turn %8.2f turns/inch",Dat.fPitch,25.4/Dat.fPitch);
else TextBuf.Printf(" ");
dc.DrawText(TextBuf,Dia_Pitch_X,Dia_Pitch_Y);
}
void DiaPanel::OnRESETClick(wxCommandEvent& event)
{
Dat.Command = C_ResPitch;
}
Last edited by catalin on Thu May 07, 2020 6:53 am, edited 1 time in total.
Reason: code tags
Reason: code tags
Re: Why are my wxButtons always flat
Hi,
So, it happens both within wxSmith and when your execute your compiled code.
And it happens in both Windows and Linux.
Can you build and ran the notebook sample and see if the problem is there?
Thank you.
So, it happens both within wxSmith and when your execute your compiled code.
And it happens in both Windows and Linux.
Can you build and ran the notebook sample and see if the problem is there?
Thank you.
Re: Why are my wxButtons always flat
Can you show a screenshot. Try building the "widgets" sample that comes with wxWidgets and check how it looks.
Use the source, Luke!
Re: Why are my wxButtons always flat
How do I send a screenshot to this forum? If you provide your email address, I can email you images.
I made some progress: My wxButtons behave better with both foreground and background color used as default:
ENGAGED = new wxButton(IntSeite, ID_BUTTON1, _("Engaged"), wxPoint(320,168), wxSize(150,30), 0, wxDefaultValidator, _T("ID_BUTTON1"));
Now my buttons become darker when hovering over it and more dark when clicking on it. However they still do not have a raised border.
I tried the sample code from the book "GUI Programming with wxWidgets" page 86:
wxButton* button = new wxButton(ExtSeite, wxID_OK, wxT("OK"),wxPoint(10,10), wxDefaultSize);
It can be simpler than this. This button is also flat.
I made some progress: My wxButtons behave better with both foreground and background color used as default:
ENGAGED = new wxButton(IntSeite, ID_BUTTON1, _("Engaged"), wxPoint(320,168), wxSize(150,30), 0, wxDefaultValidator, _T("ID_BUTTON1"));
Now my buttons become darker when hovering over it and more dark when clicking on it. However they still do not have a raised border.
I tried the sample code from the book "GUI Programming with wxWidgets" page 86:
wxButton* button = new wxButton(ExtSeite, wxID_OK, wxT("OK"),wxPoint(10,10), wxDefaultSize);
It can be simpler than this. This button is also flat.
Re: Why are my wxButtons always flat
When you create a post, there is an option at the bottom to add attachments. If you attach an image, you get the option to display it inline.
I was asking for a screenshot, because under Windows 10, buttons *do* look flat. I think what you're seeing is totally fine.
Just open any standard application, e.g. MS Paint and find the settings/properties dialog for comparison.
I was asking for a screenshot, because under Windows 10, buttons *do* look flat. I think what you're seeing is totally fine.
Just open any standard application, e.g. MS Paint and find the settings/properties dialog for comparison.
Use the source, Luke!
Re: Why are my wxButtons always flat
Thanks,
I have attached a screenshot of my wxButtons and for comparison buttons made with MS VisualC6.
Please comment.
I have attached a screenshot of my wxButtons and for comparison buttons made with MS VisualC6.
Please comment.
- Attachments
-
- VisualC6.png (515 Bytes) Viewed 2002 times
-
- wxButtons.png (2.92 KiB) Viewed 2002 times
Re: Why are my wxButtons always flat
Hi,
Is it a screenshot from the wxSmith (or whatever other RAD tool you use)?
Or this is a screenshot from the running the binary you produced?
Thank you.
Is it a screenshot from the wxSmith (or whatever other RAD tool you use)?
Or this is a screenshot from the running the binary you produced?
Thank you.
Re: Why are my wxButtons always flat
The flat version is the correct one under Windows 10. You'll get the old "Windows 95" style buttons if your executable doesn't have a proper manifest. This probably happens when you build it with VC6.I have attached a screenshot of my wxButtons and for comparison buttons made with MS VisualC6.
Use the source, Luke!
Re: Why are my wxButtons always flat
Thanks for all your help.
It looks like I was chasing ghosts.
It looks like I was chasing ghosts.