📄 wgt.cc
字号:
#include <cstring>#include <stack>#include <Pt.h>#include <photonmm/Wgt.h>// namespace Ap { Wgt::Wgt () { } // static PtWidget_t* main_widget; Wgt* Wgt::create (const char* path_name, const char* wgt_name) { static int count = 0; if (count++ == 0 ) { ApAddClass("PtArc", &PtArc); ApAddClass("PtBarGraph", &PtBarGraph); ApAddClass("PtBasic", &PtBasic); ApAddClass("PtBezier", &PtBezier); ApAddClass("PtBitmap", &PtBitmap); ApAddClass("PtBkgd", &PtBkgd); ApAddClass("PtButton", &PtButton); ApAddClass("PtCalendar", &PtCalendar); ApAddClass("PtClock", &PtClock); ApAddClass("PtColorPalette", &PtColorPalette); ApAddClass("PtColorPanel", &PtColorPanel); ApAddClass("PtColorPatch", &PtColorPatch); ApAddClass("PtColorSel", &PtColorSel); ApAddClass("PtColorSelGroup", &PtColorSelGroup); ApAddClass("PtColorWell", &PtColorWell); ApAddClass("PtComboBox", &PtComboBox); ApAddClass("PtCompound", &PtCompound); ApAddClass("PtContainer", &PtContainer); ApAddClass("PtDisjoint", &PtDisjoint); ApAddClass("PtEllipse", &PtEllipse); ApAddClass("PtFontSel", &PtFontSel); ApAddClass("PtGauge", &PtGauge); ApAddClass("PtGraphic", &PtGraphic); ApAddClass("PtGroup", &PtGroup); ApAddClass("PtIcon", &PtIcon); ApAddClass("PtImageArea", &PtImageArea); ApAddClass("PtLabel", &PtLabel); ApAddClass("PtLine", &PtLine); ApAddClass("PtList", &PtList); ApAddClass("PtMTrend", &PtMTrend); ApAddClass("PtMenu", &PtMenu); ApAddClass("PtMenuBar", &PtMenuBar); ApAddClass("PtMenuButton", &PtMenuButton); ApAddClass("PtMenuLabel", &PtMenuLabel); ApAddClass("PtMessage", &PtMessage); ApAddClass("PtMeter", &PtMeter); ApAddClass("PtMultiText", &PtMultiText); ApAddClass("PtNumeric", &PtNumeric); ApAddClass("PtNumericFloat", &PtNumericFloat); ApAddClass("PtNumericInteger", &PtNumericInteger); ApAddClass("PtOSContainer", &PtOSContainer); ApAddClass("PtOnOffButton", &PtOnOffButton); ApAddClass("PtPane", &PtPane); ApAddClass("PtPanelGroup", &PtPanelGroup); ApAddClass("PtPixel", &PtPixel); ApAddClass("PtPolygon", &PtPolygon); ApAddClass("PtPrintSel", &PtPrintSel); ApAddClass("PtProgress", &PtProgress); ApAddClass("PtRaw", &PtRaw); ApAddClass("PtRect", &PtRect); ApAddClass("PtRegion", &PtRegion); ApAddClass("PtScrollArea", &PtScrollArea); ApAddClass("PtScrollContainer", &PtScrollContainer); ApAddClass("PtScrollbar", &PtScrollbar); ApAddClass("PtSeparator", &PtSeparator); ApAddClass("PtSlider", &PtSlider); ApAddClass("PtText", &PtText); ApAddClass("PtTimer", &PtTimer); ApAddClass ("PtToggleButton", &PtToggleButton); ApAddClass ("PtToolbar", &PtToolbar); ApAddClass ("PtToolbarGroup", &PtToolbarGroup); ApAddClass ("PtTrend", &PtTrend); ApAddClass ("PtUpDown", &PtUpDown); ApAddClass ("PtWidget", &PtWidget); ApAddClass ("PtWindow", &PtWindow); ApAddClass ("PtWindowFrame", &PtWindowFrame); } using namespace std; Wgt* wgt = 0; ApDBase_t* dbase = ApOpenDBaseFile (path_name); ApDBWidgetInfo_t wi; int i; for (i = 0; ApGetWidgetInfo (dbase, i, &wi); ++i ) if (! strcmp (wgt_name, wi.wgt_name) ) { PtWidget_t* widget; if (strcmp ("PtWindow", wi.wgt_class) ) widget = ApCreateDBWidget (dbase, wgt_name, main_widget, NULL, 0, NULL ); else widget = ApCreateDBWidget (dbase, wgt_name, NULL , NULL, 0, NULL ); // PtWindow if (widget ) { wgt = new Wgt (); int level0; WidgetInfo info; (AB_WIDGET_INFO) info = wi; info.widget = widget; info.name= wgt_name; wgt->widget_list.push_back ( info ); // root widget level0 = wi.level; std::stack<ApDBWidgetInfo_t> s; s.push (wi); for (i = i +1; ApGetWidgetInfo (dbase, i, &wi); ++i ) { if (wi.level <= level0 ) break; while (wi.level <= s.top ().level) s.pop (); widget = ApCreateDBWidget (dbase, wi.wgt_name, wgt->get_cwidget (s.top ().wgt_name ) /* parent */ , NULL, 0, NULL); (AB_WIDGET_INFO) info = wi; info.widget = widget; info.name = wi.wgt_name; wgt->widget_list.push_back (info); s.push (wi ); } // for } else { cerr<<"Warning: Ap: create: Widget \'" << wgt_name << "\' not found.\n"; // delete wgt; wgt = 0; } break; // for.. }// ApCloseDBase (dbase); return wgt; } PtWidget_t* Wgt::get_cwidget (const char* wgt_name ) const { widget_list_type::const_iterator i; for (i = widget_list.begin (); i != widget_list.end (); i++)// if (!strcmp (i-> wgt_name, wgt_name ) ) if (!strcmp (i-> name.c_str (), wgt_name ) ) break; if (i != widget_list.end ()) return i->widget; return NULL; }// } // mamespace Ap
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -