📄 sugarmemoprefs.c
字号:
#include <PalmOS.h>
#include "SugarMemo.h"
#include "SugarMemoRsc.h"
#include "SugarMemoDB.h"
#include "SugarMemoTools.h"
#include "SugarMemoPrefs.h"
#define RowsInPrefsTemplateTable 4
#define FieldColumn 0
#define QuestionPaneColumn 1
#define AnswerPaneColumn 2
#define FontColumn 3
#define AlignColumn 4
extern WordFields FieldMap[4];
static void PrefsInitForm();
static void LoadTemplates();
static void SaveTemplates();
Boolean PrefsFormHandleEvent(EventType * event){
FormType* frmP = FrmGetActiveForm();
Boolean handled = false;
switch (event->eType){
case frmOpenEvent:
PrefsInitForm();
FrmDrawForm(frmP);
break;
case frmCloseEvent:
if (CurrentDB != NULL) DmCloseDatabase(CurrentDB);
break;
case ctlSelectEvent:
switch(event->data.ctlSelect.controlID){
case PrefsOKButton:
SaveTemplates();
FrmGotoForm(MainForm);
handled = true;
break;
case PrefsCancelButton:
FrmGotoForm(MainForm);
handled = true;
break;
default:
break;
}
default:
break;
}
return handled;
}
void PrefsInitForm(){
LoadTemplates();
}
void LoadTemplates(){
SugarAppInfoType* app;
ReviewMode reviewMode;
Boolean test = false;
Boolean recollection = false;
Boolean word = false;
Boolean translation = false;
Boolean lefty = false;
ControlType* ctl;
ctl = GetObjectPtr(PrefsBothCheckbox);
CtlSetValue(ctl, 0);
ctl = GetObjectPtr(PrefsWordCheckbox);
CtlSetValue(ctl, 0);
ctl = GetObjectPtr(PrefsTranslationCheckbox);
CtlSetValue(ctl, 0);
ctl = GetObjectPtr(PrefsMixedCheckbox);
CtlSetValue(ctl, 0);
ctl = GetObjectPtr(PrefsSelectionCheckbox);
CtlSetValue(ctl, 0);
ctl = GetObjectPtr(PrefsRecollectionCheckbox);
CtlSetValue(ctl, 0);
app = GetAppInfoPtr(CurrentDB);
reviewMode = app -> reviewMode;
lefty = app -> lefty;
MemPtrUnlock(app);
if (GetBitMacro(reviewMode.allBits, TranslationRecollection) != 0){
translation = true;
recollection = true;
}
if (GetBitMacro(reviewMode.allBits, WordRecollection) != 0){
word = true;
recollection = true;
}
if (GetBitMacro(reviewMode.allBits, TranslationTest) != 0){
translation = true;
test = true;
}
if (GetBitMacro(reviewMode.allBits, WordTest) != 0){
word = true;
test = true;
}
if (word && translation){
ctl = GetObjectPtr(PrefsBothCheckbox);
CtlSetValue(ctl, 1);
}
else {
if (word){
ctl = GetObjectPtr(PrefsWordCheckbox);
CtlSetValue(ctl, 1);
}
if (translation){
ctl = GetObjectPtr(PrefsTranslationCheckbox);
CtlSetValue(ctl, 1);
}
}
if (test && recollection){
ctl = GetObjectPtr(PrefsMixedCheckbox);
CtlSetValue(ctl, 1);
}
else{
if (test){
ctl = GetObjectPtr(PrefsSelectionCheckbox);
CtlSetValue(ctl, 1);
}
if (recollection){
ctl = GetObjectPtr(PrefsRecollectionCheckbox);
CtlSetValue(ctl, 1);
}
}
if (lefty){
ctl = GetObjectPtr(PrefsRightyCheckbox);
CtlSetValue(ctl, 0);
ctl = GetObjectPtr(PrefsLeftyCheckbox);
CtlSetValue(ctl, 1);
}
else {
ctl = GetObjectPtr(PrefsRightyCheckbox);
CtlSetValue(ctl, 1);
ctl = GetObjectPtr(PrefsLeftyCheckbox);
CtlSetValue(ctl, 0);
}
}
void SaveTemplates(){
SugarAppInfoType* app, *appHelper = 0;
ControlType* ctl;
Boolean select = false;
Boolean recollection = false;
Boolean word = false;
Boolean translation = false;
ReviewMode reviewMode;
UInt16 bits = 0;
UInt8 lefty;
ctl = GetObjectPtr(PrefsMixedCheckbox);
if (CtlGetValue(ctl) != 0) {
select = true;
recollection = true;
}
else{
ctl = GetObjectPtr(PrefsSelectionCheckbox);
if (CtlGetValue(ctl) != 0){
select = true;
}
ctl = GetObjectPtr(PrefsRecollectionCheckbox);
if (CtlGetValue(ctl) != 0){
recollection = true;
}
}
ctl = GetObjectPtr(PrefsBothCheckbox);
if (CtlGetValue(ctl) != 0) {
word = true;
translation = true;
}
else{
ctl = GetObjectPtr(PrefsWordCheckbox);
if (CtlGetValue(ctl) != 0){
word = true;
}
ctl = GetObjectPtr(PrefsTranslationCheckbox);
if (CtlGetValue(ctl) != 0){
translation = true;
}
}
if (select && word)
SetBitMacro(bits, WordTest);
if (select && translation)
SetBitMacro(bits, TranslationTest);
if (recollection && word)
SetBitMacro(bits, WordRecollection);
if (recollection && translation)
SetBitMacro(bits, TranslationRecollection);
reviewMode.allBits = (UInt8)bits;
ctl = GetObjectPtr(PrefsLeftyCheckbox);
lefty = CtlGetValue(ctl);
app = GetAppInfoPtr(CurrentDB);
DmWrite(app, (UInt32)&appHelper -> reviewMode, &reviewMode, sizeof(reviewMode));
DmWrite(app, (UInt32)&appHelper -> lefty, &lefty, sizeof(lefty));
MemPtrUnlock(app);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -