class MyApp: public wxApp
{
public:
virtual bool OnInit();
};
class MyTreeCtrl: public wxTreeCtrl
{
public:
MyTreeCtrl(wxWindow *parent, const wxWindowID id,
const wxPoint& pos, const wxSize& size, long style);
virtual ~MyTreeCtrl(){};
void OnItemActivated(wxTreeEvent& event);
void OnSelChanged(wxTreeEvent& event);
DECLARE_EVENT_TABLE()
};
class MyFrame: public wxFrame
{
public:
MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size);
void OnQuit(wxCommandEvent& event);
DECLARE_EVENT_TABLE()
};
enum
{ ID_LISTBOX = 6,
ID_DRZEWO = 5,
ID_Quit = 1, };
BEGIN_EVENT_TABLE(MyFrame, wxFrame)
END_EVENT_TABLE()
BEGIN_EVENT_TABLE(MyTreeCtrl, wxTreeCtrl)
EVT_TREE_SEL_CHANGED(ID_DRZEWO, MyTreeCtrl::OnSelChanged)
EVT_TREE_ITEM_ACTIVATED(ID_DRZEWO,MyTreeCtrl::OnItemActivated)
END_EVENT_TABLE()
IMPLEMENT_APP(MyApp)
bool MyApp::OnInit()
{
MyFrame *frame = new MyFrame( "zzz", wxPoint(50,50), wxSize(520,540) );
frame->Centre();
frame->Show(TRUE);
SetTopWindow(frame);
return TRUE;
}
MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const
wxSize& size)
: wxFrame((wxFrame *)NULL, -1, title, pos, size)
{
MyTreeCtrl* drzewo = new
MyTreeCtrl(this,ID_DRZEWO,wxDefaultPosition,wxSize(180,300),
wxTR_DEFAULT_STYLE|wxTR_HIDE_ROOT);
wxBoxSizer *pion = new wxBoxSizer(wxVERTICAL);
wxBoxSizer *poziom = new wxBoxSizer(wxHORIZONTAL);
poziom->Add(drzewo, 0, wxEXPAND|wxALL);
pion->Add(poziom, 1, wxEXPAND|wxALL);
SetSizer(pion);
pion->Fit(this);
SetBackgroundColour(* wxBLACK);
SetAutoLayout(TRUE);
Layout();
}
void MyTreeCtrl::OnItemActivated(wxTreeEvent& event)
{
printf(wxT("OnItemActivated"));
};
void MyTreeCtrl::OnSelChanged(wxTreeEvent& event)
{
printf(wxT("OnSelChanged"));
event.Skip();
}
__________
$ make
g++ -Wall -o ttt1 `wx-config --cxxflags --libs` ttt1.cpp
/home/times/tmp/ccgpWFjO.o: In function `MyFrame::MyFrame(wxString
const&, wxPoint const&, wxSize const&)':
ttt1.cpp:(.text+0x3a2): undefined reference to
`MyTreeCtrl::MyTreeCtrl(wxWindow*, int, wxPoint const&, wxSize const&,
long)'
/home/times/tmp/ccgpWFjO.o: In function `MyFrame::MyFrame(wxString
const&, wxPoint const&, wxSize const&)':
ttt1.cpp:(.text+0x772): undefined reference to
`MyTreeCtrl::MyTreeCtrl(wxWindow*, int, wxPoint const&, wxSize const&,
long)'
collect2: ld returned 1 exit status
make: *** [all] error 1
hm... not happened (core dumped when put empty)
MyTreeCtrl::MyTreeCtrl(wxWindow *parent, const wxWindowID id,
{
};
paul
zeroDwa> Paul Koning pisze:
>> Just like the message says: you forgot to define the constructor
>> for class MyTreeCtrl. There's a declaration in the class, but no
>> definition (no function body).
zeroDwa> hm... not happened (core dumped when put empty)
zeroDwa> MyTreeCtrl::MyTreeCtrl(wxWindow *parent, const wxWindowID
zeroDwa> id, const wxPoint& pos, const wxSize& size, long style) { };
Of course. You need to do something in that constructor. Minimally,
you have to construct the base classes (wxTreeCtrl in this case).
paul
3 version. please help me. I must select & read what I selected in
mytreectrl
http://dark-code.bulix.org/10sm74-61034
when i click in tree not hapened (printf functions is not run why?
zeroDwa> Patrick Steele pisze:
>> Change it to this:
>>
>> MyTreeCtrl::MyTreeCtrl(wxWindow *parent, const wxWindowID id,
>> const wxPoint& pos, const wxSize& size, long style) :
>> wxTreeCtrl(parent, id, pos, size, style) { //any other
>> initialisation code here };
>>
>>
>> This way, as Paul was saying, you are initialising the base class.
>> Patrick
zeroDwa> ttt1.cpp:15: error: extra qualification 'MyTreeCtrl::' on
zeroDwa> member 'MyTreeCtrl'
Outside the class declaration...
Maybe you need a C++ textbook. I've fount "C++ in a nutshell" (from
O'Reilly publications) to be very good.
paul
What is wrong?
How do you know that it is not run?
Regards,
Łukasz
yes, but Message not activate. Never activate. I ask why?
Thats why I asked how do you know that it is run or not. The printf function
does nothing under MS Windows GUI application.
Try wxMessgageBox.
Regards,
Łukasz
---------------------------------------------------------------------
To unsubscribe, e-mail: wx-users-u...@lists.wxwidgets.org
For additional commands, e-mail: wx-use...@lists.wxwidgets.org