Hi,
I want to make a widget which is a container of widget. How to make this possible ?
I tried to make the class StartOf which herit from wxPanel but there is a bug in my app with the event handler and the app is in infinite loop when there is a refresh of the main panel.
wxBoxSizer *sizerV1 = new wxBoxSizer(wxVERTICAL);
//wxGridSizer *sizerV1 = new wxGridSizer(2, 1, 0, 0);
sizerV1->Add(CreateCodeSize(), 0, wxEXPAND);
sizerV1->Add(CreateImgCodes(), 0, wxEXPAND);
with :
wxSizer *
PanSignature::CreateCodeSize(void)
{
wxStaticBox *box = new wxStaticBox( this, -1, _T("Code Size"),
wxPoint(5, 5), wxSize(300, 100));
wxStaticBoxSizer *sizerV = new wxStaticBoxSizer( box, wxVERTICAL);
// Grid sizer 1*4 with 5pix marge
wxGridSizer *gridSizer = new wxGridSizer(1, 4, 0, 0);
// RadioBox
_rb16 = new wxRadioButton(this, RB_16, "16 bits", wxDefaultPosition, wxDefaultSize, wxRB_GROUP);
_rb32 = new wxRadioButton(this, RB_32, "32 bits");
_rb48 = new wxRadioButton(this, RB_48, "48 bits");
_rb64 = new wxRadioButton(this, RB_64, "64 bits");
gridSizer->Add(_rb16, 0, wxALL|wxALIGN_CENTER_VERTICAL, GUI_BORDER);
gridSizer->Add(_rb32, 0, wxALL|wxALIGN_CENTER_VERTICAL, GUI_BORDER);
gridSizer->Add(_rb48, 0, wxALL|wxALIGN_CENTER_VERTICAL, GUI_BORDER);
gridSizer->Add(_rb64, 0, wxALL|wxALIGN_CENTER_VERTICAL, GUI_BORDER);
gridSizer->Add(_btnTest = new wxButton(this, BTN_TEST, "toto"));
sizerV->Add(gridSizer, 0, wxEXPAND);
return sizerV;
}
and
wxSizer *
PanSignature::CreateImgCodes(void)
{
wxStaticBox *box = new wxStaticBox( this, -1, "SOF",
wxPoint(5, 5), wxSize(300, 100));
wxStaticBoxSizer *sizerV = new wxStaticBoxSizer( box, wxVERTICAL);
// Grid sizer 4*3 with 5pix marge
wxGridSizer *gridSizer = new wxGridSizer(4, 5, 0, 0);
// Enable button
_enable = new wxCheckBox(this, CHK_ENABLE, "Enable SOF code");
sizerV->Add(_enable, 0, wxEXPAND);
// Text
gridSizer->Add(new wxStaticText(this, -1, "Bit"), 0, wxEXPAND|wxALL|wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT, GUI_BORDER);
gridSizer->Add(new wxStaticText(this, -1, "63-48"), 0, wxEXPAND|wxALL|wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT, GUI_BORDER);
gridSizer->Add(new wxStaticText(this, -1, "47-32"), 0, wxEXPAND|wxALL|wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT, GUI_BORDER);
gridSizer->Add(new wxStaticText(this, -1, "31-16"), 0, wxEXPAND|wxALL|wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT, GUI_BORDER);
gridSizer->Add(new wxStaticText(this, -1, "15-00"), 0, wxEXPAND|wxALL|wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT, GUI_BORDER);
// Code
gridSizer->Add(new wxStaticText(this, -1, "Code"), 0, wxEXPAND|wxALL|wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT, GUI_BORDER);
_txtCodeHighH = new wxTextCtrl(this, TXT_CODE_HIGH_H, "0000", wxDefaultPosition, wxSize(50,15));
//_txtCodeHighH->SetMaxLength(4);
gridSizer->Add(_txtCodeHighH, 0, wxEXPAND);
_txtCodeHighL = new wxTextCtrl(this, TXT_CODE_HIGH_L, "0000", wxDefaultPosition, wxSize(50,15));
gridSizer->Add(_txtCodeHighL, 0, wxEXPAND);
//_txtCodeHighL->SetMaxLength(4);
_txtCodeLowH = new wxTextCtrl(this, TXT_CODE_LOW_H, "0000", wxDefaultPosition, wxSize(50,15));
gridSizer->Add(_txtCodeLowH, 0, wxEXPAND);
//_txtCodeLowH->SetMaxLength(4);
_txtCodeLowL = new wxTextCtrl(this, TXT_CODE_LOW_L, "0000", wxDefaultPosition, wxSize(50,15));
gridSizer->Add(_txtCodeLowL, 0, wxEXPAND);
//_txtCodeLowL->SetMaxLength(4);
// Mask
gridSizer->Add(new wxStaticText(this, -1, "Mask"), 0, wxEXPAND|wxALL|wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT, GUI_BORDER);
_txtMaskHighH = new wxTextCtrl(this, TXT_MASK_HIGH_H, "0000", wxDefaultPosition, wxSize(50,15));
gridSizer->Add(_txtMaskHighH, 0, wxEXPAND);
//_txtMaskHighH->SetMaxLength(4);
_txtMaskHighL = new wxTextCtrl(this, TXT_MASK_HIGH_L, "0000", wxDefaultPosition, wxSize(50,15));
gridSizer->Add(_txtMaskHighL, 0, wxEXPAND);
//_txtMaskHighL->SetMaxLength(4);
_txtMaskLowH = new wxTextCtrl(this, TXT_MASK_LOW_H, "0000", wxDefaultPosition, wxSize(50,15));
gridSizer->Add(_txtMaskLowH, 0, wxEXPAND);
//_txtMaskLowH->SetMaxLength(4);
_txtMaskLowL = new wxTextCtrl(this, TXT_MASK_LOW_L, "0000", wxDefaultPosition, wxSize(50,15));
gridSizer->Add(_txtMaskLowL, 0, wxEXPAND);
//_txtMaskLowL->SetMaxLength(4);
sizerV->Add(gridSizer, 0 ,wxEXPAND);
return sizerV;
}
class StartOf : public wxPanel
{
public:
StartOf(DataStore *data, wxWindow * parent, wxWindowID id = -1,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
const wxString &name = "SOF", const wxString &nameFull = "Start of"
);
~StartOf();
//! Refresh children with _data
void RefreshAll(void);
void OnEnableClick(wxCommandEvent & event);
void TextEditCheck(wxTextCtrl * txtEdit);
void OnTextEditCHighH(wxCommandEvent & event);
void OnTextEditCHighL(wxCommandEvent & event);
void OnTextEditCLowH(wxCommandEvent & event);
void OnTextEditCLowL(wxCommandEvent & event);
void OnTextEditMHighH(wxCommandEvent & event);
void OnTextEditMHighL(wxCommandEvent & event);
void OnTextEditMLowH(wxCommandEvent & event);
void OnTextEditMLowL(wxCommandEvent & event);
enum
{
CHK_ENABLE = wxID_HIGHEST + 100,
TXT_CODE_HIGH_H,
TXT_CODE_HIGH_L,
TXT_CODE_LOW_H,
TXT_CODE_LOW_L,
TXT_MASK_HIGH_H,
TXT_MASK_HIGH_L,
TXT_MASK_LOW_H,
TXT_MASK_LOW_L
};
private:
DECLARE_EVENT_TABLE()
DataStore *_data;
wxCheckBox *_enable;
wxTextCtrl *_txtCodeHighH;
wxTextCtrl *_txtCodeHighL;
wxTextCtrl *_txtCodeLowH;
wxTextCtrl *_txtCodeLowL;
wxTextCtrl *_txtMaskHighH;
wxTextCtrl *_txtMaskHighL;
wxTextCtrl *_txtMaskLowH;
wxTextCtrl *_txtMaskLowL;
};
Container of widget
I see no problem deriving a wxPanel for your purposes. A wxPanel is a container for multiple wxWindow objects. So why would you use a wxStaticBox ?
-----
-----
ps. Do not post to mailinglist and forum simultaneausly. It is not nice towards people not visiting either list or forum. They might put effort on it while it is already answered.
- Jorgen
Code: Select all
/////////////////////////////////////////////////////////////////////////////
// Name: MyPanel.h
// Author: XX
// Created: Tuesday, February 22, 2005 09:31:57
// Copyright: XX
/////////////////////////////////////////////////////////////////////////////
#ifndef __MYPANEL_H__
#define __MYPANEL_H__
#ifdef __GNUG__
#pragma interface "MyPanel.cpp"
#endif
#ifndef WX_PRECOMP
#include "wx/wx.h"
#endif
// WDR: class declarations
//----------------------------------------------------------------------------
// MyPanel
//----------------------------------------------------------------------------
class MyPanel: public wxPanel
{
public:
// constructors and destructors
MyPanel( wxWindow *parent, wxWindowID id = -1,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxTAB_TRAVERSAL | wxNO_BORDER );
virtual ~MyPanel();
// WDR: method declarations for MyPanel
private:
// WDR: member variable declarations for MyPanel
private:
// WDR: handler declarations for MyPanel
private:
DECLARE_EVENT_TABLE()
};
#endif
Code: Select all
/////////////////////////////////////////////////////////////////////////////
// Name: MyPanel.cpp
// Author: XX
// Created: Tuesday, February 22, 2005 09:31:57
// Copyright: XX
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
#pragma implementation "MyPanel.cpp"
#endif
// For compilers that support precompilation, includes "wx/wx.h".
#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#include "MyPanel.h"
// WDR: class implementations
//----------------------------------------------------------------------------
// MyPanel
//----------------------------------------------------------------------------
// WDR: event table for MyPanel
BEGIN_EVENT_TABLE(MyPanel,wxPanel)
END_EVENT_TABLE()
MyPanel::MyPanel( wxWindow *parent, wxWindowID id,
const wxPoint &position, const wxSize& size, long style ) :
wxPanel( parent, id, position, size, style| wxTAB_TRAVERSAL | wxNO_BORDER )
{
// TODO: Enter constructor code here
}
MyPanel::~MyPanel()
{
// TODO: Enter destructor code here
}
// WDR: handler implementations for MyPanel
ps. Do not post to mailinglist and forum simultaneausly. It is not nice towards people not visiting either list or forum. They might put effort on it while it is already answered.
- Jorgen
Forensic Software Engineer
Netherlands Forensic Insitute
http://english.forensischinstituut.nl/
-------------------------------------
Jorg's WasteBucket
http://www.xs4all.nl/~jorgb/wb
Netherlands Forensic Insitute
http://english.forensischinstituut.nl/
-------------------------------------
Jorg's WasteBucket
http://www.xs4all.nl/~jorgb/wb