Floating points in wxSpinCtrl and pixel width of wxStaticTex Topic is solved
Floating points in wxSpinCtrl and pixel width of wxStaticTex
1) Is there a way to have floating points in wxSpinCtrl?
2) Is there a way to find out the pixel width of the label in wxStaticText?
2) Is there a way to find out the pixel width of the label in wxStaticText?
-
- I live to help wx-kind
- Posts: 178
- Joined: Mon Jul 23, 2007 9:01 am
Re: Floating points in wxSpinCtrl and pixel width of wxStati
The wxThings package contains a class wxSpinCtrlDbl. It handles floating point values in a wxSpinCtrl.simotix wrote:1) Is there a way to have floating points in wxSpinCtrl?
http://wxcode.sourceforge.net/complist.php
http://docs.wxwidgets.org/stable/wx_wxw ... textextent
2) Is there a way to find out the pixel width of the label in wxStaticText?
The wxWindow::GetTextExtent function returns the dimensions of the string as it would be drawn on the window with the currently selected font.
If you need pixel sizes you must convert the coordinates (x,y values) to pixels using the following function:
wxWindow::ConvertDialogToPixels
Best regards
Orbitcowboy
OS: Ubuntu 9.04 (32/64-Bit), Debian Lenny (32-Bit)
Compiler: gcc/g++-4.3.3 , gcc/g++-4.4.0
wxWidgets: 2.8.10,2.9.0
Compiler: gcc/g++-4.3.3 , gcc/g++-4.4.0
wxWidgets: 2.8.10,2.9.0
Ah ok, thank you. I have one other question about wxSpinCtrl's. I have a control named "wxLocationControl" and in side of it there is a wxSpinCtrl. I want to have an event for when the spinControl's numeric is changed and I want to keep it in the wxLocationControl class. How can I do this?
I thought I could do something like this, but I was wrong.
spinCtrl->Connect(wxSpinEvent, wxSpinEvent(wxcLocationControl::xNumericChanged), NULL, this);
So I tried something like this and was wrong again
#define X_NUMERIC_CHANGED 0
BEGIN_EVENT_TABLE(wxcLocationControl, wxcCollapsibleWindow)
EVT_SPINCTRL(X_NUMERIC_CHANGED, wxcLocationControl::xNumericChanged)
END_EVENT_TABLE()
wxcLocationControl::wxcLocationControl(wxWindow *parent, wxWindowID id,
const wxPoint &pos, const wxSize &size, const long borderType,
const wxColour &titleBackgroundColor)
{
spinCtrl = new wxSpinCtrl(GetBodyPanel(), X_NUMERIC_CHANGED);
}
void wxcLocationControl::xNumericChanged(wxSpinEvent& event)
{
}
I thought I could do something like this, but I was wrong.
spinCtrl->Connect(wxSpinEvent, wxSpinEvent(wxcLocationControl::xNumericChanged), NULL, this);
So I tried something like this and was wrong again
#define X_NUMERIC_CHANGED 0
BEGIN_EVENT_TABLE(wxcLocationControl, wxcCollapsibleWindow)
EVT_SPINCTRL(X_NUMERIC_CHANGED, wxcLocationControl::xNumericChanged)
END_EVENT_TABLE()
wxcLocationControl::wxcLocationControl(wxWindow *parent, wxWindowID id,
const wxPoint &pos, const wxSize &size, const long borderType,
const wxColour &titleBackgroundColor)
{
spinCtrl = new wxSpinCtrl(GetBodyPanel(), X_NUMERIC_CHANGED);
}
void wxcLocationControl::xNumericChanged(wxSpinEvent& event)
{
}
Code: Select all
spinCtrl->Connect(wxSpinEvent, wxSpinEvent(wxcLocationControl::xNumericChanged), NULL, this);
"Keyboard not detected. Press F1 to continue"
-- Windows
-- Windows
How can I bind some sort of EVT_SPIN to a SpinCtrl then?Auria wrote:This is wrong, and I'm surprised it compiles; the first parameter needs to be the ID of the event, in this case something like wxEVT_SPIN (unfortunately the documentation of these IDs is quite lacking, the stable docks don't seem to mention the Connect equivalent to the EVT_SPIN macro)Code: Select all
spinCtrl->Connect(wxSpinEvent, wxSpinEvent(wxcLocationControl::xNumericChanged), NULL, this);
I would believe :
Code: Select all
spinCtrl->Connect(wxEVT_SPIN, wxSpinEvent(wxcLocationControl::xNumericChanged), NULL, this);
"Keyboard not detected. Press F1 to continue"
-- Windows
-- Windows
wxWidgets does not seem to know what wxEVT_SPIN is though, I tried looking for it in the docs too.Auria wrote:I would believe :
Code: Select all
spinCtrl->Connect(wxEVT_SPIN, wxSpinEvent(wxcLocationControl::xNumericChanged), NULL, this);
error C2065: 'wxEVT_SPIN' : undeclared identifier
-
- I live to help wx-kind
- Posts: 178
- Joined: Mon Jul 23, 2007 9:01 am
Have you included following header?simotix wrote:wxWidgets does not seem to know what wxEVT_SPIN is though, I tried looking for it in the docs too.Auria wrote:I would believe :
Code: Select all
spinCtrl->Connect(wxEVT_SPIN, wxSpinEvent(wxcLocationControl::xNumericChanged), NULL, this);
error C2065: 'wxEVT_SPIN' : undeclared identifier
Code: Select all
#include <wx/spinctrl.h>
OS: Ubuntu 9.04 (32/64-Bit), Debian Lenny (32-Bit)
Compiler: gcc/g++-4.3.3 , gcc/g++-4.4.0
wxWidgets: 2.8.10,2.9.0
Compiler: gcc/g++-4.3.3 , gcc/g++-4.4.0
wxWidgets: 2.8.10,2.9.0
Yes, it is needed for the wxSpinCtrl to even work.orbitcowboy wrote:Have you included following header?simotix wrote:wxWidgets does not seem to know what wxEVT_SPIN is though, I tried looking for it in the docs too.Auria wrote:I would believe :
Code: Select all
spinCtrl->Connect(wxEVT_SPIN, wxSpinEvent(wxcLocationControl::xNumericChanged), NULL, this);
error C2065: 'wxEVT_SPIN' : undeclared identifier
Code: Select all
#include <wx/spinctrl.h>