关于BlockUI的Tree树控件只要研究UGOPEN里西门子官方的那个例子在结合去查NXOPEN的帮助基本就可以了。[不过我是看唐工的视频学会的,没办法自己领悟性不太强]

 //=============================================================================
//
// Copyright (c) 2009 Siemens PLM Solutions
// Unpublished - All rights reserved
//===============================================================================
//File description: Sample NX/Open Application for Block Styler
//===============================================================================
// // WARNING!! This file is overwritten by the Block Styler while generating
// the automation code. Any modifications to this file will be lost after
// generating the code again. //============================================================================== #ifndef TREELISTDEMO_H_INCLUDED
#define TREELISTDEMO_H_INCLUDED //------------------------------------------------------------------------------
//These includes are needed for the following template code
//------------------------------------------------------------------------------
#include <uf_defs.h>
#include <string.h>
#include <uf_ui_types.h>
#include <iostream>
#include <NXOpen/Session.hxx>
#include <NXOpen/UI.hxx>
#include <NXOpen/NXMessageBox.hxx>
#include <NXOpen/Callback.hxx>
#include <NXOpen/NXException.hxx>
#include <NXOpen/ListingWindow.hxx>
#include <NXOpen/BlockStyler_UIBlock.hxx>
#include <NXOpen/BlockStyler_BlockDialog.hxx>
#include <NXOpen/BlockStyler_PropertyList.hxx>
#include <NXOpen/BlockStyler_Tree.hxx>
#include <NXOpen/BlockStyler_Node.hxx> //------------------------------------------------------------------------------
//Bit Option for Property: SnapPointTypesEnabled
//------------------------------------------------------------------------------
#define SnapPointTypesEnabled_UserDefined (1 << 0);
#define SnapPointTypesEnabled_Inferred (1 << 1);
#define SnapPointTypesEnabled_ScreenPosition (1 << 2);
#define SnapPointTypesEnabled_EndPoint (1 << 3);
#define SnapPointTypesEnabled_MidPoint (1 << 4);
#define SnapPointTypesEnabled_ControlPoint (1 << 5);
#define SnapPointTypesEnabled_Intersection (1 << 6);
#define SnapPointTypesEnabled_ArcCenter (1 << 7);
#define SnapPointTypesEnabled_QuadrantPoint (1 << 8);
#define SnapPointTypesEnabled_ExistingPoint (1 << 9);
#define SnapPointTypesEnabled_PointonCurve (1 <<10);
#define SnapPointTypesEnabled_PointonSurface (1 <<11);
#define SnapPointTypesEnabled_PointConstructor (1 <<12);
#define SnapPointTypesEnabled_TwocurveIntersection (1 <<13);
#define SnapPointTypesEnabled_TangentPoint (1 <<14);
#define SnapPointTypesEnabled_Poles (1 <<15);
#define SnapPointTypesEnabled_BoundedGridPoint (1 <<16);
//------------------------------------------------------------------------------
//Bit Option for Property: SnapPointTypesOnByDefault
//------------------------------------------------------------------------------
#define SnapPointTypesOnByDefault_EndPoint (1 << 3);
#define SnapPointTypesOnByDefault_MidPoint (1 << 4);
#define SnapPointTypesOnByDefault_ControlPoint (1 << 5);
#define SnapPointTypesOnByDefault_Intersection (1 << 6);
#define SnapPointTypesOnByDefault_ArcCenter (1 << 7);
#define SnapPointTypesOnByDefault_QuadrantPoint (1 << 8);
#define SnapPointTypesOnByDefault_ExistingPoint (1 << 9);
#define SnapPointTypesOnByDefault_PointonCurve (1 <<10);
#define SnapPointTypesOnByDefault_PointonSurface (1 <<11);
#define SnapPointTypesOnByDefault_PointConstructor (1 <<12);
#define SnapPointTypesOnByDefault_BoundedGridPoint (1 <<16);
//------------------------------------------------------------------------------
// Namespaces needed for following template
//------------------------------------------------------------------------------
using namespace std;
using namespace NXOpen;
using namespace NXOpen::BlockStyler; //------------------------------------------------------------------------------
// Forward declaration for Class
//------------------------------------------------------------------------------
class TreeListDemo;
//
//------------------------------------------------------------------------------
// Declaration of global variables
//------------------------------------------------------------------------------
extern TreeListDemo *theTreeListDemo; class TreeListDemo
{
// class members
public:
static Session *theSession;
static UI *theUI;
TreeListDemo();
~TreeListDemo();
int Show(); //----------------------- BlockStyler Callback Prototypes ---------------------
// The following member function prototypes define the callbacks
// specified in your BlockStyler dialog. The empty implementaiton
// of these prototypes is provided in the TreeListDemo.cpp file.
// You are REQUIRED to write the implementation for these funtions.
//------------------------------------------------------------------------------
void initialize_cb();
void dialogShown_cb();
int apply_cb();
int ok_cb();
int update_cb(NXOpen::BlockStyler::UIBlock* block);
void focusNotify_cb(NXOpen::BlockStyler::UIBlock* block, bool focus); //void OnExpandCallback (NXOpen::BlockStyler::Tree *tree, NXOpen::BlockStyler::Node *node);
//void OnInsertColumnCallback(NXOpen::BlockStyler::Tree *tree, NXOpen::BlockStyler::Node *node, int columnID);
void OnInsertNodeCallback(NXOpen::BlockStyler::Tree *tree, NXOpen::BlockStyler::Node *node);
void OnDeleteNodeCallback(NXOpen::BlockStyler::Tree *tree, NXOpen::BlockStyler::Node *node);
//void OnPreSelectCallback(NXOpen::BlockStyler::Tree *tree, NXOpen::BlockStyler::Node *node, int ID, bool selected);
void OnSelectCallback(NXOpen::BlockStyler::Tree *, NXOpen::BlockStyler::Node *, int columnID, bool selected);
void OnStateChangeCallback(NXOpen::BlockStyler::Tree *tree, NXOpen::BlockStyler::Node *node, int state);
NXString ToolTipTextCallback(NXOpen::BlockStyler::Tree *tree, NXOpen::BlockStyler::Node *node, int columnID);
//int ColumnSortCallback(NXOpen::BlockStyler::Tree *tree, int columnID, NXOpen::BlockStyler::Node *node1, NXOpen::BlockStyler::Node *node2);
NXString StateIconNameCallback(NXOpen::BlockStyler::Tree *tree, NXOpen::BlockStyler::Node *node, int state);
NXOpen::BlockStyler::Tree::BeginLabelEditState OnBeginLabelEditCallback(NXOpen::BlockStyler::Tree *tree, NXOpen::BlockStyler::Node *node, int columnID);
NXOpen::BlockStyler::Tree::EndLabelEditState OnEndLabelEditCallback(NXOpen::BlockStyler::Tree *tree, NXOpen::BlockStyler::Node *node, int, NXString editedText);
NXOpen::BlockStyler::Tree::EditControlOption OnEditOptionSelectedCallback(NXOpen::BlockStyler::Tree *tree, NXOpen::BlockStyler::Node *node, int columnID, int selectedOptionID, NXString selectedOptionText, NXOpen::BlockStyler::Tree::ControlType type);
NXOpen::BlockStyler::Tree::ControlType AskEditControlCallback(NXOpen::BlockStyler::Tree *tree, NXOpen::BlockStyler::Node *node, int columnID);
void OnMenuCallback(NXOpen::BlockStyler::Tree *, NXOpen::BlockStyler::Node *node, int columnID);
void OnMenuSelectionCallback(NXOpen::BlockStyler::Tree *tree, NXOpen::BlockStyler::Node *node, int menuItemID);
NXOpen::BlockStyler::Node::DropType IsDropAllowedCallback(NXOpen::BlockStyler::Tree *tree, NXOpen::BlockStyler::Node *node, int columnID, NXOpen::BlockStyler::Node *targetNode, int targetColumnID);
NXOpen::BlockStyler::Node::DragType IsDragAllowedCallback(NXOpen::BlockStyler::Tree *tree, NXOpen::BlockStyler::Node *node, int columnID);
bool OnDropCallback(NXOpen::BlockStyler::Tree *tree, std::vector<NXOpen::BlockStyler::Node *> node, int columnID, NXOpen::BlockStyler::Node *targetNode, int targetColumnID, NXOpen::BlockStyler::Node::DropType dropType, int dropMenuItemId);
//void OnDropMenuCallback(NXOpen::BlockStyler::Tree *tree, NXOpen::BlockStyler::Node *node, int columnID, NXOpen::BlockStyler::Node *targetNode, int targetColumnID);
void OnDefaultAction(NXOpen::BlockStyler::Tree *tree, NXOpen::BlockStyler::Node *node, int columnID);
private:
std::string theDialogName;
NXOpen::BlockStyler::BlockDialog* theDialog;
NXOpen::BlockStyler::UIBlock* group0;// Block type: Group
NXOpen::BlockStyler::Tree* tree_control0;// Block type: Tree Control
NXOpen::BlockStyler::UIBlock* addDeleteNodeGroup;// Block type: Group
NXOpen::BlockStyler::UIBlock* nodeString;// Block type: String
NXOpen::BlockStyler::UIBlock* addNodeButton;// Block type: Button
NXOpen::BlockStyler::UIBlock* deleteNodeButton;// Block type: Button
NXOpen::BlockStyler::UIBlock* stateIconGroup;// Block type: Group
NXOpen::BlockStyler::UIBlock* stateIconOptions;// Block type: Enumeration
NXOpen::BlockStyler::UIBlock* nodeToolTip;// Block type: String
NXOpen::BlockStyler::UIBlock* NodeEditGroup;// Block type: Group
NXOpen::BlockStyler::UIBlock* nodeEditOptions;// Block type: Enumeration
NXOpen::BlockStyler::UIBlock* menuGroup;// Block type: Group
NXOpen::BlockStyler::UIBlock* showMenuToggle;// Block type: Toggle
NXOpen::BlockStyler::UIBlock* dragDropGroup;// Block type: Group
NXOpen::BlockStyler::UIBlock* disallowDragToggle;// Block type: Toggle
NXOpen::BlockStyler::UIBlock* dropOptions;// Block type: Enumeration
NXOpen::BlockStyler::UIBlock* defaultActionGroup;// Block type: Group
NXOpen::BlockStyler::UIBlock* defaultActionToggle;// Block type: Toggle
NXOpen::BlockStyler::UIBlock* nodeDataGroup;// Block type: Group
NXOpen::BlockStyler::UIBlock* instructions;// Block type: Multiline String
NXOpen::BlockStyler::UIBlock* selection0;// Block type: Selection
NXOpen::BlockStyler::UIBlock* addCrossSelectionNodeButton;// Block type: Button
NXOpen::BlockStyler::UIBlock* redrawGroup;// Block type: Group
NXOpen::BlockStyler::UIBlock* redrawInstruction;// Block type: Multiline String
NXOpen::BlockStyler::UIBlock* redrawToggle;// Block type: Toggle
NXOpen::BlockStyler::UIBlock* listingWindowGroup;// Block type: Group
NXOpen::BlockStyler::UIBlock* listingWindowToggle;// Block type: Toggle
void DeleteSelectedNodes();
BlockStyler::Node* CreateAndAddNode(BlockStyler::Node* afterNode);
void WriteCallbackToListingWindow(NXString); };
#endif //TREELISTDEMO_H_INCLUDED Caesar卢尚宇
2019年11月23日
 //===============================================================================
//
// Copyright (c) 2009 Siemens PLM Solutions
// Unpublished - All rights reserved
//===============================================================================
//File description: Sample NX/Open Application for Block Styler
//===============================================================================
// // WARNING!! This file is overwritten by the Block UI Styler while generating
// the automation code. Any modifications to this file will be lost after
// generating the code again. //================================================================================ //================================================================================
// Purpose: This TEMPLATE file contains C++ source to guide you in the
// construction of your Block application dialog. The generation of your
// dialog file (.dlx extension) is the first step towards dialog construction
// within NX. You must now create a NX Open application that
// utilizes this file (.dlx).
//
// The information in this file provides you with the following:
//
// 1. Help on how to load and display your Block UI Styler dialog in NX
// using APIs provided in NXOpen.BlockStyler namespace
// 2. The empty callback methods (stubs) associated with your dialog items
// have also been placed in this file. These empty methods have been
// created simply to start you along with your coding requirements.
// The method name, argument list and possible return values have already
// been provided for you.
//================================================================================ //--------------------------------------------------------------------------------
//These includes are needed for the following template code
//--------------------------------------------------------------------------------
#include "TreeListDemo.hpp"
#include <sstream>
using namespace NXOpen;
using namespace NXOpen::BlockStyler; //------------------------------------------------------------------------------
// Initialize static variables
//------------------------------------------------------------------------------
Session *(TreeListDemo::theSession) = NULL;
UI *(TreeListDemo::theUI) = NULL; //------------------------------------------------------------------------------
// Declaration of global variables
//------------------------------------------------------------------------------
TreeListDemo *theTreeListDemo;
//------------------------------------------------------------------------------
// Constructor for NX Styler class
//------------------------------------------------------------------------------
TreeListDemo::TreeListDemo()
{
try
{
// Initialize the NX Open C++ API environment
TreeListDemo::theSession = NXOpen::Session::GetSession();
TreeListDemo::theUI = UI::GetUI();
theDialogName = "TreeListDemo.dlx";
theDialog = TreeListDemo::theUI->CreateDialog(theDialogName.c_str());
// Registration of callback functions
theDialog->AddApplyHandler(make_callback(this, &TreeListDemo::apply_cb));
theDialog->AddOkHandler(make_callback(this, &TreeListDemo::ok_cb));
theDialog->AddUpdateHandler(make_callback(this, &TreeListDemo::update_cb));
theDialog->AddInitializeHandler(make_callback(this, &TreeListDemo::initialize_cb));
theDialog->AddFocusNotifyHandler(make_callback(this, &TreeListDemo::focusNotify_cb));
theDialog->AddDialogShownHandler(make_callback(this, &TreeListDemo::dialogShown_cb));
}
catch(exception& ex)
{
//---- Enter your exception handling code here -----
throw;
}
} //------------------------------------------------------------------------------
// Destructor for NX Styler class
//------------------------------------------------------------------------------
TreeListDemo::~TreeListDemo()
{
if (theDialog != NULL)
{
delete theDialog;
theDialog = NULL;
}
}
//------------------------------- DIALOG LAUNCHING ---------------------------------
//
// Before invoking this application one needs to open any part/empty part in NX
// because of the behavior of the blocks.
//
// Make sure the dlx file is in one of the following locations:
// 1.) From where NX session is launched
// 2.) $UGII_USER_DIR/application
// 3.) For released applications, using UGII_CUSTOM_DIRECTORY_FILE is highly
// recommended. This variable is set to a full directory path to a file
// containing a list of root directories for all custom applications.
// e.g., UGII_CUSTOM_DIRECTORY_FILE=$UGII_BASE_DIR\ugii\menus\custom_dirs.dat
//
// You can create the dialog using one of the following way:
//
// 1. USER EXIT
//
// 1) Create the Shared Library -- Refer "Block UI Styler programmer's guide"
// 2) Invoke the Shared Library through File->Execute->NX Open menu.
//
//------------------------------------------------------------------------------
extern "C" DllExport void ufusr(char *param, int *retcod, int param_len)
{
try
{
theTreeListDemo = new TreeListDemo();
// The following method shows the dialog immediately
theTreeListDemo->Show();
}
catch(exception& ex)
{
//---- Enter your exception handling code here -----
TreeListDemo::theUI->NXMessageBox()->Show("Block Styler", NXOpen::NXMessageBox::DialogTypeError, ex.what());
}
delete theTreeListDemo;
} //------------------------------------------------------------------------------
// This method specifies how a shared image is unloaded from memory
// within NX. This method gives you the capability to unload an
// internal NX Open application or user exit from NX. Specify any
// one of the three constants as a return value to determine the type
// of unload to perform:
//
//
// Immediately : unload the library as soon as the automation program has completed
// Explicitly : unload the library from the "Unload Shared Image" dialog
// AtTermination : unload the library when the NX session terminates
//
//
// NOTE: A program which associates NX Open applications with the menubar
// MUST NOT use this option since it will UNLOAD your NX Open application image
// from the menubar.
//------------------------------------------------------------------------------
extern "C" DllExport int ufusr_ask_unload()
{
//return (int)Session::LibraryUnloadOptionExplicitly;
return (int)Session::LibraryUnloadOptionImmediately;
//return (int)Session::LibraryUnloadOptionAtTermination;
} //------------------------------------------------------------------------------
// Following method cleanup any housekeeping chores that may be needed.
// This method is automatically called by NX.
//------------------------------------------------------------------------------
extern "C" DllExport void ufusr_cleanup(void)
{
try
{
//---- Enter your callback code here -----
}
catch(exception& ex)
{
//---- Enter your exception handling code here -----
TreeListDemo::theUI->NXMessageBox()->Show("Block Styler", NXOpen::NXMessageBox::DialogTypeError, ex.what());
}
} int TreeListDemo::Show()
{
try
{
theDialog->Show();
}
catch(exception& ex)
{
//---- Enter your exception handling code here -----
TreeListDemo::theUI->NXMessageBox()->Show("Block Styler", NXOpen::NXMessageBox::DialogTypeError, ex.what());
}
return ;
} //------------------------------------------------------------------------------
//---------------------Block UI Styler Callback Functions--------------------------
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
//Callback Name: initialize_cb NXOpen::NXString nodeBaseString;
int nodeSuffixNumber = ;
//------------------------------------------------------------------------------
void TreeListDemo::initialize_cb()
{
try
{
group0 = dynamic_cast<NXOpen::BlockStyler::UIBlock* >(theDialog->TopBlock()->FindBlock("group0"));
tree_control0 = dynamic_cast<NXOpen::BlockStyler::Tree* >(theDialog->TopBlock()->FindBlock("tree_control0"));
addDeleteNodeGroup = dynamic_cast<NXOpen::BlockStyler::UIBlock* >(theDialog->TopBlock()->FindBlock("addDeleteNodeGroup"));
nodeString = dynamic_cast<NXOpen::BlockStyler::UIBlock* >(theDialog->TopBlock()->FindBlock("nodeString"));
addNodeButton = dynamic_cast<NXOpen::BlockStyler::UIBlock* >(theDialog->TopBlock()->FindBlock("addNodeButton"));
deleteNodeButton = dynamic_cast<NXOpen::BlockStyler::UIBlock* >(theDialog->TopBlock()->FindBlock("deleteNodeButton"));
stateIconGroup = dynamic_cast<NXOpen::BlockStyler::UIBlock* >(theDialog->TopBlock()->FindBlock("stateIconGroup"));
stateIconOptions = dynamic_cast<NXOpen::BlockStyler::UIBlock* >(theDialog->TopBlock()->FindBlock("stateIconOptions"));
nodeToolTip = dynamic_cast<NXOpen::BlockStyler::UIBlock* >(theDialog->TopBlock()->FindBlock("nodeToolTip"));
NodeEditGroup = dynamic_cast<NXOpen::BlockStyler::UIBlock* >(theDialog->TopBlock()->FindBlock("NodeEditGroup"));
nodeEditOptions = dynamic_cast<NXOpen::BlockStyler::UIBlock* >(theDialog->TopBlock()->FindBlock("nodeEditOptions"));
menuGroup = dynamic_cast<NXOpen::BlockStyler::UIBlock* >(theDialog->TopBlock()->FindBlock("menuGroup"));
showMenuToggle = dynamic_cast<NXOpen::BlockStyler::UIBlock* >(theDialog->TopBlock()->FindBlock("showMenuToggle"));
dragDropGroup = dynamic_cast<NXOpen::BlockStyler::UIBlock* >(theDialog->TopBlock()->FindBlock("dragDropGroup"));
disallowDragToggle = dynamic_cast<NXOpen::BlockStyler::UIBlock* >(theDialog->TopBlock()->FindBlock("disallowDragToggle"));
dropOptions = dynamic_cast<NXOpen::BlockStyler::UIBlock* >(theDialog->TopBlock()->FindBlock("dropOptions"));
defaultActionGroup = dynamic_cast<NXOpen::BlockStyler::UIBlock* >(theDialog->TopBlock()->FindBlock("defaultActionGroup"));
defaultActionToggle = dynamic_cast<NXOpen::BlockStyler::UIBlock* >(theDialog->TopBlock()->FindBlock("defaultActionToggle"));
nodeDataGroup = dynamic_cast<NXOpen::BlockStyler::UIBlock* >(theDialog->TopBlock()->FindBlock("nodeDataGroup"));
instructions = dynamic_cast<NXOpen::BlockStyler::UIBlock* >(theDialog->TopBlock()->FindBlock("instructions"));
selection0 = dynamic_cast<NXOpen::BlockStyler::UIBlock* >(theDialog->TopBlock()->FindBlock("selection0"));
addCrossSelectionNodeButton = dynamic_cast<NXOpen::BlockStyler::UIBlock* >(theDialog->TopBlock()->FindBlock("addCrossSelectionNodeButton"));
redrawGroup = dynamic_cast<NXOpen::BlockStyler::UIBlock* >(theDialog->TopBlock()->FindBlock("redrawGroup"));
redrawInstruction = dynamic_cast<NXOpen::BlockStyler::UIBlock* >(theDialog->TopBlock()->FindBlock("redrawInstruction"));
redrawToggle = dynamic_cast<NXOpen::BlockStyler::UIBlock* >(theDialog->TopBlock()->FindBlock("redrawToggle"));
listingWindowGroup = dynamic_cast<NXOpen::BlockStyler::UIBlock* >(theDialog->TopBlock()->FindBlock("listingWindowGroup"));
listingWindowToggle = dynamic_cast<NXOpen::BlockStyler::UIBlock* >(theDialog->TopBlock()->FindBlock("listingWindowToggle"));
//------------------------------------------------------------------------------
//Registration of Treelist specific callbacks
//------------------------------------------------------------------------------
//tree_control0->SetOnExpandHandler(make_callback(this, &TreeListDemo::OnExpandCallback)); //tree_control0->SetOnInsertColumnHandler(make_callback(this, &TreeListDemo::OnInsertColumnCallback)); tree_control0->SetOnInsertNodeHandler(make_callback(this, &TreeListDemo::OnInsertNodeCallback)); tree_control0->SetOnDeleteNodeHandler(make_callback(this, &TreeListDemo::OnDeleteNodeCallback)); //tree_control0->SetOnPreSelectHandler(make_callback(this, &TreeListDemo::OnPreSelectCallback)); tree_control0->SetOnSelectHandler(make_callback(this, &TreeListDemo::OnSelectCallback)); tree_control0->SetOnStateChangeHandler(make_callback(this, &TreeListDemo::OnStateChangeCallback)); tree_control0->SetToolTipTextHandler(make_callback(this, &TreeListDemo::ToolTipTextCallback)); //tree_control0->SetColumnSortHandler(make_callback(this, &TreeListDemo::ColumnSortCallback)); tree_control0->SetStateIconNameHandler(make_callback(this, &TreeListDemo::StateIconNameCallback)); tree_control0->SetOnBeginLabelEditHandler(make_callback(this, &TreeListDemo::OnBeginLabelEditCallback)); tree_control0->SetOnEndLabelEditHandler(make_callback(this, &TreeListDemo::OnEndLabelEditCallback)); tree_control0->SetOnEditOptionSelectedHandler(make_callback(this, &TreeListDemo::OnEditOptionSelectedCallback)); tree_control0->SetAskEditControlHandler(make_callback(this, &TreeListDemo::AskEditControlCallback)); tree_control0->SetOnMenuHandler(make_callback(this, &TreeListDemo::OnMenuCallback)); tree_control0->SetOnMenuSelectionHandler(make_callback(this, &TreeListDemo::OnMenuSelectionCallback)); tree_control0->SetIsDropAllowedHandler(make_callback(this, &TreeListDemo::IsDropAllowedCallback)); tree_control0->SetIsDragAllowedHandler(make_callback(this, &TreeListDemo::IsDragAllowedCallback)); tree_control0->SetOnDropHandler(make_callback(this, &TreeListDemo::OnDropCallback)); //tree_control0->SetOnDropMenuHandler(make_callback(this, &TreeListDemo::OnDropMenuCallback)); tree_control0->SetOnDefaultActionHandler(make_callback(this, &TreeListDemo::OnDefaultAction)); //------------------------------------------------------------------------------ BlockStyler::PropertyList *stringPropList = nodeString->GetProperties() ;
nodeBaseString = stringPropList->GetString("Value");
NXOpen::NXString nodeDisplayString = nodeBaseString;
std::stringstream stringBuffer;
stringBuffer << nodeSuffixNumber;
nodeDisplayString += stringBuffer.str();
stringPropList->SetString("Value",nodeDisplayString);
delete stringPropList;
}
catch(exception& ex)
{
//---- Enter your exception handling code here -----
TreeListDemo::theUI->NXMessageBox()->Show("Block Styler", NXOpen::NXMessageBox::DialogTypeError, ex.what());
}
} enum Columns
{
ColumnFirst = ,
ColumnSecond = ,
ColumnThird =
};
BlockStyler::Node *previousAddedNode = NULL;
int randomIcon = ;
NXOpen::NXString randomIconString[] = {"extrude", "cone", "block", "blend"}; //------------------------------------------------------------------------------
//Callback Name: dialogShown_cb
//This callback is executed just before the dialog launch. Thus any value set
//here will take precedence and dialog will be launched showing that value.
//------------------------------------------------------------------------------
void TreeListDemo::dialogShown_cb()
{
try
{
//---- Enter your callback code here ----- //Insert Columns
tree_control0->InsertColumn(ColumnFirst, "First Column", );
tree_control0->InsertColumn(ColumnSecond, "Second Column", );
tree_control0->InsertColumn(ColumnThird, "Third Column", ); //Set resize policy for columns
tree_control0->SetColumnResizePolicy(ColumnFirst, Tree::ColumnResizePolicyConstantWidth);
tree_control0->SetColumnResizePolicy(ColumnSecond, Tree::ColumnResizePolicyConstantWidth);
tree_control0->SetColumnResizePolicy(ColumnThird, Tree::ColumnResizePolicyConstantWidth); //Let the second column interpret the text as icon
tree_control0->SetColumnDisplayType(ColumnSecond, Tree::ColumnDisplayIcon);
}
catch(exception& ex)
{
//---- Enter your exception handling code here -----
TreeListDemo::theUI->NXMessageBox()->Show("Block Styler", NXOpen::NXMessageBox::DialogTypeError, ex.what());
}
} //------------------------------------------------------------------------------
//Callback Name: apply_cb
//------------------------------------------------------------------------------
int TreeListDemo::apply_cb()
{
int errorCode = ;
try
{
//---- Enter your callback code here -----
}
catch(exception& ex)
{
//---- Enter your exception handling code here -----
errorCode = ;
TreeListDemo::theUI->NXMessageBox()->Show("Block Styler", NXOpen::NXMessageBox::DialogTypeError, ex.what());
}
return errorCode;
} BlockStyler::Node* TreeListDemo::CreateAndAddNode(BlockStyler::Node* afterNode)
{
BlockStyler::Node *parentNode = NULL; //Get node display string from the block
BlockStyler::PropertyList *stringPropList = nodeString->GetProperties() ;
NXOpen::NXString nodeDisplayString = stringPropList->GetString("Value");
delete stringPropList; BlockStyler::Node *node = tree_control0->CreateNode(nodeDisplayString); //Set few properties of node
node->SetForegroundColor();
node->SetDisplayIcon(randomIconString[randomIcon]);
node->SetSelectedIcon("draft"); //Take first selected node as parent node
std::vector<BlockStyler::Node *>selectedNodes=tree_control0->GetSelectedNodes();
if (selectedNodes.size()>)
{
parentNode = selectedNodes[];
} //Insert Node
tree_control0->InsertNode(node,parentNode,afterNode,tree_control0->NodeInsertOptionSort);
node->ScrollTo(ColumnFirst,BlockStyler::Node::ScrollCenter); //Change the last node color. Making sure that new node color is distinct
if (previousAddedNode != NULL)
{
previousAddedNode->SetForegroundColor();
}
previousAddedNode = node; return node;
} void TreeListDemo::DeleteSelectedNodes()
{
std::vector<BlockStyler::Node *>selectedNodes=tree_control0->GetSelectedNodes();
if(selectedNodes.size()>)
{
while(selectedNodes.size()>)
{
tree_control0->DeleteNode(selectedNodes[]);
selectedNodes=tree_control0->GetSelectedNodes();
}
}
else
{
theUI->NXMessageBox()->Show("Delete Node", NXOpen::NXMessageBox::DialogTypeInformation, "No Nodes are selected");
}
} //Writes callback name to ListingWindow
void TreeListDemo::WriteCallbackToListingWindow(NXString callbackName)
{
if (!listingWindowToggle)
return;
try
{
//---- Enter your callback code here ----- NXOpen::BlockStyler::PropertyList *listingWindowToggleProps = listingWindowToggle->GetProperties();
bool listingWindow = listingWindowToggleProps->GetLogical("Value");
delete listingWindowToggleProps; if(listingWindow)
{
theSession->ListingWindow()->Open();
NXString nullString = NULL;
theSession->ListingWindow()->WriteLine(nullString);
theSession->ListingWindow()->WriteLine(callbackName);
}
}
catch(exception& ex)
{
//---- Enter your exception handling code here -----
TreeListDemo::theUI->NXMessageBox()->Show("Block Styler", NXOpen::NXMessageBox::DialogTypeError, ex.what());
}
} //------------------------------------------------------------------------------
//Callback Name: update_cb
//------------------------------------------------------------------------------
int TreeListDemo::update_cb(NXOpen::BlockStyler::UIBlock* block)
{
try
{
if(block == nodeString)
{
//---------Enter your code here-----------
}
else if(block == addNodeButton)
{
//---------Enter your code here-----------
BlockStyler::Node *afterNode = NULL;
BlockStyler::Node *node = CreateAndAddNode(afterNode); //State Icon BlockStyler::PropertyList *prop = stateIconOptions->GetProperties();
int enumValue = prop->GetEnum("Value");
delete prop; if(enumValue==)
{
//Ignore
}
else if(enumValue==)
{
node->SetState();
}
else if(enumValue==)
{
node->SetState();//set value other than 1 or 2
}
}
else if(block == deleteNodeButton)
{
//---------Enter your code here-----------
DeleteSelectedNodes();
}
else if(block == stateIconOptions)
{
//---------Enter your code here-----------
}
else if(block == nodeToolTip)
{
//---------Enter your code here-----------
}
else if(block == nodeEditOptions)
{
//---------Enter your code here-----------
if (!defaultActionToggle)
{
return ;
} NXOpen::BlockStyler::PropertyList *nodeEditOptionsProps = nodeEditOptions->GetProperties();
NXString nodeEditOption = nodeEditOptionsProps->GetEnumAsString("Value");
delete nodeEditOptionsProps; NXOpen::BlockStyler::PropertyList *defaultActionToggleProps = defaultActionToggle->GetProperties(); if(!(strcmp(nodeEditOption.GetText(),"Combo Box Edit"))||!(strcmp(nodeEditOption.GetText(),"Listbox Edit")))
{
defaultActionToggleProps->SetLogical("Enable",false);
defaultActionToggleProps->SetLogical("Value",false);
}
else
{
defaultActionToggleProps->SetLogical("Enable",true);
}
delete defaultActionToggleProps;
}
else if(block == showMenuToggle)
{
//---------Enter your code here-----------
}
else if(block == disallowDragToggle)
{
//---------Enter your code here-----------
}
else if(block == dropOptions)
{
//---------Enter your code here-----------
}
else if(block == defaultActionToggle)
{
//---------Enter your code here-----------
}
else if(block == instructions)
{
//---------Enter your code here-----------
}
else if(block == selection0)
{
//---------Enter your code here-----------
}
else if(block == addCrossSelectionNodeButton)
{
//---------Enter your code here-----------
BlockStyler::PropertyList *prop = selection0->GetProperties();
std::vector<NXOpen::TaggedObject *>objects = prop->GetTaggedObjectVector("SelectedObjects"); if (objects.size()>)
{
//Create node and node data
BlockStyler::Node *node = tree_control0->CreateNode("CrossSelection-NodeData");
NXOpen::DataContainer *nodeData = node->GetNodeData();
nodeData->AddTaggedObject("Data",objects[]);
delete nodeData;
tree_control0->InsertNode(node,NULL,NULL,tree_control0->NodeInsertOptionAlwaysLast); //Reset Selection block
std::vector<TaggedObject *>blank;
prop->SetTaggedObjectVector("SelectedObjects",blank);
}
delete prop;
}
else if(block == redrawInstruction)
{
//---------Enter your code here-----------
}
else if(block == redrawToggle)
{
//---------Enter your code here-----------
BlockStyler::PropertyList *prop = redrawToggle->GetProperties();
bool isRedraw = prop->GetLogical("Value");
delete prop;
tree_control0->Redraw(isRedraw);
}
else if(block == listingWindowToggle)
{
//---------Enter your code here-----------
}
}
catch(exception& ex)
{
//---- Enter your exception handling code here -----
TreeListDemo::theUI->NXMessageBox()->Show("Block Styler", NXOpen::NXMessageBox::DialogTypeError, ex.what());
}
return ;
} //------------------------------------------------------------------------------
//Callback Name: ok_cb
//------------------------------------------------------------------------------
int TreeListDemo::ok_cb()
{
int errorCode = ;
try
{
errorCode = apply_cb();
}
catch(exception& ex)
{
//---- Enter your exception handling code here -----
errorCode = ;
TreeListDemo::theUI->NXMessageBox()->Show("Block Styler", NXOpen::NXMessageBox::DialogTypeError, ex.what());
}
return errorCode;
} //------------------------------------------------------------------------------
//Callback Name: focusNotify_cb
//This callback is executed when any block (except the ones which receive keyboard entry such as Integer block) receives focus.
//------------------------------------------------------------------------------
void TreeListDemo::focusNotify_cb(NXOpen::BlockStyler::UIBlock* block, bool focus)
{
try
{
//---- Enter your callback code here -----
}
catch(exception& ex)
{
//---- Enter your exception handling code here -----
TreeListDemo::theUI->NXMessageBox()->Show("Block Styler", NXOpen::NXMessageBox::DialogTypeError, ex.what());
}
}
//------------------------------------------------------------------------------
//Treelist specific callbacks
//------------------------------------------------------------------------------
//void TreeListDemo::OnExpandCallback (NXOpen::BlockStyler::Tree *tree, NXOpen::BlockStyler::Node *node)
//{
//} //void TreeListDemo::OnInsertColumnCallback(NXOpen::BlockStyler::Tree *tree, NXOpen::BlockStyler::Node *node, int columnID)
//{
//} void TreeListDemo::OnInsertNodeCallback(NXOpen::BlockStyler::Tree *tree, NXOpen::BlockStyler::Node *node)
{
try
{
//---- Enter your callback code here -----
WriteCallbackToListingWindow("OnInsertNodeCallback Invoked"); //Setting random icon
if (randomIcon==)
{
node->SetColumnDisplayText(ColumnSecond,randomIconString[randomIcon]);
}
else if (randomIcon==)
{
node->SetColumnDisplayText(ColumnSecond,randomIconString[randomIcon]);
}
else if (randomIcon==)
{
node->SetColumnDisplayText(ColumnSecond,randomIconString[randomIcon]);
}
else if (randomIcon==)
{
node->SetColumnDisplayText(ColumnSecond,randomIconString[randomIcon]);
}
randomIcon = randomIcon + ;
if (randomIcon > )
{
randomIcon = ;
} std::stringstream stringBuffer;
stringBuffer << "Column Text - "<<randomIcon;
NXOpen::NXString columnText ;
columnText += stringBuffer.str();
node->SetColumnDisplayText(ColumnThird,columnText); if (nodeSuffixNumber == )
{
nodeSuffixNumber = ;
}
else
{
nodeSuffixNumber = nodeSuffixNumber + ;
} //New Node text for the next node
std::stringstream stringBuffer1;
BlockStyler::PropertyList *prop = nodeString->GetProperties(); NXOpen::NXString nodeDisplayString = nodeBaseString;
stringBuffer1 << nodeSuffixNumber;
nodeDisplayString += stringBuffer1.str();
prop->SetString("Value",nodeDisplayString);
delete prop;
}
catch(exception& ex)
{
//---- Enter your exception handling code here -----
TreeListDemo::theUI->NXMessageBox()->Show("Block Styler", NXOpen::NXMessageBox::DialogTypeError, ex.what());
}
} void TreeListDemo::OnDeleteNodeCallback(NXOpen::BlockStyler::Tree *tree, NXOpen::BlockStyler::Node *node)
{
try
{
//---- Enter your callback code here -----
WriteCallbackToListingWindow("OnDeleteNodeCallback Invoked"); if(node==previousAddedNode)
{
//Set the previous node to Nothing. Done for safe execution.
previousAddedNode = NULL;
}
}
catch(exception& ex)
{
//---- Enter your exception handling code here -----
TreeListDemo::theUI->NXMessageBox()->Show("Block Styler", NXOpen::NXMessageBox::DialogTypeError, ex.what());
}
} //void TreeListDemo::OnPreSelectCallback(NXOpen::BlockStyler::Tree *tree, NXOpen::BlockStyler::Node *node, int ID, bool selected)
//{
//} void TreeListDemo::OnSelectCallback(NXOpen::BlockStyler::Tree *tree, NXOpen::BlockStyler::Node *node, int columnID, bool selected)
{
std::stringstream column;
column << columnID; std::string text = std::string("OnSelectCallback Invoked: Node \"") + std::string(node->DisplayText().GetText()) + std::string("\" ") + std::string(selected?"Selected":"Deselected") + std::string(selected?" at column ":"") + std::string(selected?column.str():"");
WriteCallbackToListingWindow(text);
} void TreeListDemo::OnStateChangeCallback(NXOpen::BlockStyler::Tree *tree, NXOpen::BlockStyler::Node *node, int state)
{
try
{
//---- Enter your callback code here -----
WriteCallbackToListingWindow("OnStateChangeCallback Invoked");
if (state == )
{
node->SetState();
}
else if(state == )
{
node->SetState();
}
else if(state == )
{
node->SetState();
}
else if(state == )
{
node->SetState();
}
}
catch(exception& ex)
{
//---- Enter your exception handling code here -----
TreeListDemo::theUI->NXMessageBox()->Show("Block Styler", NXOpen::NXMessageBox::DialogTypeError, ex.what());
}
} NXString TreeListDemo::ToolTipTextCallback(NXOpen::BlockStyler::Tree *tree, NXOpen::BlockStyler::Node *node, int columnID)
{
NXOpen::NXString ToolTipText;
try
{
//---- Enter your callback code here ----- BlockStyler::PropertyList *prop = nodeToolTip->GetProperties();
ToolTipText = prop->GetString("Value");
delete prop;
}
catch(exception& ex)
{
//---- Enter your exception handling code here -----
TreeListDemo::theUI->NXMessageBox()->Show("Block Styler", NXOpen::NXMessageBox::DialogTypeError, ex.what());
}
return ToolTipText;
}
//The possible return values are 0, positive and negative value, suggesting respectively that both nodes are same, first node greater than second, and first node smaller than second.
//int TreeListDemo::ColumnSortCallback(NXOpen::BlockStyler::Tree *tree, int columnID, NXOpen::BlockStyler::Node *node1, NXOpen::BlockStyler::Node *node2)
//{
//} NXString TreeListDemo::StateIconNameCallback(NXOpen::BlockStyler::Tree *tree, NXOpen::BlockStyler::Node *node, int state)
{
NXOpen::NXString stateIcon;
try
{
//---- Enter your callback code here -----
WriteCallbackToListingWindow("StateIconNameCallback Invoked");
if(state==)
{
stateIcon = "hole";
}
else if(state==)
{
stateIcon = "boss";
}
else if(state==)
{
stateIcon = "revolve";
}
}
catch(exception& ex)
{
//---- Enter your exception handling code here -----
TreeListDemo::theUI->NXMessageBox()->Show("Block Styler", NXOpen::NXMessageBox::DialogTypeError, ex.what());
}
return stateIcon;
} NXOpen::BlockStyler::Tree::BeginLabelEditState TreeListDemo::OnBeginLabelEditCallback(NXOpen::BlockStyler::Tree *tree, NXOpen::BlockStyler::Node *node, int columnID)
{
NXOpen::BlockStyler::Tree::BeginLabelEditState OnBeginLabelEdit = BlockStyler::Tree::BeginLabelEditStateDisallow;
try
{
//---- Enter your callback code here -----
WriteCallbackToListingWindow("OnBeginLabelEditCallback Invoked");
BlockStyler::PropertyList *prop = nodeEditOptions->GetProperties();
int labelEditOption = prop->GetEnum("Value");
delete prop; if (labelEditOption==)
{
OnBeginLabelEdit = BlockStyler::Tree::BeginLabelEditStateAllow;
}
else
{
OnBeginLabelEdit = BlockStyler::Tree::BeginLabelEditStateDisallow;
}
}
catch(exception& ex)
{
//---- Enter your exception handling code here -----
TreeListDemo::theUI->NXMessageBox()->Show("Block Styler", NXOpen::NXMessageBox::DialogTypeError, ex.what());
} return OnBeginLabelEdit; } NXOpen::BlockStyler::Tree::EndLabelEditState TreeListDemo::OnEndLabelEditCallback(NXOpen::BlockStyler::Tree *tree, NXOpen::BlockStyler::Node *node, int, NXString editedText)
{
NXOpen::BlockStyler::Tree::EndLabelEditState OnEndLabelEdit = BlockStyler::Tree::EndLabelEditStateRejectText;
try
{
//---- Enter your callback code here -----
WriteCallbackToListingWindow("OnEndLabelEditCallback Invoked"); if( == strcmp(editedText.GetText(),"Reject") )
{
OnEndLabelEdit = BlockStyler::Tree::EndLabelEditStateRejectText;
}
else
{
OnEndLabelEdit = BlockStyler::Tree::EndLabelEditStateAcceptText;
}
}
catch(exception& ex)
{
//---- Enter your exception handling code here -----
TreeListDemo::theUI->NXMessageBox()->Show("Block Styler", NXOpen::NXMessageBox::DialogTypeError, ex.what());
} return OnEndLabelEdit; } NXOpen::BlockStyler::Tree::EditControlOption TreeListDemo::OnEditOptionSelectedCallback(NXOpen::BlockStyler::Tree *tree, NXOpen::BlockStyler::Node *node, int columnID, int selectedOptionID, NXString selectedOptionText, NXOpen::BlockStyler::Tree::ControlType type)
{
NXOpen::BlockStyler::Tree::EditControlOption OnEditOptionSelected = BlockStyler::Tree::EditControlOptionReject;
try
{
//---- Enter your callback code here ----- if (BlockStyler::Tree::ControlTypeComboBox == type)
{
if ( == strcmp(selectedOptionText.GetText(),"ComboBox-RejectText"))
{
OnEditOptionSelected = BlockStyler::Tree::EditControlOptionReject;
}
else
{
OnEditOptionSelected = BlockStyler::Tree::EditControlOptionAccept;
}
}
else if (BlockStyler::Tree::ControlTypeListBox == type)
{
if ( == strcmp(selectedOptionText.GetText(),"ListBox-RejectText"))
{
OnEditOptionSelected = BlockStyler::Tree::EditControlOptionReject;
}
else
{
OnEditOptionSelected = BlockStyler::Tree::EditControlOptionAccept;
}
}
}
catch(exception& ex)
{
//---- Enter your exception handling code here -----
TreeListDemo::theUI->NXMessageBox()->Show("Block Styler", NXOpen::NXMessageBox::DialogTypeError, ex.what());
} return OnEditOptionSelected;
} NXOpen::BlockStyler::Tree::ControlType TreeListDemo::AskEditControlCallback(NXOpen::BlockStyler::Tree *tree, NXOpen::BlockStyler::Node *node, int columnID)
{
NXOpen::BlockStyler::Tree::ControlType AskEditControl = BlockStyler::Tree::ControlTypeNone;; try
{
//---- Enter your callback code here -----
BlockStyler::PropertyList *prop = nodeEditOptions->GetProperties();
int labelEditOption = prop->GetEnum("Value");
delete prop; if(labelEditOption==)
{
AskEditControl = BlockStyler::Tree::ControlTypeComboBox;
std::vector<NXOpen::NXString> options;
options.push_back(NXOpen::NXString("ComboBox-AcceptText"));
options.push_back(NXOpen::NXString("ComboBox-DefaultText"));
options.push_back(NXOpen::NXString("ComboBox-RejectText"));
tree->SetEditOptions(options,);
}
else if(labelEditOption==)
{
AskEditControl = BlockStyler::Tree::ControlTypeListBox; std::vector<NXOpen::NXString> options;
options.push_back(NXOpen::NXString("ListBox-AcceptText"));
options.push_back(NXOpen::NXString("ListBox-DefaultText"));
options.push_back(NXOpen::NXString("ListBox-RejectText")); tree->SetEditOptions(options,);
}
}
catch(exception& ex)
{
//---- Enter your exception handling code here -----
TreeListDemo::theUI->NXMessageBox()->Show("Block Styler", NXOpen::NXMessageBox::DialogTypeError, ex.what());
}
return AskEditControl;
} enum MenuID
{
AddNode = ,
DeleteNode,
CheckedMenuItem,
DefaultMenuItem,
DialogLaunchMenuItem,
DisableMenuItem,
HiddenMenuItem,
IconMenuItem, SubMenu1,
SubMenu2,
SubMenuItem1,
SubMenuItem2,
SubMenuItem3,
SubMenuItem4, TreeMenuItem,
}; void TreeListDemo::OnMenuCallback(NXOpen::BlockStyler::Tree *tree, NXOpen::BlockStyler::Node *node, int columnID)
{
try
{
//---- Enter your callback code here -----
WriteCallbackToListingWindow("OnMenuCallback Invoked");
BlockStyler::PropertyList *prop = showMenuToggle->GetProperties() ;
bool value = prop->GetLogical("Value");
delete prop; if(value == false)
{
return;
} //Create Menu
BlockStyler::TreeListMenu *menu = tree->CreateMenu();
BlockStyler::TreeListMenu *SubMenu1 = tree->CreateMenu();
BlockStyler::TreeListMenu *SubMenu2 = tree->CreateMenu(); if(node==NULL)
{
menu->AddMenuItem(AddNode,"Add Node");
menu->AddSeparator();
menu->AddMenuItem(TreeMenuItem,"Tree menu item");
}
else //Menu request for Node
{
menu->AddMenuItem(AddNode,"Add Node");
menu->AddMenuItem(MenuID(DeleteNode),"Delete Node"); menu->AddSeparator();
menu->AddMenuItem(CheckedMenuItem,"Checked Menu Item");
menu->AddMenuItem(DefaultMenuItem,"Default Menu Item");
menu->AddMenuItem(DialogLaunchMenuItem,"Dialog Launch Menu Item");
menu->AddMenuItem(DisableMenuItem,"Disable Menu Item");
menu->AddMenuItem(HiddenMenuItem,"Hidden Menu Item");
menu->AddMenuItem(IconMenuItem,"Icon Menu Item"); menu->AddSeparator();
menu->AddMenuItem(::SubMenu1,"Sub Menu 1");
menu->AddMenuItem(::SubMenu2,"Sub Menu 2"); //Sub Menu
SubMenu1->AddMenuItem(SubMenuItem1,"Sub Menu Item 1");
SubMenu1->AddMenuItem(SubMenuItem2,"Sub Menu Item 2"); SubMenu2->AddMenuItem(SubMenuItem3,"Sub Menu Item 3");
SubMenu2->AddMenuItem(SubMenuItem4,"Sub Menu Item 4"); //Set Sub Menu
menu->SetSubMenu(::SubMenu1,SubMenu1);
menu->SetSubMenu(::SubMenu2,SubMenu2); //Edit Menu Items
menu->SetItemChecked(CheckedMenuItem,true);
menu->SetItemDefault(DefaultMenuItem,true);
menu->SetItemDialogLaunching(DialogLaunchMenuItem,true);
menu->SetItemDisable(DisableMenuItem,true);
menu->SetItemHidden(HiddenMenuItem,true);
menu->SetItemIcon(IconMenuItem,"sketch");
} //Set menu on tree
tree->SetMenu(menu); //Dispose the menu only after setting the menu on tree
delete menu;
delete SubMenu1;
delete SubMenu2;
}
catch(exception& ex)
{
//---- Enter your exception handling code here -----
TreeListDemo::theUI->NXMessageBox()->Show("Block Styler", NXOpen::NXMessageBox::DialogTypeError, ex.what());
}
} void TreeListDemo::OnMenuSelectionCallback(NXOpen::BlockStyler::Tree *tree, NXOpen::BlockStyler::Node *node, int menuItemID)
{
try
{
//---- Enter your callback code here -----
WriteCallbackToListingWindow("OnMenuSelectionCallback Invoked");
if(node==NULL)
{
if((MenuID)menuItemID == AddNode)
{
CreateAndAddNode(NULL);
}
}
else
{
if((MenuID)menuItemID == AddNode)
{
CreateAndAddNode(NULL);
}
else if((MenuID)menuItemID == DeleteNode)
{
std::vector<BlockStyler::Node *>SelectedNodes = tree_control0->GetSelectedNodes();
if(SelectedNodes.size()>)
{
DeleteSelectedNodes();
}
else
{
if(node!=NULL)
{
tree->DeleteNode(node);
}
}
}
}
}
catch(exception& ex)
{
//---- Enter your exception handling code here -----
TreeListDemo::theUI->NXMessageBox()->Show("Block Styler", NXOpen::NXMessageBox::DialogTypeError, ex.what());
}
} NXOpen::BlockStyler::Node::DropType TreeListDemo::IsDropAllowedCallback(NXOpen::BlockStyler::Tree *tree, NXOpen::BlockStyler::Node *node, int columnID, NXOpen::BlockStyler::Node *targetNode, int targetColumnID)
{
NXOpen::BlockStyler::Node::DropType IsDropAllowed;
try
{
//---- Enter your callback code here -----
BlockStyler::PropertyList *prop = dropOptions->GetProperties() ;
int dropOption = prop->GetEnum("Value");
delete prop; // This will just show iconic representation that drop is allowed. No default action is performed after drop.
// OnDropCallback should be implemented for specific drop behaviour if (dropOption == )
{
IsDropAllowed = BlockStyler::Node::DropTypeNone;
}
else if (dropOption == )
{
IsDropAllowed = BlockStyler::Node::DropTypeAfter;
}
else if (dropOption == )
{
IsDropAllowed = BlockStyler::Node::DropTypeBefore;
}
else if (dropOption == )
{
IsDropAllowed = BlockStyler::Node::DropTypeBeforeAndAfter;
}
else if (dropOption == )
{
IsDropAllowed = BlockStyler::Node::DropTypeOn;
}
}
catch(exception& ex)
{
//---- Enter your exception handling code here -----
TreeListDemo::theUI->NXMessageBox()->Show("Block Styler", NXOpen::NXMessageBox::DialogTypeError, ex.what());
}
return IsDropAllowed;
} NXOpen::BlockStyler::Node::DragType TreeListDemo::IsDragAllowedCallback(NXOpen::BlockStyler::Tree *tree, NXOpen::BlockStyler::Node *node, int columnID)
{
NXOpen::BlockStyler::Node::DragType IsDragAllowedCallback;
try
{
//---- Enter your callback code here -----
BlockStyler::PropertyList *prop = disallowDragToggle->GetProperties() ;
bool isDragDisallowed = prop->GetLogical("Value");
delete prop; if(isDragDisallowed == true)
{
IsDragAllowedCallback = BlockStyler::Node::DragTypeNone;
}
else
{
IsDragAllowedCallback = BlockStyler::Node::DragTypeAll;
}
}
catch(exception& ex)
{
//---- Enter your exception handling code here -----
TreeListDemo::theUI->NXMessageBox()->Show("Block Styler", NXOpen::NXMessageBox::DialogTypeError, ex.what());
} return IsDragAllowedCallback;
} bool TreeListDemo::OnDropCallback(NXOpen::BlockStyler::Tree *tree, std::vector<NXOpen::BlockStyler::Node *> node, int columnID, NXOpen::BlockStyler::Node *targetNode, int targetColumnID, NXOpen::BlockStyler::Node::DropType dropType, int dropMenuItemId)
{
try
{
//---- Enter your callback code here -----
WriteCallbackToListingWindow("OnDropCallback Invoked");
}
catch(exception& ex)
{
//---- Enter your exception handling code here -----
TreeListDemo::theUI->NXMessageBox()->Show("Block Styler", NXOpen::NXMessageBox::DialogTypeError, ex.what());
}
return true;
} //void TreeListDemo::OnDropMenuCallback(NXOpen::BlockStyler::Tree *tree, NXOpen::BlockStyler::Node *node, int columnID, NXOpen::BlockStyler::Node *targetNode, int targetColumnID)
//{
//} void TreeListDemo::OnDefaultAction(NXOpen::BlockStyler::Tree *tree, NXOpen::BlockStyler::Node *node, int columnID)
{
try
{
//---- Enter your callback code here -----
WriteCallbackToListingWindow("OnDefaultAction Invoked"); if (!defaultActionToggle)
{
return;
} NXOpen::BlockStyler::PropertyList *defaultActionToggleProps = defaultActionToggle->GetProperties();
bool defaultActionToggle = defaultActionToggleProps->GetLogical("Value");
delete defaultActionToggleProps; if(defaultActionToggle)
{
std::vector<BlockStyler::Node *> selectedNode = tree_control0->GetSelectedNodes();
selectedNode[]->SetColumnDisplayText(,"Default Action");
TreeListDemo::theUI->NXMessageBox()->Show("Block Styler", NXOpen::NXMessageBox::DialogTypeInformation, "Default Action: Third column text is changed");
selectedNode.clear();
}
}
catch(exception& ex)
{
//---- Enter your exception handling code here -----
TreeListDemo::theUI->NXMessageBox()->Show("Block Styler", NXOpen::NXMessageBox::DialogTypeError, ex.what());
}
} Caesar卢尚宇
2019年11月23日

NX二次开发-BlockUI的Tree树控件的更多相关文章

  1. 【NX二次开发】Block UI 选项卡控件

    [NX二次开发]Block UI 选项卡控件

  2. NX二次开发-BlockUI对话框嵌套MFC对话框制作进度条

    半年前在一些QQ群看到有大神NX二次开发做出了进度条,那个时候我还不会弄,也不知道怎么弄得,后来断断续续得研究了一下,直到今天我把它做出来了.内心还是很喜悦的!回想自己这两年当初从没公司肯给我做NX二 ...

  3. 【NX二次开发】Block UI 树列表

    属性说明 属性   类型   描述   常规           BlockID    String    控件ID    Enable    Logical    是否可操作    Group    ...

  4. 【NX二次开发】Block UI 指定点

    属性说明 属性   类型   描述   常规           BlockID    String    控件ID    Enable    Logical    是否可操作    Group    ...

  5. js插件---Bootstrap 树控件

    js插件---Bootstrap 树控件 一.总结 一句话总结:可以直接用gojs,或者搜索js,jquery的树控件,或者bootstrap树控件,一大堆 gojs 二.JS组件系列——Bootst ...

  6. NX二次开发-C#使用DllImport调用libufun.dll里的UF函数(反编译.net.dll)调用loop等UF函数

    在写这篇文章的时候,我正在头晕,因为下班坐车回家,有些晕车了.头疼的要死.也吃不下去饭. 版本:NX11+VS2013 最近这一年已经由C++过度到C#,改用C#做应用程序开发和NX二次开发. C#在 ...

  7. 【NX二次开发】Block UI 目录

    Block UI 目录  基本   标签/位图   切换开关   枚举   字符串   多行字符串   操作按钮   列表框   分割线   对象颜色选择器   RGB颜色选择器   绘图区   图层 ...

  8. NX二次开发-Block UI C++界面关于 在Block UI中UF_initialize();和UF_terminate();的使用

    关于 在Block UI中UF_initialize();和UF_terminate();的使用 用Block UI作NX二次开发的时候,不需要在使用UFUN函数的时候加UF_initialize() ...

  9. NX二次开发-基于MFC界面的NX对Excel读写操作(OLE方式(COM组件))

    NX二次开发API里没有对EXCAL读写操作的相关函数,市面上有很多种方法去实现,比如UFUN调KF,ODBC,OLE(COM组件)等等.这里我是用的OLE(COM组件)方式去做的,这种在VC上创建的 ...

