First pass
This commit is contained in:
@@ -17,7 +17,7 @@
|
||||
along with KissCount. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "AccountPanel.hpp"
|
||||
/*#include "AccountPanel.hpp"
|
||||
#include "PreferencesPanel.hpp"
|
||||
#include "UsersDialog.hpp"
|
||||
#include "GenerateDialog.hpp"
|
||||
@@ -30,121 +30,115 @@
|
||||
#include "grid/wxGridCellFastBoolEditor.hpp"
|
||||
#include "grid/wxGridCellButtonRenderer.hpp"
|
||||
#include "grid/wxGridCellButtonEditor.hpp"
|
||||
|
||||
*/
|
||||
#include "wxUI.hpp"
|
||||
|
||||
enum {BUTTON_CHANGE_USER_ID=-4, BUTTON_ABOUT_ID=-5, BUTTON_QUIT_ID=-6};
|
||||
|
||||
BEGIN_EVENT_TABLE(wxUI, wxFrame)
|
||||
EVT_BUTTON(BUTTON_CHANGE_USER_ID, wxUI::OnButtonChangeUser)
|
||||
EVT_BUTTON(BUTTON_ABOUT_ID, wxUI::OnButtonAbout)
|
||||
EVT_BUTTON(BUTTON_QUIT_ID, wxUI::OnButtonQuit)
|
||||
END_EVENT_TABLE()
|
||||
std::string wxUI::months[12] ;
|
||||
QColor wxUI::categoryColors[MAX_CATEGORY] = {QColor(0x00, 0x45, 0x86),
|
||||
QColor(0xFF, 0x3E, 0x0E),
|
||||
QColor(0xFF, 0xD3, 0x20),
|
||||
QColor(0x58, 0x9D, 0x1B),
|
||||
QColor(0x7E, 0x00, 0x21),
|
||||
QColor(0x83, 0xCC, 0xFF),
|
||||
QColor(0x31, 0x40, 0x04),
|
||||
QColor(0xB0, 0xCF, 0x00),
|
||||
QColor(0x4B, 0x1F, 0x6F),
|
||||
QColor(0xFF, 0x93, 0x0E),
|
||||
QColor(0xC5, 0x00, 0x0D),
|
||||
QColor(0x00, 0x84, 0xD1)};
|
||||
|
||||
wxString wxUI::months[12] ;
|
||||
wxColour wxUI::categoryColors[MAX_CATEGORY] = {wxColour(0x00, 0x45, 0x86),
|
||||
wxColour(0xFF, 0x3E, 0x0E),
|
||||
wxColour(0xFF, 0xD3, 0x20),
|
||||
wxColour(0x58, 0x9D, 0x1B),
|
||||
wxColour(0x7E, 0x00, 0x21),
|
||||
wxColour(0x83, 0xCC, 0xFF),
|
||||
wxColour(0x31, 0x40, 0x04),
|
||||
wxColour(0xB0, 0xCF, 0x00),
|
||||
wxColour(0x4B, 0x1F, 0x6F),
|
||||
wxColour(0xFF, 0x93, 0x0E),
|
||||
wxColour(0xC5, 0x00, 0x0D),
|
||||
wxColour(0x00, 0x84, 0xD1)};
|
||||
|
||||
wxUI::wxUI(KissCount* kiss, const wxString& title, const wxPoint& pos, const wxSize& size)
|
||||
: wxFrame(0, -1, title, pos, size), _kiss(kiss),
|
||||
wxUI::wxUI(KissCount* kiss, const QString& title)
|
||||
: QFrame(0), _kiss(kiss),
|
||||
_curPanel(0), _locale(0), _needReload(false)
|
||||
{
|
||||
wxInitAllImageHandlers();
|
||||
setWindowTitle(title);
|
||||
|
||||
_vbox = new wxBoxSizer(wxVERTICAL);
|
||||
_buttonsBox = new wxBoxSizer(wxHORIZONTAL);
|
||||
// ButtonPanel* buttons = new ButtonPanel(_kiss, this);
|
||||
// wxMenu *menuFile = new wxMenu;
|
||||
// _vbox = new wxBoxSizer(wxVERTICAL);
|
||||
// _buttonsBox = new wxBoxSizer(wxHORIZONTAL);
|
||||
// // ButtonPanel* buttons = new ButtonPanel(_kiss, this);
|
||||
// // wxMenu *menuFile = new wxMenu;
|
||||
|
||||
// menuFile->Append( ID_About, wxT("&About...") );
|
||||
// menuFile->AppendSeparator();
|
||||
// menuFile->Append( ID_Quit, wxT("E&xit") );
|
||||
// // menuFile->Append( ID_About, wxT("&About...") );
|
||||
// // menuFile->AppendSeparator();
|
||||
// // menuFile->Append( ID_Quit, wxT("E&xit") );
|
||||
|
||||
// wxMenuBar *menuBar = new wxMenuBar;
|
||||
// menuBar->Append( menuFile, wxT("&File") );
|
||||
// // wxMenuBar *menuBar = new wxMenuBar;
|
||||
// // menuBar->Append( menuFile, wxT("&File") );
|
||||
|
||||
// SetMenuBar( menuBar );
|
||||
// // SetMenuBar( menuBar );
|
||||
|
||||
// CreateStatusBar();
|
||||
// SetStatusText( wxT("Welcome to wxWidgets!") );
|
||||
_buttonsBox->Add(new wxBitmapButton(this, BUTTON_CHANGE_USER_ID, wxBitmap(wxT(CHANGE_USER_ICON), wxBITMAP_TYPE_PNG), wxDefaultPosition, wxSize(128, 128)));
|
||||
_buttonsBox->Add(new wxBitmapButton(this, BUTTON_ABOUT_ID, wxBitmap(wxT(ABOUT_ICON), wxBITMAP_TYPE_PNG), wxDefaultPosition, wxSize(128, 128)));
|
||||
_buttonsBox->Add(new wxBitmapButton(this, BUTTON_QUIT_ID, wxBitmap(wxT(QUIT_ICON), wxBITMAP_TYPE_PNG), wxDefaultPosition, wxSize(128, 128)));
|
||||
// // CreateStatusBar();
|
||||
// // SetStatusText( wxT("Welcome to wxWidgets!") );
|
||||
// _buttonsBox->Add(new wxBitmapButton(this, BUTTON_CHANGE_USER_ID, wxBitmap(wxT(CHANGE_USER_ICON), wxBITMAP_TYPE_PNG), wxDefaultPosition, wxSize(128, 128)));
|
||||
// _buttonsBox->Add(new wxBitmapButton(this, BUTTON_ABOUT_ID, wxBitmap(wxT(ABOUT_ICON), wxBITMAP_TYPE_PNG), wxDefaultPosition, wxSize(128, 128)));
|
||||
// _buttonsBox->Add(new wxBitmapButton(this, BUTTON_QUIT_ID, wxBitmap(wxT(QUIT_ICON), wxBITMAP_TYPE_PNG), wxDefaultPosition, wxSize(128, 128)));
|
||||
|
||||
SetSizer(_vbox);
|
||||
// SetSizer(_vbox);
|
||||
|
||||
_vbox->Add(_buttonsBox, 0, wxGROW);
|
||||
// _vbox->Add(_buttonsBox, 0, wxGROW);
|
||||
}
|
||||
|
||||
wxUI::~wxUI()
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i=0; i<(int)_panels.size(); i++)
|
||||
Disconnect(i, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(wxUI::OnButtonClicked), _panels[i], this);
|
||||
// for (i=0; i<(int)_panels.size(); i++)
|
||||
// Disconnect(i, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(wxUI::OnButtonClicked), _panels[i], this);
|
||||
|
||||
if (_locale) delete _locale;
|
||||
}
|
||||
|
||||
bool wxUI::SetLanguage(long language)
|
||||
bool wxUI::SetLanguage(std::string language)
|
||||
{
|
||||
bool res = true;
|
||||
|
||||
if (_locale) delete _locale;
|
||||
_locale = 0;
|
||||
// if (_locale) delete _locale;
|
||||
// _locale = 0;
|
||||
|
||||
// load language if possible, fall back to english otherwise
|
||||
if(wxLocale::IsAvailable(language))
|
||||
{
|
||||
_locale = new wxLocale( language, wxLOCALE_CONV_ENCODING );
|
||||
// // load language if possible, fall back to english otherwise
|
||||
// if(wxLocale::IsAvailable(language))
|
||||
// {
|
||||
// _locale = new wxLocale( language, wxLOCALE_CONV_ENCODING );
|
||||
|
||||
#ifdef __WXGTK__
|
||||
_locale->AddCatalogLookupPathPrefix(wxT(LANG_ROOT));
|
||||
#endif
|
||||
// #ifdef __WXGTK__
|
||||
// _locale->AddCatalogLookupPathPrefix(wxT(LANG_ROOT));
|
||||
// #endif
|
||||
|
||||
_locale->AddCatalog(wxT("frenchpp"));
|
||||
_locale->AddCatalog(wxT("kisscount"));
|
||||
// _locale->AddCatalog(wxT("frenchpp"));
|
||||
// _locale->AddCatalog(wxT("kisscount"));
|
||||
|
||||
_language = (wxLanguage) language;
|
||||
}
|
||||
// _language = (wxLanguage) language;
|
||||
// }
|
||||
|
||||
if (_locale == 0 || !_locale->IsOk())
|
||||
{
|
||||
if (_locale) delete _locale;
|
||||
_locale = new wxLocale();
|
||||
// if (_locale == 0 || !_locale->IsOk())
|
||||
// {
|
||||
// if (_locale) delete _locale;
|
||||
// _locale = new wxLocale();
|
||||
|
||||
#ifdef __WXGTK__
|
||||
_locale->AddCatalogLookupPathPrefix(wxT(LANG_ROOT));
|
||||
#endif
|
||||
// #ifdef __WXGTK__
|
||||
// _locale->AddCatalogLookupPathPrefix(wxT(LANG_ROOT));
|
||||
// #endif
|
||||
|
||||
_locale->AddCatalog(wxT("kisscount"));
|
||||
// _locale->AddCatalog(wxT("kisscount"));
|
||||
|
||||
_language = wxLANGUAGE_ENGLISH;
|
||||
res = false;
|
||||
}
|
||||
// _language = wxLANGUAGE_ENGLISH;
|
||||
// res = false;
|
||||
// }
|
||||
|
||||
months[0] = _("january");
|
||||
months[1] = _("february");
|
||||
months[2] = _("marchpp");
|
||||
months[3] = _("april");
|
||||
months[4] = _("may");
|
||||
months[5] = _("june");
|
||||
months[6] = _("july");
|
||||
months[7] = _("august");
|
||||
months[8] = _("september");
|
||||
months[9] = _("october");
|
||||
months[10] = _("november");
|
||||
months[11] = _("december") ;
|
||||
// months[0] = _("january");
|
||||
// months[1] = _("february");
|
||||
// months[2] = _("marchpp");
|
||||
// months[3] = _("april");
|
||||
// months[4] = _("may");
|
||||
// months[5] = _("june");
|
||||
// months[6] = _("july");
|
||||
// months[7] = _("august");
|
||||
// months[8] = _("september");
|
||||
// months[9] = _("october");
|
||||
// months[10] = _("november");
|
||||
// months[11] = _("december") ;
|
||||
|
||||
return res;
|
||||
}
|
||||
@@ -160,50 +154,50 @@ bool wxUI::SetLanguage(long language)
|
||||
|
||||
void wxUI::InitPanels()
|
||||
{
|
||||
KissPanel* panel;
|
||||
wxBitmapButton* button;
|
||||
_panels.clear();
|
||||
// KissPanel* panel;
|
||||
// wxBitmapButton* button;
|
||||
// _panels.clear();
|
||||
|
||||
ADD_PANEL(AccountPanel, 0);
|
||||
ADD_PANEL(StatsPanel, 1);
|
||||
ADD_PANEL(SearchPanel, 2);
|
||||
ADD_PANEL(PreferencesPanel, 3);
|
||||
ADD_PANEL(ImportPanel, 4);
|
||||
ADD_PANEL(ExportPanel, 5);
|
||||
// ADD_PANEL(AccountPanel, 0);
|
||||
// ADD_PANEL(StatsPanel, 1);
|
||||
// ADD_PANEL(SearchPanel, 2);
|
||||
// ADD_PANEL(PreferencesPanel, 3);
|
||||
// ADD_PANEL(ImportPanel, 4);
|
||||
// ADD_PANEL(ExportPanel, 5);
|
||||
}
|
||||
|
||||
void wxUI::LoadPanels()
|
||||
{
|
||||
std::vector<KissPanel*>::iterator it;
|
||||
KissPanel* temp;
|
||||
int i;
|
||||
// std::vector<KissPanel*>::iterator it;
|
||||
// KissPanel* temp;
|
||||
// int i;
|
||||
|
||||
if (_curPanel)
|
||||
{
|
||||
_vbox->Detach(_curPanel);
|
||||
_curPanel = 0;
|
||||
}
|
||||
// if (_curPanel)
|
||||
// {
|
||||
// _vbox->Detach(_curPanel);
|
||||
// _curPanel = 0;
|
||||
// }
|
||||
|
||||
if (_panels.size())
|
||||
{
|
||||
for (i=0; i<(int)_panels.size(); i++)
|
||||
{
|
||||
temp = _panels[i]->CreatePanel();
|
||||
Disconnect(i, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(wxUI::OnButtonClicked), _panels[i], this);
|
||||
_panels[i] = temp;
|
||||
Connect(i, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(wxUI::OnButtonClicked), temp, this);
|
||||
_buttons[i]->SetToolTip(temp->GetToolTip());
|
||||
}
|
||||
}
|
||||
else
|
||||
InitPanels();
|
||||
// if (_panels.size())
|
||||
// {
|
||||
// for (i=0; i<(int)_panels.size(); i++)
|
||||
// {
|
||||
// temp = _panels[i]->CreatePanel();
|
||||
// Disconnect(i, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(wxUI::OnButtonClicked), _panels[i], this);
|
||||
// _panels[i] = temp;
|
||||
// Connect(i, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(wxUI::OnButtonClicked), temp, this);
|
||||
// _buttons[i]->SetToolTip(temp->GetToolTip());
|
||||
// }
|
||||
// }
|
||||
// else
|
||||
// InitPanels();
|
||||
}
|
||||
|
||||
void wxUI::LoadUser()
|
||||
{
|
||||
User* user = _kiss->GetUser();
|
||||
|
||||
if (user->_preferences[wxT("language")] != wxT(""))
|
||||
if (user->_preferences["language"].size())
|
||||
SetLanguage(user->GetLanguage());
|
||||
|
||||
LoadPanels();
|
||||
@@ -214,92 +208,92 @@ void wxUI::LoadUser()
|
||||
|
||||
void wxUI::ShowPanel(KissPanel* panel)
|
||||
{
|
||||
wxShowEvent event;
|
||||
int i;
|
||||
User* user = _kiss->GetUser();
|
||||
// wxShowEvent event;
|
||||
// int i;
|
||||
// User* user = _kiss->GetUser();
|
||||
|
||||
if (!panel) return;
|
||||
// if (!panel) return;
|
||||
|
||||
if (_curPanel)
|
||||
{
|
||||
_vbox->Detach(_curPanel);
|
||||
_curPanel->Hide();
|
||||
}
|
||||
// if (_curPanel)
|
||||
// {
|
||||
// _vbox->Detach(_curPanel);
|
||||
// _curPanel->Hide();
|
||||
// }
|
||||
|
||||
if (_needReload)
|
||||
{
|
||||
user->InvalidateOperations();
|
||||
for(i=0; i<(int)_panels.size(); i++)
|
||||
if (_panels[i] == panel) break;
|
||||
LoadPanels();
|
||||
_needReload = false;
|
||||
_curPanel = _panels[i];
|
||||
}
|
||||
else
|
||||
_curPanel = panel;
|
||||
// if (_needReload)
|
||||
// {
|
||||
// user->InvalidateOperations();
|
||||
// for(i=0; i<(int)_panels.size(); i++)
|
||||
// if (_panels[i] == panel) break;
|
||||
// LoadPanels();
|
||||
// _needReload = false;
|
||||
// _curPanel = _panels[i];
|
||||
// }
|
||||
// else
|
||||
// _curPanel = panel;
|
||||
|
||||
_curPanel->OnShow(event);
|
||||
_vbox->Add(_curPanel);
|
||||
_curPanel->Show();
|
||||
Layout();
|
||||
// _curPanel->OnShow(event);
|
||||
// _vbox->Add(_curPanel);
|
||||
// _curPanel->Show();
|
||||
// Layout();
|
||||
}
|
||||
|
||||
void wxUI::OnButtonClicked(wxCommandEvent& event)
|
||||
void wxUI::OnButtonClicked(QEvent& event)
|
||||
{
|
||||
ShowPanel(_panels[event.GetId()]);
|
||||
// ShowPanel(_panels[event.GetId()]);
|
||||
}
|
||||
|
||||
void wxUI::OnButtonChangeUser(wxCommandEvent& event)
|
||||
void wxUI::OnButtonChangeUser(QEvent& event)
|
||||
{
|
||||
ChangeUser();
|
||||
}
|
||||
|
||||
void wxUI::ChangeUser()
|
||||
{
|
||||
UsersDialog u(_kiss, this);
|
||||
// UsersDialog u(_kiss, this);
|
||||
}
|
||||
|
||||
void wxUI::OnButtonAbout(wxCommandEvent& event)
|
||||
void wxUI::OnButtonAbout(QEvent& event)
|
||||
{
|
||||
wxMessageBox( _("Personal accounting software\n\nhttp://indefero.soutade.fr/p/kisscount/\n\nLicenced under GNU GPL v3\n\nCopyright (C) 2010-2011 Grégory Soutadé"),
|
||||
wxT("KissCount " APP_VERSION "\n\n"),
|
||||
wxOK | wxICON_INFORMATION, this );
|
||||
// wxMessageBox( _("Personal accounting software\n\nhttp://indefero.soutade.fr/p/kisscount/\n\nLicenced under GNU GPL v3\n\nCopyright (C) 2010-2011 Grégory Soutadé"),
|
||||
// wxT("KissCount " APP_VERSION "\n\n"),
|
||||
// wxOK | wxICON_INFORMATION, this );
|
||||
}
|
||||
|
||||
void wxUI::OnButtonQuit(wxCommandEvent& event)
|
||||
void wxUI::OnButtonQuit(QEvent& event)
|
||||
{
|
||||
wxMessageDialog dialog(this, _("Quit KissCount ?"), wxT("KissCount"), wxYES_NO);
|
||||
if (dialog.ShowModal() == wxID_NO)
|
||||
{
|
||||
return;
|
||||
}
|
||||
// wxMessageDialog dialog(this, _("Quit KissCount ?"), wxT("KissCount"), wxYES_NO);
|
||||
// if (dialog.ShowModal() == wxID_NO)
|
||||
// {
|
||||
// return;
|
||||
// }
|
||||
|
||||
Close(true);
|
||||
// Close(true);
|
||||
}
|
||||
|
||||
void wxUI::GenerateMonth(int month, int year)
|
||||
{
|
||||
((AccountPanel*)_panels[0])->GenerateMonth(month, year);
|
||||
// ((AccountPanel*)_panels[0])->GenerateMonth(month, year);
|
||||
}
|
||||
|
||||
void wxUI::KillMe()
|
||||
{
|
||||
std::vector<KissPanel*>::iterator it;
|
||||
// std::vector<KissPanel*>::iterator it;
|
||||
|
||||
if (_curPanel)
|
||||
{
|
||||
_vbox->Detach(_curPanel);
|
||||
_curPanel = 0;
|
||||
}
|
||||
// if (_curPanel)
|
||||
// {
|
||||
// _vbox->Detach(_curPanel);
|
||||
// _curPanel = 0;
|
||||
// }
|
||||
|
||||
for (it=_panels.begin(); it!= _panels.end(); it++)
|
||||
{
|
||||
if (*it) delete *it;
|
||||
_buttonsBox->Remove(0);
|
||||
_buttons.erase(_buttons.begin());
|
||||
}
|
||||
// for (it=_panels.begin(); it!= _panels.end(); it++)
|
||||
// {
|
||||
// if (*it) delete *it;
|
||||
// _buttonsBox->Remove(0);
|
||||
// _buttons.erase(_buttons.begin());
|
||||
// }
|
||||
|
||||
_panels.clear();
|
||||
// _panels.clear();
|
||||
}
|
||||
|
||||
void wxUI::NeedReload()
|
||||
|
||||
Reference in New Issue
Block a user