vincent0 | Bonjour,
Voici le code de main.h:
Code :
- #include <wx/wxprec.h>
- #include <wx/wx.h>
- class Ini: public wxApp{
- public:
- virtual bool OnInit();
- };
- class Prog: public wxFrame{
- public:
- Prog(const wxChar *title, int xpos, int ypos, int width, int height);
- void OnFichierNouveau(wxCommandEvent &event);
- private:
- wxMenuBar *MenuBar;
- wxMenu *m_fichier;
- enum{
- FICHIER_NOUVEAU
- };
- protected:
- DECLARE_EVENT_TABLE()
- };
- class DialAllera : public wxDialog{
- public:
- DialAllera(wxWindow *parent);
- virtual ~DialAllera(){};
- void OnBoutonAnnuler(wxCommandEvent &event);
- private:
- wxButton *bouton_annuler;
- enum{
- BOUTTON_ANNULER = 1010
- };
- protected:
- DECLARE_EVENT_TABLE()
- };
- DECLARE_APP(Ini);
|
Voici le code main.cpp:
Code :
- #include <wx/wxprec.h>
- #include <wx/wx.h>
- #include <wx/file.h>
- #include <wx/stc/stc.h>
- #include "main.h"
- using namespace std;
- Prog::Prog(const wxChar *title, int xpos, int ypos, int width, int height) : wxFrame((wxFrame *) NULL, -1, title, wxPoint(xpos, ypos), wxSize(width, height)){
- MenuBar = new wxMenuBar();
- m_fichier = new wxMenu();
- m_fichier->Append(FICHIER_NOUVEAU, "&wxDialog" );
- MenuBar->Append(m_fichier, "&Fichier" );
- SetMenuBar(MenuBar);
- wxStyledTextCtrl *text = new wxStyledTextCtrl(this, -1, wxDefaultPosition, wxDefaultSize);
- wxBoxSizer *sizer_2 = new wxBoxSizer(wxHORIZONTAL);
- sizer_2->Add(text, 0, wxALL, 5);
- }
- BEGIN_EVENT_TABLE(Prog, wxFrame)
- EVT_MENU(FICHIER_NOUVEAU, Prog::OnFichierNouveau)
- END_EVENT_TABLE()
- BEGIN_EVENT_TABLE(DialAllera, wxDialog)
- EVT_BUTTON(BOUTTON_ANNULER, DialAllera::OnBoutonAnnuler)
- END_EVENT_TABLE()
- /**********DIALOG**********/
- DialAllera::DialAllera(wxWindow *parent): wxDialog(parent, -1, "Aller à", wxDefaultPosition, wxSize(-1, -1), wxDEFAULT_DIALOG_STYLE){
- bouton_annuler = new wxButton(this, BOUTTON_ANNULER, "Annuler", wxDefaultPosition, wxDefaultSize);
- wxBoxSizer *sizer_2 = new wxBoxSizer(wxHORIZONTAL);
- sizer_2->Add(bouton_annuler, 0, wxALL, 5);
- }
- void DialAllera::OnBoutonAnnuler(wxCommandEvent& command){
- Destroy();
- }
- /**********END DIALOG**********/
- void Prog::OnFichierNouveau(wxCommandEvent &event){
- DialAllera *recher = new DialAllera(this);
- recher->ShowModal();
- }
- IMPLEMENT_APP(Ini);
- bool Ini::OnInit(){
- Prog *frame = new Prog("Titre", 0, 0, -1, -1);
- frame->Maximize(TRUE);
- frame->Show(TRUE);
- return true;
- }
|
Ce code fonctionne très bien sur Windows, par contre sur Linux, j'ai un bug:
-Si j'ouvre et ferme le wxDialog, il y a le curseur du wxStyledTextCtrl qui disparait, pourquoi ?
-Ensuite si je ré-ouvre et ferme le wxDialog, le curseur réapparait.
NB: Quand le curseur disparait, il y a certaines fonction comme GotoLine() qui ne vont plus, ce qui est ennuyant.
Merci d'avance... Message édité par vincent0 le 02-02-2005 à 18:43:13
|