Changeset 181 for trunk


Ignore:
Timestamp:
18/10/08 11:53:18 (6 years ago)
Author:
guyru
Message:

make highsocres window resizable and make list columns resize automatically

Location:
trunk/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/highscores_dialog.cpp

    r175 r181  
    2929using namespace highscores_dialog; 
    3030 
     31const int HIGHSCORELIST_BORDER = 10; 
     32 
    3133HighscoresDialog::HighscoresDialog(wxWindow* parent,configuration::Configuration* config, int highlight_rank) : 
    32         wxDialog(parent, wxID_ANY, wxT("Highscores Table"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE) 
     34        wxDialog(parent, wxID_ANY, wxT("Highscores Table"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER) 
    3335{ 
    3436        this->highlight_rank = highlight_rank; 
     
    109111        wxBoxSizer *top_sizer = new wxBoxSizer( wxVERTICAL ); 
    110112         
    111         top_sizer->Add(highscoreslist, 1, wxALL, 10);  
     113        top_sizer->Add(highscoreslist, 1, wxEXPAND | wxALL, HIGHSCORELIST_BORDER);  
    112114 
    113115        wxBoxSizer *button_sizer = new wxBoxSizer( wxHORIZONTAL ); 
     
    133135        Connect(wxID_CLEAR, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(HighscoresDialog::onClear)); 
    134136        Connect(ID_CONFIGURE, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(HighscoresDialog::onConfigure)); 
     137        Connect(this->GetId(), wxEVT_SIZE, wxSizeEventHandler(HighscoresDialog::onResize)); 
    135138} 
    136139void HighscoresDialog::onClose(wxCommandEvent& event) 
     
    201204        event.Skip(); 
    202205} 
     206 
     207void HighscoresDialog::onResize(wxSizeEvent &event) { 
     208 
     209        const int width = event.GetSize().GetWidth(); 
     210        const int rank_width = highscoreslist->GetColumnWidth(0); 
     211        const int score_width = highscoreslist->GetColumnWidth(2); 
     212        const int date_width = highscoreslist->GetColumnWidth(3); 
     213        const int new_width = width - 2*HIGHSCORELIST_BORDER - rank_width - score_width - date_width; 
     214         
     215        highscoreslist->SetColumnWidth(1,new_width); 
     216        event.Skip(); 
     217} 
  • trunk/src/highscores_dialog.h

    r167 r181  
    3737        void onClear(wxCommandEvent& event);     
    3838        void onConfigure(wxCommandEvent& event);         
     39        void onResize(wxSizeEvent& event); 
    3940private: 
    4041        void createControls(); 
Note: See TracChangeset for help on using the changeset viewer.