PreferencesPanel started
This commit is contained in:
@@ -3,7 +3,9 @@
|
||||
enum {ID_BUTTON_ACCOUNT=1, ID_BUTTON_STATS, ID_BUTTON_PREFS, ID_BUTTON_CHANGE_USER};
|
||||
|
||||
BEGIN_EVENT_TABLE(ButtonPanel, wxPanel)
|
||||
EVT_BUTTON(ID_BUTTON_CHANGE_USER, ButtonPanel::OnChangeUser)
|
||||
EVT_BUTTON(ID_BUTTON_ACCOUNT, ButtonPanel::OnButtonAccount)
|
||||
EVT_BUTTON(ID_BUTTON_PREFS, ButtonPanel::OnButtonPreferences)
|
||||
EVT_BUTTON(ID_BUTTON_CHANGE_USER, ButtonPanel::OnButtonChangeUser)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
ButtonPanel::ButtonPanel(KissCount* kiss, wxUI *parent) : wxPanel(&(*parent)), _kiss(kiss), _wxUI(parent)
|
||||
@@ -33,7 +35,17 @@ ButtonPanel::~ButtonPanel()
|
||||
delete _changeUser;
|
||||
}
|
||||
|
||||
void ButtonPanel::OnChangeUser(wxCommandEvent& event)
|
||||
void ButtonPanel::OnButtonAccount(wxCommandEvent& event)
|
||||
{
|
||||
_wxUI->ShowAccount();
|
||||
}
|
||||
|
||||
void ButtonPanel::OnButtonPreferences(wxCommandEvent& event)
|
||||
{
|
||||
_wxUI->ShowPreferences();
|
||||
}
|
||||
|
||||
void ButtonPanel::OnButtonChangeUser(wxCommandEvent& event)
|
||||
{
|
||||
_wxUI->ChangeUser();
|
||||
}
|
||||
|
@@ -22,7 +22,9 @@ public:
|
||||
ButtonPanel(KissCount* kiss, wxUI *parent);
|
||||
~ButtonPanel();
|
||||
|
||||
void OnChangeUser(wxCommandEvent& event);
|
||||
void OnButtonAccount(wxCommandEvent& event);
|
||||
void OnButtonPreferences(wxCommandEvent& event);
|
||||
void OnButtonChangeUser(wxCommandEvent& event);
|
||||
|
||||
private:
|
||||
KissCount* _kiss;
|
||||
|
79
view/PreferencesPanel.cpp
Normal file
79
view/PreferencesPanel.cpp
Normal file
@@ -0,0 +1,79 @@
|
||||
#include "PreferencesPanel.h"
|
||||
|
||||
|
||||
PreferencesPanel::PreferencesPanel(KissCount* kiss, wxUI *parent) : wxPanel(&(*parent)), _kiss(kiss), _wxUI(parent)
|
||||
{
|
||||
wxBoxSizer *vbox = new wxBoxSizer(wxVERTICAL);
|
||||
//wxBoxSizer *hbox = new wxBoxSizer(wxHORIZONTAL);
|
||||
wxStaticBox* staticUser, *staticAccount, *staticCategories;
|
||||
User* user = _kiss->GetUser();
|
||||
wxGridBagSizer *gridBagSizer;
|
||||
wxStaticText* label;
|
||||
wxButton* buttonChangeName, *buttonChangePassword;
|
||||
wxStaticBoxSizer * staticBoxSizer;
|
||||
wxTextCtrl* name;
|
||||
|
||||
SetSizer(vbox);
|
||||
|
||||
staticUser = new wxStaticBox(this, -1, _("User"));
|
||||
staticAccount = new wxStaticBox(this, -1, _("Accounts"));
|
||||
staticCategories = new wxStaticBox(this, -1, _("Categories"));
|
||||
|
||||
// User
|
||||
staticBoxSizer = new wxStaticBoxSizer (staticUser, wxVERTICAL);
|
||||
|
||||
gridBagSizer = new wxGridBagSizer(10, 10);
|
||||
staticBoxSizer->Add(gridBagSizer);
|
||||
|
||||
label = new wxStaticText(this, -1, _("Name"));
|
||||
gridBagSizer->Add(label, wxGBPosition(0, 0));
|
||||
|
||||
name = new wxTextCtrl(this, -1, user->_name);
|
||||
gridBagSizer->Add(name, wxGBPosition(0, 1));
|
||||
|
||||
buttonChangeName = new wxButton(this, -1, _("Change Name"));
|
||||
buttonChangePassword = new wxButton(this, -1, _("Change Password"));
|
||||
|
||||
gridBagSizer->Add(buttonChangeName, wxGBPosition(1, 0));
|
||||
gridBagSizer->Add(buttonChangePassword, wxGBPosition(1, 1));
|
||||
|
||||
vbox->Add(staticBoxSizer);
|
||||
vbox->Add(-1, 20);
|
||||
|
||||
// Account
|
||||
staticBoxSizer = new wxStaticBoxSizer (staticAccount, wxVERTICAL);
|
||||
|
||||
_accountGrid = new wxGrid(this, -1);
|
||||
|
||||
LoadAccounts(user);
|
||||
|
||||
staticBoxSizer->Add(_accountGrid);
|
||||
|
||||
vbox->Add(staticBoxSizer);
|
||||
vbox->Add(-1, 20);
|
||||
|
||||
// Categories
|
||||
staticBoxSizer = new wxStaticBoxSizer (staticCategories, wxVERTICAL);
|
||||
|
||||
_categoriesGrid = new wxGrid(this, -1);
|
||||
|
||||
staticBoxSizer->Add(_categoriesGrid);
|
||||
|
||||
vbox->Add(staticBoxSizer);
|
||||
|
||||
Fit();
|
||||
SetMinSize(GetSize());
|
||||
|
||||
Hide();
|
||||
}
|
||||
|
||||
void PreferencesPanel::LoadAccounts(User* user)
|
||||
{
|
||||
_accountGrid->CreateGrid(0, 5);
|
||||
_accountGrid->SetRowLabelSize(0);
|
||||
_accountGrid->SetColLabelValue(0, _("Name"));
|
||||
_accountGrid->SetColLabelValue(1, _("Number"));
|
||||
_accountGrid->SetColLabelValue(2, _("Shared"));
|
||||
_accountGrid->SetColLabelValue(3, _("Default"));
|
||||
_accountGrid->SetColLabelValue(4, _(""));
|
||||
}
|
34
view/PreferencesPanel.h
Normal file
34
view/PreferencesPanel.h
Normal file
@@ -0,0 +1,34 @@
|
||||
#ifndef PREFERENCESPANEL_H
|
||||
#define PREFERENCESPANEL_H
|
||||
|
||||
#include <wx/wx.h>
|
||||
#include <wx/grid.h>
|
||||
#include <wx/treectrl.h>
|
||||
#include <wx/statbox.h>
|
||||
#include <wx/gbsizer.h>
|
||||
#include <wx/stattext.h>
|
||||
#include <wx/textctrl.h>
|
||||
|
||||
#include <controller/KissCount.h>
|
||||
#include "wxUI.h"
|
||||
#include <model/model.h>
|
||||
|
||||
class wxUI;
|
||||
class KissCount;
|
||||
|
||||
class PreferencesPanel: public wxPanel
|
||||
{
|
||||
public:
|
||||
PreferencesPanel(KissCount* kiss, wxUI *parent);
|
||||
void ChangeUser();
|
||||
|
||||
private:
|
||||
KissCount* _kiss;
|
||||
wxUI* _wxUI;
|
||||
wxGrid* _accountGrid;
|
||||
wxGrid* _categoriesGrid;
|
||||
|
||||
void LoadAccounts(User* user);
|
||||
};
|
||||
|
||||
#endif
|
@@ -8,7 +8,7 @@ END_EVENT_TABLE()
|
||||
wxString months[12] = {_("january"), _("february"), _("march"), _("april"), _("may"), _("june"), _("july"), _("august"), _("september"), _("october"), _("november"), _("december")} ;
|
||||
|
||||
wxUI::wxUI(KissCount* kiss, const wxString& title, const wxPoint& pos, const wxSize& size)
|
||||
: wxFrame(NULL, -1, title, pos, size), _kiss(kiss)
|
||||
: wxFrame(NULL, -1, title, pos, size), _kiss(kiss), _accountPanel(NULL), _preferencesPanel(NULL), _curPanel(NULL)
|
||||
{
|
||||
_hbox = new wxBoxSizer(wxVERTICAL);
|
||||
ButtonPanel* buttons = new ButtonPanel(_kiss, this);
|
||||
@@ -34,6 +34,7 @@ wxUI::wxUI(KissCount* kiss, const wxString& title, const wxPoint& pos, const wxS
|
||||
wxUI::~wxUI()
|
||||
{
|
||||
if (_accountPanel) delete _accountPanel;
|
||||
if (_preferencesPanel) delete _preferencesPanel;
|
||||
}
|
||||
|
||||
void wxUI::OnQuit(wxCommandEvent& WXUNUSED(event))
|
||||
@@ -48,6 +49,17 @@ void wxUI::OnAbout(wxCommandEvent& WXUNUSED(event))
|
||||
wxOK | wxICON_INFORMATION, this );
|
||||
}
|
||||
|
||||
|
||||
void wxUI::ShowAccount()
|
||||
{
|
||||
ShowPanel(_accountPanel);
|
||||
}
|
||||
|
||||
void wxUI::ShowPreferences()
|
||||
{
|
||||
ShowPanel(_preferencesPanel);
|
||||
}
|
||||
|
||||
void wxUI::ChangeUser()
|
||||
{
|
||||
UsersDialog u(_kiss, this);
|
||||
@@ -56,12 +68,36 @@ void wxUI::ChangeUser()
|
||||
|
||||
void wxUI::LoadUser()
|
||||
{
|
||||
if (_accountPanel)
|
||||
if (_curPanel)
|
||||
{
|
||||
_hbox->Detach(_accountPanel);
|
||||
delete _accountPanel;
|
||||
_hbox->Detach(_curPanel);
|
||||
_curPanel = NULL;
|
||||
}
|
||||
|
||||
if (_accountPanel)
|
||||
delete _accountPanel;
|
||||
|
||||
if (_preferencesPanel)
|
||||
delete _preferencesPanel;
|
||||
|
||||
_accountPanel = new AccountPanel(_kiss, this);
|
||||
_hbox->Add(_accountPanel);
|
||||
_preferencesPanel = new PreferencesPanel(_kiss, this);
|
||||
|
||||
ShowPanel(_accountPanel);
|
||||
}
|
||||
|
||||
void wxUI::ShowPanel(wxPanel* panel)
|
||||
{
|
||||
if (!panel) return;
|
||||
|
||||
if (_curPanel)
|
||||
{
|
||||
_hbox->Detach(_curPanel);
|
||||
_curPanel->Hide();
|
||||
}
|
||||
|
||||
_curPanel = panel;
|
||||
_hbox->Add(panel);
|
||||
_curPanel->Show();
|
||||
Layout();
|
||||
}
|
||||
|
16
view/wxUI.h
16
view/wxUI.h
@@ -4,11 +4,13 @@
|
||||
#include <wx/wx.h>
|
||||
#include "AccountPanel.h"
|
||||
#include "ButtonPanel.h"
|
||||
#include "PreferencesPanel.h"
|
||||
#include "UsersDialog.h"
|
||||
#include <controller/KissCount.h>
|
||||
|
||||
class KissCount;
|
||||
class AccountPanel;
|
||||
class PreferencesPanel;
|
||||
|
||||
extern wxString months[12];
|
||||
|
||||
@@ -25,12 +27,20 @@ public:
|
||||
void ChangeUser();
|
||||
void LoadUser();
|
||||
|
||||
DECLARE_EVENT_TABLE();
|
||||
|
||||
void ShowAccount();
|
||||
void ShowPreferences();
|
||||
|
||||
private:
|
||||
KissCount *_kiss;
|
||||
wxBoxSizer *_hbox;
|
||||
AccountPanel *_accountPanel;
|
||||
KissCount *_kiss;
|
||||
PreferencesPanel *_preferencesPanel;
|
||||
wxPanel *_curPanel;
|
||||
|
||||
void ShowPanel(wxPanel* panel);
|
||||
|
||||
DECLARE_EVENT_TABLE();
|
||||
|
||||
};
|
||||
|
||||
enum
|
||||
|
Reference in New Issue
Block a user