2.3.1.2 GETN_ADD_AUTO


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

#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")
    GETN_CURRENT_SUBNODE.SetAttribute(STR_ATTRIB_AUTO, "1|Auto|1");
	
    GetNBox(tr);
    return;
}


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.
		// Returns -1 if checked after clicking.
		// Otherwise returns 1 if unchecked after clicking.
		int nCheck = octree_get_auto_support(&trNode);
		if (-1 == nCheck)
		{
			if(trNode.nVal < 0)
				trNode.nVal= 0;
		}
		else if (1 == nCheck)
			trNode.nVal = -1;
	}

	return true;
}

void auto_checkbox_click_test()
{
	GETN_TREE(tr)

	// To initially check the auto checkbox and hide the control, set the control value to be -1.
	// Using GETN_ADD_AUTO(1) initially checks the checkbox. GETN_ADD_AUTO(0) initially unchecks the checkbox.
	GETN_NUM(num, _L("Set some value"), -1) GETN_ADD_AUTO(1) SET_AUTO_VALUE(-1) GETN_OPTION_EVENT_EX(_on_change)
	if (GetNBox(tr))
		out_tree(tr);
}

See Also

Header to Include

GetNbox.h

Reference