31
Advanced EZGUI / Re: Components
« Last post by Chris Boss on March 21, 2023, 02:35:11 pm »The key to understanding what a component does is this:
If you design a form you can only use one instance of this form at a time. Each form has its own name and no two can have the same name.
A Component uses a single form design, but can create multiple instances of itself and it creates a unique name for each instance which it tracks internally.
You don't talk directly to the controls on the component. Instead it is treated as if if was a control and it is given its own unique control ID at creation.
When you talk to the component, instead of talking to its controls directly, you talk to the form itself using the available component supporting commands such as:
EZ_Clear
EZ_SetImage
EZ_SetFont
EZ_SetColor
EZ_SelectItem
EZ_SetText
EZ_SwapImage
A component tracks its own colors, font, text and bitmap/icon.
If I have a component which has an ID of 100 on a Form1 , I can tell the component to clear itself simply by calling:
EZ_Clear "Form1", 100
Now EZGUI will generate an event and send it to the component. The form event routine of the component will get the %EZ_ClearUpdated event.
Now it becomes the components responsiblity to clear itself (whatever that may mean for the form and how it was designed to work.
Now let's say a component handles text. Maybe it is a mini-Wordpad emulator and has a richtext control on it.
For a component with ID = 100 and on Form1 you could call:
EZ_SetText "Form1", 100, SomeRTFtext$
The components form level event code will get the event:
%EZ_TextUpdated
Then in this event the component can retrieve the text using the EZ_GetCmpText function.
A component can store up to 32,768 unique strings. They have an Index number.
It is up to you what indexes you want to use to store your strings.
%EZ_TextUpdated will pass an index number in CVal&. EZ_SetText always passes a zero index (undefined). EZ_SetCmpText has a parameter to pass an index value which will be passed through the Cval& parameter for the event.
EZGUI does not use an array to store stings for a component. It stores them in a single string data type. It separates the records (each individual indexed string) using an ascii character 1 ( CHR$(1) ). So do not pass the ascii character 1 in your strings.
So if a component is not defined with a form name, what name do you use for the component itself (it is technically a form) when calling EZGUI commands which require a form name ?
The easiest way is to use the Form macro:
"{ME}"
Forms know their own name, so if a command is called within a components form events and you are calling itself, then this macro is what to use.
You can also retrieve the components actual form name by using the function:
EZ_CMPName
You pass the function the parent form of the component and the components ID number (remember it acts like a control to your app and has an ID rather than name) and you can get the internal form name for the component.
If you design a form you can only use one instance of this form at a time. Each form has its own name and no two can have the same name.
A Component uses a single form design, but can create multiple instances of itself and it creates a unique name for each instance which it tracks internally.
You don't talk directly to the controls on the component. Instead it is treated as if if was a control and it is given its own unique control ID at creation.
When you talk to the component, instead of talking to its controls directly, you talk to the form itself using the available component supporting commands such as:
EZ_Clear
EZ_SetImage
EZ_SetFont
EZ_SetColor
EZ_SelectItem
EZ_SetText
EZ_SwapImage
A component tracks its own colors, font, text and bitmap/icon.
If I have a component which has an ID of 100 on a Form1 , I can tell the component to clear itself simply by calling:
EZ_Clear "Form1", 100
Now EZGUI will generate an event and send it to the component. The form event routine of the component will get the %EZ_ClearUpdated event.
Now it becomes the components responsiblity to clear itself (whatever that may mean for the form and how it was designed to work.
Now let's say a component handles text. Maybe it is a mini-Wordpad emulator and has a richtext control on it.
For a component with ID = 100 and on Form1 you could call:
EZ_SetText "Form1", 100, SomeRTFtext$
The components form level event code will get the event:
%EZ_TextUpdated
Then in this event the component can retrieve the text using the EZ_GetCmpText function.
A component can store up to 32,768 unique strings. They have an Index number.
It is up to you what indexes you want to use to store your strings.
%EZ_TextUpdated will pass an index number in CVal&. EZ_SetText always passes a zero index (undefined). EZ_SetCmpText has a parameter to pass an index value which will be passed through the Cval& parameter for the event.
EZGUI does not use an array to store stings for a component. It stores them in a single string data type. It separates the records (each individual indexed string) using an ascii character 1 ( CHR$(1) ). So do not pass the ascii character 1 in your strings.
So if a component is not defined with a form name, what name do you use for the component itself (it is technically a form) when calling EZGUI commands which require a form name ?
The easiest way is to use the Form macro:
"{ME}"
Forms know their own name, so if a command is called within a components form events and you are calling itself, then this macro is what to use.
You can also retrieve the components actual form name by using the function:
EZ_CMPName
You pass the function the parent form of the component and the components ID number (remember it acts like a control to your app and has an ID rather than name) and you can get the internal form name for the component.