torfin (Nouveau membre)
Inscrit le : 19-04-2012
Messages: 1
Snippets: 0
Tutoriels: 0
Hors ligne |
Bonjour, Je suis débutant avec WxWidget, et j'essaie de me faire un lecteur média (audio uniquement).
Et mon problème vient du fait que le contenu de ma fenêtre ne s'agrandi pas. Je m'explique: - la fenêtre prend la bonne taille au démarrage mais dès que je redimensionne la fenêtre les composants reste dans leur coin en haut à gauche. - certain composant ne prennent pas toute la place disponible (boutons ou slider).
Merci pour les réponse que vous pourriez m’apporter.
Voici le code: mainframeplayer.h
Code Cpp: #ifndef __MAINFRAMEPLAYER_H__ #define __MAINFRAMEPLAYER_H__ #include <wx/wx.h> #include <wx/gbsizer.h> class MainFramePlayer : public wxFrame { public: MainFramePlayer(); ~MainFramePlayer(); private: //sizer global wxBoxSizer *gblBoxSizer; //sizer pour le reste wxGridBagSizer *gridSizer; //sizer pour les boutons wxBoxSizer *btnBoxSizer; //pour les temps wxStaticText *m_txtTempEcoule, *m_txtTempRestant, *m_txtTempTotal; wxStaticText *m_valTempEcoule, *m_valTempRestant, *m_valTempTotal; //pour le titre - artiste / album wxStaticText *m_valTitreArtiste; //pour la position dans le titre wxSlider *m_sliderPosition; //les boutons wxButton *m_btnPlayPause, *m_btnStop; }; #endif //__MAINFRAMEPLAYER_H__
mainframeplayer.cpp
Code Cpp: #include "mainframeplayer.h" MainFramePlayer::MainFramePlayer() : wxFrame (NULL, wxID_ANY, _("")) { SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE)); //création du sizer global gblBoxSizer = new wxBoxSizer (wxHORIZONTAL); //création du sizer grille pour mettre les éléments en place gridSizer = new wxGridBagSizer (5, 5); //création des textes m_txtTempEcoule = new wxStaticText (this, wxID_ANY, _("Temps ecoule")); m_txtTempRestant = new wxStaticText (this, wxID_ANY, _("Temps restant")); m_txtTempTotal = new wxStaticText (this, wxID_ANY, _("Temps total")); m_valTempEcoule = new wxStaticText (this, wxID_ANY, _("00:00:01")); m_valTempRestant = new wxStaticText (this, wxID_ANY, _("00:00:02")); m_valTempTotal = new wxStaticText (this, wxID_ANY, _("00:00:03")); m_valTitreArtiste = new wxStaticText (this, wxID_ANY, _("truc - machin / bidule")); //ajout des éléments dans la grille gridSizer->Add(m_txtTempEcoule, wxGBPosition(0, 0), wxGBSpan(1, 1)); gridSizer->Add(m_txtTempRestant, wxGBPosition(0, 1), wxGBSpan(1, 1)); gridSizer->Add(m_txtTempTotal, wxGBPosition(0, 2), wxGBSpan(1, 1)); gridSizer->Add(m_valTempEcoule, wxGBPosition(1, 0), wxGBSpan(1, 1)); gridSizer->Add(m_valTempRestant, wxGBPosition(1, 1), wxGBSpan(1, 1)); gridSizer->Add(m_valTempTotal, wxGBPosition(1, 2), wxGBSpan(1, 1)); gridSizer->Add(m_valTitreArtiste, wxGBPosition(2, 0), wxGBSpan(1, 3)); //création du slider m_sliderPosition = new wxSlider (this, wxID_ANY, 0, 0, 100); //ajout dans la grille gridSizer->Add(m_sliderPosition, wxGBPosition(3, 0), wxGBSpan(1, 3)); //création du sizer pour les boutons btnBoxSizer = new wxBoxSizer (wxHORIZONTAL); //creation des boutons m_btnPlayPause = new wxButton (this, wxID_ANY, _("Play / Pause")); m_btnStop = new wxButton (this, wxID_ANY, _("Stop")); btnBoxSizer->Add(m_btnPlayPause, 1, wxALL | wxEXPAND, 5); btnBoxSizer->Add(m_btnStop, 1, wxALL | wxEXPAND, 5); //ajout de cela dans la grille gridSizer->Add(btnBoxSizer, wxGBPosition(4, 0), wxGBSpan(1, 3)); //ajout de la grille dnas le sizer global gblBoxSizer->Add(gridSizer, 1, wxALL | wxEXPAND, 5); SetSizer(gblBoxSizer); gblBoxSizer->SetSizeHints(this); } MainFramePlayer::~MainFramePlayer() { } ---------- Re bonjour,
pour la taille qui ne prennais pas toute la place disponible, j'avais oublier wxEXPAND dans les lignes du type:
Code Cpp:gridSizer->Add(m_valTitreArtiste, wxGBPosition(2, 0), wxGBSpan(1, 3), wxEXPAND); ---------- Pour cela il fallait juste ajouter des AddGrowableCol ou AddGrowableRow.
Dernière modification par torfin (22-04-2012 09:01:47)
|