⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tracetool.cpp.svn-base

📁 股票软件源码
💻 SVN-BASE
📖 第 1 页 / 共 5 页
字号:
   Commands.Add (CST_TREE_MULTI_COLUMN, MainColIndex); 
   TTrace::SendToClient (& Commands,this);
}

//-------------------------------------------------------------------------

/// <summary>
/// set columns title
/// </summary>
/// <param name="Titles">Tab separated columns titles</param>
void WinTrace::SetColumnsTitle (const char * Titles)
{
   CommandList Commands  ;
   Commands.Add (CST_TREE_COLUMNTITLE , Titles);
   TTrace::SendToClient (& Commands,this);
}

//-------------------------------------------------------------------------

/// <summary>
/// set columns title
/// </summary>
/// <param name="Titles">Tab separated columns titles</param>
void WinTrace::SetColumnsTitle (const wchar_t * Titles)
{
   CommandList Commands  ;
   char * temp   = TTrace::WideToMbs(Titles) ;
   Commands.Add (CST_TREE_COLUMNTITLE , temp);
   if (temp != NULL)
      free (temp) ;
   TTrace::SendToClient (& Commands,this);
}

//-------------------------------------------------------------------------

/// <summary>
/// set columns widths
/// </summary>
/// <param name="Widths">Tab separated columns width. <br> 
///    The format for each column is width[:Min[:Max]] <br>
///    where Min and Max are optional minimum and maximum column width for resizing purpose.<br>
///    Example : 100:20:80 tab 200:50 tab 100
/// </param>
void WinTrace::SetColumnsWidth (const char * Widths)
{
   CommandList Commands  ;
   Commands.Add (CST_TREE_COLUMNWIDTH , Widths);
   TTrace::SendToClient (& Commands,this);
}

//-------------------------------------------------------------------------

/// <summary>
/// set columns widths
/// </summary>
/// <param name="Widths">Tab separated columns width. <br> 
///    The format for each column is width[:Min[:Max]] <br>
///    where Min and Max are optional minimum and maximum column width for resizing purpose.<br>
///    Example : 100:20:80 tab 200:50 tab 100
/// </param>
void WinTrace::SetColumnsWidth (const wchar_t * Widths)
{
   CommandList Commands  ;
   char * temp   = TTrace::WideToMbs(Widths) ;
   Commands.Add (CST_TREE_COLUMNWIDTH , temp);
   if (temp != NULL)
      free (temp) ;
  TTrace::SendToClient (& Commands,this);
}

//-------------------------------------------------------------------------

/// <summary>
/// Clear all trace for the window tree 
/// </summary>
void WinTrace::ClearAll ()
{
   CommandList Commands  ;
   Commands.Add (CST_CLEAR_ALL); 
   TTrace::SendToClient (& Commands,this);
}                        

//------------------------------------------------------------------------------
// PLUGIN API
//------------------------------------------------------------------------------
#ifndef _WIN32_WCE

/// <summary>
/// Plugin API : Create a resource.
/// </summary>
/// <param name="ResId">The resource Id (must be >= 100)</param>
/// <param name="ResType">Resource type. See TraceConst  
/// <code>
/// CST_RES_BUT_RIGHT    : Button on right
/// CST_RES_BUT_LEFT     : Button on left
/// CST_RES_LABEL_RIGHT  : Label on right
/// CST_RES_LABELH_RIGHT : Label on right HyperLink
/// CST_RES_LABEL_LEFT   : Label on left
/// CST_RES_LABELH_LEFT  : Label on left hyperlink
/// CST_RES_MENU_ACTION  : Item menu in the Actions Menu
/// CST_RES_MENU_WINDOW  : Item menu in the Windows Menu. 
///                        Call CreateResource on the main win trace to create this menu item
/// </code>
///</param>
/// <param name="ResWidth">Width of the resource. Applicable only to button and labels</param>
/// <param name="ResText">Resource text</param>

void WinTrace::CreateResource (const int ResId , const int ResType , const int ResWidth , const char * ResText /* = NULL */)
{
   CommandList Commands  ;
   Commands.Add (CST_CREATE_RESOURCE, ResId , ResType, ResWidth , ResText);
   TTrace::SendToClient (& Commands,this);
}

//------------------------------------------------------------------------------

void WinTrace::CreateResource (const int ResId , const int ResType , const int ResWidth , const wchar_t * ResText /* = NULL */)
{
   CommandList Commands  ;
   char * temp   = TTrace::WideToMbs(ResText) ;
   Commands.Add (CST_CREATE_RESOURCE, ResId , ResType, ResWidth , temp);
   if (temp != NULL)
      free (temp) ;
   TTrace::SendToClient (& Commands,this);
}

//------------------------------------------------------------------------------

/// <summary>
/// Plugin API : Disable tracetool or user created resources
/// </summary>
/// <param name="ResId">The resource Id 
/// ResId: resource id to disable. Tracetool resources :
/// <code>
/// CST_ACTION_CUT            : Cut. Same as copy then delete
/// CST_ACTION_COPY           : Copy
/// CST_ACTION_DELETE         : Delete selected
/// CST_ACTION_SELECT_ALL     : Select all
/// CST_ACTION_RESIZE_COLS    : Resize columns
/// CST_ACTION_VIEW_INFO      : View trace info
/// CST_ACTION_VIEW_PROP      : View properties
/// CST_ACTION_PAUSE          : Pause
/// CST_ACTION_SAVE           : SaveToFile
/// CST_ACTION_CLEAR_ALL      : Clear all
/// CST_ACTION_CLOSE_WIN      : Close win
/// CST_ACTION_LABEL_INFO     : TracesInfo label
/// CST_ACTION_LABEL_LOGFILE  : LabelLogFile label
/// CST_ACTION_VIEW_MAIN      : View Main trace
/// CST_ACTION_VIEW_ODS       : ODS
/// CST_ACTION_OPEN_XML       : XML trace -> Tracetool XML traces
/// CST_ACTION_EVENTLOG       : Event log
/// CST_ACTION_TAIL           : Tail
/// </code>
/// </param>

void WinTrace::DisableResource (const int ResId)
{
   CommandList Commands  ;
   Commands.Add (CST_DISABLE_RESOURCE ,ResId);
   TTrace::SendToClient (& Commands,this);
}

//------------------------------------------------------------------------------

/// <summary>
/// Plugin API : Set the resource text (tracetool or user created resources), specified by his Id
/// </summary>
/// <param name="ResId">The resource Id </param>
/// <param name="ResText">Resource text</param>

void WinTrace::SetTextResource (const int ResId, const char * ResText)
{
   CommandList Commands  ;
   Commands.Add (CST_SET_TEXT_RESOURCE ,ResId, ResText);
   TTrace::SendToClient (& Commands,this);
}

//------------------------------------------------------------------------------

void WinTrace::SetTextResource (const int ResId, const wchar_t * ResText)
{
   CommandList Commands  ;
   char * temp   = TTrace::WideToMbs(ResText) ;
   Commands.Add (CST_SET_TEXT_RESOURCE ,ResId, temp);
   if (temp != NULL)
      free (temp) ;
   TTrace::SendToClient (& Commands,this);
}

//------------------------------------------------------------------------------

/// <summary>
/// Plugin API : Attach a winTrace to a plugin. Many winTrace can be attached to a plugin.
/// Note that a plugin don't need to be attached to a WinTrace.
/// The plugin is identified by his internal name (not dll name).
/// When linked, the plugin can receive event (see ITracePLugin).
/// </summary>
/// <param name="PluginName">name of the plugin</param>
/// <param name="flags">combinaison of CST_PLUG_ONACTION , CST_PLUG_ONBEFOREDELETE , CST_PLUG_ONTIMER</param>

void WinTrace::LinkToPlugin (const char * PluginName, const int flags)
{
   CommandList Commands  ;
   Commands.Add (CST_LINKTOPLUGIN ,flags, PluginName);
   TTrace::SendToClient (& Commands,this);
}

//------------------------------------------------------------------------------

void WinTrace::LinkToPlugin (const wchar_t * PluginName, int flags)
{
   CommandList Commands  ;
   char * temp   = TTrace::WideToMbs(PluginName) ;
   Commands.Add (CST_LINKTOPLUGIN ,flags, temp);
   if (temp != NULL)
      free (temp) ;
   TTrace::SendToClient (& Commands,this);
}

#endif

//==========================================================================

/* TraceNode */

/// <summary>
/// construct a new trace node, derived from a parent node 
/// </summary>
/// <param name="parentNode">Parent node (Optional) </param>
/// <param name="generateUniqueId">generate an unique Id if true (Optional, default is true)</param>

TraceNode::TraceNode(const TraceNode * parentNode  , const bool generateUniqueId /*  = true */ ) 
{  
   id       = NULL ;                     // Node id
   enabled  = true ;                     // enable or disable traces
   winTrace = NULL ;                     // Owner
   tag      = 0 ;                        // User defined tag, NOT SEND to the viewer   
   iconIndex = CST_ICO_DEFAULT ;         // icon index
   contextList = NULL ;
   InitializeCriticalSection(&criticalSection) ;

   if (generateUniqueId)
      id = TTrace::CreateTraceID () ;
   if (parentNode != NULL)
   {
      iconIndex    = parentNode->iconIndex ;
      enabled      = parentNode->enabled ;
      winTrace     = parentNode->winTrace ;
   }
}

//-------------------------------------------------------------------------

// construct a new trace node, derived from a parent node 
TraceNode::TraceNode(const TraceNode * parentNode , const char * newNodeId )
{    
   id       = NULL ;                     // Node id
   enabled  = true ;                     // enable or disable traces
   winTrace = NULL ;                     // Owner
   tag      = 0 ;                        // User defined tag, NOT SEND to the viewer   
   iconIndex = CST_ICO_DEFAULT ;         // icon index
   contextList = NULL ;
   InitializeCriticalSection(&criticalSection) ;

   // set the node id
   if (newNodeId != NULL) 
   {
      int IdLength = strlen(newNodeId)+1 ;
      id = (char*)malloc (IdLength) ;
      #if defined(_MSC_VER) && (_MSC_VER >= 1400) && (! UNDER_CE)  // visual studio 2005 : deprecated function
      strcpy_s(id,IdLength,newNodeId) ;  
      #else
      strcpy(id,newNodeId) ;  
      #endif
   }

   if (parentNode != NULL)
   {
      iconIndex    = parentNode->iconIndex ;
      enabled      = parentNode->enabled ;
      winTrace     = parentNode->winTrace ;
   }
}

//-------------------------------------------------------------------------

// construct a new trace node, derived from a parent node 
TraceNode::TraceNode(const TraceNode * parentNode , const wchar_t * newNodeId )
{   
   id       = NULL ;                     // Node id
   enabled  = true ;                     // enable or disable traces
   winTrace = NULL ;                     // Owner
   tag      = 0 ;                        // User defined tag, NOT SEND to the viewer   
   iconIndex = CST_ICO_DEFAULT ;         // icon index
   contextList = NULL ;
   InitializeCriticalSection(&criticalSection) ;

   // set the node id
   if (newNodeId != NULL) 
      id = TTrace::WideToMbs(newNodeId);

   if (parentNode != NULL)
   {
      iconIndex    = parentNode->iconIndex ;
      enabled      = parentNode->enabled ;
      winTrace     = parentNode->winTrace ;
   }
}

//-------------------------------------------------------------------------

/// <summary>
/// destructor
/// </summary>

TraceNode::~TraceNode(void) 
{
   DeleteCriticalSection(&criticalSection) ;
   if (contextList != NULL)
      delete contextList ;
   contextList = NULL ;

   if (id != NULL)
      free (id) ;
}

//-------------------------------------------------------------------------

/// <summary>
/// prepare minimal sub node without sending it 
/// </summary>
/// <param name="leftMsg" >Optional left message</param>
/// <param name="rightMsg">Optional right message</param>

TraceNodeEx *TraceNode::CreateChildEx (const char *leftMsg /* = NULL */, const char *rightMsg /* = NULL */)
{
   TraceNodeEx *Node;
   Node = new TraceNodeEx(this);   // Node->id is generated (GUID)

   if (leftMsg != NULL && leftMsg[0]!=0) 
      Node->leftMsg = leftMsg ; 

   if (rightMsg != NULL && rightMsg[0]!=0) 
      Node->rightMsg = rightMsg ;

   Node->Commands->Add(CST_ICO_INDEX, iconIndex);      // This->iconIndex is the same as Node->iconIndex
   return Node ;                   
}

//-------------------------------------------------------------------------

/// <summary>
/// prepare minimal sub node without sending it 
/// </summary>
/// <param name="leftMsg" >Optional left message</param>
/// <param name="rightMsg">Optional right message</param>

TraceNodeEx *TraceNode::CreateChildEx (const wchar_t *leftMsg /* = NULL */, const wchar_t *rightMsg /* = NULL */)
{
   TraceNodeEx *Node;
   Node = new TraceNodeEx(this);   // Node->id is generated (GUID)

   if (leftMsg != NULL && leftMsg[0]!=0) 
   {
      char * temp = TTrace::WideToMbs(leftMsg) ;
      Node->leftMsg = temp ; // copy
      free (temp);
   }

   if (rightMsg != NULL && rightMsg[0]!=0) 
   {
      char * temp = TTrace::WideToMbs(rightMsg) ;
      Node->rightMsg = temp ; // copy
      free (temp);
   }

   Node->Commands->Add(CST_ICO_INDEX, iconIndex);      // This->iconIndex is the same as Node->iconIndex
   return Node ;                   
}

//-------------------------------------------------------------------------

/// <summary>
/// Return the IconIndex
/// <//summary>
int TraceNode::GetIconIndex (void)
{
   return iconIndex ;
}

//-------------------------------------------------------------------------

/// <summary>
/// send a node then change the indentation
/// </summary>
/// <param name="leftMsg" >Left message</param>
/// <param name="rightMsg">Optional right message</param>

void TraceNode::Indent (const char *leftMsg, const char *rightMsg) 
{
   if (enabled == false) 
      return ;

   TraceNodeEx * Node;  
   Node = CreateChildEx (leftMsg, rightMsg) ;   // create a new node using the last context as parent
   Node->Send() ;

   PushContextId (Node->id) ;  // create a context based on the node id and the current thread
   delete Node ;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -