Use new emacs indentation rules (4 spaces instead of tabs and braces position)~
This commit is contained in:
@@ -1,20 +1,20 @@
|
||||
/*
|
||||
Copyright 2010 Grégory Soutadé
|
||||
Copyright 2010 Grégory Soutadé
|
||||
|
||||
This file is part of KissCount.
|
||||
This file is part of KissCount.
|
||||
|
||||
KissCount is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
KissCount is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
KissCount is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
KissCount is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with KissCount. If not, see <http://www.gnu.org/licenses/>.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with KissCount. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "wxUI.h"
|
||||
@@ -34,187 +34,187 @@ wxColour categoryColors[12] = {wxColour(0x00, 0x45, 0x86),
|
||||
wxColour(0x00, 0x84, 0xD1)};
|
||||
|
||||
wxUI::wxUI(KissCount* kiss, const wxString& title, const wxPoint& pos, const wxSize& size)
|
||||
: wxFrame(NULL, wxID_ANY, title, pos, size), _kiss(kiss), _accountPanel(NULL), _statsPanel(NULL),
|
||||
_searchPanel(NULL), _preferencesPanel(NULL), _curPanel(NULL), _locale(NULL), _needReload(false)
|
||||
: wxFrame(NULL, wxID_ANY, title, pos, size), _kiss(kiss), _accountPanel(NULL), _statsPanel(NULL),
|
||||
_searchPanel(NULL), _preferencesPanel(NULL), _curPanel(NULL), _locale(NULL), _needReload(false)
|
||||
{
|
||||
_hbox = new wxBoxSizer(wxVERTICAL);
|
||||
ButtonPanel* buttons = new ButtonPanel(_kiss, this);
|
||||
// wxMenu *menuFile = new wxMenu;
|
||||
_hbox = new wxBoxSizer(wxVERTICAL);
|
||||
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!") );
|
||||
// CreateStatusBar();
|
||||
// SetStatusText( wxT("Welcome to wxWidgets!") );
|
||||
|
||||
SetSizer(_hbox);
|
||||
SetSizer(_hbox);
|
||||
|
||||
_hbox->Add(buttons);
|
||||
_hbox->Add(buttons);
|
||||
}
|
||||
|
||||
wxUI::~wxUI()
|
||||
{
|
||||
if (_accountPanel) delete _accountPanel;
|
||||
if (_preferencesPanel) delete _preferencesPanel;
|
||||
if (_searchPanel) delete _searchPanel;
|
||||
if (_statsPanel) delete _statsPanel;
|
||||
if (_locale) delete _locale;
|
||||
if (_accountPanel) delete _accountPanel;
|
||||
if (_preferencesPanel) delete _preferencesPanel;
|
||||
if (_searchPanel) delete _searchPanel;
|
||||
if (_statsPanel) delete _statsPanel;
|
||||
if (_locale) delete _locale;
|
||||
}
|
||||
|
||||
bool wxUI::SetLanguage(long language)
|
||||
{
|
||||
bool res = true;
|
||||
bool res = true;
|
||||
|
||||
if (_locale) delete _locale;
|
||||
_locale = NULL;
|
||||
if (_locale) delete _locale;
|
||||
_locale = NULL;
|
||||
|
||||
// load language if possible, fall back to english otherwise
|
||||
if(wxLocale::IsAvailable(language))
|
||||
// load language if possible, fall back to english otherwise
|
||||
if(wxLocale::IsAvailable(language))
|
||||
{
|
||||
_locale = new wxLocale( language, wxLOCALE_CONV_ENCODING );
|
||||
_locale = new wxLocale( language, wxLOCALE_CONV_ENCODING );
|
||||
|
||||
#ifdef __WXGTK__
|
||||
_locale->AddCatalogLookupPathPrefix(wxT("./ressources/po"));
|
||||
_locale->AddCatalogLookupPathPrefix(wxT("./ressources/po"));
|
||||
#endif
|
||||
|
||||
_locale->AddCatalog(wxT("french"));
|
||||
_locale->AddCatalog(wxT("kisscount"));
|
||||
_locale->AddCatalog(wxT("french"));
|
||||
_locale->AddCatalog(wxT("kisscount"));
|
||||
|
||||
_language = (wxLanguage) language;
|
||||
_language = (wxLanguage) language;
|
||||
}
|
||||
|
||||
if (_locale == NULL || !_locale->IsOk())
|
||||
if (_locale == NULL || !_locale->IsOk())
|
||||
{
|
||||
if (_locale) delete _locale;
|
||||
_locale = new wxLocale();
|
||||
if (_locale) delete _locale;
|
||||
_locale = new wxLocale();
|
||||
|
||||
#ifdef __WXGTK__
|
||||
_locale->AddCatalogLookupPathPrefix(wxT("./ressources/po"));
|
||||
_locale->AddCatalogLookupPathPrefix(wxT("./ressources/po"));
|
||||
#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] = _("march");
|
||||
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] = _("march");
|
||||
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;
|
||||
return res;
|
||||
}
|
||||
|
||||
void wxUI::ShowAccount()
|
||||
{
|
||||
ShowPanel(_accountPanel);
|
||||
ShowPanel(_accountPanel);
|
||||
}
|
||||
|
||||
void wxUI::ShowSearch()
|
||||
{
|
||||
ShowPanel(_searchPanel);
|
||||
ShowPanel(_searchPanel);
|
||||
}
|
||||
|
||||
void wxUI::ShowStats()
|
||||
{
|
||||
ShowPanel(_statsPanel);
|
||||
ShowPanel(_statsPanel);
|
||||
}
|
||||
|
||||
void wxUI::ShowPreferences()
|
||||
{
|
||||
ShowPanel(_preferencesPanel);
|
||||
ShowPanel(_preferencesPanel);
|
||||
}
|
||||
|
||||
void wxUI::ChangeUser()
|
||||
{
|
||||
UsersDialog u(_kiss, this);
|
||||
UsersDialog u(_kiss, this);
|
||||
}
|
||||
|
||||
void wxUI::LoadUser()
|
||||
{
|
||||
User* user = _kiss->GetUser();
|
||||
wxShowEvent event;
|
||||
User* user = _kiss->GetUser();
|
||||
wxShowEvent event;
|
||||
|
||||
if (_curPanel)
|
||||
if (_curPanel)
|
||||
{
|
||||
_hbox->Detach(_curPanel);
|
||||
_curPanel = NULL;
|
||||
_hbox->Detach(_curPanel);
|
||||
_curPanel = NULL;
|
||||
}
|
||||
|
||||
if (_accountPanel)
|
||||
delete _accountPanel;
|
||||
if (_accountPanel)
|
||||
delete _accountPanel;
|
||||
|
||||
if (_preferencesPanel)
|
||||
delete _preferencesPanel;
|
||||
if (_preferencesPanel)
|
||||
delete _preferencesPanel;
|
||||
|
||||
if (_searchPanel)
|
||||
delete _searchPanel;
|
||||
if (_searchPanel)
|
||||
delete _searchPanel;
|
||||
|
||||
if (_statsPanel)
|
||||
delete _statsPanel;
|
||||
if (_statsPanel)
|
||||
delete _statsPanel;
|
||||
|
||||
if (user->_preferences[wxT("language")].Length())
|
||||
SetLanguage(user->GetLanguage());
|
||||
if (user->_preferences[wxT("language")].Length())
|
||||
SetLanguage(user->GetLanguage());
|
||||
|
||||
_accountPanel = new AccountPanel(_kiss, this);
|
||||
_statsPanel = new StatsPanel(_kiss, this);
|
||||
_searchPanel = new SearchPanel(_kiss, this);
|
||||
_preferencesPanel = new PreferencesPanel(_kiss, this);
|
||||
_accountPanel = new AccountPanel(_kiss, this);
|
||||
_statsPanel = new StatsPanel(_kiss, this);
|
||||
_searchPanel = new SearchPanel(_kiss, this);
|
||||
_preferencesPanel = new PreferencesPanel(_kiss, this);
|
||||
|
||||
ShowPanel(_accountPanel);
|
||||
_accountPanel->OnShow(event);
|
||||
ShowPanel(_accountPanel);
|
||||
_accountPanel->OnShow(event);
|
||||
}
|
||||
|
||||
void wxUI::ShowPanel(wxPanel* panel)
|
||||
{
|
||||
int month, year, account=0, preferences=0, search=0, stats=0;
|
||||
wxShowEvent event;
|
||||
int month, year, account=0, preferences=0, search=0, stats=0;
|
||||
wxShowEvent event;
|
||||
|
||||
if (!panel) return;
|
||||
if (!panel) return;
|
||||
|
||||
if (_curPanel)
|
||||
if (_curPanel)
|
||||
{
|
||||
_hbox->Detach(_curPanel);
|
||||
_curPanel->Hide();
|
||||
_hbox->Detach(_curPanel);
|
||||
_curPanel->Hide();
|
||||
}
|
||||
|
||||
if (_needReload)
|
||||
if (_needReload)
|
||||
{
|
||||
if (panel == _accountPanel)
|
||||
if (panel == _accountPanel)
|
||||
{
|
||||
account = 1;
|
||||
month = _accountPanel->_curMonth;
|
||||
year = _accountPanel->_curYear;
|
||||
account = 1;
|
||||
month = _accountPanel->_curMonth;
|
||||
year = _accountPanel->_curYear;
|
||||
}
|
||||
|
||||
if (panel == _preferencesPanel)
|
||||
if (panel == _preferencesPanel)
|
||||
{
|
||||
preferences = 1;
|
||||
preferences = 1;
|
||||
}
|
||||
|
||||
if (panel == _searchPanel)
|
||||
if (panel == _searchPanel)
|
||||
{
|
||||
search = 1;
|
||||
search = 1;
|
||||
}
|
||||
|
||||
if (panel == _statsPanel)
|
||||
if (panel == _statsPanel)
|
||||
{
|
||||
stats = 1;
|
||||
stats = 1;
|
||||
}
|
||||
|
||||
delete _accountPanel;
|
||||
@@ -224,72 +224,72 @@ void wxUI::ShowPanel(wxPanel* panel)
|
||||
|
||||
_accountPanel = new AccountPanel(_kiss, this);
|
||||
if (year != -1)
|
||||
{
|
||||
{
|
||||
_kiss->LoadYear(year, true);
|
||||
_accountPanel->ShowMonth(month, year);
|
||||
}
|
||||
}
|
||||
_preferencesPanel = new PreferencesPanel(_kiss, this);
|
||||
_searchPanel = new SearchPanel(_kiss, this);
|
||||
_statsPanel = new StatsPanel(_kiss, this);
|
||||
|
||||
if (account)
|
||||
{
|
||||
{
|
||||
_accountPanel->OnShow(event);
|
||||
panel = _accountPanel;
|
||||
}
|
||||
}
|
||||
else if (preferences)
|
||||
{
|
||||
{
|
||||
_preferencesPanel->OnShow(event);
|
||||
panel = _preferencesPanel;
|
||||
}
|
||||
}
|
||||
else if (search)
|
||||
{
|
||||
{
|
||||
_searchPanel->OnShow(event);
|
||||
panel = _searchPanel;
|
||||
}
|
||||
}
|
||||
else if (stats)
|
||||
{
|
||||
{
|
||||
_statsPanel->OnShow(event);
|
||||
panel = _statsPanel;
|
||||
}
|
||||
}
|
||||
|
||||
_needReload = false;
|
||||
_needReload = false;
|
||||
}
|
||||
|
||||
_curPanel = panel;
|
||||
_hbox->Add(panel);
|
||||
_curPanel->Show();
|
||||
Layout();
|
||||
_curPanel = panel;
|
||||
_hbox->Add(panel);
|
||||
_curPanel->Show();
|
||||
Layout();
|
||||
}
|
||||
|
||||
void wxUI::GenerateMonth(int month, int year)
|
||||
{
|
||||
_accountPanel->GenerateMonth(month, year);
|
||||
_accountPanel->GenerateMonth(month, year);
|
||||
}
|
||||
|
||||
void wxUI::KillMe()
|
||||
{
|
||||
if (_curPanel)
|
||||
if (_curPanel)
|
||||
{
|
||||
_hbox->Detach(_curPanel);
|
||||
_curPanel = NULL;
|
||||
_hbox->Detach(_curPanel);
|
||||
_curPanel = NULL;
|
||||
}
|
||||
|
||||
if (_accountPanel)
|
||||
delete _accountPanel;
|
||||
if (_accountPanel)
|
||||
delete _accountPanel;
|
||||
|
||||
if (_preferencesPanel)
|
||||
delete _preferencesPanel;
|
||||
if (_preferencesPanel)
|
||||
delete _preferencesPanel;
|
||||
|
||||
if (_searchPanel)
|
||||
delete _searchPanel;
|
||||
if (_searchPanel)
|
||||
delete _searchPanel;
|
||||
|
||||
_accountPanel = NULL;
|
||||
_preferencesPanel = NULL;
|
||||
_searchPanel = NULL;
|
||||
_accountPanel = NULL;
|
||||
_preferencesPanel = NULL;
|
||||
_searchPanel = NULL;
|
||||
}
|
||||
|
||||
void wxUI::NeedReload()
|
||||
{
|
||||
_needReload = true;
|
||||
_needReload = true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user