//TH-Header //***************************************************************************************** // Copyright (c) 2014 KURANT Project // All rights reserved. // // $FileName : CustMenu.inc // $ProjectName : The Hammer 2.0 // $Authors : Wil van Antwerpen, Michael Kurz, Sergey V. Natarov // $Created : 01.25.2014 01:08 // $Type : LGPL // // Contents: Tools menu with a user defined part. // //***************************************************************************************** //TH-RevisionStart //TH-RevisionEnd //Derived from VDF Rev. 5.0 Navi_PM.inc Register_Object UserDefined_Menu DFCreate_Menu "&Tools" UserDefined_Menu Is a PopupMenu DFCreate_Menu " File Headers" HeaderPopupMenu Is a cBitmapPopupMenu Property Handle phoTemplates 0 DFCreate_Menu "Insert Header" InsertHeaderPopupMenu Is a cBitmapPopupMenu On_Item "Global Header" Send InsertHeaderGlobal On_Item ("Current User: "+gsUserName+"\aCtrl+H") Send InsertHeaderUser Property Integer piSelectedItem -1 Property Integer piStartItems (Item_Count(Self)) Procedure DoInsertWorkspaceHeader Integer iSelected Integer iStart Integer iCount Integer iItem Handle hoFocus Handle hoTemplates String sPath String sTemplate Get piSelectedItem To iSelected Get piStartItems To iStart Move (iSelected-(iStart+1)) To iItem // iStart+1 to take the menu separator into account Get phoTemplates To hoTemplates If (hoTemplates) Begin Get Item_Count Of hoTemplates To iCount If (iCount>0 and iItem>=0 and iItem iStart) Send Delete_Item iStart End Send CreateFiletemplateSet Move 0 To iCount Get phoTemplates To hoSet If (hoSet) Begin Get Item_Count of hoSet To iCount If (iCount>0) begin Send Add_Item msg_None "" // show a separator For iItem from 0 To (iCount-1) Get LongFileName of hoSet Item iItem To sTemplate Send Add_Item msg_DoInsertWorkspaceHeader (" "+sTemplate) Set Aux_Value Item (Item_Count(Self)-1) To Self Loop End End End_Procedure // onInitMenu Procedure change_menu Integer iItem Integer obj Integer iFlags Forward Send change_menu iItem obj iFlags Send OnChange Set piSelectedItem To iItem End_Procedure End_Menu DFCreate_Menu "Edit Header" EditHeaderPopupMenu Is a cBitmapPopupMenu On_Item "Global Header" Send CAEditHeaderGlobal To (oClientArea(Self)) On_Item ("Current User: "+gsUserName) Send CAEditHeaderUSer To (oClientArea(Self)) Property Integer piSelectedItem -1 Property Integer piStartItems (Item_Count(Self)) Procedure DoEditWorkspaceHeader Integer iSelected Integer iStart Integer iCount Integer iItem Handle hoTemplates Handle hoCA String sPath String sTemplate Move (oClientArea(Self)) To hoCA Get piSelectedItem To iSelected Get piStartItems To iStart Move (iSelected-(iStart+1)) To iItem // iStart+1 to take the menu separator into account Get phoTemplates To hoTemplates If (hoTemplates) Begin Get Item_Count Of hoTemplates To iCount If (iCount>0 and iItem>=0 and iItem iStart) Send Delete_Item iStart End Send CreateFiletemplateSet Move 0 To iCount Get phoTemplates To hoSet If (hoSet) Begin Send Add_Item msg_None "" // show a separator Get Item_Count of hoSet To iCount If (iCount>0) begin For iItem from 0 To (iCount-1) Get LongFileName of hoSet Item iItem To sTemplate Send Add_Item msg_DoEditWorkspaceHeader (" "+sTemplate) Set Aux_Value Item (Item_Count(Self)-1) To Self Loop End Else Begin // No workspace header exists, offer easy way to create one // copy the global Header.tpl to a .tpl one in the // programs folder and open it for editing. Send Add_Item msg_CAEditHeaderWorkspace "Create workspace header" End End End_Procedure // onInitMenu Procedure change_menu Integer iItem Integer obj Integer iFlags Forward Send change_menu iItem obj iFlags Send OnChange Set piSelectedItem To iItem End_Procedure End_Menu Procedure CreateFiletemplateSet Handle hoID Handle hoTemplates String sPath Get phoTemplates To hoTemplates If (hoTemplates<>0) Begin // Destroy existing fileset if exists Get Object_Id Of hoTemplates To hoID If (hoID) Begin Send Destroy Of hoID End Set phoTemplates To 0 End Get CurrentProgramPath Of ghoWorkspaceHandlerEx To sPath Get vFolderFormat sPath To sPath Get Create U_cFolderSet To hoTemplates If (hoTemplates) Begin Send LoadBuffer of hoTemplates (sPath+"*.tpl") // Not sure if we should remove these from the list? //Send RemoveBufferFileByName Of hoTemplates ("Header.tpl") //Send RemoveBufferFileByName Of hoTemplates ("Header"+gsUserName+".tpl") Set phoTemplates To hoTemplates End End_Procedure // CreateFiletemplateSet Procedure onInitMenu Integer iItem Integer iCount Boolean bFlag Handle hoFocus Handle hoCA Move (oClientArea(Self)) To hoCA Get Focus Of Desktop To hoFocus Get Item_Count to iCount For iItem From 0 To (iCount-1) Set Shadow_State Item iItem To False End If hoFocus Move (isFileWindow(hoCA,hoFocus)) To bFlag Else Move False To bFlag Set Shadow_State Item 0 To (Not(bFlag)) Send AddKeyStringToMenuItem (InsertHeaderPopupMenu(Self)) 0 CMD_ToolsInsertHeaderGlobal Send AddKeyStringToMenuItem (InsertHeaderPopupMenu(Self)) 1 CMD_ToolsInsertHeaderUser End_Procedure End_Menu Set Status_Help To "Insert header into the current source file" DFCreate_Menu " Code Lists" ASListsPopupMenu Is a cBitmapPopupMenu On_Item "Classes" Send ListClasses On_Item "Objects" Send ListObjects On_Item "Procedures" Send ListProcedures On_Item "Functions" Send ListFunctions On_Item "Local variables" Send ListVars On_Item "Keys" Send ListKeys On_Item "IDE-tags" Send ListIDETags On_Item "" Send None On_Item "Creator..." Send ListCreator Procedure onInitMenu Integer iItem Integer iCount Boolean bFlag Handle hoFocus Handle hoCA Move (oClientArea(Self)) To hoCA Get Focus Of Desktop To hoFocus Get Item_Count To iCount //For iItem From 0 To (iCount-1) // Set Shadow_State Item iItem To False //End If hoFocus Move (isFileWindow(hoCA,hoFocus)) To bFlag Else Move False To bFlag For iItem From 0 To (iCount-1) Set Shadow_State Item iItem To (Not(bFlag)) End Send AddKeyStringToMenuItem Self 0 CMD_ListClasses Send AddKeyStringToMenuItem Self 1 CMD_ListObjects Send AddKeyStringToMenuItem Self 2 CMD_ListProcedures Send AddKeyStringToMenuItem Self 3 CMD_ListFunctions Send AddKeyStringToMenuItem Self 4 CMD_ListVars Send AddKeyStringToMenuItem Self 5 CMD_ListKeys Send AddKeyStringToMenuItem Self 6 CMD_ListIDETags Send AddKeyStringToMenuItem Self 8 CMD_ListCreator End_Procedure End_Menu Set Status_Help To "Popup the selected code list" DFCreate_Menu " Macro" MacroPopupMenu Is a cBitmapPopupMenu On_Item "Record Macro" Send FloatRecordMacro On_Item "" Send None On_Item "Play macro 1" Send FloatPlayMacro1 On_Item "Play macro 2" Send FloatPlayMacro2 On_Item "Play macro 3" Send FloatPlayMacro3 On_Item "Play macro 4" Send FloatPlayMacro4 On_Item "Play macro 5" Send FloatPlayMacro5 On_Item "Play macro 6" Send FloatPlayMacro6 On_Item "Play macro 7" Send FloatPlayMacro7 On_Item "Play macro 8" Send FloatPlayMacro8 On_Item "Play macro 9" Send FloatPlayMacro9 On_Item "Play macro 10" Send FloatPlayMacro10 On_Item "" Send None On_Item "Delete all Macros" Send FloatDeleteAllMacros Procedure onInitMenu Integer iC // Set Shadow_State Item 0 To (CM_IsRecordingMacro(Self)) For iC From 2 To 11 // Set Shadow_State Item iC To (CM_IsPlayingMacro(Self)) Set Shadow_State Item iC To False If (CMGetMacro(iC-2,0)) Eq 0 Set Shadow_State Item iC To True End Send AddKeyStringToMenuItem Self 0 CMD_RECORDMACRO Send AddKeyStringToMenuItem Self 2 CMD_PLAYMACRO1 Send AddKeyStringToMenuItem Self 3 CMD_PLAYMACRO2 Send AddKeyStringToMenuItem Self 4 CMD_PLAYMACRO3 Send AddKeyStringToMenuItem Self 5 CMD_PLAYMACRO4 Send AddKeyStringToMenuItem Self 6 CMD_PLAYMACRO5 Send AddKeyStringToMenuItem Self 7 CMD_PLAYMACRO6 Send AddKeyStringToMenuItem Self 8 CMD_PLAYMACRO7 Send AddKeyStringToMenuItem Self 9 CMD_PLAYMACRO8 Send AddKeyStringToMenuItem Self 10 CMD_PLAYMACRO9 Send AddKeyStringToMenuItem Self 11 CMD_PLAYMACRO10 End_Procedure End_Menu Set Status_Help To "Record and execute the code editor macro" // DFCreate_Menu "Dependency Scan" DependPopupMenu Is a cBitmapPopupMenu // On_Item "Start scan..." Send PADependencyScan // On_Item "Configure" Send PADependencyConfig // End_Menu On_Item " Insert Revision Entry" Send InsertRevision Set Status_Help To "Inserts revision line into the header and source line" On_Item " Insert Color Value" Send InsertColorValue Set Status_Help To "Inserts RGB color value into the source" On_Item " Insert Bitmap Reference" Send InsertBitmapValue Set Status_Help To "Inserts bitmap file name into the source" // GLOBAL TODO: Make this engine more intelligent and include back. //On_Item "Class Explorer" Send Activate_Class_Explorer To (oClientArea(Self)) On_Item "" Send None Property Integer piSelectedCustMenuItem -1 Property Integer piStartDynamicItems (Item_Count(Self)) Procedure DoCustmenuExecute Integer iSelected Integer iItem String sProgram Get piSelectedCustMenuItem To iSelected Open Custmenu Clear CustMenu Move "TOOLS" To Custmenu.Menu For iItem From 0 To (iSelected-piStartDynamicItems(Self)) Find Gt Custmenu by Index.1 End Move (RTrim(CustMenu.Instruction)) To sProgram Send LaunchUtility To (Focus(Self)) sProgram "" End_Procedure Procedure onInitMenu Integer iC iFlag Integer iCount Handle hoFocus Handle hoCA Move (oClientArea(Self)) To hoCA Move (Focus(Desktop)) To hoFocus If hoFocus Move (isFileWindow(hoCA,hoFocus)) To iFlag Else Move 0 To iFlag Set Shadow_State Item 2 To (Not(iFlag)) // Macros Set Shadow_State Item 3 To (Not(iFlag)) // Insert Revision Entry. Send AddKeyStringToMenuItem Self 3 CMD_InsertRevisionMark Set Shadow_State Item 4 To (Not(iFlag)) // Insert Color value Send AddKeyStringToMenuItem Self 4 CMD_InsertColor Set Shadow_State Item 5 To (Not(iFlag)) // Insert Bitmap value While (Item_Count(Self)) Gt (piStartDynamicItems(Self)) Send Delete_Item (piStartDynamicItems(Self)) End Move 0 To iCount Open CustMenu Clear CustMenu Move "TOOLS" To Custmenu.Menu Repeat Find Gt Custmenu by Index.1 [found] Indicate found as Custmenu.Menu Eq "TOOLS" If (found) Begin If (Trim(Custmenu.Description) <> "") Begin Send Add_Item msg_DoCustMenuExecute (" "+RTrim(Custmenu.Description)) Set Aux_Value Item (Item_Count(Self)-1) To Self Increment iCount End Else On_Item "" Send msg_None // A separator End // found Until [Finderr] If (iCount>0) Send Add_Item msg_none "" Send Add_Item msg_Activate_oCustMenuView " &Customize Items..." Clear CustMenu End_Procedure Procedure change_menu Integer iItem Integer obj Integer iFlags Delegate Send change_menu iItem obj iFlags Send OnChange Set piSelectedCustMenuItem To iItem End_Procedure End_Pull_down Set Status_Help To "User Defined Menu"