I want to write my own button-component. I've got a panel, on this a static bitmap and a static text. In my gui the event is pushed only if I click on the panel, but not on the static bitmap/text. How can I make them pushing the event, too?
Code: Select all
// lknopf.h
#ifndef LKNOPF_H_
#define LKNOPF_H_
#include <wx/wx.h>
#include <wx/event.h>
class LKnopf : public wxPanel {
public:
LKnopf(wxWindow *, wxWindowID, const wxString &, const wxString &);
protected:
wxBoxSizer *bsHauptanzeige;
wxStaticBitmap *sbmpKnopf;
wxStaticText *stBeschriftung;
};
#endif /*LKNOPF_H_*/
Code: Select all
// lknopf.cpp
#include "lknopf.h"
LKnopf::LKnopf(wxWindow *parent, wxWindowID id, const wxString &bild, const wxString &beschriftung) :
wxPanel(parent, id) {
bsHauptanzeige = new wxBoxSizer(wxVERTICAL);
sbmpKnopf = new wxStaticBitmap(this, -1, wxBitmap(bild, wxBITMAP_TYPE_PNG));
stBeschriftung = new wxStaticText(this, -1, beschriftung);
stBeschriftung->Connect(wxID_ANY, wxEVT_LEFT_DOWN, wxMouseEventHandler(LKnopf::klick));
bsHauptanzeige->Add(sbmpKnopf, 0, wxALIGN_CENTER);
bsHauptanzeige->Add(stBeschriftung, 0, wxALIGN_CENTER | wxTOP, 5);
SetSizer(bsHauptanzeige);
}
Code: Select all
// Code with my own button (very dirty, just tests)
VAdministration::VAdministration(wxWindow *parent, wxWindowID id) :
wxDialog(parent, id, _("Administration"), wxDefaultPosition, wxDefaultSize) {
wxBoxSizer *test = new wxBoxSizer(wxHORIZONTAL);
test2 = new LKnopf(this, ADMIN_TEST, _("anzeigen.png"), _("Anzeigenbearbeitung"));
test->Add(test2);
SetSizer(test);
test2->Connect(wxID_ANY, wxEVT_LEFT_DOWN, wxMouseEventHandler(VAdministration::klick));
}
Morfio ...