Initial commit
A good base to start working
This commit is contained in:
21
view/AccountPanel.cpp
Normal file
21
view/AccountPanel.cpp
Normal file
@@ -0,0 +1,21 @@
|
||||
#include "AccountPanel.h"
|
||||
|
||||
|
||||
AccountPanel::AccountPanel(KissCount* kiss, wxUI *parent) : wxPanel(&(*parent)), _kiss(kiss), _wxUI(parent), _tree(this, -1), _grid(this, -1)
|
||||
{
|
||||
wxBoxSizer *hbox = new wxBoxSizer(wxHORIZONTAL);
|
||||
wxChartPanel* chart ;
|
||||
SetSizer(hbox);
|
||||
|
||||
_pie = new PiePlot();
|
||||
_grid.CreateGrid(10, 7);
|
||||
|
||||
chart = new wxChartPanel(this);
|
||||
chart->SetChart(new Chart(_pie, _("Cost repartition")));
|
||||
hbox->Add(&_tree, 0);
|
||||
hbox->Add(&_grid, 0);
|
||||
hbox->Add(chart, 0);
|
||||
|
||||
Fit();
|
||||
SetMinSize(GetSize());
|
||||
}
|
30
view/AccountPanel.h
Normal file
30
view/AccountPanel.h
Normal file
@@ -0,0 +1,30 @@
|
||||
#ifndef ACCOUNTPANEL_H
|
||||
#define ACCOUNTPANEL_H
|
||||
|
||||
#include <wx/wx.h>
|
||||
#include <wx/grid.h>
|
||||
#include <wx/treectrl.h>
|
||||
#include <wx/pie/pieplot.h>
|
||||
#include <wx/chartpanel.h>
|
||||
|
||||
#include <controller/KissCount.h>
|
||||
#include "wxUI.h"
|
||||
|
||||
class wxUI;
|
||||
class KissCount;
|
||||
|
||||
class AccountPanel: public wxPanel
|
||||
{
|
||||
public:
|
||||
|
||||
AccountPanel(KissCount* kiss, wxUI *parent);
|
||||
|
||||
private:
|
||||
KissCount* _kiss;
|
||||
wxUI* _wxUI;
|
||||
wxTreeCtrl _tree;
|
||||
wxGrid _grid;
|
||||
PiePlot* _pie;
|
||||
};
|
||||
|
||||
#endif
|
39
view/ButtonPanel.cpp
Normal file
39
view/ButtonPanel.cpp
Normal file
@@ -0,0 +1,39 @@
|
||||
#include "ButtonPanel.h"
|
||||
|
||||
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)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
ButtonPanel::ButtonPanel(KissCount* kiss, wxUI *parent) : wxPanel(&(*parent)), _kiss(kiss), _wxUI(parent)
|
||||
{
|
||||
wxBoxSizer *hbox = new wxBoxSizer(wxHORIZONTAL);
|
||||
_account = new wxBitmapButton(this, ID_BUTTON_ACCOUNT, wxBitmap(_(ACCOUNT_ICON)));
|
||||
_stats = new wxBitmapButton(this, ID_BUTTON_STATS, wxBitmap(_(STATS_ICON)));
|
||||
_prefs = new wxBitmapButton(this, ID_BUTTON_PREFS, wxBitmap(_(PREFS_ICON)));
|
||||
_changeUser = new wxBitmapButton(this, ID_BUTTON_CHANGE_USER, wxBitmap(_(CHANGE_USER_ICON)));
|
||||
|
||||
SetSizer(hbox);
|
||||
|
||||
hbox->Add(_account);
|
||||
hbox->Add(_stats);
|
||||
hbox->Add(_prefs);
|
||||
hbox->Add(_changeUser);
|
||||
|
||||
Fit();
|
||||
SetMinSize(GetSize());
|
||||
}
|
||||
|
||||
ButtonPanel::~ButtonPanel()
|
||||
{
|
||||
delete _account;
|
||||
delete _stats;
|
||||
delete _prefs;
|
||||
delete _changeUser;
|
||||
}
|
||||
|
||||
void ButtonPanel::OnChangeUser(wxCommandEvent& event)
|
||||
{
|
||||
_wxUI->ChangeUser();
|
||||
}
|
38
view/ButtonPanel.h
Normal file
38
view/ButtonPanel.h
Normal file
@@ -0,0 +1,38 @@
|
||||
#ifndef BUTTONPANEL_H
|
||||
#define BUTTONPANEL_H
|
||||
|
||||
#include <wx/wx.h>
|
||||
#include <wx/bmpbuttn.h>
|
||||
|
||||
#include <controller/KissCount.h>
|
||||
#include "wxUI.h"
|
||||
|
||||
#define ACCOUNT_ICON "ressources/administrator-icon.png"
|
||||
#define STATS_ICON "ressources/chart-icon.png"
|
||||
#define PREFS_ICON "ressources/options-icon.png"
|
||||
#define CHANGE_USER_ICON "ressources/Clients-icon.png"
|
||||
|
||||
class KissCount;
|
||||
class wxUI;
|
||||
|
||||
class ButtonPanel: public wxPanel
|
||||
{
|
||||
public:
|
||||
|
||||
ButtonPanel(KissCount* kiss, wxUI *parent);
|
||||
~ButtonPanel();
|
||||
|
||||
void OnChangeUser(wxCommandEvent& event);
|
||||
|
||||
private:
|
||||
KissCount* _kiss;
|
||||
wxUI* _wxUI;
|
||||
wxBitmapButton* _account;
|
||||
wxBitmapButton* _stats;
|
||||
wxBitmapButton* _prefs;
|
||||
wxBitmapButton* _changeUser;
|
||||
|
||||
DECLARE_EVENT_TABLE();
|
||||
};
|
||||
|
||||
#endif
|
73
view/UsersDialog.cpp
Normal file
73
view/UsersDialog.cpp
Normal file
@@ -0,0 +1,73 @@
|
||||
#include "UsersDialog.h"
|
||||
|
||||
enum {ID_BUTTON_OK=1, ID_BUTTON_CANCEL};
|
||||
|
||||
BEGIN_EVENT_TABLE(UsersDialog, wxDialog)
|
||||
EVT_BUTTON(ID_BUTTON_OK, UsersDialog::OnOK)
|
||||
EVT_BUTTON(ID_BUTTON_CANCEL, UsersDialog::OnCancel)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
UsersDialog::UsersDialog(KissCount* kiss, wxUI *parent) : wxDialog(&(*parent), -1, _("Users")), _kiss(kiss), _wxUI(parent)
|
||||
{
|
||||
wxBoxSizer *vbox = new wxBoxSizer(wxVERTICAL);
|
||||
wxBoxSizer *hbox = new wxBoxSizer(wxHORIZONTAL);
|
||||
wxBoxSizer *vbox1 = new wxBoxSizer(wxVERTICAL);
|
||||
wxBoxSizer *hbox1 = new wxBoxSizer(wxHORIZONTAL);
|
||||
|
||||
_users = new wxChoice(this, wxID_ANY);
|
||||
_password = new wxTextCtrl(this, wxID_ANY);
|
||||
|
||||
_password->SetWindowStyle(wxTE_PASSWORD);
|
||||
|
||||
wxButton* ok = new wxButton(this, ID_BUTTON_OK, _("OK"));
|
||||
wxButton* cancel = new wxButton(this, ID_BUTTON_CANCEL, _("Cancel"));
|
||||
|
||||
std::list<wxString> users_list = _kiss->GetUsers();
|
||||
|
||||
for(std::list<wxString>::iterator i = users_list.begin(); i != users_list.end(); i++)
|
||||
{
|
||||
_users->Append(*i);
|
||||
}
|
||||
|
||||
vbox1->Add(_users);
|
||||
vbox1->Add(-1, 10);
|
||||
vbox1->Add(_password);
|
||||
hbox->Add(vbox1, 0, wxEXPAND, 10);
|
||||
|
||||
hbox1->Add(ok);
|
||||
hbox1->Add(-1, 10);
|
||||
hbox1->Add(cancel);
|
||||
|
||||
vbox->Add(hbox, 0, wxALIGN_RIGHT | wxRIGHT | wxTOP, 10);
|
||||
vbox->Add(-1, 40);
|
||||
vbox->Add(hbox1, 0, wxALIGN_RIGHT | wxRIGHT | wxBOTTOM, 10);
|
||||
|
||||
Center();
|
||||
SetSizer(vbox);
|
||||
|
||||
Layout();
|
||||
}
|
||||
|
||||
void UsersDialog::OnOK(wxCommandEvent& event)
|
||||
{
|
||||
// No users in database
|
||||
if (!_users->GetStringSelection().Length())
|
||||
{
|
||||
Close();
|
||||
}
|
||||
|
||||
if (!_kiss->IsValidUser(_users->GetStringSelection(), _password->GetLineText(0)))
|
||||
{
|
||||
wxMessageBox(_("Invalid password"), _("Error"), wxICON_ERROR | wxOK );
|
||||
}
|
||||
else
|
||||
{
|
||||
_kiss->LoadUser(_users->GetStringSelection());
|
||||
Close();
|
||||
}
|
||||
}
|
||||
|
||||
void UsersDialog::OnCancel(wxCommandEvent& event)
|
||||
{
|
||||
Close();
|
||||
}
|
32
view/UsersDialog.h
Normal file
32
view/UsersDialog.h
Normal file
@@ -0,0 +1,32 @@
|
||||
#ifndef USERSDIALOG_H
|
||||
#define USERSDIALOG_H
|
||||
|
||||
#include <list>
|
||||
|
||||
#include <wx/wx.h>
|
||||
#include <wx/choice.h>
|
||||
#include <wx/textctrl.h>
|
||||
#include <controller/KissCount.h>
|
||||
#include "wxUI.h"
|
||||
|
||||
class wxUI;
|
||||
class KissCount;
|
||||
|
||||
class UsersDialog : public wxDialog
|
||||
{
|
||||
public:
|
||||
UsersDialog(KissCount* kiss, wxUI *parent);
|
||||
|
||||
void OnOK(wxCommandEvent& event);
|
||||
void OnCancel(wxCommandEvent& event);
|
||||
|
||||
private:
|
||||
KissCount* _kiss;
|
||||
wxUI* _wxUI;
|
||||
wxChoice* _users;
|
||||
wxTextCtrl* _password;
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
|
||||
};
|
||||
#endif
|
65
view/wxUI.cpp
Normal file
65
view/wxUI.cpp
Normal file
@@ -0,0 +1,65 @@
|
||||
#include "wxUI.h"
|
||||
|
||||
BEGIN_EVENT_TABLE(wxUI, wxFrame)
|
||||
EVT_MENU(ID_Quit, wxUI::OnQuit)
|
||||
EVT_MENU(ID_About, wxUI::OnAbout)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
wxUI::wxUI(KissCount* kiss, const wxString& title, const wxPoint& pos, const wxSize& size)
|
||||
: wxFrame(NULL, -1, title, pos, size), _kiss(kiss)
|
||||
{
|
||||
_hbox = new wxBoxSizer(wxVERTICAL);
|
||||
ButtonPanel* buttons = new ButtonPanel(_kiss, this);
|
||||
wxMenu *menuFile = new wxMenu;
|
||||
|
||||
menuFile->Append( ID_About, _("&About...") );
|
||||
menuFile->AppendSeparator();
|
||||
menuFile->Append( ID_Quit, _("E&xit") );
|
||||
|
||||
wxMenuBar *menuBar = new wxMenuBar;
|
||||
menuBar->Append( menuFile, _("&File") );
|
||||
|
||||
SetMenuBar( menuBar );
|
||||
|
||||
CreateStatusBar();
|
||||
SetStatusText( _("Welcome to wxWidgets!") );
|
||||
|
||||
SetSizer(_hbox);
|
||||
|
||||
_hbox->Add(buttons);
|
||||
}
|
||||
|
||||
wxUI::~wxUI()
|
||||
{
|
||||
if (_accountPanel) delete _accountPanel;
|
||||
}
|
||||
|
||||
void wxUI::OnQuit(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
Close(true);
|
||||
}
|
||||
|
||||
void wxUI::OnAbout(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
wxMessageBox( _("This is a wxWidgets Hello world sample"),
|
||||
_("About Hello World"),
|
||||
wxOK | wxICON_INFORMATION, this );
|
||||
}
|
||||
|
||||
void wxUI::ChangeUser()
|
||||
{
|
||||
UsersDialog u(_kiss, this);
|
||||
u.ShowModal();
|
||||
}
|
||||
|
||||
void wxUI::LoadUser()
|
||||
{
|
||||
if (_accountPanel)
|
||||
{
|
||||
_hbox->Detach(_accountPanel);
|
||||
delete _accountPanel;
|
||||
}
|
||||
_accountPanel = new AccountPanel(_kiss, this);
|
||||
_hbox->Add(_accountPanel);
|
||||
Layout();
|
||||
}
|
39
view/wxUI.h
Normal file
39
view/wxUI.h
Normal file
@@ -0,0 +1,39 @@
|
||||
#ifndef WXUI_H
|
||||
#define WXUI_H
|
||||
|
||||
#include <wx/wx.h>
|
||||
#include "AccountPanel.h"
|
||||
#include "ButtonPanel.h"
|
||||
#include "UsersDialog.h"
|
||||
#include <controller/KissCount.h>
|
||||
|
||||
class KissCount;
|
||||
class AccountPanel;
|
||||
|
||||
class wxUI: public wxFrame
|
||||
{
|
||||
public:
|
||||
|
||||
wxUI(KissCount* kiss, const wxString& title, const wxPoint& pos, const wxSize& size);
|
||||
~wxUI();
|
||||
|
||||
void OnQuit(wxCommandEvent& event);
|
||||
void OnAbout(wxCommandEvent& event);
|
||||
|
||||
void ChangeUser();
|
||||
void LoadUser();
|
||||
DECLARE_EVENT_TABLE();
|
||||
|
||||
private:
|
||||
wxBoxSizer *_hbox;
|
||||
AccountPanel *_accountPanel;
|
||||
KissCount *_kiss;
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
ID_Quit = 1,
|
||||
ID_About,
|
||||
};
|
||||
|
||||
#endif
|
Reference in New Issue
Block a user