In almost any application we will need an OPTIONS MENU.


As a suggestion for use, RadCORE brings a menu that is dynamically filled and each option is called dynamically, that is, you don't need to code anything, just inform how the menu's content will be.


I've been using a naming "pattern" for many years that applies to just about any situation, so I applied that to RadCORE.


- BASIC MENU

- MOVEMENT MENU

- REPORTS MENU

- TOOLS MENU

- MENU OTHERS (or OPTIONS)


For each option we rank more levels so, in my humble view, 1st. MENU level becomes simpler and easier for the user.


Of course you can change that, just understand the flow of execution.


Understanding the Process


In the main.pas Create event there will be several functions/procedures to configure the entire screen (study the code).


Dynamic building of the menu is done with rc_BuildMainMenu


which in turn will perform the individual assembly of the menu by category:


As said before, this is the pattern chosen by me, study the code and you can change it according to your need.


For each group of options, a unit was created containing its respective content.



> some users have modified and transported it to tables but I can parameterize it better and define "exclusions" using the standard way.


Adding Itens


Importante: as of version 5.0, the creation of menus has been simplified, but the entire previous structure remains active, that is,

            you can continue using the previous function.


procedure rc_BuildMenuItem( pMenuGroup        : string; 

                            pLevel            : integer;

                            pItem             : string

                            ); 


pMenuGroup        : Group of the menu to be created.( '' or 'B'asic, 'M'ovement, 'R'eport, 'T'ools, 'O'thers )

pLevel            : Level of the menu to be created.

pItem             : Definition of the menu option to be created in the following format: 

                    > rc_BuildMenuItem( 'Option Description param1:aaa param2:aaa' );


Examples of definitions: 


tbl:              > Table in the database that will be linked to this item.

fld:              > Name of the field in the restrictions table ( USUARIOS_RESTRICOES ) for permission control.

frm:              > Name of the form/frame (without the default prefix).

ico:              > Fontawesome icon to be displayed next to the item.

modal:            > If this item is a FORM, and it needs to be displayed MODAL.

hide:             > This item will be hidden if the user is not a MASTER.

asknew:           > This item will ask if you want to register another record right after SAVE a previous record.

genid:            > Generate or not a new sequence when registering a new record.

genid-off:        > Do not Generate a new sequence when registering a new record. Inform "getpk:" If "genid-off:" is informed.

closebtn:         > Whether or not to display the "( x )" to close the tab.

notshow:          > Effectively do not display in the menu. Even if the user is MASTER.

master:           > It does not display in the menu if it is not MASTER and when clicked, it will require a MASTER password.

tag-form:         > Passes a "tag string" that can be read by the form to trigger some action.

getpk:            > Informs the sequence field of the linked table ( tbl: ) because by default, the first field of the primary key is used by RC as the sequence of the linked table ( tbl: ).

expand:           > Launches the already open menu option.


Check their respective parameters to tell RadCORE the structure of each option that will be created. Study the source code to see what each option does to better understand the feature.





The final result will look like this:




Let's see the configuration of some options (according to the parameter list of "rc_BuildMenuItem" and the prefix pattern seen in "Standards and Conventions" ):


Default prefixes:

    FRM_CLASS_PREFIX: Will be used when the "table" parameter is not informed( Default: TFrm )

    FRM_CLASS_CRUD_PREFIX: Will be used whenever the "table" parameter is informed( Default: TFrmCad )


      Standard CRUD call. The FORM name is the same as its respective table (with default prefix TFrmCad)

            

      rc_BuildMenuItem( '',  0, 'Cities tbl:cidades' );


note: 

When the "table( tbl: )" parameter is informed, RadCORE composes the name of the form's class with the default prefix

( Ex: TFrmCadCIDADES )



      CRUD call inherited but the FORM name is different from the table name.


rc_BuildMenuItem( 'M', 0, 'POS Sale tbl:oses frm:POS' );


note: 

Quando informado o parâmetro "table( tbl: )" e o parâmetro "form( frm: )", o RadCORE compõe o nome da classe do formulário com o prefixo padrão

( Ex: TFrmCadPOS )


      Legacy CRUD call but FORM name is different from table name and default blank prefixes.


rc_BuildMenuItem( 'M', 0, 'POS Sale tbl:oses frm:TFrmPOS' );


note: 

Você deve preencher o parâmetro "form ( frm: )" com o nome completo da sua classe.

( Ex: TFrmPDV )


      Call WITHOUT CRUD inherited. Does not inherit from frmBaseCRUD( with default prefix TFrm )


     rc_BuildMenuItem( '',  0, 'Buttons frm:Demo_Buttons ico:fas-dot-circle' );


note: 

Quando não informado o parâmetro "table( tbl: )", o RadCORE compõe o nome da classe do formulário com o prefixo padrão

( Ex: TFrmDemo_Buttons )


      REPORT option call (inherited from frmBaseMENUREL)


      rc_BuildMenuItem( 'R', 0, 'Rel. Clients frm:reportMenuClientes' );


      Option call with continuous registration and direct sequential generation


      rc_BuildMenuItem( 'T', 0, mm.MNU_TOOLS_USERS + ' tbl:usuarios ico:fas-user-cog asknew: ' );


      Option call being MODAL FORM


      rc_BuildMenuItem( '',  0, 'Form ( open MODAL ) frm:DEMOWITHFORMModal ico:fas-dot-circle modal:'  );




Dynamically displaying forms


Another useful feature of RadCORE's menu system is the possibility to display or even start a new registration by calling the form from anywhere in your application.


In the general demo (BRAZIL/GLOBAL version) you will find "frmDEMO_FORMS" and in it examples of using the options below.



1. Displaying the form:


2. Displaying the form and showing the contents of a given record:


3. Displaying the form and showing the content of a given record and starting its editing:


4. Displaying the form and starting a new registration:


5. Displaying the form inside a Container:


6. Displaying the form with parameter passing ( "tag-form:" ) :


7. Displaying a FRAME as MODAL:



Watch this video:

https://youtu.be/9vB5yceH_4w


Study the click event of the Main Menu and debug to follow the execution flow and better understand the whole process.


Closing a frame

 

You can see that when you activate (open) a frame/form (without being modal) it is added to the upper tab control.


In this topic ( bsTABS and bsPILL ) it was discussed how this rendering of the tabs works.


In some situation, you can choose to pass the "closebtn:" parameter to hide the "X" that closes the frame directly on the tab and want to put a button inside that frame to close it manually. Enter the code below for this.


if mm.oPgGeneral <> nil then

   mm.oPgGeneral.ActivePage.Close;

Created with the Personal Edition of HelpNDoc: Create help files for the Qt Help Framework