Floating points in wxSpinCtrl and pixel width of wxStaticTex Topic is solved

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
simotix
Experienced Solver
Experienced Solver
Posts: 53
Joined: Fri May 29, 2009 5:24 am

Floating points in wxSpinCtrl and pixel width of wxStaticTex

Post by simotix »

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?
orbitcowboy
I live to help wx-kind
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

Post by orbitcowboy »

simotix wrote:1) Is there a way to have floating points in wxSpinCtrl?
The wxThings package contains a class wxSpinCtrlDbl. It handles floating point values in a wxSpinCtrl.

http://wxcode.sourceforge.net/complist.php


2) Is there a way to find out the pixel width of the label in wxStaticText?
http://docs.wxwidgets.org/stable/wx_wxw ... textextent

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
simotix
Experienced Solver
Experienced Solver
Posts: 53
Joined: Fri May 29, 2009 5:24 am

Post by simotix »

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)
{

}
Auria
Site Admin
Site Admin
Posts: 6695
Joined: Thu Sep 28, 2006 12:23 am
Contact:

Post by Auria »

Code: Select all

spinCtrl->Connect(wxSpinEvent, wxSpinEvent(wxcLocationControl::xNumericChanged), NULL, this); 
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)
"Keyboard not detected. Press F1 to continue"
-- Windows
simotix
Experienced Solver
Experienced Solver
Posts: 53
Joined: Fri May 29, 2009 5:24 am

Post by simotix »

Auria wrote:

Code: Select all

spinCtrl->Connect(wxSpinEvent, wxSpinEvent(wxcLocationControl::xNumericChanged), NULL, this); 
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)
How can I bind some sort of EVT_SPIN to a SpinCtrl then?
Auria
Site Admin
Site Admin
Posts: 6695
Joined: Thu Sep 28, 2006 12:23 am
Contact:

Post by Auria »

I would believe :

Code: Select all

spinCtrl->Connect(wxEVT_SPIN, wxSpinEvent(wxcLocationControl::xNumericChanged), NULL, this);
"Keyboard not detected. Press F1 to continue"
-- Windows
simotix
Experienced Solver
Experienced Solver
Posts: 53
Joined: Fri May 29, 2009 5:24 am

Post by simotix »

Auria wrote:I would believe :

Code: Select all

spinCtrl->Connect(wxEVT_SPIN, wxSpinEvent(wxcLocationControl::xNumericChanged), NULL, this);
wxWidgets does not seem to know what wxEVT_SPIN is though, I tried looking for it in the docs too.

error C2065: 'wxEVT_SPIN' : undeclared identifier
orbitcowboy
I live to help wx-kind
I live to help wx-kind
Posts: 178
Joined: Mon Jul 23, 2007 9:01 am

Post by orbitcowboy »

simotix wrote:
Auria wrote:I would believe :

Code: Select all

spinCtrl->Connect(wxEVT_SPIN, wxSpinEvent(wxcLocationControl::xNumericChanged), NULL, this);
wxWidgets does not seem to know what wxEVT_SPIN is though, I tried looking for it in the docs too.

error C2065: 'wxEVT_SPIN' : undeclared identifier
Have you included following header?

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
simotix
Experienced Solver
Experienced Solver
Posts: 53
Joined: Fri May 29, 2009 5:24 am

Post by simotix »

orbitcowboy wrote:
simotix wrote:
Auria wrote:I would believe :

Code: Select all

spinCtrl->Connect(wxEVT_SPIN, wxSpinEvent(wxcLocationControl::xNumericChanged), NULL, this);
wxWidgets does not seem to know what wxEVT_SPIN is though, I tried looking for it in the docs too.

error C2065: 'wxEVT_SPIN' : undeclared identifier
Have you included following header?

Code: Select all

#include <wx/spinctrl.h>
Yes, it is needed for the wxSpinCtrl to even work.
simotix
Experienced Solver
Experienced Solver
Posts: 53
Joined: Fri May 29, 2009 5:24 am

Post by simotix »

Does anyone know?
simotix
Experienced Solver
Experienced Solver
Posts: 53
Joined: Fri May 29, 2009 5:24 am

Post by simotix »

Nobody knows how to fix this issue?
User avatar
doublemax
Moderator
Moderator
Posts: 19160
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Post by doublemax »

try wxEVT_COMMAND_SPINCTRL_UPDATED instead of wxEVT_SPIN
Use the source, Luke!
simotix
Experienced Solver
Experienced Solver
Posts: 53
Joined: Fri May 29, 2009 5:24 am

Post by simotix »

doublemax wrote:try wxEVT_COMMAND_SPINCTRL_UPDATED instead of wxEVT_SPIN
Oh thank you, that is how to fix it. My end result was,

spinCtrl->Connect(wxEVT_COMMAND_SPINCTRL_UPDATED, wxSpinEventHandler(wxcLocationControl::xNumericChanged), NULL, this);
Post Reply