Bonjour,
je suis entrain de faire une interface pour configurer mon programme!
Je doit donc configurer different path pour certains fichiers!
Voila comment j'ai commencé avec ca:
Ca marche tres bien et ca rend tres jolie
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 wxBoxSizer *vbox = new wxBoxSizer(wxVERTICAL); wxFlexGridSizer *fgs = new wxFlexGridSizer(2,2, 3, 20); ... wxStaticText *st1 = new wxStaticText(this, wxID_ANY, wxT("Events File")); wxTxtCtrl *tc1 new wxTextCtrl(this,wxID_FILE1,fname), wxButton *bu1 = new wxButton(this,wxID_OPEN,_T("Browse")); Connect(wxID_OPEN,wxEVT_COMMAND_BUTTON_CLICKED,wxCommandEventHandler(ConfigFrame::OnBrowse)); wxBoxSizer *hb1 = new wxBoxSizer(wxHORIZONTAL); hb1->Add(tc1,1,wxEXPAND); hb1->Add(bu1); fgs->Add(st1); fgs->Add(hb1,1,wxEXPAND); fgs->AddGrowableCol(1); vbox->Add(fgs,0,wxEXPAND | wxALL,10 )
Le problème c'est que je doit répéter ce code au moins 10x donc je crée un objet:
Et j'appel dans mon ConfigFrame:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29 class TextCtrlPath: public wxControl { public: //constructor & destructor TextCtrlPath(wxWindow* parent,wxString fpath, wxString fname); virtual ~TextCtrlPath(); //functions void OnBrowse(wxCommandEvent& event); private: wxString fpath; wxString fname; wxButton *browse; wxTextCtrl *txtctrl; wxBoxSizer *hbox; }; TextCtrlPath::TextCtrlPath(wxWindow* parent, wxString fpath, wxString fname) : wxControl(parent,wxID_ANY),fpath(fpath), fname(fname) { txtctrl= new wxTextCtrl(this,wxID_FILE1,fname), browse = new wxButton(this,wxID_OPEN,_T("Browse")); Connect(wxID_OPEN,wxEVT_COMMAND_BUTTON_CLICKED,wxCommandEventHandler(TextCtrlPath::OnBrowse)); hbox = new wxBoxSizer(wxHORIZONTAL); hbox->Add(txtctrl,1,wxEXPAND); hbox->Add(browse); this->SetSizer(hbox); }
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12 wxBoxSizer *vbox = new wxBoxSizer(wxVERTICAL); wxFlexGridSizer *fgs = new wxFlexGridSizer(2,2, 3, 20); ... wxStaticText *st1 = new wxStaticText(this, wxID_ANY, wxT("Events File")); TextCtrlPath *tp1 = new TextCtrlPath(this,_T("C:\\"),_T("events.log")); fgs->Add(st1); fgs->Add(tp1,1,wxEXPAND); fgs->AddGrowableCol(1); vbox->Add(fgs,0,wxEXPAND | wxALL,10 );
Cependant ça me donne un truc tout zarbi (le wxButton est caché sous le wxTextCtrl, et j'ai un énorme emplacement vide.)
PS: Pas facile ces wxWidget, surtout que ça manque de doc et d'exemples!!! Qqun connaitrait pas un bon site avec des images pour chaque classes (meme en anglais) ??







Répondre avec citation







Partager