Main Functions Expected in the Tcl Script
There are four main procedures expected in the Tcl script, which are expected to do the following tasks:
- DisplayWnd
-
- Create the UI components.
- Associate a namespace/member variable for each UI component.
- GetDataFromDataModel to initialize the member variables (and the UI from a previous session).
proc ::hw::pmgr::${::hw::pmgr::namespace}::DisplayWnd {} variable mainWnd; variable id; variable m_strFileName; set mynamespace ::hw::pmgr::${::hw::pmgr::namespace}; if {[WndExists] == 0} CreateWnd "HWPM -- Load Template" "Import" # Create all the UI components set txtFileName [entry $mainWnd.txtFileName -font [hwt::AppFont] \ -textvariable ${mynamespace}::m_strFileName -width 60] . . . #Get the data from the DataModel and update the UI GetDataFromDataModel; } return 0; }
- SetDataInDataModel
- Checks to see if any of the member variable values have changed from what is
currently in the DataModel.
- Set the changed values in the DataModel.
- If nothing has changed, "RestoreOriginalState".
proc ::hw::pmgr::${::hw::pmgr::namespace}::SetDataInDataModel {} variable mainWnd; variable id; variable m_strFileName; set nDataChanged 0; # Set all the data from the UI into the data model. # As we set, check if the data has changed #Set the HM filename in the data model if {$m_strFileName != \ [::hw::pmgr::PmgrGetData $id ${id}::HM_FILENAME]} ::hw::pmgr::PmgrSetData $id ${id}::HM_FILENAME $m_strFileName; set nDataChanged 1; } if {$nDataChanged == 0} RestoreOriginalState; }; } GetDataFromDataModel · Get data from the DataModel and initialize the member variables. · If the value of the data from the DataModel is "", initialize the member variable with default value. proc ::hw::pmgr::${::hw::pmgr::namespace}::GetDataFromDataModel {} variable mainWnd; variable id; variable m_strFileName; #Get the HM filename in the data model set m_strFileName [::hw::pmgr::PmgrGetData $id ${id}::HM_FILENAME]; if {$m_strFileName == ""} set m_ strFileName "D:/altair/demos/hm/bumper.hm" } }
- Exec
- This is the heart of the module and will do whatever needs to be done by the
module.
- Relies exclusively on member variables for data.
- Does not get data from the UI components.