📄 atr_chrt.cpp
字号:
// Zinc Application Framework - CHART.CPP
// COPYRIGHT (C) 1990-1997. All Rights Reserved.
// Zinc Software Incorporated. Pleasant Grove, Utah USA
#include "atr_main.hpp"
#include <cf_api/bz_zcht.hpp>
#include <cff3_zaf.h>
const ZafEventType TST_SET_AXIS_GREEN = 14002;
const ZafEventType TST_SET_AXIS_YELLOW = 14003;
const ZafEventType TST_SET_AXIS_BLUE = 14004;
const ZafEventType TST_SET_AXIS_DEFAULT = 14005;
const ZafEventType TST_SET_TITLE_TEXT = 14006;
const ZafEventType TST_SET_XAXIS_TEXT = 14007;
const ZafEventType TST_SET_YAXIS_TEXT = 14008;
const ZafEventType TST_SET_TYPE_BASE = 15000 + 0;
const ZafEventType TST_SET_TYPE_PIE = 15000 + ZAF_PIE_2D;
const ZafEventType TST_SET_TYPE_BAR = 15000 + ZAF_BAR_2D;
const ZafEventType TST_SET_TYPE_COLUMN = 15000 + ZAF_COL_2D;
const ZafEventType TST_SET_TYPE_STACK = 15000 + ZAF_STACK_2D;
const ZafEventType TST_SET_TYPE_POINTS = 15000 + ZAF_POINTS_2D;
const ZafEventType TST_SET_TYPE_LINE = 15000 + ZAF_LINE_2D;
const ZafEventType TST_SET_TYPE_AREA = 15000 + ZAF_AREA_2D;
const ZafEventType TST_SET_INDEX_NAT = 16000 + ZAF_RANGE_NATURAL;
const ZafEventType TST_SET_INDEX_INT = 16000 + ZAF_RANGE_INTEGER;
ListEntry ZAF_FARDATA GenericTestWin::AttributeTable[] =
{
// ZafChart
{ ZAF_ITEXT("X-Axis Marks"), 0, TST_TOGGLE_XAXIS_MARKS },
{ ZAF_ITEXT("Y-Axis Marks"), 0, TST_TOGGLE_YAXIS_MARKS },
// ZafWindowObject
{ ZAF_ITEXT("Bordered"), 0, TST_TOGGLE_BORDERED },
{ ZAF_ITEXT("Visible *"), 0, TST_TOGGLE_VISIBLE },
// { ZAF_ITEXT("Accept drop *"), 0, TST_TOGGLE_ACCEPT_DROP },
{ ZAF_ITEXT("Auto update *"), 0, TST_TOGGLE_AUTOMATIC_UPDATE },
// { ZAF_ITEXT("Changed *"), 0, TST_TOGGLE_CHANGED },
// { ZAF_ITEXT("Copy Draggable *"), 0, TST_TOGGLE_COPY_DRAGGABLE },
// { ZAF_ITEXT("Link Draggable *"), 0, TST_TOGGLE_LINK_DRAGGABLE },
// { ZAF_ITEXT("Move Draggable *"), 0, TST_TOGGLE_MOVE_DRAGGABLE },
// { ZAF_ITEXT("Focus *"), 0, TST_TOGGLE_FOCUS },
{ ZAF_ITEXT("Noncurrent *"), 0, TST_TOGGLE_NONCURRENT },
{ ZAF_ITEXT("Disabled *"), 0, TST_TOGGLE_DISABLED },
{ ZAF_ITEXT("OSdraw"), 0, TST_TOGGLE_OSDRAW },
{ ZAF_ITEXT("Parentdraw border"), 0, TST_TOGGLE_PARENTDRAW_BORDER },
{ ZAF_ITEXT("Parent palette"), 0, TST_TOGGLE_PARENTPALETTE },
{ ZAF_ITEXT("Parentdraw focus"), 0, TST_TOGGLE_PARENTDRAW_FOCUS },
// { ZAF_ITEXT("Selected *"), 0, TST_TOGGLE_SELECTED },
{ ZAF_ITEXT("Edit mode"), 0, TST_TOGGLE_EDIT_MODE },
{ ZAF_NULLP(ZafIChar), 0, 0 }
};
// ---- Derived test object -------------------------------------------------
// Derive a test object so can log which events it gets.
class TestObj : public ZafChart
{
public:
TestObj();
void SendTestData();
ZafEventType Event(const ZafEventStruct &event);
};
TestObj::TestObj() : ZafChart(50, 0, 39, 10, CF_TYPE_PSER, CF_INDEX_NAT_N)
{
// !!! MUST BE "TEST_OBJECT" so can initialize testObject pointer !!!
SetStringID(ZAF_ITEXT("TEST_OBJECT"));
SendTestData(); // as per immediately below...
}
void TestObj::SendTestData()
{
const int NUM_POINTS = 10;
double SET1[ NUM_POINTS ] = { 20, 10, 20, 10, 20, 10, 20, 10, 20, 10 };
double SET2[ NUM_POINTS ] = { 20, 18, 14, 2, 14, 37, 35, 30, 24, 23 };
double SET3[ NUM_POINTS ] = { 33, 30, 27, 24, 21, 18, 15, 12, 9, 6 };
double SET4[ NUM_POINTS ] = { 20, 15, 10, 12, 14, 20, 24, 28, 30, 32 };
double SET5[ NUM_POINTS ] = { 16, 15, 23, 17, 24, 20, 18, 13, 28, 16 };
int i,j;
double *p_dTargetArray = &SET1[ 0 ];
for (i = 1; i <= 5; i++)
{
// Iterate through the target data array/pointer addresses:
if (i == 2)
p_dTargetArray = &SET2[ 0 ];
if (i == 3)
p_dTargetArray = &SET3[ 0 ];
if (i == 4)
p_dTargetArray = &SET4[ 0 ];
if (i == 5)
p_dTargetArray = &SET5[ 0 ];
// Activate the appropriate data group:
AddDataGroup(i);
// Add data points into the active data group:
for (j = 0; j < NUM_POINTS; j++)
AddDataPoint(i, *p_dTargetArray++);
}
}
ZafEventType TestObj::Event(const ZafEventStruct &event)
{
// Log the event and then pass to base class to be handled.
ZafEventType ccode = LogicalEvent(event);
GenericTestWin *testWin = DynamicPtrCast(parent, GenericTestWin);
testWin->LogEvent(ccode);
ccode = ZafChart::Event(event);
if (ccode == S_CURRENT || ccode == S_NON_CURRENT)
{
ZafVtList *attrList= DynamicPtrCast(testWin->GetObject(ZAF_ITEXT("ATTR_LIST")), ZafVtList);
attrList->GetObject((ZafNumberID)TST_TOGGLE_FOCUS)->SetSelected(Focus());
}
return (ccode);
}
// ---- Derived test window -------------------------------------------------
ObjectTestWin::ObjectTestWin() : GenericTestWin(8, 1, 90, 15)
{
// The test object can place settings combo boxes, etc. in the area
// 1, 8 (left, top) 47, 9 (right, bottom).
// Test objects can be placed in the area to the right of the divider
// line. So an area of 50, 1 (left, top) to 78, 9 (right, bottom) can
// be used. This area can be bigger or smaller simply by adjusting
// the size passed to the GenericTestWin constructor above.
// Set the title text.
SetText(ZAF_ITEXT("ZafChart"));
// Add settings objects.
ZafPrompt *prompt = new ZafPrompt(1, 8, 10, new ZafStringData("Type:"));
prompt->SetHzJustify(ZAF_HZ_RIGHT);
Add(prompt);
ZafComboBox *typeCombo = new ZafComboBox(12, 8, 14, 3);
typeCombo->SetViewOnly(true);
typeCombo->SetStringID(ZAF_ITEXT("TYPE_COMBO"));
typeCombo->Add(new ZafScrollBar(0, 0, 0, 0, ZAF_NULLP(ZafScrollData)));
ZafButton *attr = new ZafButton(0, 0, 15, 1, new ZafStringData("Base"));
attr->SetButtonType(ZAF_FLAT_BUTTON);
attr->SetHzJustify(ZAF_HZ_LEFT);
attr->SetSendMessageWhenSelected(true);
attr->SetValue(TST_SET_TYPE_BASE);
attr->SetNumberID((ZafNumberID)TST_SET_TYPE_BASE);
typeCombo->Add(attr);
attr = new ZafButton(0, 0, 15, 1, new ZafStringData("2D Pie"));
attr->SetButtonType(ZAF_FLAT_BUTTON);
attr->SetHzJustify(ZAF_HZ_LEFT);
attr->SetSendMessageWhenSelected(true);
attr->SetValue(TST_SET_TYPE_PIE);
attr->SetNumberID((ZafNumberID)TST_SET_TYPE_PIE);
typeCombo->Add(attr);
attr = new ZafButton(0, 0, 15, 1, new ZafStringData("2D Bar"));
attr->SetButtonType(ZAF_FLAT_BUTTON);
attr->SetHzJustify(ZAF_HZ_LEFT);
attr->SetSendMessageWhenSelected(true);
attr->SetValue(TST_SET_TYPE_BAR);
attr->SetNumberID((ZafNumberID)TST_SET_TYPE_BAR);
typeCombo->Add(attr);
attr = new ZafButton(0, 0, 15, 1, new ZafStringData("2D Column"));
attr->SetButtonType(ZAF_FLAT_BUTTON);
attr->SetHzJustify(ZAF_HZ_LEFT);
attr->SetSendMessageWhenSelected(true);
attr->SetValue(TST_SET_TYPE_COLUMN);
attr->SetNumberID((ZafNumberID)TST_SET_TYPE_COLUMN);
typeCombo->Add(attr);
attr = new ZafButton(0, 0, 15, 1, new ZafStringData("2D Stack"));
attr->SetButtonType(ZAF_FLAT_BUTTON);
attr->SetHzJustify(ZAF_HZ_LEFT);
attr->SetSendMessageWhenSelected(true);
attr->SetValue(TST_SET_TYPE_STACK);
attr->SetNumberID((ZafNumberID)TST_SET_TYPE_STACK);
typeCombo->Add(attr);
attr = new ZafButton(0, 0, 15, 1, new ZafStringData("2D Points"));
attr->SetButtonType(ZAF_FLAT_BUTTON);
attr->SetHzJustify(ZAF_HZ_LEFT);
attr->SetSendMessageWhenSelected(true);
attr->SetValue(TST_SET_TYPE_POINTS);
attr->SetNumberID((ZafNumberID)TST_SET_TYPE_POINTS);
typeCombo->Add(attr);
attr = new ZafButton(0, 0, 15, 1, new ZafStringData("2D Line"));
attr->SetButtonType(ZAF_FLAT_BUTTON);
attr->SetHzJustify(ZAF_HZ_LEFT);
attr->SetSendMessageWhenSelected(true);
attr->SetValue(TST_SET_TYPE_LINE);
attr->SetNumberID((ZafNumberID)TST_SET_TYPE_LINE);
typeCombo->Add(attr);
attr = new ZafButton(0, 0, 15, 1, new ZafStringData("2D Area"));
attr->SetButtonType(ZAF_FLAT_BUTTON);
attr->SetHzJustify(ZAF_HZ_LEFT);
attr->SetSendMessageWhenSelected(true);
attr->SetValue(TST_SET_TYPE_AREA);
attr->SetNumberID((ZafNumberID)TST_SET_TYPE_AREA);
typeCombo->Add(attr);
Add(typeCombo);
// Add settings objects.
prompt = new ZafPrompt(1, 9, 10, new ZafStringData("Index Method:"));
prompt->SetHzJustify(ZAF_HZ_RIGHT);
Add(prompt);
ZafComboBox *methodCombo = new ZafComboBox(12, 9, 14, 3);
methodCombo->SetViewOnly(true);
methodCombo->SetStringID(ZAF_ITEXT("METHOD_COMBO"));
methodCombo->Add(new ZafScrollBar(0, 0, 0, 0, ZAF_NULLP(ZafScrollData)));
attr = new ZafButton(0, 0, 15, 1, new ZafStringData("Natural Numbers"));
attr->SetButtonType(ZAF_FLAT_BUTTON);
attr->SetHzJustify(ZAF_HZ_LEFT);
attr->SetSendMessageWhenSelected(true);
attr->SetValue(TST_SET_INDEX_NAT);
attr->SetNumberID((ZafNumberID)TST_SET_INDEX_NAT);
methodCombo->Add(attr);
attr = new ZafButton(0, 0, 15, 1, new ZafStringData("Integer Indices"));
attr->SetButtonType(ZAF_FLAT_BUTTON);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -