【お知らせ】この部分は英語原文のみでの提供となります。何卒ご了承ください。
2.3.1.2 GETN_ADD_AUTO
Contents
Name
GETN_ADD_AUTO
Declaration
#define GETN_ADD_AUTO(_CHECK) _tmpSubNode.SetAttribute(STR_ATTRIB_AUTO, _CHECK?"1":"0");
Remark
See EX4 for a example of automatically hiding a control based on it's Auto checkbox state >= Origin 9.6b)
Parameters
- _CHECK
Return
Examples
EX1
#include <GetNbox.h> void GETN_ADD_AUTO_ex1() { GETN_TREE(tr) GETN_BEGIN_BRANCH(tt, _L("Output Find Specific X/Y Tables")) GETN_OPTION_BRANCH(GETNBRANCH_OPEN) GETN_NUM(start, "Start Time", 1) GETN_ADD_AUTO(1) GETN_NUM(stop, "Stop Time", 100) GETN_ADD_AUTO(1) GETN_END_BRANCH(tt) if(GetNBox(tr)) { tree_check_replace_auto(tr.tt.start, NANUM); tree_check_replace_auto(tr.tt.stop, -1); out_tree(tr); } }
EX2
#include <GetNbox.h> // to add Auto checkbox to text edit control void GETN_ADD_AUTO_ex2() { GETN_TREE(tr) GETN_BUTTON(path, "Path", GetOriginPath() + "OriginC\\") // add Auto checkbox. "Auto" can be replace with any other text. GETN_CURRENT_SUBNODE.SetAttribute(STR_ATTRIB_AUTO, "1|Auto|1"); GetNBox(tr, button_event); } static int button_event(TreeNode& tr, int nRow, int nEvent, DWORD& dwEnables, LPCSTR lpcszNodeName, WndContainer& getNContainer, string& strAux, string& strErrMsg) { if( nRow < 0 ) return 0; // dialog init time, nothing to do if( 0 == strcmp(lpcszNodeName, "path") ) { string strPath = BrowseGetPath(tr.path.strVal); tr.path.strVal = strPath; return 1; } return 0; }
EX3
- this example shows how to customize the auto checkbox
#include <GetNbox.h> // to add Auto checkbox to browser combo control void GETN_ADD_AUTO_ex3() { GETN_TREE(tr) GETN_COMBO_BUTTON(fname, "Browse", "Picking a Data File", "File", "User.dat|System.dat|Group.dat", "Untitle.dat") //1|test|0 //1: check //test: rename the "auto" checkbox to "test" //0: the control will not turn read-only when uncheck the checkbox GETN_CURRENT_SUBNODE.SetAttribute(STR_ATTRIB_AUTO, "1|test|0"); if( GetNBox(tr) ) { TreeNode trAuto = tr.fname; if( AUTO_CHECKED == octree_get_auto_support(&trAuto) ) trAuto.strVal = "Untitle.dat"; out_tree(tr); } }
EX4
Showing and hiding a control based on it's checkbox state.
#include <GetNBox.h> static bool _on_change(TreeNode& trGUI, int nRow, int nCol, TreeNode& trNode, DWORD dwCntrl, int nType, WndContainer& theDlg) { // Event for when user clicks on the auto checkbox associated with the control calling this event. if ( GETNEVENT_ON_AUTO_BUTTON_CLICKED & dwCntrl) { // Returns state of auto checkbox. int nCheck = octree_get_auto_support(&trNode); if (AUTO_UNCHECKED == nCheck) { if(trNode.dVal < 0) trNode.dVal= 0; } else if (AUTO_CHECKED == nCheck) { double dAutoValue; trNode.GetAttribute(STR_AUTO_VALUE, dAutoValue); trNode.dVal = dAutoValue; } } return true; } void auto_checkbox_click_test() { double dAutoValue = 12.5; GETN_TREE(tr) // To show empty value in the control, pass the control value to SET_AUTO_VALUE. GETN_NUM(num, _L("Set some value"), dAutoValue) GETN_ADD_AUTO(1) // Using GETN_ADD_AUTO(1) initially checks the checkbox. GETN_ADD_AUTO(0) initially unchecks the checkbox. SET_AUTO_VALUE(dAutoValue) GETN_OPTION_EVENT_EX(_on_change) if (GetNBox(tr)) out_tree(tr); }
EX5
- this example shows the difference between auto checkbox and left checkbox
void GETN_ADD_AUTO_AND_LEFT_CHECK_Ex() { GETN_TREE(testTree) //auto checkbox double dAutoValue = 1; GETN_NUM(start, "Start Time", dAutoValue) GETN_ADD_AUTO(1) SET_AUTO_VALUE(dAutoValue) //left checkbox //GETN_CONTROL_OPTION_BOX and GETN_ADD_LEFT_CHECK are the same GETN_STR_GROUP(ctrlh, "Uncheck to hide", "A", "|A|C|R|V|Y") GETN_CONTROL_OPTION_BOX(0) GETN_NUM(ctrle, "Uncheck to disable", 1.23) GETN_ADD_LEFT_CHECK(0) GETN_ADD_LEFT_CHECK_TYPE(DYNA_USE_CHECK_TYPE_ENABLE) if(GetNBox(testTree, NULL, NULL, NULL, NULL)) { //show how to reset the value to auto value TreeNode trAuto = testTree.end; tree_check_replace_auto(testTree.end, dAutoValue); //show how to get the status of left checkbox if( 0 == GetN_get_left_checkbox(testTree.ctrlh) ) testTree.RemoveChild("ctrlh"); //another way to get if( tree_is_left_checkbox_checked(testTree.ctrle) ) out_str("ctrle is checked"); out_tree(testTree); } }
See Also
- SET_AUTO_VALUE
- GETN_CONTROL_OPTION_BOX
- GETN_ADD_LEFT_CHECK
- GETN_ADD_LEFT_CHECK_TYPE
- tree_check_replace_auto
- octree_get_auto_support
- GetN_get_left_checkbox
- tree_is_left_checkbox_checked
Header to Include
GetNbox.h