[Gambas-user] Custom controls, Non-String arrays in the IDE

Bruce Steers bsteers4 at gmail.com
Thu Aug 18 18:22:51 CEST 2022


On Wed, 17 Aug 2022 at 21:39, Bruce Steers <bsteers4 at gmail.com> wrote:

>
>
> On Wed, 17 Aug 2022 at 16:45, Bruce Steers <bsteers4 at gmail.com> wrote:
>
>>
>>
>> On Wed, 17 Aug 2022 at 13:19, Benoit Minisini <
>> benoit.minisini at gambas-basic.org> wrote:
>>
>>> Le 17/08/2022 à 13:42, Bruce Steers a écrit :
>>> >
>>> >             Let's put the usefullness of flashy gradient buttons aside.
>>> >             What you
>>> >             would need is actually a brush, not a gradient. The
>>> gradient
>>> >             is just a
>>> >             particular case of a brush.
>>> >
>>> >             And editing a brush (or any other complex property) in the
>>> >             form editor
>>> >             needs:
>>> >
>>> >
>>> > oh my god you're right. and right about the ReportBrush too.
>>> > Sorry i didn't get it at first.
>>> >
>>> > I can just use a string value set to use {ReportBrush} type and there
>>> is
>>> > everything i needed in a string that I can easily work with. don't
>>> even
>>> > need to add gb.report.
>>> >
>>> > Awesome :)
>>> > Respects.
>>> > BruceS
>>> >
>>>
>>> It's not enough. The problem is that you must understand how property
>>> values are stored in and retrieved from form files.
>>>
>>> "ReportBrush" is not just the way the property is chosen in the form
>>> editor, it's also which code is generated in the form file to initialize
>>> the property. You can't reuse it directly.
>>>
>>> For complex objects like brushes, you usually need an equivalent object
>>> in the component. For example, properties with "ReportBrush" kind uses
>>> the 'ReportBrush[]' array method of the gb.report(2) component.
>>>
>>> That logic is located in the 'CControl.GetEachProperty()' method.
>>>
>>> Regards,
>>>
>>
>> Yes i spoke too soon in my excitement of your suggestions finally hitting
>> me and thinking i had a really simple solution.
>> It was all working editing in the IDE so I thought everything was great,
>> but then i got an error when running the program (no ReportBrush)
>>
>> So i have imported the ReportBrush.class and now it works like you say,
>> not as a string but as an actual reportbrush object.  Still that's
>> something i can use.
>>
>> Shame i cannot disable the color/image options of the reportbrush editor
>> but i'll work around it :)
>>
>
> So i did this to get a gradient only dialog...
>
> https://gitlab.com/bsteers4/gambas/-/commit/07546d3bbf2a57cf3ba793573a43dc4501407649
>
> I just added an option GradientOnly to the ReportBrush type so you can use
> MyGradient{ReportBrush:GradientOnly} and it hides the color/image options
>
> it removes the first 2 color/image items from the list and offsets all the
> combo.index calls by 2 if removed.
>
> have tested it and tested it alongside another brush property that used
> all 4 types and no problems using both.
>
> Could you accept something like this?
>


Okay here's the special meatball...
https://gitlab.com/bsteers4/gambas/-/commit/196ca091ce5e4b39b266afc68cde4a4acb8c7c43
This also solves my issue as i can make a simple Color array for my
gradients.

On that branch i have added a new property type called ListOf

You can have ListOf:Color ListOf:Font ListOf:Picture ListOf:Path  plus some
others.
All lists must point to a String[] property
A new chooser form called FArrayChooser shows font/image/color in gridview
list
Adding or editing opens up the correct chooser for the type.
The following lists should be possible to open their own chooser forms...
      Case "Font", "FixedFont"
      Case "WebFont"
      Case "Color"
      Case "Picture", "Image", "Animation", "WebImage", "SvgImage"
      Case "WebAudio"
      Case "Path"

My test class has the following line..
Public Const _Properties As String =
"ColorList{ListOf:Color},FontList{ListOf:Font},PictureList{ListOf:Picture},ImgList{ListOf:Image}"

They all work as expected.

Todo:
need to check that moving/copying/pasting items works okay


Respects.
BruceS
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20220818/d76f2c97/attachment.htm>


More information about the User mailing list