IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

wxWidgets Discussion :

wxAuiManager et wxSizer


Sujet :

wxWidgets

  1. #21
    Membre émérite
    Avatar de Ti-R
    Homme Profil pro
    Ingénieur R&D
    Inscrit en
    Avril 2003
    Messages
    1 683
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 44
    Localisation : France, Hauts de Seine (Île de France)

    Informations professionnelles :
    Activité : Ingénieur R&D
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Avril 2003
    Messages : 1 683
    Points : 2 568
    Points
    2 568
    Par défaut
    A la place de "ID_Slider_ind", placer "wxID_ANY", cela génère maintenant des index uniques.

    Ensuite, dans ta méthode "OnSliderUpdate_ind", tu peux parcourir ton tableau slider_choice pour retrouver l'index du slider qui correspond à l'event. (sur l'événement on peut faire GetId() qui renvoie l'index du composant qui a généré l'événement.)

    Le plus simple pour retrouver ton slider étant de le placer dans une map

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    //.h dans la classe
    std::map<int, wxSlider*> mapSliders;
     
    //.cpp
    //...
    slider_choice[i]=new wxSlider //...
    mapSliders[slider_choice[i]->GetId()] = slider_choice[i];
    //...
    Donc maintenant tu peux faire le lien entre un composant généré et un événement généré par un de ces composants.

  2. #22
    Membre à l'essai
    Inscrit en
    Juin 2008
    Messages
    63
    Détails du profil
    Informations forums :
    Inscription : Juin 2008
    Messages : 63
    Points : 21
    Points
    21
    Par défaut re
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    //.h dans la classe
    std::map<int, wxSlider*> mapSliders;
     
    //.cpp
    //...
    slider_choice[i]=new wxSlider //...
    mapSliders[slider_choice[i]->GetId()] = slider_choice[i];
    //...
    donc si je comprend bien dasn OnSliderUpdate_ind, il me suffira de faire :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    mapSliders[event.GetId()]->SetValue()
    Une map sert à quoi excatement, associer a un identifiants unique un objet?

  3. #23
    Membre à l'essai
    Inscrit en
    Juin 2008
    Messages
    63
    Détails du profil
    Informations forums :
    Inscription : Juin 2008
    Messages : 63
    Points : 21
    Points
    21
    Par défaut re
    l'ajout de
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    std::map<int, wxSlider*> mapSliders;
    me donne l'erreur suivante :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    AppVT3D.h:218: erreur: ISO C++ forbids declaration of «map» with no type
    AppVT3D.h:218: erreur: invalid use of «::»
    AppVT3D.h:218: erreur: expected «;» before «<» token
    résolu :
    J'ai juste oublié l'ajout de #include <map>

  4. #24
    Membre à l'essai
    Inscrit en
    Juin 2008
    Messages
    63
    Détails du profil
    Informations forums :
    Inscription : Juin 2008
    Messages : 63
    Points : 21
    Points
    21
    Par défaut re
    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
    30
    31
    32
    33
    34
    35
    wxBoxSizer* sizer_choice[profondeur[idx_cur]-3]; 
     
          for(unsigned int i=0;i<m_choice[idx_cur]->GetSelection();i++)
          {
     
            sizer_choice[i] = new wxBoxSizer(wxHORIZONTAL);
            wxSlider *slider_choice=new wxSlider(Ec[idx_cur],wxID_ANY,0,0,20,wxDefaultPosition,wxSize(120,40),wxSL_HORIZONTAL);
     
            mapInd[slider_choice->GetId()]=i;
            //Pour OnSliderUpdate...
            mapSliders[slider_choice->GetId()] = slider_choice;
            //
            wxSpinCtrl* SpinCtrl_choice = new wxSpinCtrl(Ec[idx_cur],wxID_ANY,
                                    _(""),
                                    wxDefaultPosition, wxSize(40,20),
                                    wxSP_ARROW_KEYS,
                                    0,20,0);
            mapSpinCtrl[slider_choice->GetId()] = SpinCtrl_choice;
            mapCmp[SpinCtrl_choice->GetId()]=slider_choice->GetId();
            sizer_choice[i]->Add(1, 1, 1, wxEXPAND);
     
     
            sizer_choice[i]->Add(new wxStaticText(Ec[idx_cur], wxID_ANY, wxT("Value ") + wxString::FromAscii(tab_idx[idx_cur][i])),0,wxALL,10);
            sizer_choice[i]->Add(slider_choice,0,wxALL,0);
            sizer_choice[i]->Add(SpinCtrl_choice,0,wxALL,10);
            sizer_choice[i]->Add(1, 1, 1, wxEXPAND);
            sizer_choice[i]->SetItemMinSize((size_t)1, 50, 20);
     
            Ec[idx_cur]->GetSizer()->Add(sizer_choice[i]);
           }
     
      sizer_choice[0]->Clear(true);
     
      Ec[idx_cur]->SetSizer(Ec[idx_cur]->GetSizer());
      Ec[idx_cur]->GetSizer()->SetSizeHints(Ec[idx_cur]);
    Le code ci-dessus créé récursivement plusieurs contenants avec différents composants. Ce code est placé dans une methode evenementielle de type wxChoice ( dès que je selectionne quelque chose dans mon wxChoice, je créé les sizers)...Ce que je voudrais, c'est supprimer les anciens sizer avant d'en créer de nouveaux...

  5. #25
    Membre émérite
    Avatar de Ti-R
    Homme Profil pro
    Ingénieur R&D
    Inscrit en
    Avril 2003
    Messages
    1 683
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 44
    Localisation : France, Hauts de Seine (Île de France)

    Informations professionnelles :
    Activité : Ingénieur R&D
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Avril 2003
    Messages : 1 683
    Points : 2 568
    Points
    2 568
    Par défaut
    J'en ai parlé un peu précédemment !


    Citation Envoyé par Ti-R Voir le message
    malloc en C++

    C'est possible de voir ton code ?

    Car en principe suffit de faire un vector
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    class MyToolBarPanel
    {
    //...
    std::vector<wxBoxSizer*> mListSliders;
    //...
    void CreateSlider()
    {
    wxBoxSizer* s2 = new wxBoxSizer(wxHORIZONTAL);
    //...
    mListSliders.push_back(s2 );
    }
    //...
    }
    Pour le destruction
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    void DestroySliders()
    {
    std::vector<wxBoxSizer*> itListSliders = mListSliders.begin() ;
    for(;itListSliders != mListSliders.end();++ itListSliders)
    {
    GetSizer().Remove(* itListSliders);
    }
     
    }
    Bien vérifier que la destruction désalloue le contenant des sizer s2.
    Si cela n'est pas le cas, placer s2 dans un wxPanel et ajouter le wxPanel en lieu et place de s2 dans le GetSizer().
    Lors du DestroySliders()

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    void DestroySliders()
    {
    std::vector<wxPanel*> itListSliders = mListSliders.begin() ;
    for(;itListSliders != mListSliders.end();++ itListSliders)
    {
    GetSizer().Detach(* itListSliders);
    delete *itListSliders;
    }
    mListSliders.clear();
     
    }

  6. #26
    Membre à l'essai
    Inscrit en
    Juin 2008
    Messages
    63
    Détails du profil
    Informations forums :
    Inscription : Juin 2008
    Messages : 63
    Points : 21
    Points
    21
    Par défaut re
    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
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
          std::vector<wxBoxSizer*> itListSliders = mListSliders.begin() ;
          for(;itListSliders != mListSliders.end();++ itListSliders)
          {
           Ec[idx_cur]-> GetSizer().Remove(* itListSliders);
          }
     
          wxBoxSizer* sizer_choice[profondeur[idx_cur]-3]; 
     
          for(unsigned int i=0;i<m_choice[idx_cur]->GetSelection();i++)
          {
     
            sizer_choice[i] = new wxBoxSizer(wxHORIZONTAL);
            wxSlider *slider_choice=new wxSlider(Ec[idx_cur],wxID_ANY,0,0,20,wxDefaultPosition,wxSize(120,40),wxSL_HORIZONTAL);
     
            mapInd[slider_choice->GetId()]=i;
            //Pour OnSliderUpdate...
            mapSliders[slider_choice->GetId()] = slider_choice;
            //
            wxSpinCtrl* SpinCtrl_choice = new wxSpinCtrl(Ec[idx_cur],wxID_ANY,
                                    _(""),
                                    wxDefaultPosition, wxSize(40,20),
                                    wxSP_ARROW_KEYS,
                                    0,20,0);
            mapSpinCtrl[slider_choice->GetId()] = SpinCtrl_choice;
            mapCmp[SpinCtrl_choice->GetId()]=slider_choice->GetId();
            sizer_choice[i]->Add(1, 1, 1, wxEXPAND);
     
     
            sizer_choice[i]->Add(new wxStaticText(Ec[idx_cur], wxID_ANY, wxT("Value ") + wxString::FromAscii(tab_idx[idx_cur][i])),0,wxALL,10);
            sizer_choice[i]->Add(slider_choice,0,wxALL,0);
            sizer_choice[i]->Add(SpinCtrl_choice,0,wxALL,10);
            sizer_choice[i]->Add(1, 1, 1, wxEXPAND);
            sizer_choice[i]->SetItemMinSize((size_t)1, 50, 20);
     
     
            mListSliders.push_back(sizer_choice[i]);
     
            Ec[idx_cur]->GetSizer()->Add(sizer_choice[i]);
           }
     
     
     
      //Ec[idx_cur]->SetAutoLayout(TRUE);
      Ec[idx_cur]->SetSizer(Ec[idx_cur]->GetSizer());
      //Ec->GetSizer()->Fit(Ec);
      Ec[idx_cur]->GetSizer()->SetSizeHints(Ec[idx_cur]);

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    Ec[idx_cur]->GetSizer()
    me renvoit le sizer du panel sur lequel je travaille ( j'en ai plusieurs, en fonction de la page auinotebbok qur laquelle je suis ) et ce que je veux, c'est donc supprimer chaque Child ( qui sont aussi des sizer ) de celui-ci.

    J'obtient l'erreur :
    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
    AppVT3D.cpp: In member function «void MyFrame::OnChoice(wxCommandEvent&)»:
    AppVT3D.cpp:986: erreur: conversion from «__gnu_cxx::__normal_iterator<wxBoxSizer**, std::vector<wxBoxSizer*, std::allocator<wxBoxSizer*> > >» to non-scalar type «std::vector<wxBoxSizer*, std::allocator<wxBoxSizer*> >» requested
    AppVT3D.cpp:987: erreur: no match for «operator!=» in «itListSliders != ((MyFrame*)this)->MyFrame::mListSliders.std::vector<_Tp, _Alloc>::end [with _Tp = wxBoxSizer*, _Alloc = std::allocator<wxBoxSizer*>]()»
    /usr/include/wx-2.8/wx/string.h:1566: note: candidats sont: bool operator!=(const wxString&, const wxString&)
    /usr/include/wx-2.8/wx/string.h:1568: note:                 bool operator!=(const wxString&, const wxChar*)
    /usr/include/wx-2.8/wx/string.h:1570: note:                 bool operator!=(const wxChar*, const wxString&)
    /usr/include/wx-2.8/wx/string.h:1602: note:                 bool operator!=(const wxString&, const wxWCharBuffer&)
    /usr/include/wx-2.8/wx/string.h:1604: note:                 bool operator!=(const wxWCharBuffer&, const wxString&)
    /usr/include/wx-2.8/wx/string.h:1635: note:                 bool operator!=(wxChar, const wxString&)
    /usr/include/wx-2.8/wx/string.h:1636: note:                 bool operator!=(const wxString&, wxChar)
    /usr/include/wx-2.8/wx/longlong.h:1045: note:                 bool operator!=(long int, const wxLongLong&)
    /usr/include/wx-2.8/wx/longlong.h:1058: note:                 bool operator!=(long unsigned int, const wxULongLong&)
    /usr/include/wx-2.8/wx/treebase.h:89: note:                 bool operator!=(const wxTreeItemId&, const wxTreeItemId&)
    AppVT3D.cpp:987: erreur: no match for «operator++» in «++itListSliders»
    AppVT3D.cpp:989: erreur: request for member «Remove» in «(*(((MyFrame*)this)->MyFrame::Ec + ((wxPanel**)(((unsigned int)((MyFrame*)this)->MyFrame::idx_cur) * 4u))))->wxPanel::<anonymous>.wxWindow::<anonymous>.wxWindowBase::GetSizer()», which is of non-class type «wxSizer*»
    AppVT3D.cpp:989: erreur: no match for «operator*» in «*itListSliders»
    /usr/include/wx-2.8/wx/datetime.h:2104: note: candidats sont: wxTimeSpan operator*(int, const wxTimeSpan&)
    /usr/include/wx-2.8/wx/datetime.h:2110: note:                 wxDateSpan operator*(int, const wxDateSpan&)
    /usr/include/wx-2.8/wx/geometry.h:239: note:                 wxPoint2DInt operator*(const wxPoint2DInt&, const wxPoint2DInt&)
    /usr/include/wx-2.8/wx/geometry.h:244: note:                 wxPoint2DInt operator*(wxInt32, const wxPoint2DInt&)
    /usr/include/wx-2.8/wx/geometry.h:254: note:                 wxPoint2DInt operator*(const wxPoint2DInt&, wxInt32)
    /usr/include/wx-2.8/wx/geometry.h:249: note:                 wxPoint2DInt operator*(wxDouble, const wxPoint2DInt&)
    /usr/include/wx-2.8/wx/geometry.h:259: note:                 wxPoint2DInt operator*(const wxPoint2DInt&, wxDouble)
    /usr/include/wx-2.8/wx/geometry.h:468: note:                 wxPoint2DDouble operator*(const wxPoint2DDouble&, const wxPoint2DDouble&)
    /usr/include/wx-2.8/wx/geometry.h:473: note:                 wxPoint2DDouble operator*(wxDouble, const wxPoint2DDouble&)
    /usr/include/wx-2.8/wx/geometry.h:478: note:                 wxPoint2DDouble operator*(wxInt32, const wxPoint2DDouble&)
    /usr/include/wx-2.8/wx/geometry.h:483: note:                 wxPoint2DDouble operator*(const wxPoint2DDouble&, wxDouble)
    /usr/include/wx-2.8/wx/geometry.h:488: note:                 wxPoint2DDouble operator*(const wxPoint2DDouble&, wxInt32)
    make: *** [PolyTrace] Erreur 1

  7. #27
    Membre à l'essai
    Inscrit en
    Juin 2008
    Messages
    63
    Détails du profil
    Informations forums :
    Inscription : Juin 2008
    Messages : 63
    Points : 21
    Points
    21
    Par défaut re
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
      std::vector<wxBoxSizer*>::iterator itListSliders = mListSliders.begin() ;
    marche mieux, on en a pas en tout cas des problèmes de redéfinition des operateurs.

    J'ai encore des erreurs que je posterai une fois comprises.

  8. #28
    Membre émérite
    Avatar de Ti-R
    Homme Profil pro
    Ingénieur R&D
    Inscrit en
    Avril 2003
    Messages
    1 683
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 44
    Localisation : France, Hauts de Seine (Île de France)

    Informations professionnelles :
    Activité : Ingénieur R&D
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Avril 2003
    Messages : 1 683
    Points : 2 568
    Points
    2 568
    Par défaut
    Oui désolé j'ai été un peu vite à taper

Discussions similaires

  1. gestion du wxAuiManager
    Par Ivory69 dans le forum wxWidgets
    Réponses: 2
    Dernier message: 26/04/2007, 14h55
  2. Suppression d'un wxPanel et redimension du wxSizer conteneur
    Par mister3957 dans le forum wxWidgets
    Réponses: 1
    Dernier message: 28/02/2006, 22h39
  3. [wxWindows] wxSizer
    Par Heimdall dans le forum wxWidgets
    Réponses: 1
    Dernier message: 06/02/2004, 15h19

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo