Click here to Skip to main content
15,897,371 members
Articles / Containers / Virtual Machine

TOOL

Rate me:
Please Sign up or sign in to vote.
4.98/5 (52 votes)
23 Oct 200676 min read 231.4K   5.4K   147  
TOOL (Tiny Object Oriented Language) is an easily-embedded, object-oriented, C++-like-language interpreter. The purpose of this article is to introduce the TOOL interpreter and language from the perspective of a person who has a desire to include a scripting solution as part of his project.
#ifndef XML_FORM_CORE_STRUCTURES_H_INCLUDED
#define XML_FORM_CORE_STRUCTURES_H_INCLUDED
/*****************************************************************************/
/*                              HEADER FILE                                  */
/*****************************************************************************/
/*
          $Archive:   $

         $Revision:   $

      Last Checkin:
             $Date:   $
                By:
           $Author:   $

 Last Modification:
          $ModTime:   $

       Description:   Declaration of a set of structures used by the xml-parser
                      wrapper / observer class that will create a form definition 
                      structure from a meta form presented in xml format

                      TOOL And XML FORMS License
                      ==========================

                      Except where otherwise noted, all of the documentation 
                      and software included in the TOOL package is 
                      copyrighted by Michael Swartzendruber.

                      Copyright (C) 2005 Michael John Swartzendruber. 
                      All rights reserved.

                      Access to this code, whether intentional or accidental,
                      does NOT IMPLY any transfer of rights.

                      This software is provided "as-is," without any express 
                      or implied warranty. In no event shall the author be held
                      liable for any damages arising from the use of this software.

                      Permission is granted to anyone to use this software for 
                      any purpose, including commercial applications, and to 
                      alter and redistribute it, provided that the following 
                      conditions are met:

                      1. All redistributions of source code files must retain 
                         all copyright notices that are currently in place, 
                         and this list of conditions without modification.

                      2. The origin of this software must not be misrepresented;
                         you must not claim that you wrote the original software.

                      3. If you use this software in another product, an acknowledgment
                         in the product documentation would be appreciated but is
                         not required.

                      4. Modified versions in source or binary form must be plainly 
                         marked as such, and must not be misrepresented as being 
                         the original software.
*/
/*****************************************************************************/


#include <string>
#include <vector>
#include <map>

//using namespace std;

#pragma warning( disable : 4786 )


#define WM_VALIDATE_NOW  WM_USER + 577
#define WM_DROP_TOOLTIP  WM_USER + 591
#define WM_SHOW_TOOLTIP  WM_USER + 595



typedef struct _tagRegisteredColor
{
  COLORREF m_xColor;
	char     m_achName[ 33 ];
	bool     m_bForeOrBackColor;
	int      m_iIndex;

} 
REGISTERED_COLOR, *P_REGISTERED_COLOR;


///////////////////////////////////////////////////////////////////////////////
//
// string arrays are used for initial data for controls such as:
// list boxes, combo boxes. Single element arrays are used to store
// initial values for edits, statics, radios, checks, etc.
//
// note: for trees, each string should contain the full path of each
//       node that should be added to the tree
// note: for lists, each string should contain the full path of each
//       row that should be added to the list
//
typedef std::vector< std::string* >              STRING_POINTER_ARRAY;
typedef STRING_POINTER_ARRAY::iterator           STRING_POINTER_ARRAY_ITER;

typedef std::vector< int >                       INT_ARRAY;
typedef INT_ARRAY::iterator                      INT_ARRAY_ITER;


///////////////////////////////////////////////////////////////////////////////
//
// define the types of controls that can be created and added to forms
//
// to do here: make sure that this list is complete for all the custom controls
//             that we know how to make......
//             for ex: what about a drive picker, or a path walker......
//
enum eCtrlType 
{
  eUnknownCtrlType,    // ???
  eButton,             // button
  eRadioButton,        // radio.button
  eCheckBox,           // check.box
  eEditCtrl,           // edit.text
  eCardTrackDataCtrl,  // card.swipe.ctrl
  eStaticText,         // static.text
  eLabelBox,           // label.box
  eListBox,            // list.box
  eHScroll,            // h.scroll
  eVScroll,            // v.scroll
  eComboBox,           // combobox
  eSpinButton,         // spin.button
  eSlideCtrl,          // slider.ctrl
  eListCtrl,           // list.ctrl
  eTreeCtrl,           // tree.ctrl
  eDateTimePicker,     // date.time
  eMonthCalender,      // calender
  eIPAddress,          // i.p.address
  eColorPicker,        // color.button
  eImage,              // image
  eHtmlCtrl,           // html control
  eTabCtrl,            // tab control
  eMoneyEdit,          // penny wise money edit
  eAlphaEdit,          // Alpha only edit
  eNumericEdit,        // Numeric only edit
  eAlphaNumericEdit,   // Alpha Numeric edit
  eIntegerEdit,        // Integer edit
  eFloatEdit,          // Float edit
  eFilePicker,         // File Picker control
  eDirPicker,          // Directory Picker control
  eSubForm
};


///////////////////////////////////////////////////////////////////////////////
//
// fix horizontal dimension/position
//
enum eHorizontalFix 
{
  eNoHFix     = 0,
  eWidth      = 1,
  eLeft       = 2,
  eRight      = 4,
  eWidthLeft  = 8,
  eWidthRight = 16,
  eLeftRight  = 32
};

// fix vertical dimension/position
//
enum eVerticalFix 
{
  eNoVFix       = 0,
  eHeight       = 1,
  eTop          = 2,
  eBottom       = 4,
  eHeightTop    = 8,
  eHeightBottom = 16,
  eTopBottom    = 32
};


///////////////////////////////////////////////////////////////////////////////
//
// defines the data types that can be gathered from any particular control
//
enum eDataType
{
  eAsStringValue,        // as.string
  eAsCheckedValue,       // as.boolean
  eAsSelectedIndexValue, // as.index
  eValueAsInteger,       // as.integer
  eValueAsDouble,        // as.decimal
  eValueAsItemData,      // as.item.data
  eAsIgnoredvalue        // none
};


enum eImageSourceType
{
  eLocalResource,
  eFromLocalFile,
  eFromNetFile,
  eSysResource
};


enum eActionType
{
  eOnLoseFocus,
  eOnGainFocus,
  eOnButtonClick,
  eOnComboBoxSelChange,
  eOnListBoxSelChange,
  eOnTabSelChange,
  eOnFormLoad,
  eOnFormDestroy,
  eOnFormDisplayInit,
  eOnApplicationInvoke
};


class VMFacade;

typedef std::map< int, std::string >    CTRL_ACTIONS;
typedef CTRL_ACTIONS::iterator          CTRL_ACTIONS_ITER;


typedef std::map< int, CTRL_ACTIONS* > FORM_ACTIONS;
typedef FORM_ACTIONS::iterator         FORM_ACTIONS_ITER;


///////////////////////////////////////////////////////////////////////////////
//
// defines the validations that can be used against the data from any
// particular control
//
enum eValidationType
{
  eAsString,                // simple.string
  eAsLengthCheckedString,   // length.checked.string
  eAsInteger,               // simple.number
  eAsRangeCheckedInteger,   // range.checked.number
  eAsDecimal,               // simple.money
  eAsRangeCheckedDecimal,   // range.checked.money
  eAsPhoneNumber,           // phone.number
  eAsEmailAddress,          // email.address
  eAsCreditCard,            // credit.card
  eAsCreditCardDate,        // credit.card.date
  eAsScript,                // using.script ==> reserved for complex validations
  eAsCardTrackData,         // card.track.data
  eAsNotValidated           // none
};


///////////////////////////////////////////////////////////////////////////////
//
// the following structure defines the data validation that will be used against
// the data from a specific form control
//
typedef struct _tagCtrlDDVDefn
{
  UINT             m_iCtrlID;
  eValidationType  m_eDDVType;
  std::string      m_oExtraInfo;
  bool             m_bCtrlValueIsValid;
  std::string      m_oToolTipText;
}
FORM_CONTROL_DDV_TYPE, *P_FORM_CONTROL_DDV_TYPE;

///////////////////////////////////////////////////////////////////////////////
//
// the following structure defines the data type that will be gathered from 
// a specific form control
//
typedef struct _tagCtrlDDXDefn
{
  UINT       m_iCtrlID;
  eDataType  m_eDDXType;
}
FORM_CONTROL_DDX_TYPE, *P_FORM_CONTROL_DDX_TYPE;


///////////////////////////////////////////////////////////////////////////////
//
// data required to create a form control
//
typedef struct _tagAFormControl
{
  UINT                    m_iCtrlID;
  UINT                    m_iGroupID;
  UINT                    m_iBuddyID;
  UINT                    m_iMinRangeValue;
  UINT                    m_iMaxRangeValue;
  UINT                    m_iPrecision;
  char                    m_chAltNavKey;
  COLORREF                m_xBackColor;
  COLORREF                m_xTextColor;
  std::string             m_oCtrlName; 
  std::string             m_oInternalName;   
  std::string             m_oCtrlType;
  eCtrlType               m_eCtrlType;
  eDataType               m_eBuddyType;
  eImageSourceType        m_eImageSourceType;
  DWORD                   m_dwImageType;
  std::string             m_oImageName;
  UINT                    m_iImageID;
  std::string             m_oBuddyName;
  DWORD                   m_dwStyle;
  DWORD                   m_dwExStyle;
  int                     m_eXAnchor;
  int                     m_eYAnchor;
  bool                    m_bShowGridLines;
  RECT                    m_xLocation;
  STRING_POINTER_ARRAY    m_oColumnNames;
  STRING_POINTER_ARRAY    m_oSeedData;
  INT_ARRAY               m_oItemData;
  std::string             m_oInitialValue;
  CWnd*                   m_poControl;
  P_FORM_CONTROL_DDV_TYPE m_pxMyDDV;
  P_FORM_CONTROL_DDX_TYPE m_pxMyDDX;
  CFont                   m_oFont;
  bool                    m_bCustomFont;
  bool                    m_bForcedHidden;
  bool                    m_bCanEditCombo;
  std::string             m_oTabAlias;
  std::string             m_oTabEnterTo; 
  std::string             m_oTabExitFrom;
  std::vector < struct _tagAFormControl* > m_oSubFormControls;
} 
FORM_CONTROL, *P_FORM_CONTROL, **H_FORM_CONTROL;



///////////////////////////////////////////////////////////////////////////////
//
// a form will often have a collection of controls, so define a container
// for the form controls that are part of the form's definition
// 
typedef std::vector< P_FORM_CONTROL >      FORM_CONTROL_SET;
typedef FORM_CONTROL_SET::iterator         FORM_CONTROL_SET_ITER;


typedef std::map< std::string, UINT >      FORM_NAME_TO_ID_MAP;
typedef FORM_NAME_TO_ID_MAP::iterator      FORM_NAME_TO_ID_MAP_ITER;

typedef std::map< UINT, P_FORM_CONTROL >   FORM_CONTROL_MAP;
typedef FORM_CONTROL_MAP::iterator         FORM_CONTROL_MAP_ITER;



///////////////////////////////////////////////////////////////////////////////
//
// each control has two relevant tab definitions, the previous and the next control
// to be tabbed to. However, for 'multi-part forms' there may be multiple tab-entry
// and tab-exit points for any given control, the following structures capture these
// relationships
//
typedef std::vector< int >           MULTI_POINT_TAB;
typedef MULTI_POINT_TAB::iterator    MULTI_POINT_TAB_ITER;

typedef struct _tagTabOrderDefn
{
  MULTI_POINT_TAB       m_oUpStreamTabs;
  std::string           m_oReferenceTabName;  // the current tab node is the reference
  UINT                  m_iReferenceTabID;
  MULTI_POINT_TAB       m_oDownStreamTabs;
}
TAB_ORDER_DEFN, *P_TAB_ORDER_DEFN;


///////////////////////////////////////////////////////////////////////////////
//
// a form will often have a tab order definition, so define a container
// for the tab order definitions
//
typedef std::map< UINT, P_TAB_ORDER_DEFN >   FORM_TAB_SET;
typedef FORM_TAB_SET::iterator               FORM_TAB_SET_ITER;



///////////////////////////////////////////////////////////////////////////////
//
// each data type definition will be mapped to a specific control ID
//
typedef std::map< UINT, P_FORM_CONTROL_DDX_TYPE >   CONTROL_DDX_DEFINITION;
typedef CONTROL_DDX_DEFINITION::iterator            CONTROL_DDX_DEFINITION_ITER;


///////////////////////////////////////////////////////////////////////////////
//
// each data validation definition will be mapped to a specific control ID
//
typedef std::map< UINT, P_FORM_CONTROL_DDV_TYPE >   CONTROL_DDV_DEFINITION;
typedef CONTROL_DDV_DEFINITION::iterator            CONTROL_DDV_DEFINITION_ITER;


///////////////////////////////////////////////////////////////////////////////
//
// data required to create a form
//
typedef struct _tagAForm
{
  int                     m_iFormNumber;
  int                     m_iMaxXLocation;
  int                     m_iMaxYLocation;
  int                     m_iMinXLocation;
  COLORREF                m_xBackColor;
  COLORREF                m_xTextColor;
  std::string             m_oFormName;
  std::string             m_oCaption;
  DWORD                   m_dwFrameStyle;  
  DWORD                   m_dwExFrameStyle;
  FORM_CONTROL_SET        m_oControlsSet;
  FORM_CONTROL_SET        m_oSubForms;
  FORM_CONTROL_MAP        m_oControlsMap;
  FORM_TAB_SET            m_oTabSet;
  CONTROL_DDX_DEFINITION  m_oDDXDefinition;
  CONTROL_DDV_DEFINITION  m_oDDVDefinition;
  FORM_NAME_TO_ID_MAP     m_oFormIDSet;
  FORM_ACTIONS            m_oFormActions;
  std::string             m_oRenderCode;
  std::string             m_oRenderEntryPoint;
  bool                    m_bCustomRender;
  CFont                   m_oFont;
  bool                    m_bCustomFont;
  VMFacade*               m_poFacade;
  std::string             m_oScriptText;
}
FORM_DEFINITION, *P_FORM_DEFINITION;



#endif



/*****************************************************************************/
/* Check-in history 
   $WorkFile:   $
    $Archive:   $

 *$Log:   $
*/
/*****************************************************************************/

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Web Developer
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions