Initial commit
37
AppMeganekko.cpp
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
/*
|
||||||
|
Meganekko Copyright (C) 2008 Alex Yatskov
|
||||||
|
|
||||||
|
This program 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.
|
||||||
|
|
||||||
|
This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "Pch.h"
|
||||||
|
#include "AppMeganekko.h"
|
||||||
|
#include "FrameMeganekko.h"
|
||||||
|
|
||||||
|
bool AppMeganekko::OnInit()
|
||||||
|
{
|
||||||
|
srand(time(NULL));
|
||||||
|
|
||||||
|
wxInitAllImageHandlers();
|
||||||
|
wxFileSystem::AddHandler(new wxInternetFSHandler());
|
||||||
|
wxXmlResource::Get()->InitAllHandlers();
|
||||||
|
void InitXmlResource();
|
||||||
|
InitXmlResource();
|
||||||
|
|
||||||
|
const wxString filename = argc > 1 ? argv[1] : wxEmptyString;
|
||||||
|
FrameMeganekko* frame = new FrameMeganekko(filename);
|
||||||
|
frame->Show(true);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
26
AppMeganekko.h
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
/*
|
||||||
|
Meganekko Copyright (C) 2008 Alex Yatskov
|
||||||
|
|
||||||
|
This program 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.
|
||||||
|
|
||||||
|
This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
class AppMeganekko : public wxApp
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual bool OnInit();
|
||||||
|
};
|
||||||
|
|
||||||
|
IMPLEMENT_APP(AppMeganekko);
|
106
Common.cpp
Normal file
@ -0,0 +1,106 @@
|
|||||||
|
/*
|
||||||
|
Meganekko Copyright (C) 2008 Alex Yatskov
|
||||||
|
|
||||||
|
This program 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.
|
||||||
|
|
||||||
|
This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "Pch.h"
|
||||||
|
#include "Common.h"
|
||||||
|
|
||||||
|
std::string DeckTypeToString(DeckType type)
|
||||||
|
{
|
||||||
|
switch (type)
|
||||||
|
{
|
||||||
|
case DECK_TYPE_EXPIRED:
|
||||||
|
return "expired";
|
||||||
|
case DECK_TYPE_FAILED:
|
||||||
|
return "failed";
|
||||||
|
case DECK_TYPE_PENDING:
|
||||||
|
return "pending";
|
||||||
|
default:
|
||||||
|
return "untested";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
DeckType StringToDeckType(const std::string& string)
|
||||||
|
{
|
||||||
|
if (string == "expired")
|
||||||
|
{
|
||||||
|
return DECK_TYPE_EXPIRED;
|
||||||
|
}
|
||||||
|
else if (string == "failed")
|
||||||
|
{
|
||||||
|
return DECK_TYPE_FAILED;
|
||||||
|
}
|
||||||
|
else if (string == "pending")
|
||||||
|
{
|
||||||
|
return DECK_TYPE_PENDING;
|
||||||
|
}
|
||||||
|
return DECK_TYPE_UNTESTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::wstring TimeToString(time_t time)
|
||||||
|
{
|
||||||
|
char* const string = ctime(&time);
|
||||||
|
|
||||||
|
for (char* iter = string; *iter != 0; ++iter)
|
||||||
|
{
|
||||||
|
switch (*iter)
|
||||||
|
{
|
||||||
|
case 0x0d:
|
||||||
|
case 0x0a:
|
||||||
|
*iter = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return utf8toWStr(string);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::wstring TimeToStringRel(time_t timeValue, time_t timeNow)
|
||||||
|
{
|
||||||
|
if (timeNow == 0)
|
||||||
|
{
|
||||||
|
timeNow = time(NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
static const char* s_suffixes[] = { "ago", "from now" };
|
||||||
|
|
||||||
|
const time_t timeDelta = std::max(timeValue, timeNow) - std::min(timeValue, timeNow);
|
||||||
|
const char* suffix = s_suffixes[timeValue > timeNow];
|
||||||
|
char buffer[256] = {0};
|
||||||
|
|
||||||
|
const int days = timeDelta / 86400;
|
||||||
|
const int hours = (timeDelta % 86400) / 3600;
|
||||||
|
const int minutes = (timeDelta % 3600) / 60;
|
||||||
|
const int seconds = timeDelta % 60;
|
||||||
|
|
||||||
|
if (days > 0)
|
||||||
|
{
|
||||||
|
sprintf(buffer, "%d day(s) %s", days, suffix);
|
||||||
|
}
|
||||||
|
else if (hours > 0)
|
||||||
|
{
|
||||||
|
sprintf(buffer, "%d hour(s) %s", hours, suffix);
|
||||||
|
}
|
||||||
|
else if (minutes > 0)
|
||||||
|
{
|
||||||
|
sprintf(buffer, "%d minute(s) %s", minutes, suffix);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sprintf(buffer, "%d second(s) %s", seconds, suffix);
|
||||||
|
}
|
||||||
|
|
||||||
|
return utf8toWStr(buffer);
|
||||||
|
}
|
63
Common.h
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
/*
|
||||||
|
Meganekko Copyright (C) 2008 Alex Yatskov
|
||||||
|
|
||||||
|
This program 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.
|
||||||
|
|
||||||
|
This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#define ASSERT assert
|
||||||
|
#define IS_TRUE(x) ((x) ? true : false)
|
||||||
|
#define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))
|
||||||
|
#define BIT(x) (1 << (x))
|
||||||
|
#define SECONDS_TO_DAYS(seconds) (seconds / 86400)
|
||||||
|
#define DAYS_TO_SECONDS(days) (days * 86400)
|
||||||
|
|
||||||
|
enum DeckType
|
||||||
|
{
|
||||||
|
DECK_TYPE_EXPIRED,
|
||||||
|
DECK_TYPE_FAILED,
|
||||||
|
DECK_TYPE_UNTESTED,
|
||||||
|
DECK_TYPE_PENDING,
|
||||||
|
DECK_TYPES
|
||||||
|
};
|
||||||
|
|
||||||
|
enum DeckSortType
|
||||||
|
{
|
||||||
|
DECK_SORT_TYPE_TIME_ADDED,
|
||||||
|
DECK_SORT_TYPE_TIME_REVIEW_PREVIOUS,
|
||||||
|
DECK_SORT_TYPE_TIME_REVIEW_NEXT,
|
||||||
|
DECK_SORT_TYPE_DECK,
|
||||||
|
DECK_SORT_TYPE_ENABLED,
|
||||||
|
DECK_SORT_TYPE_QUESTION,
|
||||||
|
DECK_SORT_TYPE_ANSWER,
|
||||||
|
DECK_SORT_TYPE_COUNT_REMEMBERED,
|
||||||
|
DECK_SORT_TYPE_COUNT_FORGOTTEN,
|
||||||
|
DECK_SORT_TYPE_COUNT_BUNGLED,
|
||||||
|
DECK_SORT_TYPE_SHUFFLE
|
||||||
|
};
|
||||||
|
|
||||||
|
enum GradeType
|
||||||
|
{
|
||||||
|
GRADE_TYPE_REMEMBER,
|
||||||
|
GRADE_TYPE_BUNGLE,
|
||||||
|
GRADE_TYPE_FORGET,
|
||||||
|
GRADE_TYPE_LEARN,
|
||||||
|
GRADE_TYPE_UNLEARN,
|
||||||
|
};
|
||||||
|
|
||||||
|
std::string DeckTypeToString(DeckType type);
|
||||||
|
DeckType StringToDeckType(const std::string& string);
|
||||||
|
std::wstring TimeToStringRel(time_t timeValue, time_t timeNow = 0);
|
||||||
|
std::wstring TimeToString(time_t time);
|
25
DialogAbout.cpp
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
/*
|
||||||
|
Meganekko Copyright (C) 2008 Alex Yatskov
|
||||||
|
|
||||||
|
This program 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.
|
||||||
|
|
||||||
|
This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "Pch.h"
|
||||||
|
#include "DialogAbout.h"
|
||||||
|
|
||||||
|
DialogAbout::DialogAbout(wxWindow* parent)
|
||||||
|
{
|
||||||
|
wxXmlResource::Get()->LoadDialog(this, parent, wxT("DialogAbout"));
|
||||||
|
Fit();
|
||||||
|
}
|
24
DialogAbout.h
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
/*
|
||||||
|
Meganekko Copyright (C) 2008 Alex Yatskov
|
||||||
|
|
||||||
|
This program 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.
|
||||||
|
|
||||||
|
This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
class DialogAbout : public wxDialog
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
DialogAbout(wxWindow* parent);
|
||||||
|
};
|
236
DialogCard.cpp
Normal file
@ -0,0 +1,236 @@
|
|||||||
|
/*
|
||||||
|
Meganekko Copyright (C) 2008 Alex Yatskov
|
||||||
|
|
||||||
|
This program 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.
|
||||||
|
|
||||||
|
This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "Pch.h"
|
||||||
|
#include "DialogCard.h"
|
||||||
|
#include "DialogCardEditor.h"
|
||||||
|
#include "FlashCardManager.h"
|
||||||
|
|
||||||
|
BEGIN_EVENT_TABLE(DialogCard, wxDialog)
|
||||||
|
EVT_BUTTON(XRCID("buttonShow"), DialogCard::OnButtonShow)
|
||||||
|
EVT_BUTTON(XRCID("buttonYes"), DialogCard::OnButtonYes)
|
||||||
|
EVT_BUTTON(XRCID("buttonPartially"), DialogCard::OnButtonPartially)
|
||||||
|
EVT_BUTTON(XRCID("buttonNo"), DialogCard::OnButtonNo)
|
||||||
|
EVT_BUTTON(XRCID("buttonNext"), DialogCard::OnButtonNext)
|
||||||
|
EVT_BUTTON(XRCID("buttonPrevious"), DialogCard::OnButtonPrevious)
|
||||||
|
EVT_CHECKBOX(XRCID("checkboxLearned"), DialogCard::OnCheckboxLearned)
|
||||||
|
EVT_CHECKBOX(XRCID("checkboxEnabled"), DialogCard::OnCheckboxEnabled)
|
||||||
|
END_EVENT_TABLE()
|
||||||
|
|
||||||
|
DialogCard::DialogCard(wxWindow* parent, unsigned controls, const CardDeck& cards, const FlashCardOptions& options) :
|
||||||
|
m_cards(cards),
|
||||||
|
m_cardIndex(0),
|
||||||
|
m_panelConceal(NULL),
|
||||||
|
m_panelAnswer(NULL),
|
||||||
|
m_htmlQuestion(NULL),
|
||||||
|
m_htmlAnswer(NULL),
|
||||||
|
m_buttonYes(NULL),
|
||||||
|
m_buttonPartially(NULL),
|
||||||
|
m_buttonNo(NULL),
|
||||||
|
m_buttonNext(NULL),
|
||||||
|
m_buttonPrevious(NULL),
|
||||||
|
m_checkboxLearned(NULL),
|
||||||
|
m_checkboxEnabled(NULL),
|
||||||
|
m_staticRemember(NULL)
|
||||||
|
{
|
||||||
|
wxXmlResource::Get()->LoadDialog(this, parent, wxT("DialogCard"));
|
||||||
|
|
||||||
|
m_panelConceal = XRCCTRL(*this, "panelConceal", wxPanel);
|
||||||
|
m_panelAnswer = XRCCTRL(*this, "panelAnswer", wxPanel);
|
||||||
|
m_htmlQuestion = XRCCTRL(*this, "htmlQuestion", wxHtmlWindow);
|
||||||
|
m_htmlAnswer = XRCCTRL(*this, "htmlAnswer", wxHtmlWindow);
|
||||||
|
m_buttonYes = XRCCTRL(*this, "buttonYes", wxButton);
|
||||||
|
m_buttonPartially = XRCCTRL(*this, "buttonPartially", wxButton);
|
||||||
|
m_buttonNo = XRCCTRL(*this, "buttonNo", wxButton);
|
||||||
|
m_buttonNext = XRCCTRL(*this, "buttonNext", wxButton);
|
||||||
|
m_buttonPrevious = XRCCTRL(*this, "buttonPrevious", wxButton);
|
||||||
|
m_checkboxLearned = XRCCTRL(*this, "checkboxLearned", wxCheckBox);
|
||||||
|
m_checkboxEnabled = XRCCTRL(*this, "checkboxEnabled", wxCheckBox);
|
||||||
|
m_staticRemember = XRCCTRL(*this, "staticRemember", wxStaticText);
|
||||||
|
|
||||||
|
m_htmlQuestion->SetFonts(options.fontNameNormal, options.fontNameFixed, options.fontSizes);
|
||||||
|
m_htmlQuestion->Connect(wxEVT_LEFT_DCLICK, wxMouseEventHandler(DialogCard::OnHtmlQuestionDblClick), NULL, this);
|
||||||
|
m_htmlAnswer->SetFonts(options.fontNameNormal, options.fontNameFixed, options.fontSizes);
|
||||||
|
m_htmlAnswer->Connect(wxEVT_LEFT_DCLICK, wxMouseEventHandler(DialogCard::OnHtmlAnswerDblClick), NULL, this);
|
||||||
|
|
||||||
|
if (IS_TRUE(controls & BIT(CARD_CTRL_LEARNED)))
|
||||||
|
{
|
||||||
|
m_checkboxLearned->Show();
|
||||||
|
}
|
||||||
|
if (IS_TRUE(controls & BIT(CARD_CTRL_ENABLED)))
|
||||||
|
{
|
||||||
|
m_checkboxEnabled->Show();
|
||||||
|
}
|
||||||
|
if (IS_TRUE(controls & BIT(CARD_CTRL_NAVIGATE)))
|
||||||
|
{
|
||||||
|
m_buttonPrevious->Show();
|
||||||
|
m_buttonNext->Show();
|
||||||
|
}
|
||||||
|
if (IS_TRUE(controls & BIT(CARD_CTRL_QUIZ)))
|
||||||
|
{
|
||||||
|
m_staticRemember->Show();
|
||||||
|
m_buttonYes->Show();
|
||||||
|
m_buttonPartially->Show();
|
||||||
|
m_buttonNo->Show();
|
||||||
|
HideAnswer();
|
||||||
|
}
|
||||||
|
|
||||||
|
UpdateCard();
|
||||||
|
SetSize(640, 480);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DialogCard::OnButtonShow(wxCommandEvent& event)
|
||||||
|
{
|
||||||
|
ShowAnswer();
|
||||||
|
}
|
||||||
|
|
||||||
|
void DialogCard::OnButtonYes(wxCommandEvent& event)
|
||||||
|
{
|
||||||
|
GetActiveCard()->ScheduleReview(GRADE_TYPE_REMEMBER);
|
||||||
|
HideAnswer();
|
||||||
|
if (!AdvanceCard())
|
||||||
|
{
|
||||||
|
EndModal(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void DialogCard::OnButtonPartially(wxCommandEvent& event)
|
||||||
|
{
|
||||||
|
GetActiveCard()->ScheduleReview(GRADE_TYPE_BUNGLE);
|
||||||
|
HideAnswer();
|
||||||
|
if (!AdvanceCard())
|
||||||
|
{
|
||||||
|
EndModal(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void DialogCard::OnButtonNo(wxCommandEvent& event)
|
||||||
|
{
|
||||||
|
GetActiveCard()->ScheduleReview(GRADE_TYPE_FORGET);
|
||||||
|
HideAnswer();
|
||||||
|
if (!AdvanceCard())
|
||||||
|
{
|
||||||
|
EndModal(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void DialogCard::OnButtonNext(wxCommandEvent& event)
|
||||||
|
{
|
||||||
|
AdvanceCard();
|
||||||
|
}
|
||||||
|
|
||||||
|
void DialogCard::OnButtonPrevious(wxCommandEvent& event)
|
||||||
|
{
|
||||||
|
RewindCard();
|
||||||
|
}
|
||||||
|
|
||||||
|
void DialogCard::OnCheckboxLearned(wxCommandEvent& event)
|
||||||
|
{
|
||||||
|
GetActiveCard()->ScheduleReview(event.IsChecked() ? GRADE_TYPE_LEARN : GRADE_TYPE_UNLEARN);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DialogCard::OnCheckboxEnabled(wxCommandEvent& event)
|
||||||
|
{
|
||||||
|
GetActiveCard()->Enable(event.IsChecked());
|
||||||
|
}
|
||||||
|
|
||||||
|
void DialogCard::OnHtmlQuestionDblClick(wxMouseEvent& event)
|
||||||
|
{
|
||||||
|
FlashCard* const card = GetActiveCard();
|
||||||
|
wxString question = card->GetQuestion();
|
||||||
|
|
||||||
|
DialogCardEditor* const dialog = new DialogCardEditor(this, &question);
|
||||||
|
if (dialog->ShowModal() == wxID_OK)
|
||||||
|
{
|
||||||
|
card->SetQuestion(question.c_str());
|
||||||
|
UpdateCard();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void DialogCard::OnHtmlAnswerDblClick(wxMouseEvent& event)
|
||||||
|
{
|
||||||
|
FlashCard* const card = GetActiveCard();
|
||||||
|
wxString answer = card->GetAnswer();
|
||||||
|
|
||||||
|
DialogCardEditor* const dialog = new DialogCardEditor(this, &answer);
|
||||||
|
if (dialog->ShowModal() == wxID_OK)
|
||||||
|
{
|
||||||
|
card->SetAnswer(answer.c_str());
|
||||||
|
UpdateCard();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void DialogCard::UpdateCard()
|
||||||
|
{
|
||||||
|
m_htmlQuestion->SetPage(GetActiveCard()->GetQuestion());
|
||||||
|
m_htmlAnswer->SetPage(GetActiveCard()->GetAnswer());
|
||||||
|
|
||||||
|
m_buttonYes->SetToolTip(wxString::Format(wxT("Expire about %s"), TimeToStringRel(GetActiveCard()->ComputeReview(GRADE_TYPE_REMEMBER, false)).c_str()));
|
||||||
|
m_buttonPartially->SetToolTip(wxString::Format(wxT("Expire about %s"), TimeToStringRel(GetActiveCard()->ComputeReview(GRADE_TYPE_BUNGLE, false)).c_str()));
|
||||||
|
m_buttonNo->SetToolTip(wxT("Move to failed deck"));
|
||||||
|
|
||||||
|
m_buttonNext->Enable(m_cardIndex < m_cards.size() - 1);
|
||||||
|
m_buttonPrevious->Enable(m_cardIndex > 0);
|
||||||
|
m_checkboxLearned->SetValue(GetActiveCard()->IsLearned());
|
||||||
|
m_checkboxEnabled->SetValue(GetActiveCard()->GetEnabled());
|
||||||
|
|
||||||
|
SetTitle(wxString::Format(wxT("Flash card %d of %d"), m_cardIndex + 1, m_cards.size()));
|
||||||
|
}
|
||||||
|
|
||||||
|
bool DialogCard::AdvanceCard()
|
||||||
|
{
|
||||||
|
if (m_cardIndex + 1 < m_cards.size())
|
||||||
|
{
|
||||||
|
++m_cardIndex;
|
||||||
|
UpdateCard();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool DialogCard::RewindCard()
|
||||||
|
{
|
||||||
|
if (m_cardIndex > 0)
|
||||||
|
{
|
||||||
|
--m_cardIndex;
|
||||||
|
UpdateCard();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DialogCard::ShowAnswer(bool show)
|
||||||
|
{
|
||||||
|
m_panelConceal->Show(!show);
|
||||||
|
m_htmlAnswer->Show(show);
|
||||||
|
m_buttonYes->Enable(show);
|
||||||
|
m_buttonPartially->Enable(show);
|
||||||
|
m_buttonNo->Enable(show);
|
||||||
|
m_panelAnswer->Layout();
|
||||||
|
}
|
||||||
|
|
||||||
|
void DialogCard::HideAnswer()
|
||||||
|
{
|
||||||
|
ShowAnswer(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
FlashCard* DialogCard::GetActiveCard()
|
||||||
|
{
|
||||||
|
return m_cards[m_cardIndex];
|
||||||
|
}
|
74
DialogCard.h
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
/*
|
||||||
|
Meganekko Copyright (C) 2008 Alex Yatskov
|
||||||
|
|
||||||
|
This program 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.
|
||||||
|
|
||||||
|
This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
struct FlashCardOptions;
|
||||||
|
class FlashCard;
|
||||||
|
|
||||||
|
class DialogCard : public wxDialog
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
CARD_CTRL_LEARNED,
|
||||||
|
CARD_CTRL_ENABLED,
|
||||||
|
CARD_CTRL_NAVIGATE,
|
||||||
|
CARD_CTRL_QUIZ
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef std::vector<FlashCard*> CardDeck;
|
||||||
|
|
||||||
|
DialogCard(wxWindow* parent, unsigned controls, const CardDeck& cards, const FlashCardOptions& options);
|
||||||
|
|
||||||
|
void OnButtonShow(wxCommandEvent& event);
|
||||||
|
void OnButtonYes(wxCommandEvent& event);
|
||||||
|
void OnButtonPartially(wxCommandEvent& event);
|
||||||
|
void OnButtonNo(wxCommandEvent& event);
|
||||||
|
void OnButtonNext(wxCommandEvent& event);
|
||||||
|
void OnButtonPrevious(wxCommandEvent& event);
|
||||||
|
void OnCheckboxLearned(wxCommandEvent& event);
|
||||||
|
void OnCheckboxEnabled(wxCommandEvent& event);
|
||||||
|
void OnHtmlQuestionDblClick(wxMouseEvent& event);
|
||||||
|
void OnHtmlAnswerDblClick(wxMouseEvent& event);
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool AdvanceCard();
|
||||||
|
bool RewindCard();
|
||||||
|
void UpdateCard();
|
||||||
|
void ShowAnswer(bool show = true);
|
||||||
|
void HideAnswer();
|
||||||
|
FlashCard* GetActiveCard();
|
||||||
|
|
||||||
|
DECLARE_EVENT_TABLE()
|
||||||
|
|
||||||
|
const CardDeck& m_cards;
|
||||||
|
size_t m_cardIndex;
|
||||||
|
|
||||||
|
wxPanel* m_panelConceal;
|
||||||
|
wxPanel* m_panelAnswer;
|
||||||
|
wxHtmlWindow* m_htmlQuestion;
|
||||||
|
wxHtmlWindow* m_htmlAnswer;
|
||||||
|
wxButton* m_buttonYes;
|
||||||
|
wxButton* m_buttonPartially;
|
||||||
|
wxButton* m_buttonNo;
|
||||||
|
wxButton* m_buttonNext;
|
||||||
|
wxButton* m_buttonPrevious;
|
||||||
|
wxCheckBox* m_checkboxLearned;
|
||||||
|
wxCheckBox* m_checkboxEnabled;
|
||||||
|
wxStaticText* m_staticRemember;
|
||||||
|
};
|
40
DialogCardEditor.cpp
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
/*
|
||||||
|
Meganekko Copyright (C) 2008 Alex Yatskov
|
||||||
|
|
||||||
|
This program 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.
|
||||||
|
|
||||||
|
This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "Pch.h"
|
||||||
|
#include "DialogCardEditor.h"
|
||||||
|
|
||||||
|
BEGIN_EVENT_TABLE(DialogCardEditor, wxDialog)
|
||||||
|
EVT_BUTTON(wxID_OK, DialogCardEditor::OnButtonOk)
|
||||||
|
END_EVENT_TABLE()
|
||||||
|
|
||||||
|
DialogCardEditor::DialogCardEditor(wxWindow* parent, wxString* value) :
|
||||||
|
m_textEdit(NULL),
|
||||||
|
m_value(value)
|
||||||
|
{
|
||||||
|
wxXmlResource::Get()->LoadDialog(this, parent, wxT("DialogCardEditor"));
|
||||||
|
m_textEdit = XRCCTRL(*this, "textEdit", wxTextCtrl);
|
||||||
|
m_textEdit->ChangeValue(*value);
|
||||||
|
m_textEdit->SetFocus();
|
||||||
|
SetSize(500, 300);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DialogCardEditor::OnButtonOk(wxCommandEvent& event)
|
||||||
|
{
|
||||||
|
*m_value = m_textEdit->GetValue();
|
||||||
|
event.Skip();
|
||||||
|
}
|
33
DialogCardEditor.h
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
/*
|
||||||
|
Meganekko Copyright (C) 2008 Alex Yatskov
|
||||||
|
|
||||||
|
This program 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.
|
||||||
|
|
||||||
|
This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
class DialogCardEditor : public wxDialog
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
DialogCardEditor(wxWindow* parent, wxString* value);
|
||||||
|
|
||||||
|
void OnButtonOk(wxCommandEvent& event);
|
||||||
|
|
||||||
|
private:
|
||||||
|
DECLARE_EVENT_TABLE()
|
||||||
|
|
||||||
|
wxTextCtrl* m_textEdit;
|
||||||
|
wxString* m_value;
|
||||||
|
};
|
||||||
|
|
346
DialogCardManager.cpp
Normal file
@ -0,0 +1,346 @@
|
|||||||
|
/*
|
||||||
|
Meganekko Copyright (C) 2008 Alex Yatskov
|
||||||
|
|
||||||
|
This program 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.
|
||||||
|
|
||||||
|
This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "Pch.h"
|
||||||
|
#include "DialogCardManager.h"
|
||||||
|
#include "FlashCardManager.h"
|
||||||
|
|
||||||
|
BEGIN_EVENT_TABLE(DialogCardManager, wxDialog)
|
||||||
|
EVT_MENU(ID_MENU_CARD_ADD, DialogCardManager::OnMenuCardAdd)
|
||||||
|
EVT_MENU(ID_MENU_CARD_REMOVE, DialogCardManager::OnMenuCardRemove)
|
||||||
|
EVT_MENU(ID_MENU_CARD_ENABLE, DialogCardManager::OnMenuCardEnable)
|
||||||
|
EVT_BUTTON(XRCID("buttonAdd"), DialogCardManager::OnMenuCardAdd)
|
||||||
|
EVT_BUTTON(XRCID("buttonRemove"), DialogCardManager::OnMenuCardRemove)
|
||||||
|
EVT_LISTBOX(XRCID("checkListCards"), DialogCardManager::OnCheckListCardsIndexChanged)
|
||||||
|
EVT_CHECKLISTBOX(XRCID("checkListCards"), DialogCardManager::OnCheckListCardsChecked)
|
||||||
|
EVT_TEXT_ENTER(XRCID("textFilter"), DialogCardManager::OnCardSummaryChanged)
|
||||||
|
EVT_TEXT(XRCID("textQuestion"), DialogCardManager::OnCardTextChanged)
|
||||||
|
EVT_TEXT(XRCID("textAnswer"), DialogCardManager::OnCardTextChanged)
|
||||||
|
EVT_CHOICE(XRCID("choiceSearch"), DialogCardManager::OnCardSummaryChanged)
|
||||||
|
EVT_CHOICE(XRCID("choiceSort"), DialogCardManager::OnCardSummaryChanged)
|
||||||
|
EVT_NOTEBOOK_PAGE_CHANGING(XRCID("notebookCard"), DialogCardManager::OnNotebookCardPageChanged)
|
||||||
|
END_EVENT_TABLE()
|
||||||
|
|
||||||
|
DialogCardManager::DialogCardManager(wxWindow* parent, FlashCardManager* manager) :
|
||||||
|
m_manager(manager),
|
||||||
|
m_textQuestion(NULL),
|
||||||
|
m_htmlQuestion(NULL),
|
||||||
|
m_textAnswer(NULL),
|
||||||
|
m_htmlAnswer(NULL),
|
||||||
|
m_textFilter(NULL),
|
||||||
|
m_choiceSearch(NULL),
|
||||||
|
m_choiceSort(NULL),
|
||||||
|
m_listCards(NULL),
|
||||||
|
m_notebookCard(NULL),
|
||||||
|
m_staticDeck(NULL),
|
||||||
|
m_staticRemembered(NULL),
|
||||||
|
m_staticForgotten(NULL),
|
||||||
|
m_staticBungled(NULL),
|
||||||
|
m_staticAdded(NULL),
|
||||||
|
m_staticReviewPrevious(NULL),
|
||||||
|
m_staticReviewNext(NULL)
|
||||||
|
{
|
||||||
|
wxXmlResource::Get()->LoadDialog(this, parent, wxT("DialogCardManager"));
|
||||||
|
const FlashCardOptions& options = m_manager->GetOptions();
|
||||||
|
|
||||||
|
m_textQuestion = XRCCTRL(*this, "textQuestion", wxTextCtrl);
|
||||||
|
m_htmlQuestion = XRCCTRL(*this, "htmlQuestion", wxHtmlWindow);
|
||||||
|
m_textAnswer = XRCCTRL(*this, "textAnswer", wxTextCtrl);
|
||||||
|
m_htmlAnswer = XRCCTRL(*this, "htmlAnswer", wxHtmlWindow);
|
||||||
|
m_textFilter = XRCCTRL(*this, "textFilter", wxTextCtrl);
|
||||||
|
m_choiceSearch = XRCCTRL(*this, "choiceSearch", wxChoice);
|
||||||
|
m_choiceSort = XRCCTRL(*this, "choiceSort", wxChoice);
|
||||||
|
m_listCards = XRCCTRL(*this, "checkListCards", wxCheckListBox);
|
||||||
|
m_notebookCard = XRCCTRL(*this, "notebookCard", wxNotebook);
|
||||||
|
m_staticDeck = XRCCTRL(*this, "staticDeck", wxStaticText);
|
||||||
|
m_staticRemembered = XRCCTRL(*this, "staticCountRemembered", wxStaticText);
|
||||||
|
m_staticForgotten = XRCCTRL(*this, "staticCountForgotten", wxStaticText);
|
||||||
|
m_staticBungled = XRCCTRL(*this, "staticCountBungled", wxStaticText);
|
||||||
|
m_staticAdded = XRCCTRL(*this, "staticTimeAdded", wxStaticText);
|
||||||
|
m_staticReviewPrevious = XRCCTRL(*this, "staticTimeReviewPrevious", wxStaticText);
|
||||||
|
m_staticReviewNext = XRCCTRL(*this, "staticTimeReviewNext", wxStaticText);
|
||||||
|
|
||||||
|
m_htmlQuestion->SetFonts(options.fontNameNormal, options.fontNameFixed, options.fontSizes);
|
||||||
|
m_htmlAnswer->SetFonts(options.fontNameNormal, options.fontNameFixed, options.fontSizes);
|
||||||
|
m_listCards->Connect(wxEVT_KEY_DOWN, wxKeyEventHandler(DialogCardManager::OnCheckListCardsKeyDown), NULL, this);
|
||||||
|
m_listCards->Connect(wxEVT_CONTEXT_MENU, wxContextMenuEventHandler(DialogCardManager::OnCheckListCardsContextMenu), NULL, this);
|
||||||
|
m_textFilter->SetFocus();
|
||||||
|
|
||||||
|
SetSize(800, 600);
|
||||||
|
UpdateCards();
|
||||||
|
}
|
||||||
|
|
||||||
|
void DialogCardManager::OnMenuCardAdd(wxCommandEvent& event)
|
||||||
|
{
|
||||||
|
AddCard();
|
||||||
|
}
|
||||||
|
|
||||||
|
void DialogCardManager::OnMenuCardRemove(wxCommandEvent& event)
|
||||||
|
{
|
||||||
|
RemoveCard();
|
||||||
|
}
|
||||||
|
|
||||||
|
void DialogCardManager::OnMenuCardEnable(wxCommandEvent& event)
|
||||||
|
{
|
||||||
|
wxArrayInt selections;
|
||||||
|
m_listCards->GetSelections(selections);
|
||||||
|
|
||||||
|
const bool checked = IsSelectionChecked();
|
||||||
|
for (unsigned i = 0; i < selections.Count(); ++i)
|
||||||
|
{
|
||||||
|
m_listCards->Check(selections[i], !checked);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void DialogCardManager::OnNotebookCardPageChanged(wxNotebookEvent& event)
|
||||||
|
{
|
||||||
|
if (m_htmlQuestion != NULL && m_htmlAnswer != NULL)
|
||||||
|
{
|
||||||
|
m_htmlQuestion->SetPage(m_textQuestion->GetValue());
|
||||||
|
m_htmlAnswer->SetPage(m_textAnswer->GetValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void DialogCardManager::OnCheckListCardsIndexChanged(wxCommandEvent& event)
|
||||||
|
{
|
||||||
|
UpdateCard();
|
||||||
|
}
|
||||||
|
|
||||||
|
void DialogCardManager::OnCheckListCardsChecked(wxCommandEvent& event)
|
||||||
|
{
|
||||||
|
const int selection = event.GetSelection();
|
||||||
|
FlashCard* const card = m_cardMap.find(selection)->second;
|
||||||
|
card->Enable(m_listCards->IsChecked(selection));
|
||||||
|
}
|
||||||
|
|
||||||
|
void DialogCardManager::OnCheckListCardsContextMenu(wxContextMenuEvent& event)
|
||||||
|
{
|
||||||
|
wxArrayInt selections;
|
||||||
|
const int selectedCount = m_listCards->GetSelections(selections);
|
||||||
|
|
||||||
|
wxMenu* const menu = new wxMenu();
|
||||||
|
menu->Append(ID_MENU_CARD_ADD, wxT("&Add new card"));
|
||||||
|
if (selectedCount > 0)
|
||||||
|
{
|
||||||
|
menu->Append(ID_MENU_CARD_REMOVE, wxT("&Remove card(s)"));
|
||||||
|
menu->AppendSeparator();
|
||||||
|
menu->AppendCheckItem(ID_MENU_CARD_ENABLE, wxT("&Enable card(s)"))->Check(IsSelectionChecked());
|
||||||
|
}
|
||||||
|
|
||||||
|
PopupMenu(menu);
|
||||||
|
delete menu;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DialogCardManager::OnCheckListCardsKeyDown(wxKeyEvent& event)
|
||||||
|
{
|
||||||
|
switch (event.GetKeyCode())
|
||||||
|
{
|
||||||
|
case WXK_DELETE:
|
||||||
|
RemoveCard();
|
||||||
|
break;
|
||||||
|
case WXK_INSERT:
|
||||||
|
AddCard();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
event.Skip();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void DialogCardManager::OnCardSummaryChanged(wxCommandEvent& event)
|
||||||
|
{
|
||||||
|
UpdateCards();
|
||||||
|
}
|
||||||
|
|
||||||
|
void DialogCardManager::UpdateCards()
|
||||||
|
{
|
||||||
|
const wxString filterText = m_textFilter->GetValue().Strip().Lower();
|
||||||
|
const FilterMode filterMode = static_cast<FilterMode>(m_choiceSearch->GetSelection());
|
||||||
|
const DeckSortType sortType = static_cast<DeckSortType>(m_choiceSort->GetSelection());
|
||||||
|
|
||||||
|
std::vector<FlashCard*> cards;
|
||||||
|
m_manager->EnumerateCards(&cards, static_cast<unsigned>(-1), true, true, sortType);
|
||||||
|
|
||||||
|
m_cardMap.clear();
|
||||||
|
|
||||||
|
std::vector<bool> states;
|
||||||
|
wxArrayString questions;
|
||||||
|
int index = 0;
|
||||||
|
|
||||||
|
for (std::vector<FlashCard*>::const_iterator iter = cards.begin(); iter != cards.end(); ++iter)
|
||||||
|
{
|
||||||
|
FlashCard* const card = *iter;
|
||||||
|
const wxString question = card->GetQuestion();
|
||||||
|
const wxString answer = card->GetAnswer();
|
||||||
|
|
||||||
|
if (!filterText.IsEmpty())
|
||||||
|
{
|
||||||
|
const wxString questionTemp = question.Strip().Lower();
|
||||||
|
const wxString answerTemp = answer.Strip().Lower();
|
||||||
|
const bool filtered =
|
||||||
|
(filterMode == FILTER_MODE_QUESTION && questionTemp.Find(filterText) == wxNOT_FOUND) ||
|
||||||
|
(filterMode == FILTER_MODE_ANSWER && answerTemp.Find(filterText) == wxNOT_FOUND);
|
||||||
|
|
||||||
|
if (filtered)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
states.push_back(card->GetEnabled());
|
||||||
|
questions.Add(question);
|
||||||
|
|
||||||
|
m_cardMap.insert(std::make_pair(index++, card));
|
||||||
|
}
|
||||||
|
|
||||||
|
m_listCards->SetSelection(wxNOT_FOUND);
|
||||||
|
m_listCards->Set(questions);
|
||||||
|
for (size_t i = 0; i < states.size(); ++i)
|
||||||
|
{
|
||||||
|
m_listCards->Check(i, states[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_listCards->GetCount() > 0)
|
||||||
|
{
|
||||||
|
m_listCards->Select(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
UpdateCard();
|
||||||
|
}
|
||||||
|
|
||||||
|
void DialogCardManager::UpdateCard()
|
||||||
|
{
|
||||||
|
wxArrayInt selections;
|
||||||
|
const bool canDisplaySelection = m_listCards->GetSelections(selections) == 1;
|
||||||
|
m_notebookCard->Enable(canDisplaySelection);
|
||||||
|
|
||||||
|
const wxString unspecified = wxT("-");
|
||||||
|
wxString question = wxEmptyString;
|
||||||
|
wxString answer = wxEmptyString;
|
||||||
|
wxString deck = unspecified;
|
||||||
|
wxString countRemembered = unspecified;
|
||||||
|
wxString countForgotten = unspecified;
|
||||||
|
wxString countBungled = unspecified;
|
||||||
|
wxString timeAdded = unspecified;
|
||||||
|
wxString timeReviewPrevious = unspecified;
|
||||||
|
wxString timeReviewNext = unspecified;
|
||||||
|
|
||||||
|
if (canDisplaySelection)
|
||||||
|
{
|
||||||
|
const FlashCard* const card = m_cardMap.find(selections[0])->second;
|
||||||
|
|
||||||
|
question = card->GetQuestion();
|
||||||
|
answer = card->GetAnswer();
|
||||||
|
deck = wxString::FromAscii(DeckTypeToString(card->GetDeck()).c_str());
|
||||||
|
countRemembered = wxString::Format(wxT("%d"), card->GetCountRemembered());
|
||||||
|
countForgotten = wxString::Format(wxT("%d"), card->GetCountForgotten());
|
||||||
|
countBungled = wxString::Format(wxT("%d"), card->GetCountBungled());
|
||||||
|
timeAdded = TimeToStringRel(card->GetTimeAdded());
|
||||||
|
|
||||||
|
if (card->GetDeck() != DECK_TYPE_UNTESTED)
|
||||||
|
{
|
||||||
|
timeReviewPrevious = TimeToStringRel(card->GetTimeReviewPrevious());
|
||||||
|
}
|
||||||
|
if (card->GetDeck() == DECK_TYPE_EXPIRED || card->GetDeck() == DECK_TYPE_PENDING)
|
||||||
|
{
|
||||||
|
timeReviewNext = TimeToStringRel(card->GetTimeReviewNext());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
m_textQuestion->ChangeValue(question);
|
||||||
|
m_htmlQuestion->SetPage(question);
|
||||||
|
m_textAnswer->ChangeValue(answer);
|
||||||
|
m_htmlAnswer->SetPage(answer);
|
||||||
|
m_staticDeck->SetLabel(deck);
|
||||||
|
m_staticRemembered->SetLabel(countRemembered);
|
||||||
|
m_staticForgotten->SetLabel(countForgotten);
|
||||||
|
m_staticBungled->SetLabel(countBungled);
|
||||||
|
m_staticAdded->SetLabel(timeAdded);
|
||||||
|
m_staticReviewPrevious->SetLabel(timeReviewPrevious);
|
||||||
|
m_staticReviewNext->SetLabel(timeReviewNext);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DialogCardManager::AddCard()
|
||||||
|
{
|
||||||
|
FlashCard* const card = m_manager->AddCard(wxEmptyString, wxEmptyString, true);
|
||||||
|
|
||||||
|
m_listCards->Append(card->GetQuestion());
|
||||||
|
const int selectionIndex = m_listCards->GetCount() - 1;
|
||||||
|
m_listCards->Check(selectionIndex, card->GetEnabled());
|
||||||
|
m_listCards->SetSelection(wxNOT_FOUND);
|
||||||
|
m_listCards->SetSelection(selectionIndex);
|
||||||
|
|
||||||
|
m_cardMap.insert(std::make_pair(selectionIndex, card));
|
||||||
|
|
||||||
|
m_notebookCard->SetSelection(1);
|
||||||
|
m_textQuestion->SetFocus();
|
||||||
|
|
||||||
|
UpdateCard();
|
||||||
|
}
|
||||||
|
|
||||||
|
void DialogCardManager::RemoveCard()
|
||||||
|
{
|
||||||
|
wxArrayInt selections;
|
||||||
|
m_listCards->GetSelections(selections);
|
||||||
|
|
||||||
|
const bool remove =
|
||||||
|
selections.Count() > 0 &&
|
||||||
|
wxMessageBox(wxT("Are you sure you want to remove the selected card(s)?"), wxT("Meganekko"), wxYES_NO) == wxYES;
|
||||||
|
|
||||||
|
if (remove)
|
||||||
|
{
|
||||||
|
for (unsigned i = 0; i < selections.Count(); ++i)
|
||||||
|
{
|
||||||
|
m_manager->RemoveCard(m_cardMap.find(selections[i])->second);
|
||||||
|
}
|
||||||
|
|
||||||
|
UpdateCards();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void DialogCardManager::OnCardTextChanged(wxCommandEvent& event)
|
||||||
|
{
|
||||||
|
wxArrayInt selections;
|
||||||
|
if (m_listCards->GetSelections(selections) == 1)
|
||||||
|
{
|
||||||
|
const int selection = selections[0];
|
||||||
|
|
||||||
|
FlashCard* const card = m_cardMap.find(selection)->second;
|
||||||
|
card->SetQuestion(m_textQuestion->GetValue().c_str());
|
||||||
|
card->SetAnswer(m_textAnswer->GetValue().c_str());
|
||||||
|
|
||||||
|
m_listCards->SetString(selection, card->GetQuestion());
|
||||||
|
m_listCards->Check(selection, card->GetEnabled());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool DialogCardManager::IsSelectionChecked() const
|
||||||
|
{
|
||||||
|
wxArrayInt selections;
|
||||||
|
m_listCards->GetSelections(selections);
|
||||||
|
|
||||||
|
unsigned checked = 0;
|
||||||
|
for (unsigned i = 0; i < selections.GetCount(); ++i)
|
||||||
|
{
|
||||||
|
if (m_listCards->IsChecked(selections[i]))
|
||||||
|
{
|
||||||
|
++checked;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return checked == selections.GetCount() || checked > selections.GetCount() / 2;
|
||||||
|
}
|
83
DialogCardManager.h
Normal file
@ -0,0 +1,83 @@
|
|||||||
|
/*
|
||||||
|
Meganekko Copyright (C) 2008 Alex Yatskov
|
||||||
|
|
||||||
|
This program 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.
|
||||||
|
|
||||||
|
This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
class FlashCardManager;
|
||||||
|
class FlashCard;
|
||||||
|
|
||||||
|
class DialogCardManager : public wxDialog
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
DialogCardManager(wxWindow* parent, FlashCardManager* manager);
|
||||||
|
|
||||||
|
void OnMenuCardAdd(wxCommandEvent& event);
|
||||||
|
void OnMenuCardRemove(wxCommandEvent& event);
|
||||||
|
void OnMenuCardEnable(wxCommandEvent& event);
|
||||||
|
void OnCheckListCardsIndexChanged(wxCommandEvent& event);
|
||||||
|
void OnCheckListCardsChecked(wxCommandEvent& event);
|
||||||
|
void OnCheckListCardsKeyDown(wxKeyEvent& event);
|
||||||
|
void OnCheckListCardsContextMenu(wxContextMenuEvent& event);
|
||||||
|
void OnNotebookCardPageChanged(wxNotebookEvent& event);
|
||||||
|
void OnCardSummaryChanged(wxCommandEvent& event);
|
||||||
|
void OnCardTextChanged(wxCommandEvent& event);
|
||||||
|
|
||||||
|
private:
|
||||||
|
void AddCard();
|
||||||
|
void RemoveCard();
|
||||||
|
void UpdateCards();
|
||||||
|
void UpdateCard();
|
||||||
|
|
||||||
|
bool IsSelectionChecked() const;
|
||||||
|
|
||||||
|
enum FilterMode
|
||||||
|
{
|
||||||
|
FILTER_MODE_QUESTION,
|
||||||
|
FILTER_MODE_ANSWER
|
||||||
|
};
|
||||||
|
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
ID_MENU_CARD_ADD,
|
||||||
|
ID_MENU_CARD_REMOVE,
|
||||||
|
ID_MENU_CARD_ENABLE
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef std::map<int, FlashCard*> CardMap;
|
||||||
|
|
||||||
|
DECLARE_EVENT_TABLE()
|
||||||
|
|
||||||
|
FlashCardManager* m_manager;
|
||||||
|
CardMap m_cardMap;
|
||||||
|
|
||||||
|
wxTextCtrl* m_textQuestion;
|
||||||
|
wxHtmlWindow* m_htmlQuestion;
|
||||||
|
wxTextCtrl* m_textAnswer;
|
||||||
|
wxHtmlWindow* m_htmlAnswer;
|
||||||
|
wxTextCtrl* m_textFilter;
|
||||||
|
wxChoice* m_choiceSearch;
|
||||||
|
wxChoice* m_choiceSort;
|
||||||
|
wxCheckListBox* m_listCards;
|
||||||
|
wxNotebook* m_notebookCard;
|
||||||
|
wxStaticText* m_staticDeck;
|
||||||
|
wxStaticText* m_staticRemembered;
|
||||||
|
wxStaticText* m_staticForgotten;
|
||||||
|
wxStaticText* m_staticBungled;
|
||||||
|
wxStaticText* m_staticAdded;
|
||||||
|
wxStaticText* m_staticReviewPrevious;
|
||||||
|
wxStaticText* m_staticReviewNext;
|
||||||
|
};
|
95
DialogOptions.cpp
Normal file
@ -0,0 +1,95 @@
|
|||||||
|
/*
|
||||||
|
Meganekko Copyright (C) 2008 Alex Yatskov
|
||||||
|
|
||||||
|
This program 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.
|
||||||
|
|
||||||
|
This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "Pch.h"
|
||||||
|
#include "DialogOptions.h"
|
||||||
|
#include "FlashCardManager.h"
|
||||||
|
|
||||||
|
BEGIN_EVENT_TABLE(DialogOptions, wxDialog)
|
||||||
|
EVT_BUTTON(wxID_OK, DialogOptions::OnButtonOk)
|
||||||
|
END_EVENT_TABLE()
|
||||||
|
|
||||||
|
DialogOptions::DialogOptions(wxWindow* parent, FlashCardManager* manager) :
|
||||||
|
m_manager(manager),
|
||||||
|
m_spinTimeReviewMin(NULL),
|
||||||
|
m_spinTimeReviewMax(NULL),
|
||||||
|
m_sliderTimeReviewEntropy(NULL),
|
||||||
|
m_checkAutoSave(NULL),
|
||||||
|
m_textFontNameNormal(NULL),
|
||||||
|
m_textFontNameFixed(NULL)
|
||||||
|
{
|
||||||
|
wxXmlResource::Get()->LoadDialog(this, parent, wxT("DialogOptions"));
|
||||||
|
|
||||||
|
m_spinTimeReviewMin = XRCCTRL(*this, "spinTimeReviewMin", wxSpinCtrl);
|
||||||
|
m_spinTimeReviewMax = XRCCTRL(*this, "spinTimeReviewMax", wxSpinCtrl);
|
||||||
|
m_sliderTimeReviewEntropy = XRCCTRL(*this, "sliderTimeReviewEntropy", wxSlider);
|
||||||
|
m_checkAutoSave = XRCCTRL(*this, "checkAutoSave", wxCheckBox);
|
||||||
|
m_textFontNameNormal = XRCCTRL(*this, "textFontNameNormal", wxTextCtrl);
|
||||||
|
m_textFontNameFixed = XRCCTRL(*this, "textFontNameFixed", wxTextCtrl);
|
||||||
|
m_spinFontSizes[0] = XRCCTRL(*this, "spinFontSize0", wxSpinCtrl);
|
||||||
|
m_spinFontSizes[1] = XRCCTRL(*this, "spinFontSize1", wxSpinCtrl);
|
||||||
|
m_spinFontSizes[2] = XRCCTRL(*this, "spinFontSize2", wxSpinCtrl);
|
||||||
|
m_spinFontSizes[3] = XRCCTRL(*this, "spinFontSize3", wxSpinCtrl);
|
||||||
|
m_spinFontSizes[4] = XRCCTRL(*this, "spinFontSize4", wxSpinCtrl);
|
||||||
|
m_spinFontSizes[5] = XRCCTRL(*this, "spinFontSize5", wxSpinCtrl);
|
||||||
|
m_spinFontSizes[6] = XRCCTRL(*this, "spinFontSize6", wxSpinCtrl);
|
||||||
|
|
||||||
|
MoveOptionsToUi();
|
||||||
|
Fit();
|
||||||
|
}
|
||||||
|
|
||||||
|
void DialogOptions::OnButtonOk(wxCommandEvent& event)
|
||||||
|
{
|
||||||
|
MoveUiToOptions();
|
||||||
|
event.Skip();
|
||||||
|
}
|
||||||
|
|
||||||
|
void DialogOptions::MoveOptionsToUi()
|
||||||
|
{
|
||||||
|
const FlashCardOptions& options = m_manager->GetOptions();
|
||||||
|
m_spinTimeReviewMin->SetValue(SECONDS_TO_DAYS(options.timeReviewMin));
|
||||||
|
m_spinTimeReviewMax->SetValue(SECONDS_TO_DAYS(options.timeReviewMax));
|
||||||
|
m_sliderTimeReviewEntropy->SetValue(options.timeReviewEntropy);
|
||||||
|
m_checkAutoSave->SetValue(options.autoSave);
|
||||||
|
m_textFontNameNormal->SetValue(options.fontNameNormal);
|
||||||
|
m_textFontNameFixed->SetValue(options.fontNameFixed);
|
||||||
|
for (size_t i = 0; i < 7; ++i)
|
||||||
|
{
|
||||||
|
m_spinFontSizes[i]->SetValue(options.fontSizes[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void DialogOptions::MoveUiToOptions()
|
||||||
|
{
|
||||||
|
int fontSizes[7] = {0};
|
||||||
|
for (int i = 0; i < 7; ++i)
|
||||||
|
{
|
||||||
|
fontSizes[i] = m_spinFontSizes[i]->GetValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
const FlashCardOptions options(
|
||||||
|
DAYS_TO_SECONDS(m_spinTimeReviewMin->GetValue()),
|
||||||
|
DAYS_TO_SECONDS(m_spinTimeReviewMax->GetValue()),
|
||||||
|
m_sliderTimeReviewEntropy->GetValue(),
|
||||||
|
m_checkAutoSave->GetValue(),
|
||||||
|
m_textFontNameNormal->GetValue().c_str(),
|
||||||
|
m_textFontNameFixed->GetValue().c_str(),
|
||||||
|
fontSizes
|
||||||
|
);
|
||||||
|
|
||||||
|
m_manager->SetOptions(options);
|
||||||
|
}
|
44
DialogOptions.h
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
/*
|
||||||
|
Meganekko Copyright (C) 2008 Alex Yatskov
|
||||||
|
|
||||||
|
This program 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.
|
||||||
|
|
||||||
|
This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
class FlashCardManager;
|
||||||
|
|
||||||
|
class DialogOptions : public wxDialog
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
DialogOptions(wxWindow* parent, FlashCardManager* manager);
|
||||||
|
|
||||||
|
void OnButtonOk(wxCommandEvent& event);
|
||||||
|
|
||||||
|
private:
|
||||||
|
void MoveOptionsToUi();
|
||||||
|
void MoveUiToOptions();
|
||||||
|
|
||||||
|
DECLARE_EVENT_TABLE()
|
||||||
|
|
||||||
|
FlashCardManager* m_manager;
|
||||||
|
|
||||||
|
wxSpinCtrl* m_spinTimeReviewMin;
|
||||||
|
wxSpinCtrl* m_spinTimeReviewMax;
|
||||||
|
wxSlider* m_sliderTimeReviewEntropy;
|
||||||
|
wxCheckBox* m_checkAutoSave;
|
||||||
|
wxTextCtrl* m_textFontNameNormal;
|
||||||
|
wxTextCtrl* m_textFontNameFixed;
|
||||||
|
wxSpinCtrl* m_spinFontSizes[7];
|
||||||
|
};
|
283
FlashCard.cpp
Normal file
@ -0,0 +1,283 @@
|
|||||||
|
/*
|
||||||
|
Meganekko Copyright (C) 2008 Alex Yatskov
|
||||||
|
|
||||||
|
This program 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.
|
||||||
|
|
||||||
|
This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "Pch.h"
|
||||||
|
#include "FlashCard.h"
|
||||||
|
#include "FlashCardManager.h"
|
||||||
|
|
||||||
|
FlashCard::FlashCard(
|
||||||
|
FlashCardManager* manager,
|
||||||
|
DeckType deck,
|
||||||
|
const std::wstring& question,
|
||||||
|
const std::wstring& answer,
|
||||||
|
bool enabled,
|
||||||
|
int countRemembered,
|
||||||
|
int countForgotten,
|
||||||
|
int countBungled,
|
||||||
|
time_t timeReviewPrevious,
|
||||||
|
time_t timeReviewNext,
|
||||||
|
time_t timeAdded
|
||||||
|
) :
|
||||||
|
m_manager(manager),
|
||||||
|
m_deck(deck),
|
||||||
|
m_question(question),
|
||||||
|
m_answer(answer),
|
||||||
|
m_enabled(enabled),
|
||||||
|
m_countRemembered(countRemembered),
|
||||||
|
m_countForgotten(countForgotten),
|
||||||
|
m_countBungled(countBungled),
|
||||||
|
m_timeReviewPrevious(timeReviewPrevious),
|
||||||
|
m_timeReviewNext(timeReviewNext),
|
||||||
|
m_timeAdded(timeAdded)
|
||||||
|
{
|
||||||
|
ASSERT(m_timeAdded > 0);
|
||||||
|
ASSERT(m_timeReviewPrevious > 0 && m_timeReviewPrevious >= m_timeAdded);
|
||||||
|
ASSERT(m_timeReviewNext > 0 && m_timeReviewNext >= m_timeReviewPrevious);
|
||||||
|
}
|
||||||
|
|
||||||
|
void FlashCard::SetDeck(DeckType deck)
|
||||||
|
{
|
||||||
|
if (m_deck != deck)
|
||||||
|
{
|
||||||
|
m_deck = deck;
|
||||||
|
m_manager->FlagModified();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
DeckType FlashCard::GetDeck() const
|
||||||
|
{
|
||||||
|
return m_deck;
|
||||||
|
}
|
||||||
|
|
||||||
|
void FlashCard::SetQuestion(const std::wstring& question)
|
||||||
|
{
|
||||||
|
if (m_question != question)
|
||||||
|
{
|
||||||
|
m_question = question;
|
||||||
|
m_manager->FlagModified();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const std::wstring& FlashCard::GetQuestion() const
|
||||||
|
{
|
||||||
|
return m_question;
|
||||||
|
}
|
||||||
|
|
||||||
|
void FlashCard::SetAnswer(const std::wstring& answer)
|
||||||
|
{
|
||||||
|
if (m_answer != answer)
|
||||||
|
{
|
||||||
|
m_manager->FlagModified();
|
||||||
|
m_answer = answer;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const std::wstring& FlashCard::GetAnswer() const
|
||||||
|
{
|
||||||
|
return m_answer;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool FlashCard::GetEnabled() const
|
||||||
|
{
|
||||||
|
return m_enabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool FlashCard::IsLearned() const
|
||||||
|
{
|
||||||
|
return m_deck != DECK_TYPE_FAILED;
|
||||||
|
}
|
||||||
|
|
||||||
|
void FlashCard::Enable(bool enable)
|
||||||
|
{
|
||||||
|
if (m_enabled != enable)
|
||||||
|
{
|
||||||
|
m_enabled = enable;
|
||||||
|
m_manager->FlagModified();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void FlashCard::Disable()
|
||||||
|
{
|
||||||
|
Enable(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool FlashCard::Expire()
|
||||||
|
{
|
||||||
|
if (m_deck == DECK_TYPE_PENDING && m_timeReviewNext <= GetTimeCurrent())
|
||||||
|
{
|
||||||
|
SetDeck(DECK_TYPE_EXPIRED);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
time_t FlashCard::GetTimeReviewPrevious() const
|
||||||
|
{
|
||||||
|
return m_timeReviewPrevious;
|
||||||
|
}
|
||||||
|
|
||||||
|
time_t FlashCard::GetTimeReviewNext() const
|
||||||
|
{
|
||||||
|
return m_timeReviewNext;
|
||||||
|
}
|
||||||
|
|
||||||
|
time_t FlashCard::GetTimeAdded() const
|
||||||
|
{
|
||||||
|
return m_timeAdded;
|
||||||
|
}
|
||||||
|
|
||||||
|
int FlashCard::GetCountRemembered() const
|
||||||
|
{
|
||||||
|
return m_countRemembered;
|
||||||
|
}
|
||||||
|
|
||||||
|
int FlashCard::GetCountForgotten() const
|
||||||
|
{
|
||||||
|
return m_countForgotten;
|
||||||
|
}
|
||||||
|
|
||||||
|
int FlashCard::GetCountBungled() const
|
||||||
|
{
|
||||||
|
return m_countBungled;
|
||||||
|
}
|
||||||
|
|
||||||
|
void FlashCard::SetCountRemembered(int count)
|
||||||
|
{
|
||||||
|
if (count != m_countRemembered)
|
||||||
|
{
|
||||||
|
m_countRemembered = count;
|
||||||
|
m_manager->FlagModified();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void FlashCard::SetCountForgotten(int count)
|
||||||
|
{
|
||||||
|
if (count != m_countForgotten)
|
||||||
|
{
|
||||||
|
m_countForgotten = count;
|
||||||
|
m_manager->FlagModified();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void FlashCard::SetCountBungled(int count)
|
||||||
|
{
|
||||||
|
if (count != m_countBungled)
|
||||||
|
{
|
||||||
|
m_countBungled = count;
|
||||||
|
m_manager->FlagModified();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void FlashCard::SetTimeReviewPrevious(time_t time)
|
||||||
|
{
|
||||||
|
if (time != m_timeReviewPrevious)
|
||||||
|
{
|
||||||
|
m_timeReviewPrevious = time;
|
||||||
|
m_manager->FlagModified();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void FlashCard::SetTimeReviewNext(time_t time)
|
||||||
|
{
|
||||||
|
if (time != m_timeReviewNext)
|
||||||
|
{
|
||||||
|
m_timeReviewNext = time;
|
||||||
|
m_manager->FlagModified();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void FlashCard::ScheduleReview(GradeType grade)
|
||||||
|
{
|
||||||
|
SetTimeReviewNext(ComputeReview(grade, true));
|
||||||
|
SetTimeReviewPrevious(GetTimeCurrent());
|
||||||
|
|
||||||
|
switch (grade)
|
||||||
|
{
|
||||||
|
case GRADE_TYPE_REMEMBER:
|
||||||
|
SetDeck(DECK_TYPE_PENDING);
|
||||||
|
SetCountRemembered(m_countRemembered + 1);
|
||||||
|
break;
|
||||||
|
case GRADE_TYPE_BUNGLE:
|
||||||
|
SetDeck(DECK_TYPE_PENDING);
|
||||||
|
SetCountBungled(m_countBungled + 1);
|
||||||
|
break;
|
||||||
|
case GRADE_TYPE_FORGET:
|
||||||
|
SetDeck(DECK_TYPE_FAILED);
|
||||||
|
SetCountForgotten(m_countForgotten + 1);
|
||||||
|
break;
|
||||||
|
case GRADE_TYPE_LEARN:
|
||||||
|
SetDeck(DECK_TYPE_PENDING);
|
||||||
|
break;
|
||||||
|
case GRADE_TYPE_UNLEARN:
|
||||||
|
SetDeck(DECK_TYPE_FAILED);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
time_t FlashCard::ComputeReview(GradeType grade, bool scatter) const
|
||||||
|
{
|
||||||
|
const FlashCardOptions& options = m_manager->GetOptions();
|
||||||
|
const int timeReviewEntropy = scatter ? options.timeReviewEntropy : 0;
|
||||||
|
const time_t timeNow = GetTimeCurrent();
|
||||||
|
|
||||||
|
time_t timeNext = 0;
|
||||||
|
if (grade == GRADE_TYPE_REMEMBER)
|
||||||
|
{
|
||||||
|
const time_t timeDelta = (std::min(m_timeReviewNext, timeNow) - m_timeReviewPrevious) * 2;
|
||||||
|
timeNext = std::max(m_timeReviewNext, timeNow) + ScatterTime(timeDelta, timeReviewEntropy);
|
||||||
|
}
|
||||||
|
else if (grade == GRADE_TYPE_BUNGLE)
|
||||||
|
{
|
||||||
|
const time_t timeDelta = (std::min(m_timeReviewNext, timeNow) - m_timeReviewPrevious) / 2;
|
||||||
|
timeNext = std::max(m_timeReviewNext, timeNow) + ScatterTime(timeDelta, timeReviewEntropy);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
timeNext = timeNow + ScatterTime(options.timeReviewMin, timeReviewEntropy);
|
||||||
|
}
|
||||||
|
|
||||||
|
const time_t timeDeltaNext = timeNext - timeNow;
|
||||||
|
if (timeDeltaNext < options.timeReviewMin)
|
||||||
|
{
|
||||||
|
timeNext = timeNow + options.timeReviewMin;
|
||||||
|
}
|
||||||
|
else if (timeDeltaNext > options.timeReviewMax)
|
||||||
|
{
|
||||||
|
timeNext = timeNow + options.timeReviewMax;
|
||||||
|
}
|
||||||
|
|
||||||
|
return timeNext;
|
||||||
|
}
|
||||||
|
|
||||||
|
time_t FlashCard::GetTimeCurrent()
|
||||||
|
{
|
||||||
|
return time(NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
time_t FlashCard::ScatterTime(time_t time, int percent)
|
||||||
|
{
|
||||||
|
if (percent == 0)
|
||||||
|
{
|
||||||
|
return time;
|
||||||
|
}
|
||||||
|
|
||||||
|
const double multiplier = 1.0 + static_cast<double>(percent / 2 - rand() % percent) / 100.0;
|
||||||
|
const time_t result = static_cast<time_t>(multiplier * static_cast<double>(time));
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
82
FlashCard.h
Normal file
@ -0,0 +1,82 @@
|
|||||||
|
/*
|
||||||
|
Meganekko Copyright (C) 2008 Alex Yatskov
|
||||||
|
|
||||||
|
This program 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.
|
||||||
|
|
||||||
|
This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
class FlashCardManager;
|
||||||
|
|
||||||
|
class FlashCard
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
FlashCard(
|
||||||
|
FlashCardManager* manager,
|
||||||
|
DeckType deck,
|
||||||
|
const std::wstring& question,
|
||||||
|
const std::wstring& answer,
|
||||||
|
bool enabled,
|
||||||
|
int countRemembered,
|
||||||
|
int countForgotten,
|
||||||
|
int countBungled,
|
||||||
|
time_t timeReviewPrevious,
|
||||||
|
time_t timeReviewNext,
|
||||||
|
time_t timeAdded
|
||||||
|
);
|
||||||
|
|
||||||
|
void SetDeck(DeckType deck);
|
||||||
|
DeckType GetDeck() const;
|
||||||
|
void SetQuestion(const std::wstring& question);
|
||||||
|
const std::wstring& GetQuestion() const;
|
||||||
|
void SetAnswer(const std::wstring& answer);
|
||||||
|
const std::wstring& GetAnswer() const;
|
||||||
|
bool GetEnabled() const;
|
||||||
|
bool IsLearned() const;
|
||||||
|
void Enable(bool enable = true);
|
||||||
|
void Disable();
|
||||||
|
bool Expire();
|
||||||
|
|
||||||
|
time_t GetTimeReviewPrevious() const;
|
||||||
|
time_t GetTimeReviewNext() const;
|
||||||
|
time_t GetTimeAdded() const;
|
||||||
|
int GetCountRemembered() const;
|
||||||
|
int GetCountForgotten() const;
|
||||||
|
int GetCountBungled() const;
|
||||||
|
|
||||||
|
void ScheduleReview(GradeType grade);
|
||||||
|
time_t ComputeReview(GradeType grade, bool scatter) const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
void SetCountRemembered(int count);
|
||||||
|
void SetCountForgotten(int count);
|
||||||
|
void SetCountBungled(int count);
|
||||||
|
void SetTimeReviewPrevious(time_t time);
|
||||||
|
void SetTimeReviewNext(time_t time);
|
||||||
|
|
||||||
|
static time_t GetTimeCurrent();
|
||||||
|
static time_t ScatterTime(time_t time, int percent);
|
||||||
|
|
||||||
|
FlashCardManager* m_manager;
|
||||||
|
DeckType m_deck;
|
||||||
|
std::wstring m_question;
|
||||||
|
std::wstring m_answer;
|
||||||
|
bool m_enabled;
|
||||||
|
int m_countRemembered;
|
||||||
|
int m_countForgotten;
|
||||||
|
int m_countBungled;
|
||||||
|
time_t m_timeReviewPrevious;
|
||||||
|
time_t m_timeReviewNext;
|
||||||
|
time_t m_timeAdded;
|
||||||
|
};
|
190
FlashCardManager.cpp
Normal file
@ -0,0 +1,190 @@
|
|||||||
|
/*
|
||||||
|
Meganekko Copyright (C) 2008 Alex Yatskov
|
||||||
|
|
||||||
|
This program 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.
|
||||||
|
|
||||||
|
This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "Pch.h"
|
||||||
|
#include "FlashCardManager.h"
|
||||||
|
|
||||||
|
const FlashCardOptions FlashCardOptions::DEFAULT;
|
||||||
|
|
||||||
|
FlashCardManager::FlashCardManager() :
|
||||||
|
m_modified(false)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
bool FlashCardManager::Open(const std::wstring& filename)
|
||||||
|
{
|
||||||
|
TiXmlDocument document;
|
||||||
|
if (document.LoadFile(wstrToUtf8(filename).c_str()))
|
||||||
|
{
|
||||||
|
Close();
|
||||||
|
XmlImportRoot(&document);
|
||||||
|
ExpireCards();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool FlashCardManager::Save(const std::wstring& filename) const
|
||||||
|
{
|
||||||
|
TiXmlDocument document;
|
||||||
|
XmlExportRoot(&document);
|
||||||
|
if (document.SaveFile(wstrToUtf8(filename).c_str()))
|
||||||
|
{
|
||||||
|
m_modified = false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void FlashCardManager::Close()
|
||||||
|
{
|
||||||
|
m_cards.clear();
|
||||||
|
m_options = FlashCardOptions::DEFAULT;
|
||||||
|
m_modified = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool FlashCardManager::IsModified() const
|
||||||
|
{
|
||||||
|
return m_modified;
|
||||||
|
}
|
||||||
|
|
||||||
|
void FlashCardManager::FlagModified()
|
||||||
|
{
|
||||||
|
m_modified = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
const FlashCardOptions& FlashCardManager::GetOptions() const
|
||||||
|
{
|
||||||
|
return m_options;
|
||||||
|
}
|
||||||
|
|
||||||
|
void FlashCardManager::SetOptions(const FlashCardOptions& options)
|
||||||
|
{
|
||||||
|
m_modified |= (
|
||||||
|
m_options.timeReviewMin != options.timeReviewMin ||
|
||||||
|
m_options.timeReviewMax != options.timeReviewMax ||
|
||||||
|
m_options.timeReviewEntropy != options.timeReviewEntropy ||
|
||||||
|
m_options.autoSave != options.autoSave ||
|
||||||
|
m_options.fontNameNormal != options.fontNameNormal ||
|
||||||
|
m_options.fontNameFixed != options.fontNameFixed ||
|
||||||
|
memcmp(m_options.fontSizes, options.fontSizes, sizeof(m_options.fontSizes)) != 0
|
||||||
|
);
|
||||||
|
m_options = options;
|
||||||
|
}
|
||||||
|
|
||||||
|
FlashCard* FlashCardManager::AddCard(const std::wstring& question, const std::wstring& answer, bool enabled)
|
||||||
|
{
|
||||||
|
const time_t timeNow = time(NULL);
|
||||||
|
const FlashCard card(
|
||||||
|
this,
|
||||||
|
DECK_TYPE_UNTESTED,
|
||||||
|
question,
|
||||||
|
answer,
|
||||||
|
enabled,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
timeNow,
|
||||||
|
timeNow,
|
||||||
|
timeNow
|
||||||
|
);
|
||||||
|
m_cards.push_front(card);
|
||||||
|
FlagModified();
|
||||||
|
return &*m_cards.begin();
|
||||||
|
}
|
||||||
|
|
||||||
|
void FlashCardManager::EnumerateCards(std::vector<FlashCard*>* cards, unsigned decks, bool allowEnabled, bool allowDisabled, DeckSortType sort)
|
||||||
|
{
|
||||||
|
for (CardList::iterator iter = m_cards.begin(); iter != m_cards.end(); ++iter)
|
||||||
|
{
|
||||||
|
if ((allowEnabled || !iter->GetEnabled()) && (allowDisabled || iter->GetEnabled()) && IS_TRUE(decks & BIT(iter->GetDeck())))
|
||||||
|
{
|
||||||
|
cards->push_back(&*iter);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cards->size() == 0)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sort == DECK_SORT_TYPE_SHUFFLE)
|
||||||
|
{
|
||||||
|
for (size_t i = 0; i < cards->size(); ++i)
|
||||||
|
{
|
||||||
|
std::swap(cards->at(i), cards->at(rand() % cards->size()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
static int (*const s_compareFuncs[])(const void*, const void*) =
|
||||||
|
{
|
||||||
|
CompareByTimeAdded,
|
||||||
|
CompareByTimeReviewPrevious,
|
||||||
|
CompareByTimeReviewNext,
|
||||||
|
CompareByDeck,
|
||||||
|
CompareByEnabled,
|
||||||
|
CompareByQuestion,
|
||||||
|
CompareByAnswer,
|
||||||
|
CompareByCountRemembered,
|
||||||
|
CompareByCountForgotten,
|
||||||
|
CompareByCountBungled
|
||||||
|
};
|
||||||
|
|
||||||
|
qsort(&cards->at(0), cards->size(), sizeof(FlashCard*), s_compareFuncs[sort]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int FlashCardManager::GetDeckSize(DeckType deck, bool allowDisabled) const
|
||||||
|
{
|
||||||
|
int count = 0;
|
||||||
|
for (CardList::const_iterator iter = m_cards.begin(); iter != m_cards.end(); ++iter)
|
||||||
|
{
|
||||||
|
if (iter->GetDeck() == deck && (allowDisabled || iter->GetEnabled()))
|
||||||
|
{
|
||||||
|
++count;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool FlashCardManager::RemoveCard(FlashCard* card)
|
||||||
|
{
|
||||||
|
for (CardList::iterator iter = m_cards.begin(); iter != m_cards.end(); ++iter)
|
||||||
|
{
|
||||||
|
if (&*iter == card)
|
||||||
|
{
|
||||||
|
m_cards.erase(iter);
|
||||||
|
FlagModified();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
int FlashCardManager::ExpireCards()
|
||||||
|
{
|
||||||
|
int count = 0;
|
||||||
|
for (CardList::iterator iter = m_cards.begin(); iter != m_cards.end(); ++iter)
|
||||||
|
{
|
||||||
|
if (iter->Expire())
|
||||||
|
{
|
||||||
|
++count;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return count;
|
||||||
|
}
|
134
FlashCardManager.h
Normal file
@ -0,0 +1,134 @@
|
|||||||
|
/*
|
||||||
|
Meganekko Copyright (C) 2008 Alex Yatskov
|
||||||
|
|
||||||
|
This program 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.
|
||||||
|
|
||||||
|
This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
#include "FlashCard.h"
|
||||||
|
|
||||||
|
#define COMPARE_FUNC(name) \
|
||||||
|
static int CompareBy##name(const void* data1, const void* data2) \
|
||||||
|
{ \
|
||||||
|
const FlashCard* const card1 = *static_cast<const FlashCard* const *>(data1); \
|
||||||
|
const FlashCard* const card2 = *static_cast<const FlashCard* const *>(data2); \
|
||||||
|
if (card1->Get##name() > card2->Get##name()) \
|
||||||
|
{ \
|
||||||
|
return 1; \
|
||||||
|
} \
|
||||||
|
if (card1->Get##name() < card2->Get##name()) \
|
||||||
|
{ \
|
||||||
|
return -1; \
|
||||||
|
} \
|
||||||
|
return 0;\
|
||||||
|
}
|
||||||
|
|
||||||
|
struct FlashCardOptions
|
||||||
|
{
|
||||||
|
FlashCardOptions(
|
||||||
|
time_t timeReviewMin,
|
||||||
|
time_t timeReviewMax,
|
||||||
|
int timeReviewEntropy,
|
||||||
|
bool autoSave,
|
||||||
|
const std::wstring& fontNameNormal,
|
||||||
|
const std::wstring fontNameFixed,
|
||||||
|
const int fontSizes[]
|
||||||
|
) :
|
||||||
|
timeReviewMin(timeReviewMin),
|
||||||
|
timeReviewMax(timeReviewMax),
|
||||||
|
timeReviewEntropy(timeReviewEntropy),
|
||||||
|
autoSave(autoSave),
|
||||||
|
fontNameNormal(fontNameNormal),
|
||||||
|
fontNameFixed(fontNameFixed)
|
||||||
|
{
|
||||||
|
memcpy(this->fontSizes, fontSizes, sizeof(this->fontSizes));
|
||||||
|
}
|
||||||
|
|
||||||
|
FlashCardOptions() :
|
||||||
|
timeReviewMin(DAYS_TO_SECONDS(1)),
|
||||||
|
timeReviewMax(DAYS_TO_SECONDS(365)),
|
||||||
|
timeReviewEntropy(25),
|
||||||
|
autoSave(false)
|
||||||
|
{
|
||||||
|
fontSizes[0] = 9;
|
||||||
|
fontSizes[1] = 12;
|
||||||
|
fontSizes[2] = 14;
|
||||||
|
fontSizes[3] = 18;
|
||||||
|
fontSizes[4] = 24;
|
||||||
|
fontSizes[5] = 30;
|
||||||
|
fontSizes[6] = 36;
|
||||||
|
}
|
||||||
|
|
||||||
|
static const FlashCardOptions DEFAULT;
|
||||||
|
|
||||||
|
time_t timeReviewMin;
|
||||||
|
time_t timeReviewMax;
|
||||||
|
int timeReviewEntropy;
|
||||||
|
bool autoSave;
|
||||||
|
std::wstring fontNameNormal;
|
||||||
|
std::wstring fontNameFixed;
|
||||||
|
int fontSizes[7];
|
||||||
|
};
|
||||||
|
|
||||||
|
class FlashCardManager
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
FlashCardManager();
|
||||||
|
|
||||||
|
bool Open(const std::wstring& filename);
|
||||||
|
bool Save(const std::wstring& filename) const;
|
||||||
|
void Close();
|
||||||
|
void FlagModified();
|
||||||
|
bool IsModified() const;
|
||||||
|
|
||||||
|
const FlashCardOptions& GetOptions() const;
|
||||||
|
void SetOptions(const FlashCardOptions& options);
|
||||||
|
|
||||||
|
FlashCard* AddCard(const std::wstring& question, const std::wstring& answer, bool enabled);
|
||||||
|
void EnumerateCards(std::vector<FlashCard*>* cards, unsigned decks, bool allowEnabled, bool allowDisabled, DeckSortType sort);
|
||||||
|
int GetDeckSize(DeckType deck, bool allowDisabled) const;
|
||||||
|
bool RemoveCard(FlashCard* card);
|
||||||
|
int ExpireCards();
|
||||||
|
|
||||||
|
private:
|
||||||
|
typedef std::list<FlashCard> CardList;
|
||||||
|
|
||||||
|
void XmlExportRoot(TiXmlDocument* parent) const;
|
||||||
|
void XmlExportOptions(TiXmlElement* parent) const;
|
||||||
|
void XmlExportDecks(TiXmlElement* parent) const;
|
||||||
|
void XmlExportDeck(TiXmlElement* parent, DeckType deck) const;
|
||||||
|
void XmlExportCard(TiXmlElement* parent, const FlashCard& card) const;
|
||||||
|
void XmlImportRoot(const TiXmlDocument* parent);
|
||||||
|
void XmlImportOptions(const TiXmlElement* parent);
|
||||||
|
void XmlImportDecks(const TiXmlElement* parent);
|
||||||
|
void XmlImportDeck(const TiXmlElement* parent, DeckType deck);
|
||||||
|
void XmlImportCard(const TiXmlElement* parent, DeckType deck);
|
||||||
|
|
||||||
|
COMPARE_FUNC(Question);
|
||||||
|
COMPARE_FUNC(Answer);
|
||||||
|
COMPARE_FUNC(Enabled);
|
||||||
|
COMPARE_FUNC(Deck);
|
||||||
|
COMPARE_FUNC(CountRemembered);
|
||||||
|
COMPARE_FUNC(CountForgotten);
|
||||||
|
COMPARE_FUNC(CountBungled);
|
||||||
|
COMPARE_FUNC(TimeReviewPrevious);
|
||||||
|
COMPARE_FUNC(TimeReviewNext);
|
||||||
|
COMPARE_FUNC(TimeAdded);
|
||||||
|
|
||||||
|
CardList m_cards;
|
||||||
|
FlashCardOptions m_options;
|
||||||
|
mutable bool m_modified;
|
||||||
|
};
|
||||||
|
|
||||||
|
#undef COMPARE_FUNC
|
249
FlashCardManagerXml.cpp
Normal file
@ -0,0 +1,249 @@
|
|||||||
|
/*
|
||||||
|
Meganekko Copyright (C) 2008 Alex Yatskov
|
||||||
|
|
||||||
|
This program 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.
|
||||||
|
|
||||||
|
This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "Pch.h"
|
||||||
|
#include "FlashCardManager.h"
|
||||||
|
|
||||||
|
void FlashCardManager::XmlExportRoot(TiXmlDocument* parent) const
|
||||||
|
{
|
||||||
|
TiXmlElement* const rootElement = new TiXmlElement("Meganekko");
|
||||||
|
XmlExportOptions(rootElement);
|
||||||
|
XmlExportDecks(rootElement);
|
||||||
|
parent->LinkEndChild(rootElement);
|
||||||
|
}
|
||||||
|
|
||||||
|
void FlashCardManager::XmlExportOptions(TiXmlElement* parent) const
|
||||||
|
{
|
||||||
|
TiXmlElement* const optionsElement = new TiXmlElement("Options");
|
||||||
|
|
||||||
|
optionsElement->SetAttribute("timeReviewMin", m_options.timeReviewMin);
|
||||||
|
optionsElement->SetAttribute("timeReviewMax", m_options.timeReviewMax);
|
||||||
|
optionsElement->SetAttribute("timeReviewEntropy", m_options.timeReviewEntropy);
|
||||||
|
optionsElement->SetAttribute("autoSave", m_options.autoSave);
|
||||||
|
optionsElement->SetAttribute("fontNameNormal", wstrToUtf8(m_options.fontNameNormal).c_str());
|
||||||
|
optionsElement->SetAttribute("fontNameFixed", wstrToUtf8(m_options.fontNameFixed).c_str());
|
||||||
|
for (size_t i = 0; i < ARRAY_SIZE(m_options.fontSizes); ++i)
|
||||||
|
{
|
||||||
|
char attribute[16] = {0};
|
||||||
|
sprintf(attribute, "fontSize%d", static_cast<int>(i));
|
||||||
|
optionsElement->SetAttribute(attribute, m_options.fontSizes[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
parent->LinkEndChild(optionsElement);
|
||||||
|
}
|
||||||
|
|
||||||
|
void FlashCardManager::XmlExportDecks(TiXmlElement* parent) const
|
||||||
|
{
|
||||||
|
TiXmlElement* const decksElement = new TiXmlElement("Decks");
|
||||||
|
|
||||||
|
for (size_t i = 0; i < DECK_TYPES; ++i)
|
||||||
|
{
|
||||||
|
XmlExportDeck(decksElement, static_cast<DeckType>(i));
|
||||||
|
}
|
||||||
|
|
||||||
|
parent->LinkEndChild(decksElement);
|
||||||
|
}
|
||||||
|
|
||||||
|
void FlashCardManager::XmlExportDeck(TiXmlElement* parent, DeckType deck) const
|
||||||
|
{
|
||||||
|
TiXmlElement* const deckElement = new TiXmlElement("Deck");
|
||||||
|
deckElement->SetAttribute("type", DeckTypeToString(deck).c_str());
|
||||||
|
|
||||||
|
for (CardList::const_iterator iter = m_cards.begin(); iter != m_cards.end(); ++iter)
|
||||||
|
{
|
||||||
|
if (iter->GetDeck() == deck)
|
||||||
|
{
|
||||||
|
XmlExportCard(deckElement, *iter);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
parent->LinkEndChild(deckElement);
|
||||||
|
}
|
||||||
|
|
||||||
|
void FlashCardManager::XmlExportCard(TiXmlElement* parent, const FlashCard& card) const
|
||||||
|
{
|
||||||
|
TiXmlElement* const cardElement = new TiXmlElement("Card");
|
||||||
|
|
||||||
|
TiXmlElement* const questionElement = new TiXmlElement("Question");
|
||||||
|
TiXmlText* const questionText = new TiXmlText(wstrToUtf8(card.GetQuestion()).c_str());
|
||||||
|
questionText->SetCDATA(true);
|
||||||
|
questionElement->LinkEndChild(questionText);
|
||||||
|
cardElement->LinkEndChild(questionElement);
|
||||||
|
|
||||||
|
TiXmlElement* const answerElement = new TiXmlElement("Answer");
|
||||||
|
TiXmlText* const answerText = new TiXmlText(wstrToUtf8(card.GetAnswer()).c_str());
|
||||||
|
answerText->SetCDATA(true);
|
||||||
|
answerElement->LinkEndChild(answerText);
|
||||||
|
cardElement->LinkEndChild(answerElement);
|
||||||
|
|
||||||
|
cardElement->SetAttribute("enabled", card.GetEnabled());
|
||||||
|
cardElement->SetAttribute("countRemembered", card.GetCountRemembered());
|
||||||
|
cardElement->SetAttribute("countForgotten", card.GetCountForgotten());
|
||||||
|
cardElement->SetAttribute("countBungled", card.GetCountBungled());
|
||||||
|
cardElement->SetAttribute("timeReviewNext", card.GetTimeReviewNext());
|
||||||
|
cardElement->SetAttribute("timeReviewPrevious", card.GetTimeReviewPrevious());
|
||||||
|
cardElement->SetAttribute("timeAdded", card.GetTimeAdded());
|
||||||
|
|
||||||
|
parent->LinkEndChild(cardElement);
|
||||||
|
}
|
||||||
|
|
||||||
|
void FlashCardManager::XmlImportRoot(const TiXmlDocument* parent)
|
||||||
|
{
|
||||||
|
const TiXmlElement* const rootElement = parent->RootElement();
|
||||||
|
if (rootElement == NULL || strcmp(rootElement->Value(), "Meganekko") != 0)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const TiXmlElement* baseElement = rootElement->FirstChildElement(); baseElement != NULL; baseElement = baseElement->NextSiblingElement())
|
||||||
|
{
|
||||||
|
const char* const value = baseElement->Value();
|
||||||
|
if (strcmp(value, "Options") == 0)
|
||||||
|
{
|
||||||
|
XmlImportOptions(baseElement);
|
||||||
|
}
|
||||||
|
else if (strcmp(value, "Decks") == 0)
|
||||||
|
{
|
||||||
|
XmlImportDecks(baseElement);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void FlashCardManager::XmlImportOptions(const TiXmlElement* parent)
|
||||||
|
{
|
||||||
|
int timeReviewMin = FlashCardOptions::DEFAULT.timeReviewMin;
|
||||||
|
parent->Attribute("timeReviewMin", &timeReviewMin);
|
||||||
|
|
||||||
|
int timeReviewMax = FlashCardOptions::DEFAULT.timeReviewMax;
|
||||||
|
parent->Attribute("timeReviewMax", &timeReviewMax);
|
||||||
|
|
||||||
|
int timeReviewEntropy = FlashCardOptions::DEFAULT.timeReviewEntropy;;
|
||||||
|
parent->Attribute("timeReviewEntropy", &timeReviewEntropy);
|
||||||
|
|
||||||
|
int autoSave = FlashCardOptions::DEFAULT.autoSave;;
|
||||||
|
parent->Attribute("autoSave", &autoSave);
|
||||||
|
|
||||||
|
const char* const fontNameNormal = parent->Attribute("fontNameNormal");
|
||||||
|
const char* const fontNameFixed = parent->Attribute("fontNameFixed");
|
||||||
|
|
||||||
|
for (size_t i = 0; i < ARRAY_SIZE(m_options.fontSizes); ++i)
|
||||||
|
{
|
||||||
|
char attribute[16] = {0};
|
||||||
|
sprintf(attribute, "fontSize%d", static_cast<int>(i));
|
||||||
|
m_options.fontSizes[i] = FlashCardOptions::DEFAULT.fontSizes[i];
|
||||||
|
parent->Attribute(attribute, m_options.fontSizes + i);
|
||||||
|
}
|
||||||
|
|
||||||
|
m_options.timeReviewMin = timeReviewMin;
|
||||||
|
m_options.timeReviewMax = timeReviewMax;
|
||||||
|
m_options.timeReviewEntropy = timeReviewEntropy;
|
||||||
|
m_options.autoSave = IS_TRUE(autoSave);
|
||||||
|
m_options.fontNameNormal = fontNameNormal == NULL ? FlashCardOptions::DEFAULT.fontNameNormal : utf8toWStr(fontNameNormal);
|
||||||
|
m_options.fontNameFixed = fontNameFixed == NULL ? FlashCardOptions::DEFAULT.fontNameFixed : utf8toWStr(fontNameFixed);
|
||||||
|
}
|
||||||
|
|
||||||
|
void FlashCardManager::XmlImportDecks(const TiXmlElement* parent)
|
||||||
|
{
|
||||||
|
for (const TiXmlElement* decksElement = parent->FirstChildElement(); decksElement != NULL; decksElement = decksElement->NextSiblingElement())
|
||||||
|
{
|
||||||
|
const char* const value = decksElement->Value();
|
||||||
|
if (strcmp(value, "Deck") == 0)
|
||||||
|
{
|
||||||
|
const char* const deckString = decksElement->Attribute("type");
|
||||||
|
const DeckType deck = deckString == NULL ? DECK_TYPE_UNTESTED : StringToDeckType(deckString);
|
||||||
|
XmlImportDeck(decksElement, deck);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void FlashCardManager::XmlImportDeck(const TiXmlElement* parent, DeckType deck)
|
||||||
|
{
|
||||||
|
for (const TiXmlElement* deckElement = parent->FirstChildElement(); deckElement != NULL; deckElement = deckElement->NextSiblingElement())
|
||||||
|
{
|
||||||
|
const char* const value = deckElement->Value();
|
||||||
|
if (strcmp(value, "Card") == 0)
|
||||||
|
{
|
||||||
|
XmlImportCard(deckElement, deck);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void FlashCardManager::XmlImportCard(const TiXmlElement* parent, DeckType deck)
|
||||||
|
{
|
||||||
|
std::wstring question;
|
||||||
|
std::wstring answer;
|
||||||
|
|
||||||
|
for (const TiXmlElement* cardElement = parent->FirstChildElement(); cardElement != NULL; cardElement = cardElement->NextSiblingElement())
|
||||||
|
{
|
||||||
|
const char* const value = cardElement->Value();
|
||||||
|
if (strcmp(value, "Question") == 0)
|
||||||
|
{
|
||||||
|
question = utf8toWStr(cardElement->GetText());
|
||||||
|
}
|
||||||
|
else if (strcmp(value, "Answer") == 0)
|
||||||
|
{
|
||||||
|
answer = utf8toWStr(cardElement->GetText());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int enabled = 0;
|
||||||
|
parent->Attribute("enabled", &enabled);
|
||||||
|
|
||||||
|
int countRemembered = 0;
|
||||||
|
parent->Attribute("countRemembered", &countRemembered);
|
||||||
|
|
||||||
|
int countForgotten = 0;
|
||||||
|
parent->Attribute("countForgotten", &countForgotten);
|
||||||
|
|
||||||
|
int countBungled = 0;
|
||||||
|
parent->Attribute("countBungled", &countBungled);
|
||||||
|
|
||||||
|
int timeReviewNext = 0;
|
||||||
|
parent->Attribute("timeReviewNext", &timeReviewNext);
|
||||||
|
|
||||||
|
int timeReviewPrevious = 0;
|
||||||
|
parent->Attribute("timeReviewPrevious", &timeReviewPrevious);
|
||||||
|
|
||||||
|
int timeAdded = 0;
|
||||||
|
parent->Attribute("timeAdded", &timeAdded);
|
||||||
|
|
||||||
|
const bool valid =
|
||||||
|
timeAdded > 0 &&
|
||||||
|
timeAdded <= timeReviewPrevious &&
|
||||||
|
timeReviewPrevious <= timeReviewNext;
|
||||||
|
|
||||||
|
if (!valid)
|
||||||
|
{
|
||||||
|
timeAdded = timeReviewPrevious = timeReviewNext = time(NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
const FlashCard card(
|
||||||
|
this,
|
||||||
|
deck,
|
||||||
|
question,
|
||||||
|
answer,
|
||||||
|
IS_TRUE(enabled),
|
||||||
|
countRemembered,
|
||||||
|
countForgotten,
|
||||||
|
countBungled,
|
||||||
|
timeReviewPrevious,
|
||||||
|
timeReviewNext,
|
||||||
|
timeAdded
|
||||||
|
);
|
||||||
|
|
||||||
|
m_cards.push_front(card);
|
||||||
|
}
|
394
FrameMeganekko.cpp
Normal file
@ -0,0 +1,394 @@
|
|||||||
|
/*
|
||||||
|
Meganekko Copyright (C) 2008 Alex Yatskov
|
||||||
|
|
||||||
|
This program 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.
|
||||||
|
|
||||||
|
This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "Pch.h"
|
||||||
|
#include "FrameMeganekko.h"
|
||||||
|
#include "DialogCardManager.h"
|
||||||
|
#include "DialogCard.h"
|
||||||
|
#include "DialogAbout.h"
|
||||||
|
#include "DialogOptions.h"
|
||||||
|
|
||||||
|
BEGIN_EVENT_TABLE(FrameMeganekko, wxFrame)
|
||||||
|
EVT_MENU(XRCID("menuFileNew"), FrameMeganekko::OnMenuFileNew)
|
||||||
|
EVT_MENU(XRCID("menuFileOpen"), FrameMeganekko::OnMenuFileOpen)
|
||||||
|
EVT_MENU(XRCID("menuFileSave"), FrameMeganekko::OnMenuFileSave)
|
||||||
|
EVT_MENU(XRCID("menuFileSaveAs"), FrameMeganekko::OnMenuFileSaveAs)
|
||||||
|
EVT_MENU(XRCID("menuFileExit"), FrameMeganekko::OnMenuFileExit)
|
||||||
|
EVT_MENU(XRCID("menuToolsCardsManage"), FrameMeganekko::OnMenuToolsCardsManage)
|
||||||
|
EVT_MENU(XRCID("menuToolsCardsExpire"), FrameMeganekko::OnMenuToolsCardsExpire)
|
||||||
|
EVT_MENU(XRCID("menuToolsOptions"), FrameMeganekko::OnMenuToolsOptions)
|
||||||
|
EVT_MENU(XRCID("menuToolsReviewSequential"), FrameMeganekko::OnMenuToolsReviewSequential)
|
||||||
|
EVT_MENU(XRCID("menuToolsReviewStudy"), FrameMeganekko::OnMenuToolsReviewStudy)
|
||||||
|
EVT_MENU(XRCID("menuHelpHomepage"), FrameMeganekko::OnMenuHelpHomepage)
|
||||||
|
EVT_MENU(XRCID("menuHelpAbout"), FrameMeganekko::OnMenuHelpAbout)
|
||||||
|
EVT_BUTTON(XRCID("buttonExpired"), FrameMeganekko::OnButtonExpired)
|
||||||
|
EVT_BUTTON(XRCID("buttonFailed"), FrameMeganekko::OnButtonFailed)
|
||||||
|
EVT_BUTTON(XRCID("buttonUntested"), FrameMeganekko::OnButtonUntested)
|
||||||
|
EVT_BUTTON(XRCID("buttonPending"), FrameMeganekko::OnButtonPending)
|
||||||
|
EVT_CLOSE(FrameMeganekko::OnClose)
|
||||||
|
END_EVENT_TABLE()
|
||||||
|
|
||||||
|
FrameMeganekko::FrameMeganekko(const wxString& filename) :
|
||||||
|
m_gaugeExpired(NULL),
|
||||||
|
m_gaugeFailed(NULL),
|
||||||
|
m_gaugeUntested(NULL),
|
||||||
|
m_gaugePending(NULL),
|
||||||
|
m_buttonExpired(NULL),
|
||||||
|
m_buttonFailed(NULL),
|
||||||
|
m_buttonUntested(NULL),
|
||||||
|
m_buttonPending(NULL)
|
||||||
|
{
|
||||||
|
wxXmlResource::Get()->LoadFrame(this, NULL, wxT("FrameMeganekko"));
|
||||||
|
SetSize(wxSize(640, 480));
|
||||||
|
|
||||||
|
m_gaugeExpired = XRCCTRL(*this, "gaugeExpired", wxGauge);
|
||||||
|
m_gaugeFailed = XRCCTRL(*this, "gaugeFailed", wxGauge);
|
||||||
|
m_gaugeUntested = XRCCTRL(*this, "gaugeUntested", wxGauge);
|
||||||
|
m_gaugePending = XRCCTRL(*this, "gaugePending", wxGauge);
|
||||||
|
m_buttonExpired = XRCCTRL(*this, "buttonExpired", wxButton);
|
||||||
|
m_buttonFailed = XRCCTRL(*this, "buttonFailed", wxButton);
|
||||||
|
m_buttonUntested = XRCCTRL(*this, "buttonUntested", wxButton);
|
||||||
|
m_buttonPending = XRCCTRL(*this, "buttonPending", wxButton);
|
||||||
|
|
||||||
|
if (!filename.IsEmpty())
|
||||||
|
{
|
||||||
|
OpenDecks(filename);
|
||||||
|
}
|
||||||
|
|
||||||
|
UpdateDecks();
|
||||||
|
}
|
||||||
|
|
||||||
|
void FrameMeganekko::OnMenuFileNew(wxCommandEvent& event)
|
||||||
|
{
|
||||||
|
if (!SavePromptBail())
|
||||||
|
{
|
||||||
|
NewDecks();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void FrameMeganekko::OnMenuFileOpen(wxCommandEvent& event)
|
||||||
|
{
|
||||||
|
if (SavePromptBail())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
wxString filename = wxFileSelector(
|
||||||
|
wxT("Choose a deck file to open"),
|
||||||
|
wxEmptyString,
|
||||||
|
wxEmptyString,
|
||||||
|
wxT("mnko"),
|
||||||
|
wxT("Meganekko files|*.mnko"),
|
||||||
|
wxOPEN,
|
||||||
|
this
|
||||||
|
);
|
||||||
|
|
||||||
|
if (filename.IsEmpty())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef wxGTK
|
||||||
|
// is this a bug in gtk wx? the default_extension doesn't appear to do anything
|
||||||
|
// so for now just explicitly provide an extension if one isn't specified
|
||||||
|
wxFileName temp(filename);
|
||||||
|
if (temp.GetExt().IsEmpty())
|
||||||
|
{
|
||||||
|
temp.SetExt(wxT("mnko"));
|
||||||
|
filename = temp.GetFullPath();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
OpenDecks(filename);
|
||||||
|
}
|
||||||
|
|
||||||
|
void FrameMeganekko::OnMenuFileSave(wxCommandEvent& event)
|
||||||
|
{
|
||||||
|
SaveDecks();
|
||||||
|
}
|
||||||
|
|
||||||
|
void FrameMeganekko::OnMenuFileSaveAs(wxCommandEvent& event)
|
||||||
|
{
|
||||||
|
SaveDecksAs();
|
||||||
|
}
|
||||||
|
|
||||||
|
void FrameMeganekko::OnMenuFileExit(wxCommandEvent&)
|
||||||
|
{
|
||||||
|
Close(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
void FrameMeganekko::OnMenuToolsCardsManage(wxCommandEvent& event)
|
||||||
|
{
|
||||||
|
DialogCardManager* const dialog = new DialogCardManager(this, &m_manager);
|
||||||
|
dialog->ShowModal();
|
||||||
|
UpdateDecks();
|
||||||
|
}
|
||||||
|
|
||||||
|
void FrameMeganekko::OnMenuToolsCardsExpire(wxCommandEvent& event)
|
||||||
|
{
|
||||||
|
const int count = m_manager.ExpireCards();
|
||||||
|
if (count == 0)
|
||||||
|
{
|
||||||
|
wxMessageBox(wxT("There are no newly expired cards"), wxT("Meganekko"), wxOK | wxICON_INFORMATION, this);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
wxMessageBox(wxString::Format(wxT("There are %d newly expired cards"), count), wxT("Meganekko"), wxOK | wxICON_INFORMATION, this);
|
||||||
|
UpdateDecks();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void FrameMeganekko::OnMenuToolsOptions(wxCommandEvent& event)
|
||||||
|
{
|
||||||
|
DialogOptions* const dialog = new DialogOptions(this, &m_manager);
|
||||||
|
dialog->ShowModal();
|
||||||
|
UpdateDecks();
|
||||||
|
}
|
||||||
|
|
||||||
|
void FrameMeganekko::OnMenuToolsReviewSequential(wxCommandEvent& event)
|
||||||
|
{
|
||||||
|
std::vector<FlashCard*> cards;
|
||||||
|
m_manager.EnumerateCards(&cards, static_cast<unsigned>(-1) & ~BIT(DECK_TYPE_FAILED), true, false, DECK_SORT_TYPE_TIME_REVIEW_PREVIOUS);
|
||||||
|
|
||||||
|
if (cards.size() > 0)
|
||||||
|
{
|
||||||
|
DialogCard* const dialog = new DialogCard(this, BIT(DialogCard::CARD_CTRL_QUIZ), cards, m_manager.GetOptions());
|
||||||
|
dialog->ShowModal();
|
||||||
|
UpdateDecks();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void FrameMeganekko::OnMenuToolsReviewStudy(wxCommandEvent& event)
|
||||||
|
{
|
||||||
|
std::vector<FlashCard*> cards;
|
||||||
|
m_manager.EnumerateCards(&cards, static_cast<unsigned>(-1), false, true, DECK_SORT_TYPE_TIME_ADDED);
|
||||||
|
|
||||||
|
if (cards.size() > 0)
|
||||||
|
{
|
||||||
|
const unsigned controls = BIT(DialogCard::CARD_CTRL_ENABLED) | BIT(DialogCard::CARD_CTRL_NAVIGATE);
|
||||||
|
DialogCard* const dialog = new DialogCard(this, controls, cards, m_manager.GetOptions());
|
||||||
|
dialog->ShowModal();
|
||||||
|
UpdateDecks();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void FrameMeganekko::OnMenuHelpHomepage(wxCommandEvent& event)
|
||||||
|
{
|
||||||
|
wxLaunchDefaultBrowser(wxT("http://foosoft.net/meganekko"));
|
||||||
|
}
|
||||||
|
|
||||||
|
void FrameMeganekko::OnMenuHelpAbout(wxCommandEvent& event)
|
||||||
|
{
|
||||||
|
DialogAbout* const dialog = new DialogAbout(this);
|
||||||
|
dialog->ShowModal();
|
||||||
|
}
|
||||||
|
|
||||||
|
void FrameMeganekko::OnButtonExpired(wxCommandEvent& event)
|
||||||
|
{
|
||||||
|
UseDeck(DECK_TYPE_EXPIRED);
|
||||||
|
}
|
||||||
|
|
||||||
|
void FrameMeganekko::OnButtonFailed(wxCommandEvent& event)
|
||||||
|
{
|
||||||
|
UseDeck(DECK_TYPE_FAILED);
|
||||||
|
}
|
||||||
|
|
||||||
|
void FrameMeganekko::OnButtonUntested(wxCommandEvent& event)
|
||||||
|
{
|
||||||
|
UseDeck(DECK_TYPE_UNTESTED);
|
||||||
|
}
|
||||||
|
|
||||||
|
void FrameMeganekko::OnButtonPending(wxCommandEvent& event)
|
||||||
|
{
|
||||||
|
UseDeck(DECK_TYPE_PENDING);
|
||||||
|
}
|
||||||
|
|
||||||
|
void FrameMeganekko::OnClose(wxCloseEvent& event)
|
||||||
|
{
|
||||||
|
if (event.CanVeto() && SavePromptBail())
|
||||||
|
{
|
||||||
|
event.Veto();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Destroy();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool FrameMeganekko::UseDeck(DeckType type)
|
||||||
|
{
|
||||||
|
unsigned controls = BIT(DialogCard::CARD_CTRL_QUIZ);
|
||||||
|
if (type == DECK_TYPE_FAILED)
|
||||||
|
{
|
||||||
|
controls = BIT(DialogCard::CARD_CTRL_LEARNED) | BIT(DialogCard::CARD_CTRL_NAVIGATE);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<FlashCard*> cards;
|
||||||
|
m_manager.EnumerateCards(&cards, BIT(type), true, false, DECK_SORT_TYPE_SHUFFLE);
|
||||||
|
|
||||||
|
if (cards.size() > 0)
|
||||||
|
{
|
||||||
|
DialogCard* const dialog = new DialogCard(this, controls, cards, m_manager.GetOptions());
|
||||||
|
dialog->ShowModal();
|
||||||
|
UpdateDecks();
|
||||||
|
}
|
||||||
|
|
||||||
|
return cards.size() > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool FrameMeganekko::SaveDecksAs()
|
||||||
|
{
|
||||||
|
wxString filename = wxFileSelector(
|
||||||
|
wxT("Choose a deck file to save"),
|
||||||
|
wxEmptyString,
|
||||||
|
wxEmptyString,
|
||||||
|
wxT("mnko"),
|
||||||
|
wxT("Meganekko files|*.mnko"),
|
||||||
|
wxSAVE,
|
||||||
|
this
|
||||||
|
);
|
||||||
|
|
||||||
|
if (filename.IsEmpty())
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_filename = filename;
|
||||||
|
|
||||||
|
#ifdef wxGTK
|
||||||
|
// is this a bug in gtk wx? the default_extension doesn't appear to do anything
|
||||||
|
// so for now just explicitly provide an extension if one isn't specified
|
||||||
|
wxFileName temp(m_filename);
|
||||||
|
if (temp.GetExt().IsEmpty())
|
||||||
|
{
|
||||||
|
temp.SetExt(wxT("mnko"));
|
||||||
|
m_filename = temp.GetFullPath();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return SaveDecks(m_filename);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool FrameMeganekko::SaveDecks()
|
||||||
|
{
|
||||||
|
return m_filename.IsEmpty() ? SaveDecksAs() : SaveDecks(m_filename);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool FrameMeganekko::SaveDecks(const wxString& filename)
|
||||||
|
{
|
||||||
|
if (!m_manager.Save(filename.c_str()))
|
||||||
|
{
|
||||||
|
wxMessageBox(wxString::Format(wxT("Cannot save deck %s"), filename.c_str()), wxT("Meganekko"), wxOK | wxICON_ERROR, this);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_filename = filename;
|
||||||
|
UpdateDecks();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool FrameMeganekko::OpenDecks(const wxString& filename)
|
||||||
|
{
|
||||||
|
if (!m_manager.Open(filename.c_str()))
|
||||||
|
{
|
||||||
|
wxMessageBox(wxString::Format(wxT("Cannot open deck %s"), filename.c_str()), wxT("Meganekko"), wxOK | wxICON_ERROR, this);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_filename = filename;
|
||||||
|
UpdateDecks();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool FrameMeganekko::NewDecks()
|
||||||
|
{
|
||||||
|
m_manager.Close();
|
||||||
|
m_filename.Clear();
|
||||||
|
UpdateDecks();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void FrameMeganekko::UpdateDecks()
|
||||||
|
{
|
||||||
|
const wxString title = wxString::Format(
|
||||||
|
wxT("Meganekko - %s %c"),
|
||||||
|
m_filename.IsEmpty() ? wxT("Untitled") : m_filename.c_str(),
|
||||||
|
m_manager.IsModified() ? '*' : ' '
|
||||||
|
);
|
||||||
|
SetTitle(title);
|
||||||
|
|
||||||
|
const int expired = m_manager.GetDeckSize(DECK_TYPE_EXPIRED, false);
|
||||||
|
const int failed = m_manager.GetDeckSize(DECK_TYPE_FAILED, false);
|
||||||
|
const int untested = m_manager.GetDeckSize(DECK_TYPE_UNTESTED, false);
|
||||||
|
const int pending = m_manager.GetDeckSize(DECK_TYPE_PENDING, false);
|
||||||
|
const int total = expired + failed + untested + pending;
|
||||||
|
|
||||||
|
float percentExpired = 0;
|
||||||
|
float percentFailed = 0;
|
||||||
|
float percentUntested = 0;
|
||||||
|
float percentPending = 0;
|
||||||
|
|
||||||
|
if (total > 0)
|
||||||
|
{
|
||||||
|
percentExpired = 100.0f * static_cast<float>(expired) / static_cast<float>(total);
|
||||||
|
percentFailed = 100.0f * static_cast<float>(failed) / static_cast<float>(total);
|
||||||
|
percentUntested = 100.0f * static_cast<float>(untested) / static_cast<float>(total);
|
||||||
|
percentPending = 100.0f * static_cast<float>(pending) / static_cast<float>(total);
|
||||||
|
}
|
||||||
|
|
||||||
|
m_gaugeExpired->SetValue(static_cast<int>(percentExpired));
|
||||||
|
m_gaugeExpired->SetToolTip(wxString::Format(wxT("%.2f%%"), percentExpired));
|
||||||
|
m_buttonExpired->SetLabel(wxString::Format(wxT("&Expired (%d)"), expired));
|
||||||
|
m_buttonExpired->Enable(expired > 0);
|
||||||
|
|
||||||
|
m_gaugeFailed->SetValue(static_cast<int>(percentFailed));
|
||||||
|
m_gaugeFailed->SetToolTip(wxString::Format(wxT("%.2f%%"), percentFailed));
|
||||||
|
m_buttonFailed->SetLabel(wxString::Format(wxT("F&ailed (%d)"), failed));
|
||||||
|
m_buttonFailed->Enable(failed > 0);
|
||||||
|
|
||||||
|
m_gaugeUntested->SetValue(static_cast<int>(percentUntested));
|
||||||
|
m_gaugeUntested->SetToolTip(wxString::Format(wxT("%.2f%%"), percentUntested));
|
||||||
|
m_buttonUntested->SetLabel(wxString::Format(wxT("&Untested (%d)"), untested));
|
||||||
|
m_buttonUntested->Enable(untested > 0);
|
||||||
|
|
||||||
|
m_gaugePending->SetValue(static_cast<int>(percentPending));
|
||||||
|
m_gaugePending->SetToolTip(wxString::Format(wxT("%.2f%%"), percentPending));
|
||||||
|
m_buttonPending->SetLabel(wxString::Format(wxT("&Pending (%d)"), pending));
|
||||||
|
m_buttonPending->Enable(pending > 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool FrameMeganekko::SavePromptBail()
|
||||||
|
{
|
||||||
|
if (!m_manager.IsModified())
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const int result = m_manager.GetOptions().autoSave ? wxYES : wxMessageBox(
|
||||||
|
wxT("The flash card database has been modified, do you want to save?"),
|
||||||
|
wxT("Meganekko"),
|
||||||
|
wxYES_NO | wxCANCEL | wxICON_QUESTION,
|
||||||
|
this
|
||||||
|
);
|
||||||
|
|
||||||
|
if (result == wxNO || (result == wxYES && SaveDecks()))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
67
FrameMeganekko.h
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
/*
|
||||||
|
Meganekko Copyright (C) 2008 Alex Yatskov
|
||||||
|
|
||||||
|
This program 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.
|
||||||
|
|
||||||
|
This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
#include "FlashCardManager.h"
|
||||||
|
|
||||||
|
class FrameMeganekko : public wxFrame
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
FrameMeganekko(const wxString& filename);
|
||||||
|
|
||||||
|
void OnMenuFileNew(wxCommandEvent& event);
|
||||||
|
void OnMenuFileOpen(wxCommandEvent& event);
|
||||||
|
void OnMenuFileSave(wxCommandEvent& event);
|
||||||
|
void OnMenuFileSaveAs(wxCommandEvent& event);
|
||||||
|
void OnMenuFileExit(wxCommandEvent& event);
|
||||||
|
void OnMenuToolsCardsManage(wxCommandEvent& event);
|
||||||
|
void OnMenuToolsCardsExpire(wxCommandEvent& event);
|
||||||
|
void OnMenuToolsOptions(wxCommandEvent& event);
|
||||||
|
void OnMenuToolsReviewSequential(wxCommandEvent& event);
|
||||||
|
void OnMenuToolsReviewStudy(wxCommandEvent& event);
|
||||||
|
void OnMenuHelpHomepage(wxCommandEvent& event);
|
||||||
|
void OnMenuHelpAbout(wxCommandEvent& event);
|
||||||
|
void OnButtonExpired(wxCommandEvent& event);
|
||||||
|
void OnButtonFailed(wxCommandEvent& event);
|
||||||
|
void OnButtonUntested(wxCommandEvent& event);
|
||||||
|
void OnButtonPending(wxCommandEvent& event);
|
||||||
|
void OnClose(wxCloseEvent& event);
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool UseDeck(DeckType type);
|
||||||
|
bool SaveDecksAs();
|
||||||
|
bool SaveDecks();
|
||||||
|
bool SaveDecks(const wxString& filename);
|
||||||
|
bool OpenDecks(const wxString& filename);
|
||||||
|
bool NewDecks();
|
||||||
|
void UpdateDecks();
|
||||||
|
bool SavePromptBail();
|
||||||
|
|
||||||
|
DECLARE_EVENT_TABLE()
|
||||||
|
|
||||||
|
FlashCardManager m_manager;
|
||||||
|
wxString m_filename;
|
||||||
|
|
||||||
|
wxGauge* m_gaugeExpired;
|
||||||
|
wxGauge* m_gaugeFailed;
|
||||||
|
wxGauge* m_gaugeUntested;
|
||||||
|
wxGauge* m_gaugePending;
|
||||||
|
wxButton* m_buttonExpired;
|
||||||
|
wxButton* m_buttonFailed;
|
||||||
|
wxButton* m_buttonUntested;
|
||||||
|
wxButton* m_buttonPending;
|
||||||
|
};
|
BIN
Graphics/KuroKona.png
Normal file
After Width: | Height: | Size: 35 KiB |
BIN
Graphics/file-new.png
Normal file
After Width: | Height: | Size: 999 B |
BIN
Graphics/file-open.png
Normal file
After Width: | Height: | Size: 1.6 KiB |
BIN
Graphics/file-save.png
Normal file
After Width: | Height: | Size: 1.7 KiB |
BIN
Graphics/tools-cards-expire.png
Normal file
After Width: | Height: | Size: 2.3 KiB |
BIN
Graphics/tools-cards-manage.png
Normal file
After Width: | Height: | Size: 903 B |
BIN
Graphics/tools-cards-options.png
Normal file
After Width: | Height: | Size: 1.8 KiB |
674
License.txt
Normal file
@ -0,0 +1,674 @@
|
|||||||
|
GNU GENERAL PUBLIC LICENSE
|
||||||
|
Version 3, 29 June 2007
|
||||||
|
|
||||||
|
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||||
|
Everyone is permitted to copy and distribute verbatim copies
|
||||||
|
of this license document, but changing it is not allowed.
|
||||||
|
|
||||||
|
Preamble
|
||||||
|
|
||||||
|
The GNU General Public License is a free, copyleft license for
|
||||||
|
software and other kinds of works.
|
||||||
|
|
||||||
|
The licenses for most software and other practical works are designed
|
||||||
|
to take away your freedom to share and change the works. By contrast,
|
||||||
|
the GNU General Public License is intended to guarantee your freedom to
|
||||||
|
share and change all versions of a program--to make sure it remains free
|
||||||
|
software for all its users. We, the Free Software Foundation, use the
|
||||||
|
GNU General Public License for most of our software; it applies also to
|
||||||
|
any other work released this way by its authors. You can apply it to
|
||||||
|
your programs, too.
|
||||||
|
|
||||||
|
When we speak of free software, we are referring to freedom, not
|
||||||
|
price. Our General Public Licenses are designed to make sure that you
|
||||||
|
have the freedom to distribute copies of free software (and charge for
|
||||||
|
them if you wish), that you receive source code or can get it if you
|
||||||
|
want it, that you can change the software or use pieces of it in new
|
||||||
|
free programs, and that you know you can do these things.
|
||||||
|
|
||||||
|
To protect your rights, we need to prevent others from denying you
|
||||||
|
these rights or asking you to surrender the rights. Therefore, you have
|
||||||
|
certain responsibilities if you distribute copies of the software, or if
|
||||||
|
you modify it: responsibilities to respect the freedom of others.
|
||||||
|
|
||||||
|
For example, if you distribute copies of such a program, whether
|
||||||
|
gratis or for a fee, you must pass on to the recipients the same
|
||||||
|
freedoms that you received. You must make sure that they, too, receive
|
||||||
|
or can get the source code. And you must show them these terms so they
|
||||||
|
know their rights.
|
||||||
|
|
||||||
|
Developers that use the GNU GPL protect your rights with two steps:
|
||||||
|
(1) assert copyright on the software, and (2) offer you this License
|
||||||
|
giving you legal permission to copy, distribute and/or modify it.
|
||||||
|
|
||||||
|
For the developers' and authors' protection, the GPL clearly explains
|
||||||
|
that there is no warranty for this free software. For both users' and
|
||||||
|
authors' sake, the GPL requires that modified versions be marked as
|
||||||
|
changed, so that their problems will not be attributed erroneously to
|
||||||
|
authors of previous versions.
|
||||||
|
|
||||||
|
Some devices are designed to deny users access to install or run
|
||||||
|
modified versions of the software inside them, although the manufacturer
|
||||||
|
can do so. This is fundamentally incompatible with the aim of
|
||||||
|
protecting users' freedom to change the software. The systematic
|
||||||
|
pattern of such abuse occurs in the area of products for individuals to
|
||||||
|
use, which is precisely where it is most unacceptable. Therefore, we
|
||||||
|
have designed this version of the GPL to prohibit the practice for those
|
||||||
|
products. If such problems arise substantially in other domains, we
|
||||||
|
stand ready to extend this provision to those domains in future versions
|
||||||
|
of the GPL, as needed to protect the freedom of users.
|
||||||
|
|
||||||
|
Finally, every program is threatened constantly by software patents.
|
||||||
|
States should not allow patents to restrict development and use of
|
||||||
|
software on general-purpose computers, but in those that do, we wish to
|
||||||
|
avoid the special danger that patents applied to a free program could
|
||||||
|
make it effectively proprietary. To prevent this, the GPL assures that
|
||||||
|
patents cannot be used to render the program non-free.
|
||||||
|
|
||||||
|
The precise terms and conditions for copying, distribution and
|
||||||
|
modification follow.
|
||||||
|
|
||||||
|
TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
0. Definitions.
|
||||||
|
|
||||||
|
"This License" refers to version 3 of the GNU General Public License.
|
||||||
|
|
||||||
|
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||||
|
works, such as semiconductor masks.
|
||||||
|
|
||||||
|
"The Program" refers to any copyrightable work licensed under this
|
||||||
|
License. Each licensee is addressed as "you". "Licensees" and
|
||||||
|
"recipients" may be individuals or organizations.
|
||||||
|
|
||||||
|
To "modify" a work means to copy from or adapt all or part of the work
|
||||||
|
in a fashion requiring copyright permission, other than the making of an
|
||||||
|
exact copy. The resulting work is called a "modified version" of the
|
||||||
|
earlier work or a work "based on" the earlier work.
|
||||||
|
|
||||||
|
A "covered work" means either the unmodified Program or a work based
|
||||||
|
on the Program.
|
||||||
|
|
||||||
|
To "propagate" a work means to do anything with it that, without
|
||||||
|
permission, would make you directly or secondarily liable for
|
||||||
|
infringement under applicable copyright law, except executing it on a
|
||||||
|
computer or modifying a private copy. Propagation includes copying,
|
||||||
|
distribution (with or without modification), making available to the
|
||||||
|
public, and in some countries other activities as well.
|
||||||
|
|
||||||
|
To "convey" a work means any kind of propagation that enables other
|
||||||
|
parties to make or receive copies. Mere interaction with a user through
|
||||||
|
a computer network, with no transfer of a copy, is not conveying.
|
||||||
|
|
||||||
|
An interactive user interface displays "Appropriate Legal Notices"
|
||||||
|
to the extent that it includes a convenient and prominently visible
|
||||||
|
feature that (1) displays an appropriate copyright notice, and (2)
|
||||||
|
tells the user that there is no warranty for the work (except to the
|
||||||
|
extent that warranties are provided), that licensees may convey the
|
||||||
|
work under this License, and how to view a copy of this License. If
|
||||||
|
the interface presents a list of user commands or options, such as a
|
||||||
|
menu, a prominent item in the list meets this criterion.
|
||||||
|
|
||||||
|
1. Source Code.
|
||||||
|
|
||||||
|
The "source code" for a work means the preferred form of the work
|
||||||
|
for making modifications to it. "Object code" means any non-source
|
||||||
|
form of a work.
|
||||||
|
|
||||||
|
A "Standard Interface" means an interface that either is an official
|
||||||
|
standard defined by a recognized standards body, or, in the case of
|
||||||
|
interfaces specified for a particular programming language, one that
|
||||||
|
is widely used among developers working in that language.
|
||||||
|
|
||||||
|
The "System Libraries" of an executable work include anything, other
|
||||||
|
than the work as a whole, that (a) is included in the normal form of
|
||||||
|
packaging a Major Component, but which is not part of that Major
|
||||||
|
Component, and (b) serves only to enable use of the work with that
|
||||||
|
Major Component, or to implement a Standard Interface for which an
|
||||||
|
implementation is available to the public in source code form. A
|
||||||
|
"Major Component", in this context, means a major essential component
|
||||||
|
(kernel, window system, and so on) of the specific operating system
|
||||||
|
(if any) on which the executable work runs, or a compiler used to
|
||||||
|
produce the work, or an object code interpreter used to run it.
|
||||||
|
|
||||||
|
The "Corresponding Source" for a work in object code form means all
|
||||||
|
the source code needed to generate, install, and (for an executable
|
||||||
|
work) run the object code and to modify the work, including scripts to
|
||||||
|
control those activities. However, it does not include the work's
|
||||||
|
System Libraries, or general-purpose tools or generally available free
|
||||||
|
programs which are used unmodified in performing those activities but
|
||||||
|
which are not part of the work. For example, Corresponding Source
|
||||||
|
includes interface definition files associated with source files for
|
||||||
|
the work, and the source code for shared libraries and dynamically
|
||||||
|
linked subprograms that the work is specifically designed to require,
|
||||||
|
such as by intimate data communication or control flow between those
|
||||||
|
subprograms and other parts of the work.
|
||||||
|
|
||||||
|
The Corresponding Source need not include anything that users
|
||||||
|
can regenerate automatically from other parts of the Corresponding
|
||||||
|
Source.
|
||||||
|
|
||||||
|
The Corresponding Source for a work in source code form is that
|
||||||
|
same work.
|
||||||
|
|
||||||
|
2. Basic Permissions.
|
||||||
|
|
||||||
|
All rights granted under this License are granted for the term of
|
||||||
|
copyright on the Program, and are irrevocable provided the stated
|
||||||
|
conditions are met. This License explicitly affirms your unlimited
|
||||||
|
permission to run the unmodified Program. The output from running a
|
||||||
|
covered work is covered by this License only if the output, given its
|
||||||
|
content, constitutes a covered work. This License acknowledges your
|
||||||
|
rights of fair use or other equivalent, as provided by copyright law.
|
||||||
|
|
||||||
|
You may make, run and propagate covered works that you do not
|
||||||
|
convey, without conditions so long as your license otherwise remains
|
||||||
|
in force. You may convey covered works to others for the sole purpose
|
||||||
|
of having them make modifications exclusively for you, or provide you
|
||||||
|
with facilities for running those works, provided that you comply with
|
||||||
|
the terms of this License in conveying all material for which you do
|
||||||
|
not control copyright. Those thus making or running the covered works
|
||||||
|
for you must do so exclusively on your behalf, under your direction
|
||||||
|
and control, on terms that prohibit them from making any copies of
|
||||||
|
your copyrighted material outside their relationship with you.
|
||||||
|
|
||||||
|
Conveying under any other circumstances is permitted solely under
|
||||||
|
the conditions stated below. Sublicensing is not allowed; section 10
|
||||||
|
makes it unnecessary.
|
||||||
|
|
||||||
|
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||||
|
|
||||||
|
No covered work shall be deemed part of an effective technological
|
||||||
|
measure under any applicable law fulfilling obligations under article
|
||||||
|
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||||
|
similar laws prohibiting or restricting circumvention of such
|
||||||
|
measures.
|
||||||
|
|
||||||
|
When you convey a covered work, you waive any legal power to forbid
|
||||||
|
circumvention of technological measures to the extent such circumvention
|
||||||
|
is effected by exercising rights under this License with respect to
|
||||||
|
the covered work, and you disclaim any intention to limit operation or
|
||||||
|
modification of the work as a means of enforcing, against the work's
|
||||||
|
users, your or third parties' legal rights to forbid circumvention of
|
||||||
|
technological measures.
|
||||||
|
|
||||||
|
4. Conveying Verbatim Copies.
|
||||||
|
|
||||||
|
You may convey verbatim copies of the Program's source code as you
|
||||||
|
receive it, in any medium, provided that you conspicuously and
|
||||||
|
appropriately publish on each copy an appropriate copyright notice;
|
||||||
|
keep intact all notices stating that this License and any
|
||||||
|
non-permissive terms added in accord with section 7 apply to the code;
|
||||||
|
keep intact all notices of the absence of any warranty; and give all
|
||||||
|
recipients a copy of this License along with the Program.
|
||||||
|
|
||||||
|
You may charge any price or no price for each copy that you convey,
|
||||||
|
and you may offer support or warranty protection for a fee.
|
||||||
|
|
||||||
|
5. Conveying Modified Source Versions.
|
||||||
|
|
||||||
|
You may convey a work based on the Program, or the modifications to
|
||||||
|
produce it from the Program, in the form of source code under the
|
||||||
|
terms of section 4, provided that you also meet all of these conditions:
|
||||||
|
|
||||||
|
a) The work must carry prominent notices stating that you modified
|
||||||
|
it, and giving a relevant date.
|
||||||
|
|
||||||
|
b) The work must carry prominent notices stating that it is
|
||||||
|
released under this License and any conditions added under section
|
||||||
|
7. This requirement modifies the requirement in section 4 to
|
||||||
|
"keep intact all notices".
|
||||||
|
|
||||||
|
c) You must license the entire work, as a whole, under this
|
||||||
|
License to anyone who comes into possession of a copy. This
|
||||||
|
License will therefore apply, along with any applicable section 7
|
||||||
|
additional terms, to the whole of the work, and all its parts,
|
||||||
|
regardless of how they are packaged. This License gives no
|
||||||
|
permission to license the work in any other way, but it does not
|
||||||
|
invalidate such permission if you have separately received it.
|
||||||
|
|
||||||
|
d) If the work has interactive user interfaces, each must display
|
||||||
|
Appropriate Legal Notices; however, if the Program has interactive
|
||||||
|
interfaces that do not display Appropriate Legal Notices, your
|
||||||
|
work need not make them do so.
|
||||||
|
|
||||||
|
A compilation of a covered work with other separate and independent
|
||||||
|
works, which are not by their nature extensions of the covered work,
|
||||||
|
and which are not combined with it such as to form a larger program,
|
||||||
|
in or on a volume of a storage or distribution medium, is called an
|
||||||
|
"aggregate" if the compilation and its resulting copyright are not
|
||||||
|
used to limit the access or legal rights of the compilation's users
|
||||||
|
beyond what the individual works permit. Inclusion of a covered work
|
||||||
|
in an aggregate does not cause this License to apply to the other
|
||||||
|
parts of the aggregate.
|
||||||
|
|
||||||
|
6. Conveying Non-Source Forms.
|
||||||
|
|
||||||
|
You may convey a covered work in object code form under the terms
|
||||||
|
of sections 4 and 5, provided that you also convey the
|
||||||
|
machine-readable Corresponding Source under the terms of this License,
|
||||||
|
in one of these ways:
|
||||||
|
|
||||||
|
a) Convey the object code in, or embodied in, a physical product
|
||||||
|
(including a physical distribution medium), accompanied by the
|
||||||
|
Corresponding Source fixed on a durable physical medium
|
||||||
|
customarily used for software interchange.
|
||||||
|
|
||||||
|
b) Convey the object code in, or embodied in, a physical product
|
||||||
|
(including a physical distribution medium), accompanied by a
|
||||||
|
written offer, valid for at least three years and valid for as
|
||||||
|
long as you offer spare parts or customer support for that product
|
||||||
|
model, to give anyone who possesses the object code either (1) a
|
||||||
|
copy of the Corresponding Source for all the software in the
|
||||||
|
product that is covered by this License, on a durable physical
|
||||||
|
medium customarily used for software interchange, for a price no
|
||||||
|
more than your reasonable cost of physically performing this
|
||||||
|
conveying of source, or (2) access to copy the
|
||||||
|
Corresponding Source from a network server at no charge.
|
||||||
|
|
||||||
|
c) Convey individual copies of the object code with a copy of the
|
||||||
|
written offer to provide the Corresponding Source. This
|
||||||
|
alternative is allowed only occasionally and noncommercially, and
|
||||||
|
only if you received the object code with such an offer, in accord
|
||||||
|
with subsection 6b.
|
||||||
|
|
||||||
|
d) Convey the object code by offering access from a designated
|
||||||
|
place (gratis or for a charge), and offer equivalent access to the
|
||||||
|
Corresponding Source in the same way through the same place at no
|
||||||
|
further charge. You need not require recipients to copy the
|
||||||
|
Corresponding Source along with the object code. If the place to
|
||||||
|
copy the object code is a network server, the Corresponding Source
|
||||||
|
may be on a different server (operated by you or a third party)
|
||||||
|
that supports equivalent copying facilities, provided you maintain
|
||||||
|
clear directions next to the object code saying where to find the
|
||||||
|
Corresponding Source. Regardless of what server hosts the
|
||||||
|
Corresponding Source, you remain obligated to ensure that it is
|
||||||
|
available for as long as needed to satisfy these requirements.
|
||||||
|
|
||||||
|
e) Convey the object code using peer-to-peer transmission, provided
|
||||||
|
you inform other peers where the object code and Corresponding
|
||||||
|
Source of the work are being offered to the general public at no
|
||||||
|
charge under subsection 6d.
|
||||||
|
|
||||||
|
A separable portion of the object code, whose source code is excluded
|
||||||
|
from the Corresponding Source as a System Library, need not be
|
||||||
|
included in conveying the object code work.
|
||||||
|
|
||||||
|
A "User Product" is either (1) a "consumer product", which means any
|
||||||
|
tangible personal property which is normally used for personal, family,
|
||||||
|
or household purposes, or (2) anything designed or sold for incorporation
|
||||||
|
into a dwelling. In determining whether a product is a consumer product,
|
||||||
|
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||||
|
product received by a particular user, "normally used" refers to a
|
||||||
|
typical or common use of that class of product, regardless of the status
|
||||||
|
of the particular user or of the way in which the particular user
|
||||||
|
actually uses, or expects or is expected to use, the product. A product
|
||||||
|
is a consumer product regardless of whether the product has substantial
|
||||||
|
commercial, industrial or non-consumer uses, unless such uses represent
|
||||||
|
the only significant mode of use of the product.
|
||||||
|
|
||||||
|
"Installation Information" for a User Product means any methods,
|
||||||
|
procedures, authorization keys, or other information required to install
|
||||||
|
and execute modified versions of a covered work in that User Product from
|
||||||
|
a modified version of its Corresponding Source. The information must
|
||||||
|
suffice to ensure that the continued functioning of the modified object
|
||||||
|
code is in no case prevented or interfered with solely because
|
||||||
|
modification has been made.
|
||||||
|
|
||||||
|
If you convey an object code work under this section in, or with, or
|
||||||
|
specifically for use in, a User Product, and the conveying occurs as
|
||||||
|
part of a transaction in which the right of possession and use of the
|
||||||
|
User Product is transferred to the recipient in perpetuity or for a
|
||||||
|
fixed term (regardless of how the transaction is characterized), the
|
||||||
|
Corresponding Source conveyed under this section must be accompanied
|
||||||
|
by the Installation Information. But this requirement does not apply
|
||||||
|
if neither you nor any third party retains the ability to install
|
||||||
|
modified object code on the User Product (for example, the work has
|
||||||
|
been installed in ROM).
|
||||||
|
|
||||||
|
The requirement to provide Installation Information does not include a
|
||||||
|
requirement to continue to provide support service, warranty, or updates
|
||||||
|
for a work that has been modified or installed by the recipient, or for
|
||||||
|
the User Product in which it has been modified or installed. Access to a
|
||||||
|
network may be denied when the modification itself materially and
|
||||||
|
adversely affects the operation of the network or violates the rules and
|
||||||
|
protocols for communication across the network.
|
||||||
|
|
||||||
|
Corresponding Source conveyed, and Installation Information provided,
|
||||||
|
in accord with this section must be in a format that is publicly
|
||||||
|
documented (and with an implementation available to the public in
|
||||||
|
source code form), and must require no special password or key for
|
||||||
|
unpacking, reading or copying.
|
||||||
|
|
||||||
|
7. Additional Terms.
|
||||||
|
|
||||||
|
"Additional permissions" are terms that supplement the terms of this
|
||||||
|
License by making exceptions from one or more of its conditions.
|
||||||
|
Additional permissions that are applicable to the entire Program shall
|
||||||
|
be treated as though they were included in this License, to the extent
|
||||||
|
that they are valid under applicable law. If additional permissions
|
||||||
|
apply only to part of the Program, that part may be used separately
|
||||||
|
under those permissions, but the entire Program remains governed by
|
||||||
|
this License without regard to the additional permissions.
|
||||||
|
|
||||||
|
When you convey a copy of a covered work, you may at your option
|
||||||
|
remove any additional permissions from that copy, or from any part of
|
||||||
|
it. (Additional permissions may be written to require their own
|
||||||
|
removal in certain cases when you modify the work.) You may place
|
||||||
|
additional permissions on material, added by you to a covered work,
|
||||||
|
for which you have or can give appropriate copyright permission.
|
||||||
|
|
||||||
|
Notwithstanding any other provision of this License, for material you
|
||||||
|
add to a covered work, you may (if authorized by the copyright holders of
|
||||||
|
that material) supplement the terms of this License with terms:
|
||||||
|
|
||||||
|
a) Disclaiming warranty or limiting liability differently from the
|
||||||
|
terms of sections 15 and 16 of this License; or
|
||||||
|
|
||||||
|
b) Requiring preservation of specified reasonable legal notices or
|
||||||
|
author attributions in that material or in the Appropriate Legal
|
||||||
|
Notices displayed by works containing it; or
|
||||||
|
|
||||||
|
c) Prohibiting misrepresentation of the origin of that material, or
|
||||||
|
requiring that modified versions of such material be marked in
|
||||||
|
reasonable ways as different from the original version; or
|
||||||
|
|
||||||
|
d) Limiting the use for publicity purposes of names of licensors or
|
||||||
|
authors of the material; or
|
||||||
|
|
||||||
|
e) Declining to grant rights under trademark law for use of some
|
||||||
|
trade names, trademarks, or service marks; or
|
||||||
|
|
||||||
|
f) Requiring indemnification of licensors and authors of that
|
||||||
|
material by anyone who conveys the material (or modified versions of
|
||||||
|
it) with contractual assumptions of liability to the recipient, for
|
||||||
|
any liability that these contractual assumptions directly impose on
|
||||||
|
those licensors and authors.
|
||||||
|
|
||||||
|
All other non-permissive additional terms are considered "further
|
||||||
|
restrictions" within the meaning of section 10. If the Program as you
|
||||||
|
received it, or any part of it, contains a notice stating that it is
|
||||||
|
governed by this License along with a term that is a further
|
||||||
|
restriction, you may remove that term. If a license document contains
|
||||||
|
a further restriction but permits relicensing or conveying under this
|
||||||
|
License, you may add to a covered work material governed by the terms
|
||||||
|
of that license document, provided that the further restriction does
|
||||||
|
not survive such relicensing or conveying.
|
||||||
|
|
||||||
|
If you add terms to a covered work in accord with this section, you
|
||||||
|
must place, in the relevant source files, a statement of the
|
||||||
|
additional terms that apply to those files, or a notice indicating
|
||||||
|
where to find the applicable terms.
|
||||||
|
|
||||||
|
Additional terms, permissive or non-permissive, may be stated in the
|
||||||
|
form of a separately written license, or stated as exceptions;
|
||||||
|
the above requirements apply either way.
|
||||||
|
|
||||||
|
8. Termination.
|
||||||
|
|
||||||
|
You may not propagate or modify a covered work except as expressly
|
||||||
|
provided under this License. Any attempt otherwise to propagate or
|
||||||
|
modify it is void, and will automatically terminate your rights under
|
||||||
|
this License (including any patent licenses granted under the third
|
||||||
|
paragraph of section 11).
|
||||||
|
|
||||||
|
However, if you cease all violation of this License, then your
|
||||||
|
license from a particular copyright holder is reinstated (a)
|
||||||
|
provisionally, unless and until the copyright holder explicitly and
|
||||||
|
finally terminates your license, and (b) permanently, if the copyright
|
||||||
|
holder fails to notify you of the violation by some reasonable means
|
||||||
|
prior to 60 days after the cessation.
|
||||||
|
|
||||||
|
Moreover, your license from a particular copyright holder is
|
||||||
|
reinstated permanently if the copyright holder notifies you of the
|
||||||
|
violation by some reasonable means, this is the first time you have
|
||||||
|
received notice of violation of this License (for any work) from that
|
||||||
|
copyright holder, and you cure the violation prior to 30 days after
|
||||||
|
your receipt of the notice.
|
||||||
|
|
||||||
|
Termination of your rights under this section does not terminate the
|
||||||
|
licenses of parties who have received copies or rights from you under
|
||||||
|
this License. If your rights have been terminated and not permanently
|
||||||
|
reinstated, you do not qualify to receive new licenses for the same
|
||||||
|
material under section 10.
|
||||||
|
|
||||||
|
9. Acceptance Not Required for Having Copies.
|
||||||
|
|
||||||
|
You are not required to accept this License in order to receive or
|
||||||
|
run a copy of the Program. Ancillary propagation of a covered work
|
||||||
|
occurring solely as a consequence of using peer-to-peer transmission
|
||||||
|
to receive a copy likewise does not require acceptance. However,
|
||||||
|
nothing other than this License grants you permission to propagate or
|
||||||
|
modify any covered work. These actions infringe copyright if you do
|
||||||
|
not accept this License. Therefore, by modifying or propagating a
|
||||||
|
covered work, you indicate your acceptance of this License to do so.
|
||||||
|
|
||||||
|
10. Automatic Licensing of Downstream Recipients.
|
||||||
|
|
||||||
|
Each time you convey a covered work, the recipient automatically
|
||||||
|
receives a license from the original licensors, to run, modify and
|
||||||
|
propagate that work, subject to this License. You are not responsible
|
||||||
|
for enforcing compliance by third parties with this License.
|
||||||
|
|
||||||
|
An "entity transaction" is a transaction transferring control of an
|
||||||
|
organization, or substantially all assets of one, or subdividing an
|
||||||
|
organization, or merging organizations. If propagation of a covered
|
||||||
|
work results from an entity transaction, each party to that
|
||||||
|
transaction who receives a copy of the work also receives whatever
|
||||||
|
licenses to the work the party's predecessor in interest had or could
|
||||||
|
give under the previous paragraph, plus a right to possession of the
|
||||||
|
Corresponding Source of the work from the predecessor in interest, if
|
||||||
|
the predecessor has it or can get it with reasonable efforts.
|
||||||
|
|
||||||
|
You may not impose any further restrictions on the exercise of the
|
||||||
|
rights granted or affirmed under this License. For example, you may
|
||||||
|
not impose a license fee, royalty, or other charge for exercise of
|
||||||
|
rights granted under this License, and you may not initiate litigation
|
||||||
|
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||||
|
any patent claim is infringed by making, using, selling, offering for
|
||||||
|
sale, or importing the Program or any portion of it.
|
||||||
|
|
||||||
|
11. Patents.
|
||||||
|
|
||||||
|
A "contributor" is a copyright holder who authorizes use under this
|
||||||
|
License of the Program or a work on which the Program is based. The
|
||||||
|
work thus licensed is called the contributor's "contributor version".
|
||||||
|
|
||||||
|
A contributor's "essential patent claims" are all patent claims
|
||||||
|
owned or controlled by the contributor, whether already acquired or
|
||||||
|
hereafter acquired, that would be infringed by some manner, permitted
|
||||||
|
by this License, of making, using, or selling its contributor version,
|
||||||
|
but do not include claims that would be infringed only as a
|
||||||
|
consequence of further modification of the contributor version. For
|
||||||
|
purposes of this definition, "control" includes the right to grant
|
||||||
|
patent sublicenses in a manner consistent with the requirements of
|
||||||
|
this License.
|
||||||
|
|
||||||
|
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||||
|
patent license under the contributor's essential patent claims, to
|
||||||
|
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||||
|
propagate the contents of its contributor version.
|
||||||
|
|
||||||
|
In the following three paragraphs, a "patent license" is any express
|
||||||
|
agreement or commitment, however denominated, not to enforce a patent
|
||||||
|
(such as an express permission to practice a patent or covenant not to
|
||||||
|
sue for patent infringement). To "grant" such a patent license to a
|
||||||
|
party means to make such an agreement or commitment not to enforce a
|
||||||
|
patent against the party.
|
||||||
|
|
||||||
|
If you convey a covered work, knowingly relying on a patent license,
|
||||||
|
and the Corresponding Source of the work is not available for anyone
|
||||||
|
to copy, free of charge and under the terms of this License, through a
|
||||||
|
publicly available network server or other readily accessible means,
|
||||||
|
then you must either (1) cause the Corresponding Source to be so
|
||||||
|
available, or (2) arrange to deprive yourself of the benefit of the
|
||||||
|
patent license for this particular work, or (3) arrange, in a manner
|
||||||
|
consistent with the requirements of this License, to extend the patent
|
||||||
|
license to downstream recipients. "Knowingly relying" means you have
|
||||||
|
actual knowledge that, but for the patent license, your conveying the
|
||||||
|
covered work in a country, or your recipient's use of the covered work
|
||||||
|
in a country, would infringe one or more identifiable patents in that
|
||||||
|
country that you have reason to believe are valid.
|
||||||
|
|
||||||
|
If, pursuant to or in connection with a single transaction or
|
||||||
|
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||||
|
covered work, and grant a patent license to some of the parties
|
||||||
|
receiving the covered work authorizing them to use, propagate, modify
|
||||||
|
or convey a specific copy of the covered work, then the patent license
|
||||||
|
you grant is automatically extended to all recipients of the covered
|
||||||
|
work and works based on it.
|
||||||
|
|
||||||
|
A patent license is "discriminatory" if it does not include within
|
||||||
|
the scope of its coverage, prohibits the exercise of, or is
|
||||||
|
conditioned on the non-exercise of one or more of the rights that are
|
||||||
|
specifically granted under this License. You may not convey a covered
|
||||||
|
work if you are a party to an arrangement with a third party that is
|
||||||
|
in the business of distributing software, under which you make payment
|
||||||
|
to the third party based on the extent of your activity of conveying
|
||||||
|
the work, and under which the third party grants, to any of the
|
||||||
|
parties who would receive the covered work from you, a discriminatory
|
||||||
|
patent license (a) in connection with copies of the covered work
|
||||||
|
conveyed by you (or copies made from those copies), or (b) primarily
|
||||||
|
for and in connection with specific products or compilations that
|
||||||
|
contain the covered work, unless you entered into that arrangement,
|
||||||
|
or that patent license was granted, prior to 28 March 2007.
|
||||||
|
|
||||||
|
Nothing in this License shall be construed as excluding or limiting
|
||||||
|
any implied license or other defenses to infringement that may
|
||||||
|
otherwise be available to you under applicable patent law.
|
||||||
|
|
||||||
|
12. No Surrender of Others' Freedom.
|
||||||
|
|
||||||
|
If conditions are imposed on you (whether by court order, agreement or
|
||||||
|
otherwise) that contradict the conditions of this License, they do not
|
||||||
|
excuse you from the conditions of this License. If you cannot convey a
|
||||||
|
covered work so as to satisfy simultaneously your obligations under this
|
||||||
|
License and any other pertinent obligations, then as a consequence you may
|
||||||
|
not convey it at all. For example, if you agree to terms that obligate you
|
||||||
|
to collect a royalty for further conveying from those to whom you convey
|
||||||
|
the Program, the only way you could satisfy both those terms and this
|
||||||
|
License would be to refrain entirely from conveying the Program.
|
||||||
|
|
||||||
|
13. Use with the GNU Affero General Public License.
|
||||||
|
|
||||||
|
Notwithstanding any other provision of this License, you have
|
||||||
|
permission to link or combine any covered work with a work licensed
|
||||||
|
under version 3 of the GNU Affero General Public License into a single
|
||||||
|
combined work, and to convey the resulting work. The terms of this
|
||||||
|
License will continue to apply to the part which is the covered work,
|
||||||
|
but the special requirements of the GNU Affero General Public License,
|
||||||
|
section 13, concerning interaction through a network will apply to the
|
||||||
|
combination as such.
|
||||||
|
|
||||||
|
14. Revised Versions of this License.
|
||||||
|
|
||||||
|
The Free Software Foundation may publish revised and/or new versions of
|
||||||
|
the GNU General Public License from time to time. Such new versions will
|
||||||
|
be similar in spirit to the present version, but may differ in detail to
|
||||||
|
address new problems or concerns.
|
||||||
|
|
||||||
|
Each version is given a distinguishing version number. If the
|
||||||
|
Program specifies that a certain numbered version of the GNU General
|
||||||
|
Public License "or any later version" applies to it, you have the
|
||||||
|
option of following the terms and conditions either of that numbered
|
||||||
|
version or of any later version published by the Free Software
|
||||||
|
Foundation. If the Program does not specify a version number of the
|
||||||
|
GNU General Public License, you may choose any version ever published
|
||||||
|
by the Free Software Foundation.
|
||||||
|
|
||||||
|
If the Program specifies that a proxy can decide which future
|
||||||
|
versions of the GNU General Public License can be used, that proxy's
|
||||||
|
public statement of acceptance of a version permanently authorizes you
|
||||||
|
to choose that version for the Program.
|
||||||
|
|
||||||
|
Later license versions may give you additional or different
|
||||||
|
permissions. However, no additional obligations are imposed on any
|
||||||
|
author or copyright holder as a result of your choosing to follow a
|
||||||
|
later version.
|
||||||
|
|
||||||
|
15. Disclaimer of Warranty.
|
||||||
|
|
||||||
|
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||||
|
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||||
|
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||||
|
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||||
|
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||||
|
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||||
|
|
||||||
|
16. Limitation of Liability.
|
||||||
|
|
||||||
|
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||||
|
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||||
|
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||||
|
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||||
|
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||||
|
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||||
|
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||||
|
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||||
|
SUCH DAMAGES.
|
||||||
|
|
||||||
|
17. Interpretation of Sections 15 and 16.
|
||||||
|
|
||||||
|
If the disclaimer of warranty and limitation of liability provided
|
||||||
|
above cannot be given local legal effect according to their terms,
|
||||||
|
reviewing courts shall apply local law that most closely approximates
|
||||||
|
an absolute waiver of all civil liability in connection with the
|
||||||
|
Program, unless a warranty or assumption of liability accompanies a
|
||||||
|
copy of the Program in return for a fee.
|
||||||
|
|
||||||
|
END OF TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
How to Apply These Terms to Your New Programs
|
||||||
|
|
||||||
|
If you develop a new program, and you want it to be of the greatest
|
||||||
|
possible use to the public, the best way to achieve this is to make it
|
||||||
|
free software which everyone can redistribute and change under these terms.
|
||||||
|
|
||||||
|
To do so, attach the following notices to the program. It is safest
|
||||||
|
to attach them to the start of each source file to most effectively
|
||||||
|
state the exclusion of warranty; and each file should have at least
|
||||||
|
the "copyright" line and a pointer to where the full notice is found.
|
||||||
|
|
||||||
|
<one line to give the program's name and a brief idea of what it does.>
|
||||||
|
Copyright (C) <year> <name of author>
|
||||||
|
|
||||||
|
This program 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.
|
||||||
|
|
||||||
|
This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Also add information on how to contact you by electronic and paper mail.
|
||||||
|
|
||||||
|
If the program does terminal interaction, make it output a short
|
||||||
|
notice like this when it starts in an interactive mode:
|
||||||
|
|
||||||
|
<program> Copyright (C) <year> <name of author>
|
||||||
|
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||||
|
This is free software, and you are welcome to redistribute it
|
||||||
|
under certain conditions; type `show c' for details.
|
||||||
|
|
||||||
|
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||||
|
parts of the General Public License. Of course, your program's commands
|
||||||
|
might be different; for a GUI interface, you would use an "about box".
|
||||||
|
|
||||||
|
You should also get your employer (if you work as a programmer) or school,
|
||||||
|
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||||
|
For more information on this, and how to apply and follow the GNU GPL, see
|
||||||
|
<http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
The GNU General Public License does not permit incorporating your program
|
||||||
|
into proprietary programs. If your program is a subroutine library, you
|
||||||
|
may consider it more useful to permit linking proprietary applications with
|
||||||
|
the library. If this is what you want to do, use the GNU Lesser General
|
||||||
|
Public License instead of this License. But first, please read
|
||||||
|
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
|
141
Meganekko.cbp
Normal file
@ -0,0 +1,141 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
|
||||||
|
<CodeBlocks_project_file>
|
||||||
|
<FileVersion major="1" minor="6" />
|
||||||
|
<Project>
|
||||||
|
<Option title="Meganekko" />
|
||||||
|
<Option pch_mode="2" />
|
||||||
|
<Option compiler="gcc" />
|
||||||
|
<Option virtualFolders="Ui/;Data/;Common/;External/;External/TinyXml/;" />
|
||||||
|
<Build>
|
||||||
|
<Target title="Debug">
|
||||||
|
<Option output="bin/Debug/Meganekko" prefix_auto="1" extension_auto="1" />
|
||||||
|
<Option object_output="obj/Debug/" />
|
||||||
|
<Option type="0" />
|
||||||
|
<Option compiler="gcc" />
|
||||||
|
<Compiler>
|
||||||
|
<Add option="-g" />
|
||||||
|
</Compiler>
|
||||||
|
</Target>
|
||||||
|
<Target title="Release">
|
||||||
|
<Option output="bin/Release/Meganekko" prefix_auto="1" extension_auto="1" />
|
||||||
|
<Option object_output="obj/Release/" />
|
||||||
|
<Option type="0" />
|
||||||
|
<Option compiler="gcc" />
|
||||||
|
<Compiler>
|
||||||
|
<Add option="-O2" />
|
||||||
|
</Compiler>
|
||||||
|
<Linker>
|
||||||
|
<Add option="-s" />
|
||||||
|
</Linker>
|
||||||
|
</Target>
|
||||||
|
</Build>
|
||||||
|
<Compiler>
|
||||||
|
<Add option="-Wall" />
|
||||||
|
<Add option="`wx-config --cppflags`" />
|
||||||
|
</Compiler>
|
||||||
|
<Linker>
|
||||||
|
<Add option="`wx-config --libs`" />
|
||||||
|
</Linker>
|
||||||
|
<Unit filename="AppMeganekko.cpp">
|
||||||
|
<Option virtualFolder="Ui/" />
|
||||||
|
</Unit>
|
||||||
|
<Unit filename="AppMeganekko.h">
|
||||||
|
<Option virtualFolder="Ui/" />
|
||||||
|
</Unit>
|
||||||
|
<Unit filename="Common.cpp">
|
||||||
|
<Option virtualFolder="Common/" />
|
||||||
|
</Unit>
|
||||||
|
<Unit filename="Common.h">
|
||||||
|
<Option virtualFolder="Common/" />
|
||||||
|
</Unit>
|
||||||
|
<Unit filename="DialogAbout.cpp">
|
||||||
|
<Option virtualFolder="Ui/" />
|
||||||
|
</Unit>
|
||||||
|
<Unit filename="DialogAbout.h">
|
||||||
|
<Option virtualFolder="Ui/" />
|
||||||
|
</Unit>
|
||||||
|
<Unit filename="DialogCard.cpp">
|
||||||
|
<Option virtualFolder="Ui/" />
|
||||||
|
</Unit>
|
||||||
|
<Unit filename="DialogCard.h">
|
||||||
|
<Option virtualFolder="Ui/" />
|
||||||
|
</Unit>
|
||||||
|
<Unit filename="DialogCardEditor.cpp">
|
||||||
|
<Option virtualFolder="Ui/" />
|
||||||
|
</Unit>
|
||||||
|
<Unit filename="DialogCardEditor.h">
|
||||||
|
<Option virtualFolder="Ui/" />
|
||||||
|
</Unit>
|
||||||
|
<Unit filename="DialogCardManager.cpp">
|
||||||
|
<Option virtualFolder="Ui/" />
|
||||||
|
</Unit>
|
||||||
|
<Unit filename="DialogCardManager.h">
|
||||||
|
<Option virtualFolder="Ui/" />
|
||||||
|
</Unit>
|
||||||
|
<Unit filename="DialogOptions.cpp">
|
||||||
|
<Option virtualFolder="Ui/" />
|
||||||
|
</Unit>
|
||||||
|
<Unit filename="DialogOptions.h">
|
||||||
|
<Option virtualFolder="Ui/" />
|
||||||
|
</Unit>
|
||||||
|
<Unit filename="FlashCard.cpp">
|
||||||
|
<Option virtualFolder="Data/" />
|
||||||
|
</Unit>
|
||||||
|
<Unit filename="FlashCard.h">
|
||||||
|
<Option virtualFolder="Data/" />
|
||||||
|
</Unit>
|
||||||
|
<Unit filename="FlashCardManager.cpp">
|
||||||
|
<Option virtualFolder="Data/" />
|
||||||
|
</Unit>
|
||||||
|
<Unit filename="FlashCardManager.h">
|
||||||
|
<Option virtualFolder="Data/" />
|
||||||
|
</Unit>
|
||||||
|
<Unit filename="FlashCardManagerXml.cpp">
|
||||||
|
<Option virtualFolder="Data/" />
|
||||||
|
</Unit>
|
||||||
|
<Unit filename="FrameMeganekko.cpp">
|
||||||
|
<Option virtualFolder="Ui/" />
|
||||||
|
</Unit>
|
||||||
|
<Unit filename="FrameMeganekko.h">
|
||||||
|
<Option virtualFolder="Ui/" />
|
||||||
|
</Unit>
|
||||||
|
<Unit filename="Pch.h">
|
||||||
|
<Option compile="1" />
|
||||||
|
<Option weight="0" />
|
||||||
|
<Option virtualFolder="Common/" />
|
||||||
|
</Unit>
|
||||||
|
<Unit filename="Resource.cpp">
|
||||||
|
<Option virtualFolder="Ui/" />
|
||||||
|
</Unit>
|
||||||
|
<Unit filename="Util.cpp">
|
||||||
|
<Option virtualFolder="External/" />
|
||||||
|
</Unit>
|
||||||
|
<Unit filename="Util.h">
|
||||||
|
<Option virtualFolder="External/" />
|
||||||
|
</Unit>
|
||||||
|
<Unit filename="tinystr.cpp">
|
||||||
|
<Option virtualFolder="External/TinyXml/" />
|
||||||
|
</Unit>
|
||||||
|
<Unit filename="tinystr.h">
|
||||||
|
<Option virtualFolder="External/TinyXml/" />
|
||||||
|
</Unit>
|
||||||
|
<Unit filename="tinyxml.cpp">
|
||||||
|
<Option virtualFolder="External/TinyXml/" />
|
||||||
|
</Unit>
|
||||||
|
<Unit filename="tinyxml.h">
|
||||||
|
<Option virtualFolder="External/TinyXml/" />
|
||||||
|
</Unit>
|
||||||
|
<Unit filename="tinyxmlerror.cpp">
|
||||||
|
<Option virtualFolder="External/TinyXml/" />
|
||||||
|
</Unit>
|
||||||
|
<Unit filename="tinyxmlparser.cpp">
|
||||||
|
<Option virtualFolder="External/TinyXml/" />
|
||||||
|
</Unit>
|
||||||
|
<Extensions>
|
||||||
|
<envvars />
|
||||||
|
<code_completion />
|
||||||
|
<debugger />
|
||||||
|
<lib_finder disable_auto="1" />
|
||||||
|
</Extensions>
|
||||||
|
</Project>
|
||||||
|
</CodeBlocks_project_file>
|
6617
Meganekko.fbp
Normal file
4
Meganekko.layout
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
|
||||||
|
<CodeBlocks_layout_file>
|
||||||
|
<ActiveTarget name="Debug" />
|
||||||
|
</CodeBlocks_layout_file>
|
20
Meganekko.sln
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 10.00
|
||||||
|
# Visual Studio 2008
|
||||||
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Meganekko", "Meganekko.vcproj", "{0FF0EEAD-98A7-4EE0-B5A3-C3911A222F91}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|Win32 = Debug|Win32
|
||||||
|
Release|Win32 = Release|Win32
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{0FF0EEAD-98A7-4EE0-B5A3-C3911A222F91}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||||
|
{0FF0EEAD-98A7-4EE0-B5A3-C3911A222F91}.Debug|Win32.Build.0 = Debug|Win32
|
||||||
|
{0FF0EEAD-98A7-4EE0-B5A3-C3911A222F91}.Release|Win32.ActiveCfg = Release|Win32
|
||||||
|
{0FF0EEAD-98A7-4EE0-B5A3-C3911A222F91}.Release|Win32.Build.0 = Release|Win32
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
625
Meganekko.vcproj
Normal file
@ -0,0 +1,625 @@
|
|||||||
|
<?xml version="1.0" encoding="Windows-1252"?>
|
||||||
|
<VisualStudioProject
|
||||||
|
ProjectType="Visual C++"
|
||||||
|
Version="9.00"
|
||||||
|
Name="Meganekko"
|
||||||
|
ProjectGUID="{0FF0EEAD-98A7-4EE0-B5A3-C3911A222F91}"
|
||||||
|
RootNamespace="Meganekko"
|
||||||
|
Keyword="Win32Proj"
|
||||||
|
TargetFrameworkVersion="196613"
|
||||||
|
>
|
||||||
|
<Platforms>
|
||||||
|
<Platform
|
||||||
|
Name="Win32"
|
||||||
|
/>
|
||||||
|
</Platforms>
|
||||||
|
<ToolFiles>
|
||||||
|
</ToolFiles>
|
||||||
|
<Configurations>
|
||||||
|
<Configuration
|
||||||
|
Name="Debug|Win32"
|
||||||
|
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
|
||||||
|
IntermediateDirectory="$(ConfigurationName)"
|
||||||
|
ConfigurationType="1"
|
||||||
|
CharacterSet="1"
|
||||||
|
>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreBuildEventTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCCustomBuildTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCXMLDataGeneratorTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCWebServiceProxyGeneratorTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCMIDLTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCCLCompilerTool"
|
||||||
|
Optimization="0"
|
||||||
|
AdditionalIncludeDirectories=""$(WXWIDGETS_ROOT)\include";"$(WXWIDGETS_ROOT)\lib\vc_lib\mswu";"$(WXWIDGETS_ROOT)\include\msvc""
|
||||||
|
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS"
|
||||||
|
MinimalRebuild="true"
|
||||||
|
BasicRuntimeChecks="3"
|
||||||
|
RuntimeLibrary="1"
|
||||||
|
UsePrecompiledHeader="0"
|
||||||
|
WarningLevel="3"
|
||||||
|
DebugInformationFormat="4"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCManagedResourceCompilerTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCResourceCompilerTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreLinkEventTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCLinkerTool"
|
||||||
|
AdditionalDependencies="wxbase28ud.lib wxmsw28ud_core.lib wxmsw28ud_adv.lib wxmsw28ud_xrc.lib wxmsw28ud_html.lib wxbase28ud_xml.lib wxbase28ud_net.lib wxregexud.lib wxexpatd.lib wxjpegd.lib wxpngd.lib wxtiffd.lib wxzlibd.lib comctl32.lib oleacc.lib rpcrt4.lib wsock32.lib"
|
||||||
|
LinkIncremental="2"
|
||||||
|
AdditionalLibraryDirectories="$(WXWIDGETS_ROOT)\lib\vc_lib"
|
||||||
|
GenerateDebugInformation="true"
|
||||||
|
SubSystem="2"
|
||||||
|
TargetMachine="1"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCALinkTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCManifestTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCXDCMakeTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCBscMakeTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCFxCopTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCAppVerifierTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPostBuildEventTool"
|
||||||
|
/>
|
||||||
|
</Configuration>
|
||||||
|
<Configuration
|
||||||
|
Name="Release|Win32"
|
||||||
|
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
|
||||||
|
IntermediateDirectory="$(ConfigurationName)"
|
||||||
|
ConfigurationType="1"
|
||||||
|
CharacterSet="1"
|
||||||
|
WholeProgramOptimization="1"
|
||||||
|
>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreBuildEventTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCCustomBuildTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCXMLDataGeneratorTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCWebServiceProxyGeneratorTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCMIDLTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCCLCompilerTool"
|
||||||
|
Optimization="2"
|
||||||
|
EnableIntrinsicFunctions="true"
|
||||||
|
AdditionalIncludeDirectories=""$(WXWIDGETS_ROOT)\include";"$(WXWIDGETS_ROOT)\lib\vc_lib\mswu";"$(WXWIDGETS_ROOT)\include\msvc""
|
||||||
|
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS"
|
||||||
|
RuntimeLibrary="0"
|
||||||
|
EnableFunctionLevelLinking="true"
|
||||||
|
UsePrecompiledHeader="0"
|
||||||
|
WarningLevel="3"
|
||||||
|
DebugInformationFormat="3"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCManagedResourceCompilerTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCResourceCompilerTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreLinkEventTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCLinkerTool"
|
||||||
|
AdditionalDependencies="wxbase28u.lib wxmsw28u_core.lib wxmsw28u_adv.lib wxmsw28u_xrc.lib wxmsw28u_html.lib wxbase28u_xml.lib wxbase28u_net.lib wxregexu.lib wxexpat.lib wxjpeg.lib wxpng.lib wxtiff.lib wxzlib.lib comctl32.lib oleacc.lib rpcrt4.lib wsock32.lib"
|
||||||
|
LinkIncremental="1"
|
||||||
|
AdditionalLibraryDirectories="$(WXWIDGETS_ROOT)\lib\vc_lib"
|
||||||
|
GenerateDebugInformation="true"
|
||||||
|
SubSystem="2"
|
||||||
|
OptimizeReferences="2"
|
||||||
|
EnableCOMDATFolding="2"
|
||||||
|
TargetMachine="1"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCALinkTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCManifestTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCXDCMakeTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCBscMakeTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCFxCopTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCAppVerifierTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPostBuildEventTool"
|
||||||
|
/>
|
||||||
|
</Configuration>
|
||||||
|
</Configurations>
|
||||||
|
<References>
|
||||||
|
</References>
|
||||||
|
<Files>
|
||||||
|
<Filter
|
||||||
|
Name="Source Files"
|
||||||
|
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
|
||||||
|
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
|
||||||
|
>
|
||||||
|
<File
|
||||||
|
RelativePath=".\AppMeganekko.cpp"
|
||||||
|
>
|
||||||
|
<FileConfiguration
|
||||||
|
Name="Debug|Win32"
|
||||||
|
>
|
||||||
|
<Tool
|
||||||
|
Name="VCCLCompilerTool"
|
||||||
|
UsePrecompiledHeader="1"
|
||||||
|
PrecompiledHeaderThrough="Pch.h"
|
||||||
|
/>
|
||||||
|
</FileConfiguration>
|
||||||
|
<FileConfiguration
|
||||||
|
Name="Release|Win32"
|
||||||
|
>
|
||||||
|
<Tool
|
||||||
|
Name="VCCLCompilerTool"
|
||||||
|
UsePrecompiledHeader="1"
|
||||||
|
PrecompiledHeaderThrough="Pch.h"
|
||||||
|
/>
|
||||||
|
</FileConfiguration>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\Common.cpp"
|
||||||
|
>
|
||||||
|
<FileConfiguration
|
||||||
|
Name="Debug|Win32"
|
||||||
|
>
|
||||||
|
<Tool
|
||||||
|
Name="VCCLCompilerTool"
|
||||||
|
UsePrecompiledHeader="2"
|
||||||
|
PrecompiledHeaderThrough="Pch.h"
|
||||||
|
/>
|
||||||
|
</FileConfiguration>
|
||||||
|
<FileConfiguration
|
||||||
|
Name="Release|Win32"
|
||||||
|
>
|
||||||
|
<Tool
|
||||||
|
Name="VCCLCompilerTool"
|
||||||
|
UsePrecompiledHeader="2"
|
||||||
|
PrecompiledHeaderThrough="Pch.h"
|
||||||
|
/>
|
||||||
|
</FileConfiguration>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\DialogAbout.cpp"
|
||||||
|
>
|
||||||
|
<FileConfiguration
|
||||||
|
Name="Debug|Win32"
|
||||||
|
>
|
||||||
|
<Tool
|
||||||
|
Name="VCCLCompilerTool"
|
||||||
|
UsePrecompiledHeader="2"
|
||||||
|
PrecompiledHeaderThrough="Pch.h"
|
||||||
|
/>
|
||||||
|
</FileConfiguration>
|
||||||
|
<FileConfiguration
|
||||||
|
Name="Release|Win32"
|
||||||
|
>
|
||||||
|
<Tool
|
||||||
|
Name="VCCLCompilerTool"
|
||||||
|
UsePrecompiledHeader="2"
|
||||||
|
PrecompiledHeaderThrough="Pch.h"
|
||||||
|
/>
|
||||||
|
</FileConfiguration>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\DialogCard.cpp"
|
||||||
|
>
|
||||||
|
<FileConfiguration
|
||||||
|
Name="Debug|Win32"
|
||||||
|
>
|
||||||
|
<Tool
|
||||||
|
Name="VCCLCompilerTool"
|
||||||
|
UsePrecompiledHeader="2"
|
||||||
|
PrecompiledHeaderThrough="Pch.h"
|
||||||
|
/>
|
||||||
|
</FileConfiguration>
|
||||||
|
<FileConfiguration
|
||||||
|
Name="Release|Win32"
|
||||||
|
>
|
||||||
|
<Tool
|
||||||
|
Name="VCCLCompilerTool"
|
||||||
|
UsePrecompiledHeader="2"
|
||||||
|
PrecompiledHeaderThrough="Pch.h"
|
||||||
|
/>
|
||||||
|
</FileConfiguration>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\DialogCardEditor.cpp"
|
||||||
|
>
|
||||||
|
<FileConfiguration
|
||||||
|
Name="Debug|Win32"
|
||||||
|
>
|
||||||
|
<Tool
|
||||||
|
Name="VCCLCompilerTool"
|
||||||
|
UsePrecompiledHeader="2"
|
||||||
|
PrecompiledHeaderThrough="Pch.h"
|
||||||
|
/>
|
||||||
|
</FileConfiguration>
|
||||||
|
<FileConfiguration
|
||||||
|
Name="Release|Win32"
|
||||||
|
>
|
||||||
|
<Tool
|
||||||
|
Name="VCCLCompilerTool"
|
||||||
|
UsePrecompiledHeader="2"
|
||||||
|
PrecompiledHeaderThrough="Pch.h"
|
||||||
|
/>
|
||||||
|
</FileConfiguration>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\DialogCardManager.cpp"
|
||||||
|
>
|
||||||
|
<FileConfiguration
|
||||||
|
Name="Debug|Win32"
|
||||||
|
>
|
||||||
|
<Tool
|
||||||
|
Name="VCCLCompilerTool"
|
||||||
|
UsePrecompiledHeader="2"
|
||||||
|
PrecompiledHeaderThrough="Pch.h"
|
||||||
|
/>
|
||||||
|
</FileConfiguration>
|
||||||
|
<FileConfiguration
|
||||||
|
Name="Release|Win32"
|
||||||
|
>
|
||||||
|
<Tool
|
||||||
|
Name="VCCLCompilerTool"
|
||||||
|
UsePrecompiledHeader="2"
|
||||||
|
PrecompiledHeaderThrough="Pch.h"
|
||||||
|
/>
|
||||||
|
</FileConfiguration>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\DialogOptions.cpp"
|
||||||
|
>
|
||||||
|
<FileConfiguration
|
||||||
|
Name="Debug|Win32"
|
||||||
|
>
|
||||||
|
<Tool
|
||||||
|
Name="VCCLCompilerTool"
|
||||||
|
UsePrecompiledHeader="2"
|
||||||
|
PrecompiledHeaderThrough="Pch.h"
|
||||||
|
/>
|
||||||
|
</FileConfiguration>
|
||||||
|
<FileConfiguration
|
||||||
|
Name="Release|Win32"
|
||||||
|
>
|
||||||
|
<Tool
|
||||||
|
Name="VCCLCompilerTool"
|
||||||
|
UsePrecompiledHeader="2"
|
||||||
|
PrecompiledHeaderThrough="Pch.h"
|
||||||
|
/>
|
||||||
|
</FileConfiguration>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\FlashCard.cpp"
|
||||||
|
>
|
||||||
|
<FileConfiguration
|
||||||
|
Name="Debug|Win32"
|
||||||
|
>
|
||||||
|
<Tool
|
||||||
|
Name="VCCLCompilerTool"
|
||||||
|
UsePrecompiledHeader="2"
|
||||||
|
PrecompiledHeaderThrough="Pch.h"
|
||||||
|
/>
|
||||||
|
</FileConfiguration>
|
||||||
|
<FileConfiguration
|
||||||
|
Name="Release|Win32"
|
||||||
|
>
|
||||||
|
<Tool
|
||||||
|
Name="VCCLCompilerTool"
|
||||||
|
UsePrecompiledHeader="2"
|
||||||
|
PrecompiledHeaderThrough="Pch.h"
|
||||||
|
/>
|
||||||
|
</FileConfiguration>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\FlashCardManager.cpp"
|
||||||
|
>
|
||||||
|
<FileConfiguration
|
||||||
|
Name="Debug|Win32"
|
||||||
|
>
|
||||||
|
<Tool
|
||||||
|
Name="VCCLCompilerTool"
|
||||||
|
UsePrecompiledHeader="2"
|
||||||
|
PrecompiledHeaderThrough="Pch.h"
|
||||||
|
/>
|
||||||
|
</FileConfiguration>
|
||||||
|
<FileConfiguration
|
||||||
|
Name="Release|Win32"
|
||||||
|
>
|
||||||
|
<Tool
|
||||||
|
Name="VCCLCompilerTool"
|
||||||
|
UsePrecompiledHeader="2"
|
||||||
|
PrecompiledHeaderThrough="Pch.h"
|
||||||
|
/>
|
||||||
|
</FileConfiguration>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\FlashCardManagerXml.cpp"
|
||||||
|
>
|
||||||
|
<FileConfiguration
|
||||||
|
Name="Debug|Win32"
|
||||||
|
>
|
||||||
|
<Tool
|
||||||
|
Name="VCCLCompilerTool"
|
||||||
|
UsePrecompiledHeader="2"
|
||||||
|
PrecompiledHeaderThrough="Pch.h"
|
||||||
|
/>
|
||||||
|
</FileConfiguration>
|
||||||
|
<FileConfiguration
|
||||||
|
Name="Release|Win32"
|
||||||
|
>
|
||||||
|
<Tool
|
||||||
|
Name="VCCLCompilerTool"
|
||||||
|
UsePrecompiledHeader="2"
|
||||||
|
PrecompiledHeaderThrough="Pch.h"
|
||||||
|
/>
|
||||||
|
</FileConfiguration>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\FrameMeganekko.cpp"
|
||||||
|
>
|
||||||
|
<FileConfiguration
|
||||||
|
Name="Debug|Win32"
|
||||||
|
>
|
||||||
|
<Tool
|
||||||
|
Name="VCCLCompilerTool"
|
||||||
|
UsePrecompiledHeader="2"
|
||||||
|
PrecompiledHeaderThrough="Pch.h"
|
||||||
|
/>
|
||||||
|
</FileConfiguration>
|
||||||
|
<FileConfiguration
|
||||||
|
Name="Release|Win32"
|
||||||
|
>
|
||||||
|
<Tool
|
||||||
|
Name="VCCLCompilerTool"
|
||||||
|
UsePrecompiledHeader="2"
|
||||||
|
PrecompiledHeaderThrough="Pch.h"
|
||||||
|
/>
|
||||||
|
</FileConfiguration>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\Resource.cpp"
|
||||||
|
>
|
||||||
|
<FileConfiguration
|
||||||
|
Name="Debug|Win32"
|
||||||
|
>
|
||||||
|
<Tool
|
||||||
|
Name="VCCLCompilerTool"
|
||||||
|
UsePrecompiledHeader="0"
|
||||||
|
PrecompiledHeaderThrough=""
|
||||||
|
/>
|
||||||
|
</FileConfiguration>
|
||||||
|
<FileConfiguration
|
||||||
|
Name="Release|Win32"
|
||||||
|
>
|
||||||
|
<Tool
|
||||||
|
Name="VCCLCompilerTool"
|
||||||
|
UsePrecompiledHeader="0"
|
||||||
|
PrecompiledHeaderThrough=""
|
||||||
|
/>
|
||||||
|
</FileConfiguration>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\tinystr.cpp"
|
||||||
|
>
|
||||||
|
<FileConfiguration
|
||||||
|
Name="Debug|Win32"
|
||||||
|
>
|
||||||
|
<Tool
|
||||||
|
Name="VCCLCompilerTool"
|
||||||
|
UsePrecompiledHeader="0"
|
||||||
|
PrecompiledHeaderThrough=""
|
||||||
|
/>
|
||||||
|
</FileConfiguration>
|
||||||
|
<FileConfiguration
|
||||||
|
Name="Release|Win32"
|
||||||
|
>
|
||||||
|
<Tool
|
||||||
|
Name="VCCLCompilerTool"
|
||||||
|
UsePrecompiledHeader="0"
|
||||||
|
PrecompiledHeaderThrough=""
|
||||||
|
/>
|
||||||
|
</FileConfiguration>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\tinyxml.cpp"
|
||||||
|
>
|
||||||
|
<FileConfiguration
|
||||||
|
Name="Debug|Win32"
|
||||||
|
>
|
||||||
|
<Tool
|
||||||
|
Name="VCCLCompilerTool"
|
||||||
|
UsePrecompiledHeader="0"
|
||||||
|
PrecompiledHeaderThrough=""
|
||||||
|
/>
|
||||||
|
</FileConfiguration>
|
||||||
|
<FileConfiguration
|
||||||
|
Name="Release|Win32"
|
||||||
|
>
|
||||||
|
<Tool
|
||||||
|
Name="VCCLCompilerTool"
|
||||||
|
UsePrecompiledHeader="0"
|
||||||
|
PrecompiledHeaderThrough=""
|
||||||
|
/>
|
||||||
|
</FileConfiguration>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\tinyxmlerror.cpp"
|
||||||
|
>
|
||||||
|
<FileConfiguration
|
||||||
|
Name="Debug|Win32"
|
||||||
|
>
|
||||||
|
<Tool
|
||||||
|
Name="VCCLCompilerTool"
|
||||||
|
UsePrecompiledHeader="0"
|
||||||
|
PrecompiledHeaderThrough=""
|
||||||
|
/>
|
||||||
|
</FileConfiguration>
|
||||||
|
<FileConfiguration
|
||||||
|
Name="Release|Win32"
|
||||||
|
>
|
||||||
|
<Tool
|
||||||
|
Name="VCCLCompilerTool"
|
||||||
|
UsePrecompiledHeader="0"
|
||||||
|
PrecompiledHeaderThrough=""
|
||||||
|
/>
|
||||||
|
</FileConfiguration>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\tinyxmlparser.cpp"
|
||||||
|
>
|
||||||
|
<FileConfiguration
|
||||||
|
Name="Debug|Win32"
|
||||||
|
>
|
||||||
|
<Tool
|
||||||
|
Name="VCCLCompilerTool"
|
||||||
|
UsePrecompiledHeader="0"
|
||||||
|
PrecompiledHeaderThrough=""
|
||||||
|
/>
|
||||||
|
</FileConfiguration>
|
||||||
|
<FileConfiguration
|
||||||
|
Name="Release|Win32"
|
||||||
|
>
|
||||||
|
<Tool
|
||||||
|
Name="VCCLCompilerTool"
|
||||||
|
UsePrecompiledHeader="0"
|
||||||
|
PrecompiledHeaderThrough=""
|
||||||
|
/>
|
||||||
|
</FileConfiguration>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\Util.cpp"
|
||||||
|
>
|
||||||
|
<FileConfiguration
|
||||||
|
Name="Debug|Win32"
|
||||||
|
>
|
||||||
|
<Tool
|
||||||
|
Name="VCCLCompilerTool"
|
||||||
|
UsePrecompiledHeader="2"
|
||||||
|
PrecompiledHeaderThrough="Pch.h"
|
||||||
|
/>
|
||||||
|
</FileConfiguration>
|
||||||
|
<FileConfiguration
|
||||||
|
Name="Release|Win32"
|
||||||
|
>
|
||||||
|
<Tool
|
||||||
|
Name="VCCLCompilerTool"
|
||||||
|
UsePrecompiledHeader="2"
|
||||||
|
PrecompiledHeaderThrough="Pch.h"
|
||||||
|
/>
|
||||||
|
</FileConfiguration>
|
||||||
|
</File>
|
||||||
|
</Filter>
|
||||||
|
<Filter
|
||||||
|
Name="Header Files"
|
||||||
|
Filter="h;hpp;hxx;hm;inl;inc;xsd"
|
||||||
|
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
|
||||||
|
>
|
||||||
|
<File
|
||||||
|
RelativePath=".\AppMeganekko.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\Common.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\DialogAbout.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\DialogCard.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\DialogCardEditor.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\DialogCardManager.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\DialogOptions.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\FlashCard.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\FlashCardManager.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\FrameMeganekko.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\Pch.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\tinystr.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\tinyxml.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\Util.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
</Filter>
|
||||||
|
<Filter
|
||||||
|
Name="Resource Files"
|
||||||
|
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
|
||||||
|
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
|
||||||
|
>
|
||||||
|
</Filter>
|
||||||
|
</Files>
|
||||||
|
<Globals>
|
||||||
|
</Globals>
|
||||||
|
</VisualStudioProject>
|
1316
Meganekko.xrc
Normal file
46
Pch.h
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
/*
|
||||||
|
Meganekko Copyright (C) 2008 Alex Yatskov
|
||||||
|
|
||||||
|
This program 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.
|
||||||
|
|
||||||
|
This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef PCH_H
|
||||||
|
#define PCH_H
|
||||||
|
|
||||||
|
// wx
|
||||||
|
#include <wx/wx.h>
|
||||||
|
#include <wx/xrc/xmlres.h>
|
||||||
|
#include <wx/html/htmlwin.h>
|
||||||
|
#include <wx/notebook.h>
|
||||||
|
#include <wx/spinctrl.h>
|
||||||
|
#include <wx/tglbtn.h>
|
||||||
|
#include <wx/fs_inet.h>
|
||||||
|
|
||||||
|
// stl
|
||||||
|
#include <algorithm>
|
||||||
|
#include <vector>
|
||||||
|
#include <string>
|
||||||
|
#include <map>
|
||||||
|
#include <list>
|
||||||
|
|
||||||
|
// crt
|
||||||
|
#include <assert.h>
|
||||||
|
#include <time.h>
|
||||||
|
|
||||||
|
// project
|
||||||
|
#include "Common.h"
|
||||||
|
#include "Util.h"
|
||||||
|
#include "tinyxml.h"
|
||||||
|
|
||||||
|
#endif
|
4748
Resource.cpp
Normal file
88
Util.cpp
Normal file
@ -0,0 +1,88 @@
|
|||||||
|
#include "Pch.h"
|
||||||
|
#include "Util.h"
|
||||||
|
|
||||||
|
typedef std::string Str;
|
||||||
|
typedef std::wstring WStr;
|
||||||
|
|
||||||
|
static void utf8toWStr(WStr& dest, const Str& src){
|
||||||
|
dest.clear();
|
||||||
|
wchar_t w = 0;
|
||||||
|
int bytes = 0;
|
||||||
|
wchar_t err = L'<EFBFBD>';
|
||||||
|
for (size_t i = 0; i < src.size(); i++){
|
||||||
|
unsigned char c = (unsigned char)src[i];
|
||||||
|
if (c <= 0x7f){//first byte
|
||||||
|
if (bytes){
|
||||||
|
dest.push_back(err);
|
||||||
|
bytes = 0;
|
||||||
|
}
|
||||||
|
dest.push_back((wchar_t)c);
|
||||||
|
}
|
||||||
|
else if (c <= 0xbf){//second/third/etc byte
|
||||||
|
if (bytes){
|
||||||
|
w = ((w << 6)|(c & 0x3f));
|
||||||
|
bytes--;
|
||||||
|
if (bytes == 0)
|
||||||
|
dest.push_back(w);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
dest.push_back(err);
|
||||||
|
}
|
||||||
|
else if (c <= 0xdf){//2byte sequence start
|
||||||
|
bytes = 1;
|
||||||
|
w = c & 0x1f;
|
||||||
|
}
|
||||||
|
else if (c <= 0xef){//3byte sequence start
|
||||||
|
bytes = 2;
|
||||||
|
w = c & 0x0f;
|
||||||
|
}
|
||||||
|
else if (c <= 0xf7){//3byte sequence start
|
||||||
|
bytes = 3;
|
||||||
|
w = c & 0x07;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
dest.push_back(err);
|
||||||
|
bytes = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (bytes)
|
||||||
|
dest.push_back(err);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void wstrToUtf8(Str& dest, const WStr& src){
|
||||||
|
dest.clear();
|
||||||
|
for (size_t i = 0; i < src.size(); i++){
|
||||||
|
wchar_t w = src[i];
|
||||||
|
if (w <= 0x7f)
|
||||||
|
dest.push_back((char)w);
|
||||||
|
else if (w <= 0x7ff){
|
||||||
|
dest.push_back(0xc0 | ((w >> 6)& 0x1f));
|
||||||
|
dest.push_back(0x80| (w & 0x3f));
|
||||||
|
}
|
||||||
|
else if (w <= 0xffff){
|
||||||
|
dest.push_back(0xe0 | ((w >> 12)& 0x0f));
|
||||||
|
dest.push_back(0x80| ((w >> 6) & 0x3f));
|
||||||
|
dest.push_back(0x80| (w & 0x3f));
|
||||||
|
}
|
||||||
|
else if (w <= 0x10ffff){
|
||||||
|
dest.push_back(0xf0 | ((w >> 18)& 0x07));
|
||||||
|
dest.push_back(0x80| ((w >> 12) & 0x3f));
|
||||||
|
dest.push_back(0x80| ((w >> 6) & 0x3f));
|
||||||
|
dest.push_back(0x80| (w & 0x3f));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
dest.push_back('?');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Str wstrToUtf8(const WStr& str){
|
||||||
|
Str result;
|
||||||
|
wstrToUtf8(result, str);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
WStr utf8toWStr(const Str& str){
|
||||||
|
WStr result;
|
||||||
|
utf8toWStr(result, str);
|
||||||
|
return result;
|
||||||
|
}
|
5
Util.h
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
std::string wstrToUtf8(const std::wstring& str);
|
||||||
|
std::wstring utf8toWStr(const std::string& str);
|
||||||
|
|
115
tinystr.cpp
Normal file
@ -0,0 +1,115 @@
|
|||||||
|
/*
|
||||||
|
www.sourceforge.net/projects/tinyxml
|
||||||
|
Original file by Yves Berquin.
|
||||||
|
|
||||||
|
This software is provided 'as-is', without any express or implied
|
||||||
|
warranty. In no event will the authors be held liable for any
|
||||||
|
damages arising from the use of this software.
|
||||||
|
|
||||||
|
Permission is granted to anyone to use this software for any
|
||||||
|
purpose, including commercial applications, and to alter it and
|
||||||
|
redistribute it freely, subject to the following restrictions:
|
||||||
|
|
||||||
|
1. The origin of this software must not be misrepresented; you must
|
||||||
|
not claim that you wrote the original software. If you use this
|
||||||
|
software in a product, an acknowledgment in the product documentation
|
||||||
|
would be appreciated but is not required.
|
||||||
|
|
||||||
|
2. Altered source versions must be plainly marked as such, and
|
||||||
|
must not be misrepresented as being the original software.
|
||||||
|
|
||||||
|
3. This notice may not be removed or altered from any source
|
||||||
|
distribution.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* THIS FILE WAS ALTERED BY Tyge Løvset, 7. April 2005.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef TIXML_USE_STL
|
||||||
|
|
||||||
|
#include "tinystr.h"
|
||||||
|
|
||||||
|
// Error value for find primitive
|
||||||
|
const TiXmlString::size_type TiXmlString::npos = static_cast< TiXmlString::size_type >(-1);
|
||||||
|
|
||||||
|
|
||||||
|
// Null rep.
|
||||||
|
TiXmlString::Rep TiXmlString::nullrep_ = { 0, 0, { '\0' } };
|
||||||
|
|
||||||
|
|
||||||
|
void TiXmlString::reserve (size_type cap)
|
||||||
|
{
|
||||||
|
if (cap > capacity())
|
||||||
|
{
|
||||||
|
TiXmlString tmp;
|
||||||
|
tmp.init(length(), cap);
|
||||||
|
memcpy(tmp.start(), data(), length());
|
||||||
|
swap(tmp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
TiXmlString& TiXmlString::assign(const char* str, size_type len)
|
||||||
|
{
|
||||||
|
size_type cap = capacity();
|
||||||
|
if (len > cap || cap > 3*(len + 8))
|
||||||
|
{
|
||||||
|
TiXmlString tmp;
|
||||||
|
tmp.init(len);
|
||||||
|
memcpy(tmp.start(), str, len);
|
||||||
|
swap(tmp);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
memmove(start(), str, len);
|
||||||
|
set_size(len);
|
||||||
|
}
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
TiXmlString& TiXmlString::append(const char* str, size_type len)
|
||||||
|
{
|
||||||
|
size_type newsize = length() + len;
|
||||||
|
if (newsize > capacity())
|
||||||
|
{
|
||||||
|
reserve (newsize + capacity());
|
||||||
|
}
|
||||||
|
memmove(finish(), str, len);
|
||||||
|
set_size(newsize);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
TiXmlString operator + (const TiXmlString & a, const TiXmlString & b)
|
||||||
|
{
|
||||||
|
TiXmlString tmp;
|
||||||
|
tmp.reserve(a.length() + b.length());
|
||||||
|
tmp += a;
|
||||||
|
tmp += b;
|
||||||
|
return tmp;
|
||||||
|
}
|
||||||
|
|
||||||
|
TiXmlString operator + (const TiXmlString & a, const char* b)
|
||||||
|
{
|
||||||
|
TiXmlString tmp;
|
||||||
|
TiXmlString::size_type b_len = static_cast<TiXmlString::size_type>( strlen(b) );
|
||||||
|
tmp.reserve(a.length() + b_len);
|
||||||
|
tmp += a;
|
||||||
|
tmp.append(b, b_len);
|
||||||
|
return tmp;
|
||||||
|
}
|
||||||
|
|
||||||
|
TiXmlString operator + (const char* a, const TiXmlString & b)
|
||||||
|
{
|
||||||
|
TiXmlString tmp;
|
||||||
|
TiXmlString::size_type a_len = static_cast<TiXmlString::size_type>( strlen(a) );
|
||||||
|
tmp.reserve(a_len + b.length());
|
||||||
|
tmp.append(a, a_len);
|
||||||
|
tmp += b;
|
||||||
|
return tmp;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#endif // TIXML_USE_STL
|
319
tinystr.h
Normal file
@ -0,0 +1,319 @@
|
|||||||
|
/*
|
||||||
|
www.sourceforge.net/projects/tinyxml
|
||||||
|
Original file by Yves Berquin.
|
||||||
|
|
||||||
|
This software is provided 'as-is', without any express or implied
|
||||||
|
warranty. In no event will the authors be held liable for any
|
||||||
|
damages arising from the use of this software.
|
||||||
|
|
||||||
|
Permission is granted to anyone to use this software for any
|
||||||
|
purpose, including commercial applications, and to alter it and
|
||||||
|
redistribute it freely, subject to the following restrictions:
|
||||||
|
|
||||||
|
1. The origin of this software must not be misrepresented; you must
|
||||||
|
not claim that you wrote the original software. If you use this
|
||||||
|
software in a product, an acknowledgment in the product documentation
|
||||||
|
would be appreciated but is not required.
|
||||||
|
|
||||||
|
2. Altered source versions must be plainly marked as such, and
|
||||||
|
must not be misrepresented as being the original software.
|
||||||
|
|
||||||
|
3. This notice may not be removed or altered from any source
|
||||||
|
distribution.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* THIS FILE WAS ALTERED BY Tyge Lovset, 7. April 2005.
|
||||||
|
*
|
||||||
|
* - completely rewritten. compact, clean, and fast implementation.
|
||||||
|
* - sizeof(TiXmlString) = pointer size (4 bytes on 32-bit systems)
|
||||||
|
* - fixed reserve() to work as per specification.
|
||||||
|
* - fixed buggy compares operator==(), operator<(), and operator>()
|
||||||
|
* - fixed operator+=() to take a const ref argument, following spec.
|
||||||
|
* - added "copy" constructor with length, and most compare operators.
|
||||||
|
* - added swap(), clear(), size(), capacity(), operator+().
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef TIXML_USE_STL
|
||||||
|
|
||||||
|
#ifndef TIXML_STRING_INCLUDED
|
||||||
|
#define TIXML_STRING_INCLUDED
|
||||||
|
|
||||||
|
#include <assert.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
/* The support for explicit isn't that universal, and it isn't really
|
||||||
|
required - it is used to check that the TiXmlString class isn't incorrectly
|
||||||
|
used. Be nice to old compilers and macro it here:
|
||||||
|
*/
|
||||||
|
#if defined(_MSC_VER) && (_MSC_VER >= 1200 )
|
||||||
|
// Microsoft visual studio, version 6 and higher.
|
||||||
|
#define TIXML_EXPLICIT explicit
|
||||||
|
#elif defined(__GNUC__) && (__GNUC__ >= 3 )
|
||||||
|
// GCC version 3 and higher.s
|
||||||
|
#define TIXML_EXPLICIT explicit
|
||||||
|
#else
|
||||||
|
#define TIXML_EXPLICIT
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
TiXmlString is an emulation of a subset of the std::string template.
|
||||||
|
Its purpose is to allow compiling TinyXML on compilers with no or poor STL support.
|
||||||
|
Only the member functions relevant to the TinyXML project have been implemented.
|
||||||
|
The buffer allocation is made by a simplistic power of 2 like mechanism : if we increase
|
||||||
|
a string and there's no more room, we allocate a buffer twice as big as we need.
|
||||||
|
*/
|
||||||
|
class TiXmlString
|
||||||
|
{
|
||||||
|
public :
|
||||||
|
// The size type used
|
||||||
|
typedef size_t size_type;
|
||||||
|
|
||||||
|
// Error value for find primitive
|
||||||
|
static const size_type npos; // = -1;
|
||||||
|
|
||||||
|
|
||||||
|
// TiXmlString empty constructor
|
||||||
|
TiXmlString () : rep_(&nullrep_)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
// TiXmlString copy constructor
|
||||||
|
TiXmlString ( const TiXmlString & copy) : rep_(0)
|
||||||
|
{
|
||||||
|
init(copy.length());
|
||||||
|
memcpy(start(), copy.data(), length());
|
||||||
|
}
|
||||||
|
|
||||||
|
// TiXmlString constructor, based on a string
|
||||||
|
TIXML_EXPLICIT TiXmlString ( const char * copy) : rep_(0)
|
||||||
|
{
|
||||||
|
init( static_cast<size_type>( strlen(copy) ));
|
||||||
|
memcpy(start(), copy, length());
|
||||||
|
}
|
||||||
|
|
||||||
|
// TiXmlString constructor, based on a string
|
||||||
|
TIXML_EXPLICIT TiXmlString ( const char * str, size_type len) : rep_(0)
|
||||||
|
{
|
||||||
|
init(len);
|
||||||
|
memcpy(start(), str, len);
|
||||||
|
}
|
||||||
|
|
||||||
|
// TiXmlString destructor
|
||||||
|
~TiXmlString ()
|
||||||
|
{
|
||||||
|
quit();
|
||||||
|
}
|
||||||
|
|
||||||
|
// = operator
|
||||||
|
TiXmlString& operator = (const char * copy)
|
||||||
|
{
|
||||||
|
return assign( copy, (size_type)strlen(copy));
|
||||||
|
}
|
||||||
|
|
||||||
|
// = operator
|
||||||
|
TiXmlString& operator = (const TiXmlString & copy)
|
||||||
|
{
|
||||||
|
return assign(copy.start(), copy.length());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// += operator. Maps to append
|
||||||
|
TiXmlString& operator += (const char * suffix)
|
||||||
|
{
|
||||||
|
return append(suffix, static_cast<size_type>( strlen(suffix) ));
|
||||||
|
}
|
||||||
|
|
||||||
|
// += operator. Maps to append
|
||||||
|
TiXmlString& operator += (char single)
|
||||||
|
{
|
||||||
|
return append(&single, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// += operator. Maps to append
|
||||||
|
TiXmlString& operator += (const TiXmlString & suffix)
|
||||||
|
{
|
||||||
|
return append(suffix.data(), suffix.length());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Convert a TiXmlString into a null-terminated char *
|
||||||
|
const char * c_str () const { return rep_->str; }
|
||||||
|
|
||||||
|
// Convert a TiXmlString into a char * (need not be null terminated).
|
||||||
|
const char * data () const { return rep_->str; }
|
||||||
|
|
||||||
|
// Return the length of a TiXmlString
|
||||||
|
size_type length () const { return rep_->size; }
|
||||||
|
|
||||||
|
// Alias for length()
|
||||||
|
size_type size () const { return rep_->size; }
|
||||||
|
|
||||||
|
// Checks if a TiXmlString is empty
|
||||||
|
bool empty () const { return rep_->size == 0; }
|
||||||
|
|
||||||
|
// Return capacity of string
|
||||||
|
size_type capacity () const { return rep_->capacity; }
|
||||||
|
|
||||||
|
|
||||||
|
// single char extraction
|
||||||
|
const char& at (size_type index) const
|
||||||
|
{
|
||||||
|
assert( index < length() );
|
||||||
|
return rep_->str[ index ];
|
||||||
|
}
|
||||||
|
|
||||||
|
// [] operator
|
||||||
|
char& operator [] (size_type index) const
|
||||||
|
{
|
||||||
|
assert( index < length() );
|
||||||
|
return rep_->str[ index ];
|
||||||
|
}
|
||||||
|
|
||||||
|
// find a char in a string. Return TiXmlString::npos if not found
|
||||||
|
size_type find (char lookup) const
|
||||||
|
{
|
||||||
|
return find(lookup, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
// find a char in a string from an offset. Return TiXmlString::npos if not found
|
||||||
|
size_type find (char tofind, size_type offset) const
|
||||||
|
{
|
||||||
|
if (offset >= length()) return npos;
|
||||||
|
|
||||||
|
for (const char* p = c_str() + offset; *p != '\0'; ++p)
|
||||||
|
{
|
||||||
|
if (*p == tofind) return static_cast< size_type >( p - c_str() );
|
||||||
|
}
|
||||||
|
return npos;
|
||||||
|
}
|
||||||
|
|
||||||
|
void clear ()
|
||||||
|
{
|
||||||
|
//Lee:
|
||||||
|
//The original was just too strange, though correct:
|
||||||
|
// TiXmlString().swap(*this);
|
||||||
|
//Instead use the quit & re-init:
|
||||||
|
quit();
|
||||||
|
init(0,0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Function to reserve a big amount of data when we know we'll need it. Be aware that this
|
||||||
|
function DOES NOT clear the content of the TiXmlString if any exists.
|
||||||
|
*/
|
||||||
|
void reserve (size_type cap);
|
||||||
|
|
||||||
|
TiXmlString& assign (const char* str, size_type len);
|
||||||
|
|
||||||
|
TiXmlString& append (const char* str, size_type len);
|
||||||
|
|
||||||
|
void swap (TiXmlString& other)
|
||||||
|
{
|
||||||
|
Rep* r = rep_;
|
||||||
|
rep_ = other.rep_;
|
||||||
|
other.rep_ = r;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
void init(size_type sz) { init(sz, sz); }
|
||||||
|
void set_size(size_type sz) { rep_->str[ rep_->size = sz ] = '\0'; }
|
||||||
|
char* start() const { return rep_->str; }
|
||||||
|
char* finish() const { return rep_->str + rep_->size; }
|
||||||
|
|
||||||
|
struct Rep
|
||||||
|
{
|
||||||
|
size_type size, capacity;
|
||||||
|
char str[1];
|
||||||
|
};
|
||||||
|
|
||||||
|
void init(size_type sz, size_type cap)
|
||||||
|
{
|
||||||
|
if (cap)
|
||||||
|
{
|
||||||
|
// Lee: the original form:
|
||||||
|
// rep_ = static_cast<Rep*>(operator new(sizeof(Rep) + cap));
|
||||||
|
// doesn't work in some cases of new being overloaded. Switching
|
||||||
|
// to the normal allocation, although use an 'int' for systems
|
||||||
|
// that are overly picky about structure alignment.
|
||||||
|
const size_type bytesNeeded = sizeof(Rep) + cap;
|
||||||
|
const size_type intsNeeded = ( bytesNeeded + sizeof(int) - 1 ) / sizeof( int );
|
||||||
|
rep_ = reinterpret_cast<Rep*>( new int[ intsNeeded ] );
|
||||||
|
|
||||||
|
rep_->str[ rep_->size = sz ] = '\0';
|
||||||
|
rep_->capacity = cap;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
rep_ = &nullrep_;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void quit()
|
||||||
|
{
|
||||||
|
if (rep_ != &nullrep_)
|
||||||
|
{
|
||||||
|
// The rep_ is really an array of ints. (see the allocator, above).
|
||||||
|
// Cast it back before delete, so the compiler won't incorrectly call destructors.
|
||||||
|
delete [] ( reinterpret_cast<int*>( rep_ ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Rep * rep_;
|
||||||
|
static Rep nullrep_;
|
||||||
|
|
||||||
|
} ;
|
||||||
|
|
||||||
|
|
||||||
|
inline bool operator == (const TiXmlString & a, const TiXmlString & b)
|
||||||
|
{
|
||||||
|
return ( a.length() == b.length() ) // optimization on some platforms
|
||||||
|
&& ( strcmp(a.c_str(), b.c_str()) == 0 ); // actual compare
|
||||||
|
}
|
||||||
|
inline bool operator < (const TiXmlString & a, const TiXmlString & b)
|
||||||
|
{
|
||||||
|
return strcmp(a.c_str(), b.c_str()) < 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool operator != (const TiXmlString & a, const TiXmlString & b) { return !(a == b); }
|
||||||
|
inline bool operator > (const TiXmlString & a, const TiXmlString & b) { return b < a; }
|
||||||
|
inline bool operator <= (const TiXmlString & a, const TiXmlString & b) { return !(b < a); }
|
||||||
|
inline bool operator >= (const TiXmlString & a, const TiXmlString & b) { return !(a < b); }
|
||||||
|
|
||||||
|
inline bool operator == (const TiXmlString & a, const char* b) { return strcmp(a.c_str(), b) == 0; }
|
||||||
|
inline bool operator == (const char* a, const TiXmlString & b) { return b == a; }
|
||||||
|
inline bool operator != (const TiXmlString & a, const char* b) { return !(a == b); }
|
||||||
|
inline bool operator != (const char* a, const TiXmlString & b) { return !(b == a); }
|
||||||
|
|
||||||
|
TiXmlString operator + (const TiXmlString & a, const TiXmlString & b);
|
||||||
|
TiXmlString operator + (const TiXmlString & a, const char* b);
|
||||||
|
TiXmlString operator + (const char* a, const TiXmlString & b);
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
TiXmlOutStream is an emulation of std::ostream. It is based on TiXmlString.
|
||||||
|
Only the operators that we need for TinyXML have been developped.
|
||||||
|
*/
|
||||||
|
class TiXmlOutStream : public TiXmlString
|
||||||
|
{
|
||||||
|
public :
|
||||||
|
|
||||||
|
// TiXmlOutStream << operator.
|
||||||
|
TiXmlOutStream & operator << (const TiXmlString & in)
|
||||||
|
{
|
||||||
|
*this += in;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TiXmlOutStream << operator.
|
||||||
|
TiXmlOutStream & operator << (const char * in)
|
||||||
|
{
|
||||||
|
*this += in;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
} ;
|
||||||
|
|
||||||
|
#endif // TIXML_STRING_INCLUDED
|
||||||
|
#endif // TIXML_USE_STL
|
1888
tinyxml.cpp
Normal file
53
tinyxmlerror.cpp
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
/*
|
||||||
|
www.sourceforge.net/projects/tinyxml
|
||||||
|
Original code (2.0 and earlier )copyright (c) 2000-2006 Lee Thomason (www.grinninglizard.com)
|
||||||
|
|
||||||
|
This software is provided 'as-is', without any express or implied
|
||||||
|
warranty. In no event will the authors be held liable for any
|
||||||
|
damages arising from the use of this software.
|
||||||
|
|
||||||
|
Permission is granted to anyone to use this software for any
|
||||||
|
purpose, including commercial applications, and to alter it and
|
||||||
|
redistribute it freely, subject to the following restrictions:
|
||||||
|
|
||||||
|
1. The origin of this software must not be misrepresented; you must
|
||||||
|
not claim that you wrote the original software. If you use this
|
||||||
|
software in a product, an acknowledgment in the product documentation
|
||||||
|
would be appreciated but is not required.
|
||||||
|
|
||||||
|
2. Altered source versions must be plainly marked as such, and
|
||||||
|
must not be misrepresented as being the original software.
|
||||||
|
|
||||||
|
3. This notice may not be removed or altered from any source
|
||||||
|
distribution.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "tinyxml.h"
|
||||||
|
|
||||||
|
// The goal of the seperate error file is to make the first
|
||||||
|
// step towards localization. tinyxml (currently) only supports
|
||||||
|
// english error messages, but the could now be translated.
|
||||||
|
//
|
||||||
|
// It also cleans up the code a bit.
|
||||||
|
//
|
||||||
|
|
||||||
|
const char* TiXmlBase::errorString[ TIXML_ERROR_STRING_COUNT ] =
|
||||||
|
{
|
||||||
|
"No error",
|
||||||
|
"Error",
|
||||||
|
"Failed to open file",
|
||||||
|
"Memory allocation failed.",
|
||||||
|
"Error parsing Element.",
|
||||||
|
"Failed to read Element name",
|
||||||
|
"Error reading Element value.",
|
||||||
|
"Error reading Attributes.",
|
||||||
|
"Error: empty tag.",
|
||||||
|
"Error reading end tag.",
|
||||||
|
"Error parsing Unknown.",
|
||||||
|
"Error parsing Comment.",
|
||||||
|
"Error parsing Declaration.",
|
||||||
|
"Error document empty.",
|
||||||
|
"Error null (0) or unexpected EOF found in input stream.",
|
||||||
|
"Error parsing CDATA.",
|
||||||
|
"Error when TiXmlDocument added to document, because TiXmlDocument can only be at the root.",
|
||||||
|
};
|