📄 atr_main.cpp
字号:
else if (!strncmp(quickTip, ZAF_ITEXT("Single"), 6))
helpTipCombo->Get(1)->SetSelected(true);
else
helpTipCombo->Get(2)->SetSelected(true);
}
break;
case TST_SET_HELP_CONTEXT:
{
ZafComboBox *helpCombo = DynamicPtrCast(GetObject(ZAF_ITEXT("HELP_CONTEXT_COMBO")), ZafComboBox);
ZafWindowObject *attr = helpCombo->Current();
ZafStringID newHelpContext = ZAF_NULLP(ZafIChar);
if (strcmp(attr->StringID(), ZAF_ITEXT("HELP_CONTEXT_NONE")))
newHelpContext = helpCombo->Current()->StringID();
testObject->SetHelpContext(newHelpContext);
const ZafIChar *helpContext = testObject->HelpContext();
attr = helpCombo->First();
while (attr && helpContext && strcmp(helpContext, attr->StringID()))
attr = attr->Next();
if (attr)
attr->SetSelected(true);
}
break;
case TST_SET_TEXT_DEFAULT:
testObject->SetTextColor(ZAF_CLR_NULL);
break;
case TST_SET_TEXT_RED:
testObject->SetTextColor(ZAF_CLR_RED);
break;
case TST_SET_TEXT_YELLOW:
testObject->SetTextColor(ZAF_CLR_YELLOW);
break;
case TST_SET_TEXT_BLACK:
testObject->SetTextColor(ZAF_CLR_BLACK);
break;
case TST_SET_BACK_DEFAULT:
testObject->SetBackgroundColor(ZAF_CLR_NULL);
break;
case TST_SET_BACK_RED:
testObject->SetBackgroundColor(ZAF_CLR_RED);
break;
case TST_SET_BACK_YELLOW:
testObject->SetBackgroundColor(ZAF_CLR_YELLOW);
break;
case TST_SET_BACK_LIGHTGRAY:
testObject->SetBackgroundColor(ZAF_CLR_LIGHTGRAY);
break;
case TST_SET_BACK_LIGHTBLUE:
testObject->SetBackgroundColor(ZAF_CLR_LIGHTBLUE);
break;
case TST_SET_BACK_WHITE:
testObject->SetBackgroundColor(ZAF_CLR_WHITE);
break;
case TST_SET_FONT_SMALL:
case TST_SET_FONT_DIALOG:
case TST_SET_FONT_APPLICATION:
case TST_SET_FONT_SYSTEM:
case TST_SET_FONT_FIXED:
{
if (ccode == TST_SET_FONT_SMALL)
testObject->SetFont(ZAF_FNT_SMALL);
else if (ccode == TST_SET_FONT_DIALOG)
testObject->SetFont(ZAF_FNT_DIALOG);
else if (ccode == TST_SET_FONT_SYSTEM)
testObject->SetFont(ZAF_FNT_SYSTEM);
else if (ccode == TST_SET_FONT_APPLICATION)
testObject->SetFont(ZAF_FNT_APPLICATION);
else if (ccode == TST_SET_FONT_FIXED)
testObject->SetFont(ZAF_FNT_FIXED);
ZafComboBox *fontCombo = DynamicPtrCast(GetObject(ZAF_ITEXT("FONT_COMBO")), ZafComboBox);
ZafLogicalFont font = testObject->Font();
if (font == ZAF_FNT_SMALL)
fontCombo->Get(0)->SetSelected(true);
if (font == ZAF_FNT_DIALOG)
fontCombo->Get(1)->SetSelected(true);
if (font == ZAF_FNT_SYSTEM)
fontCombo->Get(2)->SetSelected(true);
if (font == ZAF_FNT_APPLICATION)
fontCombo->Get(3)->SetSelected(true);
if (font == ZAF_FNT_FIXED)
fontCombo->Get(4)->SetSelected(true);
}
break;
// Store the window, then load a copy of it from the dat file.
case TST_STORE:
{
// If the testObject is not on the window, add it so it will be
// stored.
if (!testObject->screenID)
Event(TST_ADD_TESTOBJECT);
ZafStorage *storage = new ZafStorage(ZAF_ITEXT("test.znc"), ZAF_FILE_CREATE | ZAF_FILE_READWRITE);
ZafObjectPersistence *persist = new ZafObjectPersistence(storage, zafDefaultDataConstructor, zafDefaultObjectConstructor);
Write(*persist);
storage->Save();
ObjectTestWin *newWin = new ObjectTestWin(StringID(), *persist);
windowManager->Add(newWin);
newWin->SynchronizeAttributes();
delete persist;
delete storage;
}
break;
// Display the event log.
case TST_SHOW_EVENT_LOG:
{
ZafVtList *eventList = new ZafVtList(1, 1, 25, 7);
eventList->SetRegionType(ZAF_AVAILABLE_REGION);
eventList->Add(new ZafScrollBar(0, 0, 0, 0, ZAF_NULLP(ZafScrollData)));
// Add attribute items to list.
ZafIChar buf[64];
ZafButton *eventItem = ZAF_NULLP(ZafButton);
for (int count = 0; EventLog[count].text; count++)
{
sprintf(buf, ZAF_ITEXT("%s %d"), EventLog[count].text, EventLog[count].count);
eventItem = new ZafButton(0, 0, 15, 1, buf);
eventItem->SetHzJustify(ZAF_HZ_LEFT);
eventItem->SetButtonType(ZAF_FLAT_BUTTON);
eventList->Add(eventItem);
}
ZafWindow *eventWindow = new ZafWindow(40, 10, 30, 6);
eventWindow->AddGenericObjects(new ZafStringData("Event Log"));
// eventWindow->SetModal(true);
eventWindow->Add(eventList);
windowManager->Add(eventWindow);
}
break;
// Redraw the window. Sometimes changing an attribute doesn't update the
// display properly. Redrawing may indicate that the attribute _did_ get
// set just not shown.
case TST_REDRAW:
Event(S_REDISPLAY);
break;
case TST_DUPLICATE:
{
// If the testObject is not on the window, add it so it will be
// duplicated.
if (!testObject->screenID)
Event(TST_ADD_TESTOBJECT);
ObjectTestWin *newWin = DynamicPtrCast(Duplicate(), ObjectTestWin);
windowManager->Add(newWin);
newWin->SynchronizeAttributes();
}
break;
case TST_SUBTRACT_TESTOBJECT:
{
ZafButton *addSubtract = DynamicPtrCast(GetObject(ZAF_ITEXT("ADD_SUBTRACT")), ZafButton);
addSubtract->SetValue(TST_ADD_TESTOBJECT);
addSubtract->SetText(ZAF_ITEXT("Add"));
testObjectSibling = testObject->Next();
testObjectParent->Subtract(testObject);
}
break;
case TST_ADD_TESTOBJECT:
{
ZafButton *addSubtract = DynamicPtrCast(GetObject(ZAF_ITEXT("ADD_SUBTRACT")), ZafButton);
addSubtract->SetValue(TST_SUBTRACT_TESTOBJECT);
addSubtract->SetText(ZAF_ITEXT("Subtract"));
testObjectParent->Add(testObject, testObjectSibling);
}
break;
default:
ccode = ZafWindow::Event(event);
break;
}
return (ccode);
}
void GenericTestWin::LogEvent(ZafEventType ccode)
{
// Update the count for the event ccode.
for (int count = 0; EventLog[count].text; count++)
{
if (EventLog[count].value == ccode)
{
EventLog[count].count++;
break;
}
}
}
void GenericTestWin::SynchronizeAttributes()
{
ZafWindowObject *attr = 0;
// Indicate if the testObject has a particular attribute setting.
attr = attrList->GetObject((ZafNumberID)TST_TOGGLE_BORDERED);
if (attr)
attr->SetSelected(testObject->Bordered());
attr = attrList->GetObject((ZafNumberID)TST_TOGGLE_VISIBLE);
if (attr)
attr->SetSelected(testObject->Visible());
attr = attrList->GetObject((ZafNumberID)TST_TOGGLE_ACCEPT_DROP);
if (attr)
attr->SetSelected(testObject->AcceptDrop());
attr = attrList->GetObject((ZafNumberID)TST_TOGGLE_AUTOMATIC_UPDATE);
if (attr)
attr->SetSelected(testObject->AutomaticUpdate(false));
attr = attrList->GetObject((ZafNumberID)TST_TOGGLE_CHANGED);
if (attr)
attr->SetSelected(testObject->Changed());
attr = attrList->GetObject((ZafNumberID)TST_TOGGLE_COPY_DRAGGABLE);
if (attr)
attr->SetSelected(testObject->CopyDraggable());
attr = attrList->GetObject((ZafNumberID)TST_TOGGLE_LINK_DRAGGABLE);
if (attr)
attr->SetSelected(testObject->LinkDraggable());
attr = attrList->GetObject((ZafNumberID)TST_TOGGLE_MOVE_DRAGGABLE);
if (attr)
attr->SetSelected(testObject->MoveDraggable());
attr = attrList->GetObject((ZafNumberID)TST_TOGGLE_FOCUS);
if (attr)
attr->SetSelected(testObject->Focus());
attr = attrList->GetObject((ZafNumberID)TST_TOGGLE_NONCURRENT);
if (attr)
attr->SetSelected(testObject->Noncurrent());
attr = attrList->GetObject((ZafNumberID)TST_TOGGLE_DISABLED);
if (attr)
attr->SetSelected(testObject->Disabled());
attr = attrList->GetObject((ZafNumberID)TST_TOGGLE_OSDRAW);
if (attr)
attr->SetSelected(testObject->OSDraw());
attr = attrList->GetObject((ZafNumberID)TST_TOGGLE_PARENTDRAW_BORDER);
if (attr)
attr->SetSelected(testObject->ParentDrawBorder());
attr = attrList->GetObject((ZafNumberID)TST_TOGGLE_PARENTPALETTE);
if (attr)
attr->SetSelected(testObject->ParentPalette());
attr = attrList->GetObject((ZafNumberID)TST_TOGGLE_PARENTDRAW_FOCUS);
if (attr)
attr->SetSelected(testObject->ParentDrawFocus());
attr = attrList->GetObject((ZafNumberID)TST_TOGGLE_SELECTED);
if (attr)
attr->SetSelected(testObject->Selected());
ZafComboBox *helpCombo = DynamicPtrCast(GetObject(ZAF_ITEXT("HELP_CONTEXT_COMBO")), ZafComboBox);
const ZafIChar *helpContext = testObject->HelpContext();
attr = helpCombo->First();
while (attr && helpContext && strcmp(helpContext, attr->StringID()))
attr = attr->Next();
if (attr)
attr->SetSelected(true);
ZafComboBox *helpTipCombo = DynamicPtrCast(GetObject(ZAF_ITEXT("TOOL_TIP_COMBO")), ZafComboBox);
const ZafIChar *quickTip = testObject->QuickTip();
if (!quickTip)
helpTipCombo->First()->SetSelected(true);
else if (!strncmp(quickTip, ZAF_ITEXT("Single"), 6))
helpTipCombo->Get(1)->SetSelected(true);
else
helpTipCombo->Get(2)->SetSelected(true);
ZafComboBox *fontCombo = DynamicPtrCast(GetObject(ZAF_ITEXT("FONT_COMBO")), ZafComboBox);
ZafLogicalFont font = testObject->Font();
if (font == ZAF_FNT_SMALL)
fontCombo->Get(0)->SetSelected(true);
if (font == ZAF_FNT_DIALOG)
fontCombo->Get(1)->SetSelected(true);
if (font == ZAF_FNT_SYSTEM)
fontCombo->Get(2)->SetSelected(true);
}
ObjectTestWin::ObjectTestWin(const ZafIChar *name, ZafObjectPersistence &persist) :
GenericTestWin(name, persist)
{
// Nothing to do.
}
ObjectTestWin::ObjectTestWin(ObjectTestWin ©): GenericTestWin(copy)
{
// Nothing to do.
}
int ZafApplication::Main(void)
{
// Ensure main() is linked properly.
LinkMain();
helpTip = new ZafHelpTips(D_ON, ZAF_HELPTIPS_BOTH);
zafEventManager->Add(helpTip);
ZafStorage *storage = new ZafStorage(ZAF_ITEXT("help.znc"), ZAF_FILE_READWRITE);
if (!storage->Error())
zafHelpSystem = new ZafHelpSystem(storage);
// Add the test window.
ObjectTestWin *testWindow = new ObjectTestWin;
zafWindowManager->Add(testWindow);
testWindow->SynchronizeAttributes();
// Set windowManager's screenID so if the main window is closed, the
// entire app is shut down.
zafWindowManager->screenID = testWindow->screenID;
// Get the user input.
Control();
if (zafHelpSystem)
delete zafHelpSystem;
if (storage)
delete storage;
// Return success.
return (0);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -