Wxgenericdirctrl

Résolu
AfroDurf Messages postés 23 Date d'inscription jeudi 18 septembre 2003 Statut Membre Dernière intervention 12 mai 2010 - 25 oct. 2005 à 17:17
fredcl Messages postés 547 Date d'inscription mercredi 8 janvier 2003 Statut Membre Dernière intervention 7 octobre 2007 - 28 oct. 2005 à 09:44
Bonjour,

voilà je cherche à faire une zone dans ma fenêtre principale pour l'utiliser comme explorer de fichier. J'ai vu sur le forum qu'un exemple était dispo sur le site de Fredl (XPm convert). C'est effectivement ce genre de chose que je recherche mais je ne comprends pas le fonctionnement de Wxgenericdirctrl car je tente de créer une listbox d'y appliquer Wxgenericdirctrl mais sans succès. dans l'exemple de Xmp il passe par une frame dans un header. Je ne comprends pas pourquoi l'application direct decette fonction dans une liste box n'est pas possible?

Vous avez une explication ou une piste?

Merci d'avance

Developpement votre !!!

10 réponses

fredcl Messages postés 547 Date d'inscription mercredi 8 janvier 2003 Statut Membre Dernière intervention 7 octobre 2007 1
28 oct. 2005 à 09:44
Bonjour,


regardez bien votre code, vous avez deux classes de fenêtres : wxMainFrame et MyFrame.
Vous créez dans OnInit la classe wxMainFrame qui semble t'il pose problème.
Vous auriez du enlever votre classe la remplacer par la mienne, vérifier que cela s'affichait correctement. Puis modifier ma classe pour rajouter tout ce que vous vouliez avoir.


Je vous conseille vivement, d'apprendre les base du C++ et de la programmation orienté objet avant de vous lancer avec un framework entiérement objet comme wxWidgets (ou d'autre d'ailleurs)


Cordialement

Fred Cailleau-Lepetit (http://cfred.free.fr)
3
fredcl Messages postés 547 Date d'inscription mercredi 8 janvier 2003 Statut Membre Dernière intervention 7 octobre 2007 1
25 oct. 2005 à 17:32
Bonjour,



wxGenericDirCtrl n'est pas une fonction mais un classe.

Pour être précis c'est un controle composé de deux autres controles un wxTreeCtrl et en option un wxChoice.



Il faut donc utiliser le wxGenericDirCtrl à la place de votre listbox.

Cordialement

Fred Cailleau-Lepetit (http://cfred.free.fr)
0
AfroDurf Messages postés 23 Date d'inscription jeudi 18 septembre 2003 Statut Membre Dernière intervention 12 mai 2010
27 oct. 2005 à 11:03
Bonjour,

cela fait quatre jour et je n'arrive a rien avec cette classe wxgenericdirctrl...

Je cherche un exemple de code simple, une fenêtre et le control Wxgenericdirctrl qui affiche l'arbo du pc histoire de comprendre le fonctionnement. Mais je ne trouve ça nul part je ne comprend pas en fait!!!
0
AfroDurf Messages postés 23 Date d'inscription jeudi 18 septembre 2003 Statut Membre Dernière intervention 12 mai 2010
27 oct. 2005 à 11:30
Si ça peut aider mon code :============================================================================// declarations// ============================================================================
// ----------------------------------------------------------------------------// headers// ----------------------------------------------------------------------------
// For compilers that support precompilation, includes "wx/wx.h".#include "wx/wxprec.h"#ifdef __BORLANDC__    #pragma hdrstop#endif
// for all others, include the necessary headers (this file is usually all you// need because it includes almost all "standard" wxWindows headers)#ifndef WX_PRECOMP    #include "wx/wx.h"#endif
#include "wx/dirctrl.h"#include "wx/dir.h"#include "wx/filename.h"// ----------------------------------------------------------------------------// resources// ----------------------------------------------------------------------------#define ID_ARBO             10001// the application icon (under Windows and OS/2 it is in resources)#if defined(__WXGTK__) || defined(__WXMOTIF__) || defined(__WXMAC__) || defined(__WXMGL__) || defined(__WXX11__)    #include "mondrian.xpm"#endif
// ----------------------------------------------------------------------------// private classes// ----------------------------------------------------------------------------
// Define a new application type, each program should derive a class from wxAppclass MyApp : public wxApp{public:    // override base class virtuals    // ----------------------------
    // this one is called on application startup and is a good place for the app    // initialization (doing it here and not in the ctor allows to have an error    // return: if OnInit() returns false, the application terminates)    virtual bool OnInit();};
// Define a new frame type: this is going to be our main frameclass MyFrame : public wxFrame{public:    // ctor(s)    MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size,            long style = wxDEFAULT_FRAME_STYLE);
    // event handlers (these functions should _not_ be virtual)    void OnNouveau(wxCommandEvent& event);    void OnOuvrir(wxCommandEvent& event);    void OnEnregistrer(wxCommandEvent& event);    void OnQuitter(wxCommandEvent& event);    void OnProprietes(wxCommandEvent& event);    void OnCouper(wxCommandEvent& event);    void OnCopier(wxCommandEvent& event);    void OnColler(wxCommandEvent& event);    void OnSupprimer(wxCommandEvent& event);    void OnRenomer(wxCommandEvent& event);    void OnRechercher(wxCommandEvent& event);    void OnSelectout(wxCommandEvent& event);    void OnSelectimage(wxCommandEvent& event);    void OnEffacerselec(wxCommandEvent& event);    void OnApercu(wxCommandEvent& event);    void OnBaroutils(wxCommandEvent& event);    void OnModaffi(wxCommandEvent& event);    void OnClasser(wxCommandEvent& event);    void OnPivoter(wxCommandEvent& event);    void OnRedim(wxCommandEvent& event);    void OnPapierpeint(wxCommandEvent& event);    void OnAide(wxCommandEvent& event);    void OnInfo(wxCommandEvent& event);
private:          // any class wishing to process wxWindows events must use this macro    DECLARE_EVENT_TABLE()          };
class DirFrame: public wxGenericDirCtrl{   DECLARE_EVENT_TABLE()
   public:
      DirFrame(wxWindow* parent, const wxPoint& pos = wxDefaultPosition,               const wxSize& size = wxSize(400, 300));
      void DirDir();         private:      wxGenericDirCtrl* Dir;};
// ----------------------------------------------------------------------------// constants// ----------------------------------------------------------------------------
// IDs for the controls and the menu commandsenum{    // menu items    DSW_Quitter = 1,    DSW_Nouveau,    DSW_Ouvrir,    DSW_Enregistrer,    DSW_Proprietes,    DSW_Couper,    DSW_Copier,    DSW_Coller,    DSW_Supprimer,    DSW_Renomer,    DSW_Rechercher,    DSW_Selectout,    DSW_Selectimage,    DSW_Effacerselec,    DSW_Apercu,    DSW_Baroutils,    DSW_Modaffi,    DSW_Classer,    DSW_Pivoter,    DSW_Redim,    DSW_Papierpeint,    DSW_Aide,    dcDirectory,            // it is important for the id corresponding to the "About" command to have    // this standard value as otherwise it won't be handled properly under Mac    // (where it is special and put into the "Apple" menu)    DSW_Info = wxID_ABOUT};
// ----------------------------------------------------------------------------// event tables and other macros for wxWindows// ----------------------------------------------------------------------------
// the event tables connect the wxWindows events with the functions (event// handlers) which process them. It can be also done at run-time, but for the// simple menu events like this the static method is much simpler.BEGIN_EVENT_TABLE(MyFrame, wxFrame)    EVT_MENU(DSW_Quitter,  MyFrame::OnQuitter)    EVT_MENU(DSW_Nouveau,  MyFrame::OnNouveau)    EVT_MENU(DSW_Ouvrir,  MyFrame::OnOuvrir)    EVT_MENU(DSW_Enregistrer,  MyFrame::OnEnregistrer)    EVT_MENU(DSW_Proprietes,  MyFrame::OnProprietes)    EVT_MENU(DSW_Couper,  MyFrame::OnCouper)    EVT_MENU(DSW_Copier,  MyFrame::OnCopier)    EVT_MENU(DSW_Coller,  MyFrame::OnColler)    EVT_MENU(DSW_Supprimer,  MyFrame::OnSupprimer)    EVT_MENU(DSW_Renomer,  MyFrame::OnRenomer)    EVT_MENU(DSW_Rechercher,  MyFrame::OnRechercher)    EVT_MENU(DSW_Selectout,  MyFrame::OnSelectout)    EVT_MENU(DSW_Selectimage,  MyFrame::OnSelectimage)    EVT_MENU(DSW_Effacerselec,  MyFrame::OnEffacerselec)    EVT_MENU(DSW_Apercu,  MyFrame::OnApercu)    EVT_MENU(DSW_Baroutils,  MyFrame::OnBaroutils)    EVT_MENU(DSW_Modaffi,  MyFrame::OnModaffi)    EVT_MENU(DSW_Classer,  MyFrame::OnClasser)    EVT_MENU(DSW_Pivoter,  MyFrame::OnPivoter)    EVT_MENU(DSW_Redim,  MyFrame::OnRedim)    EVT_MENU(DSW_Papierpeint,  MyFrame::OnPapierpeint)    EVT_MENU(DSW_Aide,  MyFrame::OnAide)    EVT_MENU(DSW_Info,  MyFrame::OnInfo)
END_EVENT_TABLE()
// Create a new application object: this macro will allow wxWindows to create// the application object during program execution (it's better than using a// static object for many reasons) and also declares the accessor function// wxGetApp() which will return the reference of the right type (i.e. MyApp and// not wxApp)IMPLEMENT_APP(MyApp)
// ============================================================================// implementation// ============================================================================
// ----------------------------------------------------------------------------// the application class// ----------------------------------------------------------------------------
// 'Main program' equivalent: the program execution "starts" herebool MyApp::OnInit(){
    // create the main application window    MyFrame *frame = new MyFrame(_T("AfroView"),                                 wxPoint(100, 50), wxSize(600, 600), wxDEFAULT_FRAME_STYLE | wxTAB_TRAVERSAL);
    // and show it (the frames, unlike simple controls, are not shown when    // created initially)    frame->Show(TRUE);
    // success: wxApp::OnRun() will be called which will enter the main message    // loop and the application will run. If we returned FALSE here, the    // application would exit immediately.    return TRUE;}
// ----------------------------------------------------------------------------// main frame// ----------------------------------------------------------------------------
// frame constructor
DirFrame::DirFrame(wxWindow* parent, const wxPoint& pos, const wxSize& size){
   Dir = NULL;
}
MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size, long style)       : wxFrame(NULL, -1, title, pos, size, style){     // set the frame icon    SetIcon(wxICON(mondrian));SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE));
#if wxUSE_MENUS    // create a menu bar    wxMenu *menuFichier = new wxMenu;    menuFichier->Append(DSW_Nouveau, _T("&Nouveau\tCtrl-N"), _T("Créer un nouveau fichier"));    menuFichier->Append(DSW_Ouvrir, _T("&Ouvrir\tCtrl-O"), _T("Ouvrir un fichier"));    menuFichier->Append(DSW_Enregistrer, _T("&Enregistrer sous\tCtrl-S"), _T("Enregistrer le fichier en cours"));    menuFichier->Append(DSW_Proprietes, _T("&Proriètés"), _T("Propriètés du fichier"));    menuFichier->Append(DSW_Quitter, _T("&Quitter\tAlt-Q"), _T("Quitter ce programme"));        wxMenu *menuEditer = new wxMenu;    menuEditer->Append(DSW_Couper, _T("&Couper\tCtrl-X"));    menuEditer->Append(DSW_Copier, _T("&Copier\tCtrl-C"));    menuEditer->Append(DSW_Coller, _T("&Coller\tCtrl-V"));    menuEditer->Append(DSW_Supprimer, _T("Supprimer"));    menuEditer->Append(DSW_Renomer, _T("Renomer"));    menuEditer->Append(DSW_Rechercher, _T("Rechercher"));    menuEditer->Append(DSW_Selectout, _T("Selectionner tout"));    menuEditer->Append(DSW_Selectimage, _T("Selectionner les images"));    menuEditer->Append(DSW_Effacerselec, _T("Effacer la sélectoin"));        wxMenu *menuAffichage = new wxMenu;    menuAffichage->Append(DSW_Apercu, _T("Aperçu"));    menuAffichage->Append(DSW_Baroutils, _T("Barre d'outils"));    menuAffichage->Append(DSW_Modaffi, _T("Mode d'affichage"));        wxMenu *menuOutils = new wxMenu;    menuOutils->Append(DSW_Classer, _T("Classer"));    menuOutils->Append(DSW_Pivoter, _T("Faire pivoter"));    menuOutils->Append(DSW_Redim, _T("Redimensionner"));    menuOutils->Append(DSW_Renomer, _T("Renomer"));    menuOutils->Append(DSW_Papierpeint, _T("Utiliser comme papier peint"));        // the "About" item should be in the help menu    wxMenu *menuAide = new wxMenu;    menuAide->Append(DSW_Aide, _T("Aide"));    menuAide->Append(DSW_Info, _T("&A propos de...\tF1"));
               // now append the freshly created menu to the menu bar...    wxMenuBar *menuBar = new wxMenuBar();    menuBar->Append(menuFichier, _T("&Fichier"));    menuBar->Append(menuEditer, _T("&Editer"));    menuBar->Append(menuAffichage, _T("&Affichage"));    menuBar->Append(menuOutils, _T("&Outils"));    menuBar->Append(menuAide, _T("&Aide"));    // ... and attach this menu bar to the frame    SetMenuBar(menuBar);#endif // wxUSE_MENUS
#if wxUSE_STATUSBAR    // create a status bar just for fun (by default with 1 pane only)    CreateStatusBar(2);    SetStatusText(_T("AfroView : Organiser et visualiser vos images en toute simplicité"));#endif // wxUSE_STATUSBAR}
// event handlersvoid MyFrame::OnNouveau(wxCommandEvent& WXUNUSED(event)){    Close(TRUE);}
void MyFrame::OnOuvrir(wxCommandEvent& WXUNUSED(event)){        Close(TRUE);}
void MyFrame::OnEnregistrer(wxCommandEvent& WXUNUSED(event)){    Close(TRUE);}
void MyFrame::OnProprietes(wxCommandEvent& WXUNUSED(event)){    Close(TRUE);}
void MyFrame::OnQuitter(wxCommandEvent& WXUNUSED(event)){    Close(TRUE);}
void MyFrame::OnCouper(wxCommandEvent& WXUNUSED(event)){    Close(TRUE);}
void MyFrame::OnCopier(wxCommandEvent& WXUNUSED(event)){    Close(TRUE);}
void MyFrame::OnColler(wxCommandEvent& WXUNUSED(event)){    Close(TRUE);}
void MyFrame::OnSupprimer(wxCommandEvent& WXUNUSED(event)){    Close(TRUE);}
void MyFrame::OnRenomer(wxCommandEvent& WXUNUSED(event)){    Close(TRUE);}
void MyFrame::OnRechercher(wxCommandEvent& WXUNUSED(event)){    Close(TRUE);}
void MyFrame::OnSelectout(wxCommandEvent& WXUNUSED(event)){    Close(TRUE);}
void MyFrame::OnSelectimage(wxCommandEvent& WXUNUSED(event)){    Close(TRUE);}
void MyFrame::OnEffacerselec(wxCommandEvent& WXUNUSED(event)){    Close(TRUE);}
void MyFrame::OnApercu(wxCommandEvent& WXUNUSED(event)){    Close(TRUE);}
void MyFrame::OnBaroutils(wxCommandEvent& WXUNUSED(event)){    Close(TRUE);}
void MyFrame::OnModaffi(wxCommandEvent& WXUNUSED(event)){    Close(TRUE);}
void MyFrame::OnClasser(wxCommandEvent& WXUNUSED(event)){    Close(TRUE);}
void MyFrame::OnPivoter(wxCommandEvent& WXUNUSED(event)){    Close(TRUE);}
void MyFrame::OnRedim(wxCommandEvent& WXUNUSED(event)){    Close(TRUE);}
void MyFrame::OnPapierpeint(wxCommandEvent& WXUNUSED(event)){    Close(TRUE);}
void MyFrame::OnAide(wxCommandEvent& WXUNUSED(event)){    Close(TRUE);}
void MyFrame::OnInfo(wxCommandEvent& WXUNUSED(event)){    wxString msg;    msg.Printf( _T("AfroView.\n")                _T("By AfroDurf, version 1.0"));
    wxMessageBox(msg, _T("A propos d'AfroView..."), wxOK | wxICON_INFORMATION, this);}
void DirFrame::DirDir(){
Dir = new wxGenericDirCtrl(ID_ARBO, wxEmptyString,                                     wxDefaultPosition, wxDefaultSize,                                     wxDIRCTRL_3D_INTERNAL|wxDIRCTRL_EDIT_LABELS|wxSUNKEN_BORDER,                                     _("All files (*.*)|*.*"), 0);
}
0

Vous n’avez pas trouvé la réponse que vous recherchez ?

Posez votre question
fredcl Messages postés 547 Date d'inscription mercredi 8 janvier 2003 Statut Membre Dernière intervention 7 octobre 2007 1
27 oct. 2005 à 12:41
Bonjour,



Voici un code pour créer une fenêtre simple (wxFrame) contenant un wxGenericDirCtrl:



fichier mainframe.h

---------

#ifndef _MAINFRAME_H_

#define _MAINFRAME_H_



#if defined(__GNUG__) && !defined(__APPLE__)

#pragma interface "mainframe.cpp"

#endif



class wxGenericDirCtrl;



class wxMainFrame: public wxFrame

{

public:



wxMainFrame();

wxMainFrame(wxWindow* parent, wxWindowID id = -1,


const wxString& caption = _("Test wxGenericDirCtrl"),


const wxPoint& pos = wxDefaultPosition,


const wxSize& size = wxDefaultSize,


long style = wxDEFAULT_FRAME_STYLE);



bool Create(wxWindow* parent, wxWindowID id = -1,


const wxString& caption = _("Test wxGenericDirCtrl"),


const wxPoint& pos = wxDefaultPosition,


const wxSize& size = wxDefaultSize,


long style = wxDEFAULT_FRAME_STYLE);



protected:



void CreateControls();



private:



wxGenericDirCtrl* GenDirCtrl;



DECLARE_CLASS(wxMainFrame)

DECLARE_EVENT_TABLE()



};



#endif // _MAINFRAME_H_

---------


fichier mainframe.cpp

---------

#if defined(__GNUG__) && !defined(__APPLE__)

#pragma implementation "mainframe.h"

#endif



// For compilers that support precompilation, includes "wx/wx.h".

#include "wx/wxprec.h"



#ifdef __BORLANDC__

#pragma hdrstop

#endif



#ifndef WX_PRECOMP

#include "wx/wx.h"

#endif



#include "wx/dirctrl.h"

#include "mainframe.h"



#define ID_DIRCTRL 10001



IMPLEMENT_CLASS( wxMainFrame, wxFrame )



BEGIN_EVENT_TABLE( wxMainFrame, wxFrame )

END_EVENT_TABLE()



wxMainFrame::wxMainFrame(){}



wxMainFrame::wxMainFrame(wxWindow* parent, wxWindowID id,


const wxString& caption, const wxPoint& pos,


const wxSize& size, long style)

{

Create(parent, id, caption, pos, size, style);

}



bool wxMainFrame::Create(wxWindow* parent, wxWindowID id,


const wxString& caption, const wxPoint& pos,


const wxSize& size, long style)

{

GenDirCtrl = NULL;

wxFrame::Create( parent, id, caption, pos, size, style );

CreateControls();

return TRUE;

}



void wxMainFrame::CreateControls()

{

GenDirCtrl = new wxGenericDirCtrl(this, ID_DIRCTRL, wxEmptyString,


wxDefaultPosition, wxDefaultSize,


/*wxDIRCTRL_SHOW_FILTERS*/0,


_T("All files (*.*)|*.*|Text Files (*.txt)|*.txt"),


0);

// Attention l'utilisation du style wxDIRCTRL_SHOW_FILTERS pose

// problème l'affichage ne se faisant pas correctement un message

// sur comp.soft-sys.wxwindows évoque le problème

}

---------

J'espère que ce code répond à votre question


Cordialement

Fred Cailleau-Lepetit (http://cfred.free.fr)
0
AfroDurf Messages postés 23 Date d'inscription jeudi 18 septembre 2003 Statut Membre Dernière intervention 12 mai 2010
27 oct. 2005 à 14:53
Merci beaucoup pour ce code Fred qui m'éclaire.

Cependant, j'ai fait le test rapide avec ce code (je n'ai plus d'erreur lors de la compilation, se qui est déja énorme) mais dans ma fenêtre je n'ai rien en fait !! Je l'ai inséré dans mon code etle résultat est toujours ma fenêtre, mes menus et c'est tout, pas de fenêtre avec mon arborescence ????

Est-ce que c'est parce que je dois créer une Wxtreectrl?

Merci d'avance.

Developpement Vôtre !!!
0
fredcl Messages postés 547 Date d'inscription mercredi 8 janvier 2003 Statut Membre Dernière intervention 7 octobre 2007 1
27 oct. 2005 à 15:22
La compilation de ce code (en ajoutant les fichiers pour la classe
dérivée de wxApp bien sur) et uniquement de ce code fonctionne t'elle
correctement?

Si non, quel version de wxWidgets utilisez vous?

Non vous ne devez rien créer de plus, pour l'instant.

Cordialement

Fred Cailleau-Lepetit (http://cfred.free.fr)
0
fredcl Messages postés 547 Date d'inscription mercredi 8 janvier 2003 Statut Membre Dernière intervention 7 octobre 2007 1
27 oct. 2005 à 15:27
Voila précisément ce que j'obtiens avec mon code.




Cordialement

Fred Cailleau-Lepetit (http://cfred.free.fr)
0
AfroDurf Messages postés 23 Date d'inscription jeudi 18 septembre 2003 Statut Membre Dernière intervention 12 mai 2010
27 oct. 2005 à 15:55
Hé ben, j'utilise Dev cpp 4.9.9.2 avec Wxwidgets 2.6.2.

Mon code (avec votre code intégré) :

mainframe.cpp
#if defined(__GNUG__) && !defined(__APPLE__)
#pragma implementation "mainframe.h"
#endif



// For compilers that support precompilation, includes "wx/wx.h".
#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif


// for all others, include the necessary headers (this file is usually all you
// need because it includes almost all "standard" wxWindows headers)
#ifndef WX_PRECOMP
#include "wx/wx.h"
#endif


#include "wx/app.h"
#include "wx/dirctrl.h"
#include "mainframe.h"



// ----------------------------------------------------------------------------
// resources
// ----------------------------------------------------------------------------


// the application icon (under Windows and OS/2 it is in resources)
#if defined(__WXGTK__) || defined(__WXMOTIF__) || defined(__WXMAC__) || defined(__WXMGL__) || defined(__WXX11__)
#include "toolchar.xpm"
#endif


#define ID_DIRCTRL 10001


IMPLEMENT_CLASS( wxMainFrame, wxFrame )


BEGIN_EVENT_TABLE( wxMainFrame, wxFrame )
END_EVENT_TABLE()


// ----------------------------------------------------------------------------
// private classes
// ----------------------------------------------------------------------------


// Define a new application type, each program should derive a class from wxApp
class MyApp : public wxApp
{
public:
// override base class virtuals
// ----------------------------


// this one is called on application startup and is a good place for the app
// initialization (doing it here and not in the ctor allows to have an error
// return: if OnInit() returns false, the application terminates)
virtual bool OnInit();
};


// Define a new frame type: this is going to be our main frame
class MyFrame : public wxFrame
{
public:
// ctor(s)
MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size,
long style = wxDEFAULT_FRAME_STYLE);


// event handlers (these functions should _not_ be virtual)
void OnNouveau(wxCommandEvent& event);
void OnOuvrir(wxCommandEvent& event);
void OnEnregistrer(wxCommandEvent& event);
void OnQuitter(wxCommandEvent& event);
void OnProprietes(wxCommandEvent& event);
void OnCouper(wxCommandEvent& event);
void OnCopier(wxCommandEvent& event);
void OnColler(wxCommandEvent& event);
void OnSupprimer(wxCommandEvent& event);
void OnRenomer(wxCommandEvent& event);
void OnRechercher(wxCommandEvent& event);
void OnSelectout(wxCommandEvent& event);
void OnSelectimage(wxCommandEvent& event);
void OnEffacerselec(wxCommandEvent& event);
void OnApercu(wxCommandEvent& event);
void OnBaroutils(wxCommandEvent& event);
void OnModaffi(wxCommandEvent& event);
void OnClasser(wxCommandEvent& event);
void OnPivoter(wxCommandEvent& event);
void OnRedim(wxCommandEvent& event);
void OnPapierpeint(wxCommandEvent& event);
void OnAide(wxCommandEvent& event);
void OnInfo(wxCommandEvent& event);


private:
// any class wishing to process wxWindows events must use this macro
DECLARE_EVENT_TABLE()

};


// ----------------------------------------------------------------------------
// constants
// ----------------------------------------------------------------------------


// IDs for the controls and the menu commands
enum
{
// menu items
DSW_Quitter = 1,
DSW_Nouveau,
DSW_Ouvrir,
DSW_Enregistrer,
DSW_Proprietes,
DSW_Couper,
DSW_Copier,
DSW_Coller,
DSW_Supprimer,
DSW_Renomer,
DSW_Rechercher,
DSW_Selectout,
DSW_Selectimage,
DSW_Effacerselec,
DSW_Apercu,
DSW_Baroutils,
DSW_Modaffi,
DSW_Classer,
DSW_Pivoter,
DSW_Redim,
DSW_Papierpeint,
DSW_Aide,
Dir,


// it is important for the id corresponding to the "About" command to have
// this standard value as otherwise it won't be handled properly under Mac
// (where it is special and put into the "Apple" menu)
DSW_Info = wxID_ABOUT
};


// ----------------------------------------------------------------------------
// event tables and other macros for wxWindows
// ----------------------------------------------------------------------------


// the event tables connect the wxWindows events with the functions (event
// handlers) which process them. It can be also done at run-time, but for the
// simple menu events like this the static method is much simpler.
BEGIN_EVENT_TABLE(MyFrame, wxFrame)
EVT_MENU(DSW_Quitter, MyFrame::OnQuitter)
EVT_MENU(DSW_Nouveau, MyFrame::OnNouveau)
EVT_MENU(DSW_Ouvrir, MyFrame::OnOuvrir)
EVT_MENU(DSW_Enregistrer, MyFrame::OnEnregistrer)
EVT_MENU(DSW_Proprietes, MyFrame::OnProprietes)
EVT_MENU(DSW_Couper, MyFrame::OnCouper)
EVT_MENU(DSW_Copier, MyFrame::OnCopier)
EVT_MENU(DSW_Coller, MyFrame::OnColler)
EVT_MENU(DSW_Supprimer, MyFrame::OnSupprimer)
EVT_MENU(DSW_Renomer, MyFrame::OnRenomer)
EVT_MENU(DSW_Rechercher, MyFrame::OnRechercher)
EVT_MENU(DSW_Selectout, MyFrame::OnSelectout)
EVT_MENU(DSW_Selectimage, MyFrame::OnSelectimage)
EVT_MENU(DSW_Effacerselec, MyFrame::OnEffacerselec)
EVT_MENU(DSW_Apercu, MyFrame::OnApercu)
EVT_MENU(DSW_Baroutils, MyFrame::OnBaroutils)
EVT_MENU(DSW_Modaffi, MyFrame::OnModaffi)
EVT_MENU(DSW_Classer, MyFrame::OnClasser)
EVT_MENU(DSW_Pivoter, MyFrame::OnPivoter)
EVT_MENU(DSW_Redim, MyFrame::OnRedim)
EVT_MENU(DSW_Papierpeint, MyFrame::OnPapierpeint)
EVT_MENU(DSW_Aide, MyFrame::OnAide)
EVT_MENU(DSW_Info, MyFrame::OnInfo)


END_EVENT_TABLE()


// Create a new application object: this macro will allow wxWindows to create
// the application object during program execution (it's better than using a
// static object for many reasons) and also declares the accessor function
// wxGetApp() which will return the reference of the right type (i.e. MyApp and
// not wxApp)
IMPLEMENT_APP(MyApp)


// ============================================================================
// implementation
// ============================================================================


// ----------------------------------------------------------------------------
// the application class
// ----------------------------------------------------------------------------


// 'Main program' equivalent: the program execution "starts" here
bool MyApp::OnInit()
{


// create the main application window
MyFrame *frame = new MyFrame(_T("AfroView"),
wxPoint(100, 50), wxSize(600, 600), wxDEFAULT_FRAME_STYLE | wxTAB_TRAVERSAL);


// and show it (the frames, unlike simple controls, are not shown when
// created initially)
frame->Show(TRUE);


// success: wxApp::OnRun() will be called which will enter the main message
// loop and the application will run. If we returned FALSE here, the
// application would exit immediately.
return TRUE;
}


// ----------------------------------------------------------------------------
// main frame
// ----------------------------------------------------------------------------


// frame constructor



wxMainFrame::wxMainFrame(wxWindow* parent, wxWindowID id,
const wxString& caption, const wxPoint& pos,
const wxSize& size, long style)
{
Create(parent, id, caption, pos, size, style);
}


bool wxMainFrame::Create(wxWindow* parent, wxWindowID id,
const wxString& caption, const wxPoint& pos,
const wxSize& size, long style)
{
GenDirCtrl = NULL;
wxFrame::Create( parent, id, caption, pos, size, style );
CreateControls();
return TRUE;
}
void wxMainFrame::CreateControls()
{
GenDirCtrl = new wxGenericDirCtrl(this, ID_DIRCTRL, wxEmptyString,
wxDefaultPosition, wxDefaultSize,
/*wxDIRCTRL_SHOW_FILTERS*/0,
_T("All files (*.*)|*.*|Text Files (*.txt)|*.txt"),
0);
// Attention l'utilisation du style wxDIRCTRL_SHOW_FILTERS pose
// problème l'affichage ne se faisant pas correctement un message
// sur comp.soft-sys.wxwindows évoque le problème
}


MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size, long style)
: wxFrame(NULL, -1, title, pos, size, style)
{

// set the frame icon
SetIcon(wxICON(toolchar));
SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE));



#if wxUSE_MENUS
// create a menu bar
wxMenu *menuFichier = new wxMenu;
menuFichier->Append(DSW_Nouveau, _T("&Nouveau\tCtrl-N"), _T("Créer un nouveau fichier"));
menuFichier->Append(DSW_Ouvrir, _T("&Ouvrir\tCtrl-O"), _T("Ouvrir un fichier"));
menuFichier->Append(DSW_Enregistrer, _T("&Enregistrer sous\tCtrl-S"), _T("Enregistrer le fichier en cours"));
menuFichier->Append(DSW_Proprietes, _T("&Proriètés"), _T("Propriètés du fichier"));
menuFichier->Append(DSW_Quitter, _T("&Quitter\tAlt-Q"), _T("Quitter ce programme"));

wxMenu *menuEditer = new wxMenu;
menuEditer->Append(DSW_Couper, _T("&Couper\tCtrl-X"));
menuEditer->Append(DSW_Copier, _T("&Copier\tCtrl-C"));
menuEditer->Append(DSW_Coller, _T("&Coller\tCtrl-V"));
menuEditer->Append(DSW_Supprimer, _T("Supprimer"));
menuEditer->Append(DSW_Renomer, _T("Renomer"));
menuEditer->Append(DSW_Rechercher, _T("Rechercher"));
menuEditer->Append(DSW_Selectout, _T("Selectionner tout"));
menuEditer->Append(DSW_Selectimage, _T("Selectionner les images"));
menuEditer->Append(DSW_Effacerselec, _T("Effacer la sélectoin"));

wxMenu *menuAffichage = new wxMenu;
menuAffichage->Append(DSW_Apercu, _T("Aperçu"));
menuAffichage->Append(DSW_Baroutils, _T("Barre d'outils"));
menuAffichage->Append(DSW_Modaffi, _T("Mode d'affichage"));

wxMenu *menuOutils = new wxMenu;
menuOutils->Append(DSW_Classer, _T("Classer"));
menuOutils->Append(DSW_Pivoter, _T("Faire pivoter"));
menuOutils->Append(DSW_Redim, _T("Redimensionner"));
menuOutils->Append(DSW_Renomer, _T("Renomer"));
menuOutils->Append(DSW_Papierpeint, _T("Utiliser comme papier peint"));

// the "About" item should be in the help menu
wxMenu *menuAide = new wxMenu;
menuAide->Append(DSW_Aide, _T("Aide"));
menuAide->Append(DSW_Info, _T("&A propos de...\tF1"));





// now append the freshly created menu to the menu bar...
wxMenuBar *menuBar = new wxMenuBar();
menuBar->Append(menuFichier, _T("&Fichier"));
menuBar->Append(menuEditer, _T("&Editer"));
menuBar->Append(menuAffichage, _T("&Affichage"));
menuBar->Append(menuOutils, _T("&Outils"));
menuBar->Append(menuAide, _T("&Aide"));
// ... and attach this menu bar to the frame
SetMenuBar(menuBar);
#endif // wxUSE_MENUS


#if wxUSE_STATUSBAR
// create a status bar just for fun (by default with 1 pane only)
CreateStatusBar(2);
SetStatusText(_T("AfroView : Organiser et visualiser vos images en toute simplicité"));
#endif // wxUSE_STATUSBAR
}



// event handlers
void MyFrame::OnNouveau(wxCommandEvent& WXUNUSED(event))
{
Close(TRUE);
}


void MyFrame::OnOuvrir(wxCommandEvent& WXUNUSED(event))
{

Close(TRUE);
}


void MyFrame::OnEnregistrer(wxCommandEvent& WXUNUSED(event))
{
Close(TRUE);
}


void MyFrame::OnProprietes(wxCommandEvent& WXUNUSED(event))
{
Close(TRUE);
}


void MyFrame::OnQuitter(wxCommandEvent& WXUNUSED(event))
{
Close(TRUE);
}


void MyFrame::OnCouper(wxCommandEvent& WXUNUSED(event))
{
Close(TRUE);
}


void MyFrame::OnCopier(wxCommandEvent& WXUNUSED(event))
{
Close(TRUE);
}


void MyFrame::OnColler(wxCommandEvent& WXUNUSED(event))
{
Close(TRUE);
}


void MyFrame::OnSupprimer(wxCommandEvent& WXUNUSED(event))
{
Close(TRUE);
}


void MyFrame::OnRenomer(wxCommandEvent& WXUNUSED(event))
{
Close(TRUE);
}


void MyFrame::OnRechercher(wxCommandEvent& WXUNUSED(event))
{
Close(TRUE);
}


void MyFrame::OnSelectout(wxCommandEvent& WXUNUSED(event))
{
Close(TRUE);
}


void MyFrame::OnSelectimage(wxCommandEvent& WXUNUSED(event))
{
Close(TRUE);
}


void MyFrame::OnEffacerselec(wxCommandEvent& WXUNUSED(event))
{
Close(TRUE);
}


void MyFrame::OnApercu(wxCommandEvent& WXUNUSED(event))
{
Close(TRUE);
}


void MyFrame::OnBaroutils(wxCommandEvent& WXUNUSED(event))
{
Close(TRUE);
}


void MyFrame::OnModaffi(wxCommandEvent& WXUNUSED(event))
{
Close(TRUE);
}


void MyFrame::OnClasser(wxCommandEvent& WXUNUSED(event))
{
Close(TRUE);
}


void MyFrame::OnPivoter(wxCommandEvent& WXUNUSED(event))
{
Close(TRUE);
}


void MyFrame::OnRedim(wxCommandEvent& WXUNUSED(event))
{
Close(TRUE);
}


void MyFrame::OnPapierpeint(wxCommandEvent& WXUNUSED(event))
{
Close(TRUE);
}


void MyFrame::OnAide(wxCommandEvent& WXUNUSED(event))
{
Close(TRUE);
}


void MyFrame::OnInfo(wxCommandEvent& WXUNUSED(event))
{
wxString msg;
msg.Printf( _T("AfroView.\n")
_T("By AfroDurf, version 1.0"));


wxMessageBox(msg, _T("A propos d'AfroView..."), wxOK | wxICON_INFORMATION, this);
}


mainframe.h

#ifndef _MAINFRAME_H_
#define _MAINFRAME_H_


#if defined(__GNUG__) && !defined(__APPLE__)
#pragma interface "mainframe.cpp"
#endif


class wxGenericDirCtrl;


class wxMainFrame: public wxFrame
{
public:


wxMainFrame();
wxMainFrame(wxWindow* parent, wxWindowID id = -1,
const wxString& caption = _("Test wxGenericDirCtrl"),
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxDEFAULT_FRAME_STYLE);


bool Create(wxWindow* parent, wxWindowID id = -1,
const wxString& caption = _("Test wxGenericDirCtrl"),
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxDEFAULT_FRAME_STYLE);


protected:


void CreateControls();


private:


wxGenericDirCtrl* GenDirCtrl;


DECLARE_CLASS(wxMainFrame)
DECLARE_EVENT_TABLE()


};


#endif // _MAINFRAME_H_

AV.rc

// RESOURCES OF THIS PROJECT


// DO NOT REMOVE THIS LINE (WXWIDGETS RESOURCE)
#include <wx/msw/wx.rc>
0
AfroDurf Messages postés 23 Date d'inscription jeudi 18 septembre 2003 Statut Membre Dernière intervention 12 mai 2010
27 oct. 2005 à 15:56
J'obtiens ceci
0
Rejoignez-nous