随机推荐

  1. BZOJ 2301 莫比乌斯反演入门

    2301: [HAOI2011]Problem b Description 对于给出的n个询问,每次求有多少个数对(x,y),满足a≤x≤b,c≤y≤d,且gcd(x,y) = k,gcd(x,y)函 ...

  2. POJ 2955 Brackets (区间dp入门)

    Description We give the following inductive definition of a “regular brackets” sequence: the empty s ...

  3. 【Flutter学习】页面跳转之路由及导航

    一,概述 移动应用通常通过成为‘屏幕’或者‘页面’的全屏元素显示其内容,在Flutter中,这些元素统称为路由,它们由导航器Navigator组件管理.导航器管理一组路由Route对象,并提供了管理堆 ...

  4. vue iframe嵌套单页面时打开新窗口并自定义浏览器标题

    vue打开新窗口两种写法,效果一样: 第一种: router-link 传参用query或者params都可以,tagget和tag一定要加上才可以: 第二种: 直接写成a标签就可以了. 改变浏览器窗 ...

  5. 关于Extjs6.0 controller文件过大,实现模块化分离

    Extjs一般都是一个视图对应着一个controller 一旦碰到视图中逻辑过于繁琐造成controller文件过大不利于维护和修改,所以要通过混入mixins混入功能来实现模块化! 首先创建一个视图 ...

  6. Red Hat Enterprise Linux 7.x新特性

    Red Hat Enterprise Linux 7.x新特性 RHEL7新特性简介 1.      RHEL7目前支持架构 64-bit AMD.64-bit Intel.IBM POWER.IBM ...

  7. php开发面试题---jquery和vue对比(整理)

    php开发面试题---jquery和vue对比(整理) 一.总结 一句话总结: jquery的本质是更方便的选取和操作DOM对象,vue的本质是数据和页面分离 反思的回顾非常有用,因为决定了我的方向和 ...

  8. Android ROM 开发技能图谱

    # Android ROM 开发技能图谱 ## 1. 操作系统 * Ubuntu(首选)* MacOSX ## 2. 编程语言 * Java * JNI(务必掌握)* C++* C ## 3. 源码 ...

  9. multiple-cursors做代码对齐

    multiple-cursors做代码对齐 */--> code {color: #FF0000} pre.src {background-color: #002b36; color: #839 ...

  10. 用IDEA打可运行的jar包

    今天,需要将一个定时项目打成jar包,直接放在服务器上运行,看了一下要求是将依赖包几种放到lib文件夹下,以前都是用maven来打包的.这一次想利用idea直接打包. 但是打完包后运行发现一直缺失ma ...