📄 wizard.cxx
字号:
// The screen property is a little bit special and cannot be handled by the// generic parsers. There are two arguments, a number and some Tcl code.intCdlWizardBody::parse_screen(CdlInterpreter interp, int argc, char** argv){ CYG_REPORT_FUNCNAME("CdlParse::parse_screen"); CYG_REPORT_FUNCARG1("argc %d", argc); CYG_PRECONDITION_CLASSC(interp); CdlProperty_TclCode new_property = 0; cdl_int number = 0; try { std::vector<std::pair<std::string,std::string> > options; int data_index = CdlParse::parse_options(interp, std::string("property ") + argv[0], 0, argc, argv, 1, options); if ((data_index + 2) != argc) { CdlParse::report_property_parse_error(interp, argv[0], std::string("Invalid number of arguments.\n") + " Expecting two arguments, a number and some Tcl code."); } else if (!Cdl::string_to_integer(argv[data_index], number)) { CdlParse::report_property_parse_error(interp, argv[0], std::string(argv[data_index]) + " is not a valid number."); } else if (!Tcl_CommandComplete(argv[data_index + 1])) { CdlParse::report_property_parse_error(interp, argv[0], "incomplete Tcl code fragment."); } else { CdlNode current_node = interp->get_node(); CYG_ASSERTC(0 != current_node); new_property = CdlProperty_TclCodeBody::make(current_node, CdlPropertyId_Screen, number, argv[data_index + 1], argc, argv, options); } } catch(...) { if (0 != new_property) { delete new_property; } throw; } return TCL_OK;}//}}}//{{{ Persistence // ----------------------------------------------------------------------------// For now there is no information in a wizard that should end up in a// save file, but it is still desirable to override the base class// member function.voidCdlWizardBody::save(CdlInterpreter interp, Tcl_Channel chan, int indentation, bool minimal) throw(CdlInputOutputException, std::bad_alloc){ CYG_REPORT_FUNCNAME("CdlWizard::save"); CYG_REPORT_FUNCARG5XV(this, interp, chan, indentation, minimal); CYG_PRECONDITION_THISC(); CYG_UNUSED_PARAM(CdlInterpreter, interp); CYG_UNUSED_PARAM(Tcl_Channel, chan); CYG_UNUSED_PARAM(int, indentation); CYG_UNUSED_PARAM(bool, minimal); CYG_REPORT_RETURN();}//}}}//{{{ Data access // ----------------------------------------------------------------------------boolCdlWizardBody::has_init_proc() const{ CYG_REPORT_FUNCNAMETYPE("CdlWizard::has_init_proc", "result %d"); CYG_REPORT_FUNCARG1XV(this); CYG_PRECONDITION_THISC(); bool result = has_property(CdlPropertyId_InitProc); CYG_REPORT_RETVAL(result); return result;}boolCdlWizardBody::has_decoration_proc() const{ CYG_REPORT_FUNCNAMETYPE("CdlWizard::has_decoration_proc", "result %d"); CYG_REPORT_FUNCARG1XV(this); CYG_PRECONDITION_THISC(); bool result = has_property(CdlPropertyId_DecorationProc); CYG_REPORT_RETVAL(result); return result;}boolCdlWizardBody::has_screen(cdl_int screen) const{ CYG_REPORT_FUNCNAMETYPE("CdlWizard::has_screen", "result %d"); CYG_REPORT_FUNCARG2XV(this, (int) screen); CYG_PRECONDITION_THISC(); bool result = false; const std::vector<CdlProperty>& properties = get_properties(); std::vector<CdlProperty>::const_iterator prop_i; for (prop_i = properties.begin(); prop_i != properties.end(); prop_i++) { if (CdlPropertyId_Screen != (*prop_i)->get_property_name()) { continue; } CdlProperty_TclCode tclprop = dynamic_cast<CdlProperty_TclCode>(*prop_i); CYG_ASSERT_CLASSC(tclprop); if (screen == tclprop->get_number()) { result = true; break; } } CYG_REPORT_RETVAL(result); return result;}const cdl_tcl_code&CdlWizardBody::get_init_proc() const{ CYG_REPORT_FUNCNAME("CdlWizard::get_init_proc"); CYG_REPORT_FUNCARG1XV(this); CYG_PRECONDITION_THISC(); static cdl_tcl_code null_result = ""; cdl_tcl_code& result = null_result; CdlProperty prop = get_property(CdlPropertyId_InitProc); if (0 != prop) { CdlProperty_TclCode tclprop = dynamic_cast<CdlProperty_TclCode>(prop); CYG_ASSERT_CLASSC(tclprop); result = tclprop->get_code(); } CYG_REPORT_RETURN(); return result;}const cdl_tcl_code&CdlWizardBody::get_decoration_proc() const{ CYG_REPORT_FUNCNAME("CdlWizard::get_decoration_proc"); CYG_REPORT_FUNCARG1XV(this); CYG_PRECONDITION_THISC(); static cdl_tcl_code null_result = ""; cdl_tcl_code& result = null_result; CdlProperty prop = get_property(CdlPropertyId_DecorationProc); if (0 != prop) { CdlProperty_TclCode tclprop = dynamic_cast<CdlProperty_TclCode>(prop); CYG_ASSERT_CLASSC(tclprop); result = tclprop->get_code(); } CYG_REPORT_RETURN(); return result;}const cdl_tcl_code&CdlWizardBody::get_confirm_proc() const{ CYG_REPORT_FUNCNAME("CdlWizard::get_display_proc"); CYG_REPORT_FUNCARG1XV(this); CYG_PRECONDITION_THISC(); CdlProperty prop = get_property(CdlPropertyId_ConfirmProc); CYG_ASSERT_CLASSC(prop); CdlProperty_TclCode tclprop = dynamic_cast<CdlProperty_TclCode>(prop); CYG_ASSERT_CLASSC(tclprop); const cdl_tcl_code& result = tclprop->get_code(); CYG_REPORT_RETURN(); return result;}const cdl_tcl_code&CdlWizardBody::get_cancel_proc() const{ CYG_REPORT_FUNCNAME("CdlWizard::get_display_proc"); CYG_REPORT_FUNCARG1XV(this); CYG_PRECONDITION_THISC(); CdlProperty prop = get_property(CdlPropertyId_CancelProc); CYG_ASSERT_CLASSC(prop); CdlProperty_TclCode tclprop = dynamic_cast<CdlProperty_TclCode>(prop); CYG_ASSERT_CLASSC(tclprop); const cdl_tcl_code& result = tclprop->get_code(); CYG_REPORT_RETURN(); return result;}cdl_intCdlWizardBody::get_first_screen_number() const{ CYG_REPORT_FUNCNAMETYPE("CdlWizard::get_first_screen_number", "result %d"); CYG_REPORT_FUNCARG1XV(this); CYG_PRECONDITION_THISC(); // The result should really be initialized to MININT, but that is // slightly tricky given that we are dealing with cdl_int's rather // than plain int's. Instead a separate flag gives the same // effect. bool result_set = false; cdl_int result = -1; const std::vector<CdlProperty>& properties = get_properties(); std::vector<CdlProperty>::const_iterator prop_i; for (prop_i = properties.begin(); prop_i != properties.end(); prop_i++) { if (CdlPropertyId_Screen != (*prop_i)->get_property_name()) { continue; } CdlProperty_TclCode tclprop = dynamic_cast<CdlProperty_TclCode>(*prop_i); cdl_int its_num = tclprop->get_number(); if (!result_set || (its_num < result)) { result = its_num; result_set = true; } } CYG_REPORT_RETVAL((int) result); return result;}const cdl_tcl_code&CdlWizardBody::get_first_screen() const{ CYG_REPORT_FUNCNAME("CdlWizard::get_first_screen"); CYG_REPORT_FUNCARG1XV(this); CYG_PRECONDITION_THISC(); // The result should really be initialized to MININT, but that is // slightly tricky given that we are dealing with cdl_int's rather // than plain int's. Instead a separate flag gives the same // effect. static cdl_tcl_code null_result = ""; bool result_set = false; cdl_tcl_code& result = null_result; cdl_int result_num = -1; const std::vector<CdlProperty>& properties = get_properties(); std::vector<CdlProperty>::const_iterator prop_i; for (prop_i = properties.begin(); prop_i != properties.end(); prop_i++) { if (CdlPropertyId_Screen != (*prop_i)->get_property_name()) { continue; } CdlProperty_TclCode tclprop = dynamic_cast<CdlProperty_TclCode>(*prop_i); cdl_int its_num = tclprop->get_number(); if (!result_set || (its_num < result_num)) { result = tclprop->get_code(); result_num = its_num; result_set = true; } } CYG_REPORT_RETURN(); return result;}const cdl_tcl_code&CdlWizardBody::get_screen(cdl_int screen) const{ CYG_REPORT_FUNCNAME("CdlWizard::get_screen"); CYG_REPORT_FUNCARG2XV(this, (int)screen); CYG_PRECONDITION_THISC(); static cdl_tcl_code null_result = ""; cdl_tcl_code& result = null_result; const std::vector<CdlProperty>& properties = get_properties(); std::vector<CdlProperty>::const_iterator prop_i; for (prop_i = properties.begin(); prop_i != properties.end(); prop_i++) { if (CdlPropertyId_Screen != (*prop_i)->get_property_name()) { continue; } CdlProperty_TclCode tclprop = dynamic_cast<CdlProperty_TclCode>(*prop_i); if (tclprop->get_number() == screen) { result = tclprop->get_code(); break; } } CYG_REPORT_RETURN(); return result;}//}}}//{{{ check_this() // ----------------------------------------------------------------------------// check_this(). There is very little data associated with a wizard,// most of the checks happen in the base classes.boolCdlWizardBody::check_this(cyg_assert_class_zeal zeal) const{ if (CdlWizardBody_Magic != cdlwizardbody_cookie) { return false; } CYGDBG_MEMLEAK_CHECKTHIS(); return CdlUserVisibleBody::check_this(zeal);}//}}}//{{{ misc // ----------------------------------------------------------------------------std::stringCdlWizardBody::get_class_name() const{ CYG_REPORT_FUNCNAME("CdlWizard::get_class_name"); CYG_PRECONDITION_THISC(); CYG_REPORT_RETURN(); return "wizard";}//}}}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -