//TH-Header //***************************************************************************************** // Copyright (c) 2014 KURANT Project // All rights reserved. // // $FileName : CustMenu.VW // $ProjectName : The Hammer 2.0 // $Authors : Wil van Antwerpen, Michael Kurz, Sergey V. Natarov // $Created : 01.25.2014 01:08 // $Type : LGPL // // Contents: Maintain User Menu // //***************************************************************************************** //TH-RevisionStart //TH-RevisionEnd // Project Object Structure // oCustMenuView is a dbView // Custmenu_DD is a DataDictionary // Custmenu_Description is a dbForm // Custmenu_Instruction is a dbForm // oMenuList is a dbList // oBottomLine is a LineControl // oSave_bn is a Button // oCancel_bn is a Button // oAdd_bn is a Button // oRemove_bn is a Button // oUp_bn is a Button // oDown_bn is a Button // Register all objects Register_Object Custmenu_DD Register_Object Custmenu_Description Register_Object Custmenu_Instruction Register_Object oAdd_bn Register_Object oBottomLine Register_Object oCancel_bn Register_Object oCustMenuView Register_Object oDown_bn Register_Object oMenuList Register_Object oRemove_bn Register_Object oSave_bn Register_Object oUp_bn Use DFAllEnt.pkg Use ctButton.Pkg Use CUSTMENU.DD Deferred_View Activate_oCustMenuView For ; ; Object oCustMenuView Is a cIcondbView Set LargeTaskbarIcon To "PANEL32.bmp" Set SmallTaskbarIcon To "PANEL16.bmp" Set IconTransparentColor To (Rgb(255,0,255)) // Set Popup_State To True // Procedure Activate_View // Send Popup // End_Procedure Set Label To "Custom Menu" Set Size To 198 413 Set Location To 1 2 Object Custmenu_DD Is a Custmenu_DataDictionary Procedure Item_Find Integer iMode Integer iFile Integer iField Integer iEntry1 Integer iErrs Integer iDef Forward Send Item_Find iMode iFile iField iEntry1 iErrs iDef Send Beginning_Of_Data To (oMenuList(Self)) End_Procedure Procedure Request_Save Forward Send Request_Save Send Beginning_of_Data To (oMenuList(Self)) End_Procedure End_Object // Custmenu_DD Set Main_DD To (Custmenu_DD(Self)) Set Server To (Custmenu_DD(Self)) Object Custmenu_Description Is a dbForm Entry_Item Custmenu.Description Set Label To "Menu Label:" Set Size To 13 126 Set Location To 22 165 Set Label_Col_Offset To 0 Set Label_Justification_Mode To jMode_Top Procedure DoSetEnabledState Integer bEnabled Set Enabled_State To bEnabled End_Procedure // DoSetEnabledState End_Object // Custmenu_Description Object Custmenu_Instruction Is a dbForm Entry_Item Custmenu.Instruction Set Label To "Commandline instruction:" Set Size To 13 180 Set Location To 52 165 Set Label_Col_Offset To 0 Set Label_Justification_Mode To jMode_Top Procedure DoSetEnabledState Integer bEnabled Set Enabled_State To bEnabled End_Procedure // DoSetEnabledState End_Object // Custmenu_Instruction Object oMenuList Is a dbList //Set Static_State To True //Set Allow_insert_add_state To False //Set GridLine_Mode To Grid_Visible_None Set Move_Value_Out_State To False // Use as a Display_List Set Auto_Shadow_State To False //Set vpbReorder_Header_List To False //Set Highlight_row_state To False Set Main_File To Custmenu.File_Number Set Ordering To 1 Set Size To 122 117 Set Location To 10 10 //Set CurrentRowColor to clBlue //Set CurrentRowTextColor to clWhite //Set CurrentCellColor to clBlue //Set CurrentCellTextColor to clWhite Set Resize_Column_state To FALSE Set Auto_Column_State To FALSE Set Move_Value_Out_State To FALSE Begin_Row Entry_Item Custmenu.Description End_Row Set Form_Width Item 0 To 109 Set Header_Label Item 0 To "Menu" End_Object // oMenuList Object oBottomLine Is a LineControl Set Size To 2 393 Set Location To 156 8 End_Object // oBottomLine Object oSave_bn Is a Button Set Label To "&Save" Set Location To 163 298 Procedure OnClick Delegate Send Request_Save //_No_Confirm End_Procedure // OnClick End_Object // oSave_bn Object oCancel_bn Is a Button Set Label To "&Close" Set Location To 163 353 Procedure OnClick Delegate Send Request_Cancel End_Procedure // OnClick End_Object // oCancel_bn Object oAdd_bn Is a Button Set Label To "&New" Set Location To 137 15 Procedure OnClick Delegate Send Request_Clear End_Procedure // OnClick End_Object // oAdd_bn Object oRemove_bn Is a Button Set Label To "&Delete" Set Location To 137 70 Procedure OnClick Delegate Send Request_Delete End_Procedure // OnClick End_Object // oRemove_bn Object oUp_bn Is a ctButton Set Bitmap To "Abup.bmp" Set Size To 20 20 Set Location To 51 132 Procedure OnClick Integer iCurrent iLast iNew iFirst Get Field_Current_Value Of (Custmenu_DD(Self)) Field CUSTMENU.MENUORDER To iCurrent // Get FirstOrderNr To iFirst If (iCurrent <> iFirst) Begin Get LastOrderNr To iLast Find Lt CUSTMENU By Index.1 Move CUSTMENU.MENUORDER To iNew Reread CUSTMENU Move (iLast+1) To CUSTMENU.MENUORDER Saverecord CUSTMENU UnLock Clear CUSTMENU Move iCurrent To CUSTMENU.MENUORDER Find Eq CUSTMENU By Index.1 Reread CUSTMENU // ? Move iNew To CUSTMENU.MENUORDER Saverecord CUSTMENU UnLock Clear CUSTMENU Move (iLast+1) To CUSTMENU.MENUORDER Find Eq CUSTMENU By Index.1 Reread CUSTMENU Move iCurrent To CUSTMENU.MENUORDER Saverecord CUSTMENU UnLock // Display the new menu-item again. Clear CUSTMENU Move iNew To CUSTMENU.MENUORDER Find Eq CUSTMENU By Index.1 Send Request_Assign To (Custmenu_DD(Self)) End End_Procedure // OnClick End_Object // oUp_bn Object oDown_bn Is a ctButton Set Bitmap To "Abdown.bmp" Set Size To 20 20 Set Location To 80 132 Procedure OnClick Integer iCurrent iLast iNew Get Field_Current_Value Of (Custmenu_DD(Self)) Field CUSTMENU.MENUORDER To iCurrent // Get LastOrderNr To iLast If (iCurrent <> iLast) Begin Find Gt CUSTMENU By Index.1 Move CUSTMENU.MENUORDER To iNew Reread CUSTMENU Move (iLast+1) To CUSTMENU.MENUORDER Saverecord CUSTMENU UnLock Clear CUSTMENU Move iCurrent To CUSTMENU.MENUORDER Find Eq CUSTMENU By Index.1 Reread CUSTMENU Move iNew To CUSTMENU.MENUORDER Saverecord CUSTMENU UnLock Clear CUSTMENU Move (iLast+1) To CUSTMENU.MENUORDER Find Eq CUSTMENU By Index.1 Reread CUSTMENU Move iCurrent To CUSTMENU.MENUORDER Saverecord CUSTMENU UnLock // Display the new menu-item again. Clear CUSTMENU Move iNew To CUSTMENU.MENUORDER Find Eq CUSTMENU By Index.1 Send Request_Assign To (Custmenu_DD(Self)) End End_Procedure // OnClick End_Object // oDown_bn On_Key Key_Alt+Key_N Send OnClick To (oAdd_bn(Current_Object)) On_Key Key_Alt+Key_D Send OnClick To (oRemove_bn(Current_Object)) On_Key Key_Alt+Key_S Send OnClick To (oSave_bn(Current_Object)) Function LastOrderNr Returns Integer Integer iLast iOldRecnum Move CUSTMENU.RECNUM To iOldRecnum Clear CUSTMENU Find Lt CUSTMENU By Index.1 If (found) Move CUSTMENU.MENUORDER To iLast If iOldRecnum Begin Clear CUSTMENU Move iOldRecnum To CUSTMENU.RECNUM Find Eq CUSTMENU By Recnum End Function_Return iLast End_Function // LastOrderNr Function FirstOrderNr Returns Integer Integer iFirst iOldRecnum Move CUSTMENU.RECNUM To iOldRecnum Clear CUSTMENU Find Gt CUSTMENU By Index.1 If (found) Move CUSTMENU.MENUORDER To iFirst If iOldRecnum Begin Clear CUSTMENU Move iOldRecnum To CUSTMENU.RECNUM Find Eq CUSTMENU By Recnum End Function_Return iFirst End_Function // FirstOrderNr Procedure DoSetAllEnabledState Integer bEnabled Broadcast Recursive Send DoSetEnabledState bEnabled End_Procedure // DoSetAllEnabledState Procedure Entering_scope //Set Print_Button_Shadow_State To False Forward Send Entering_Scope End_Procedure // Entering_Scope // disable the printbutton again. Procedure Exiting_scope Integer new_scope //Set Print_Button_Shadow_State to True Forward Send Exiting_scope new_scope End_Procedure // Exiting_scope Cd_End_Object // oCustMenuView