Page 1 of 2

Custom Buttons & custom Labels - updated 1.4

Posted: 2 May 2007 21:19
by Gildas Menier
Hi !

Here is an example of custom control for custom buttons. Font, Size, Color, Background Color, pictures are supported, as well as a toggle button type (see the included picture for samples).

Best Regards


ps : As always (! :roll:), this lacks real documentation, but the name of the predicates and the example should be sufficient (? ).

Seems the package size exceeds the allowed size for attachment, so you can download the package there :

Code: Select all

domains     ebuttonCallback =  (boolean State, string Text) procedure (i,i).   predicates     % to change or get the text, use settext and gettext (defined in userControlSupport)     % you can even set the button text in the custom control wizard.     setBackgroundColor      : (color)    procedure (i). % sets the color of the button's background (gray is the default value)         setBackgroundPicture    : (string FileName) procedure (i). % sets the filename (a .bmp file) of the background         enableBackgroundPicture: ().  % should be called to display a background picture     disableBackGroundPicture: (). % no background picture (default value)         enableBackGroundPictureFull: ().  % if a background picture is used, then it is resized to use the full button area (default value)     disableBackGroundPictureFull: ().  % in this case, PictureClip and backgroundclip are used         setBackGroundPictureClip: (rct) procedure (i). % defines the part of the picture...     setBackGroundClip: (rct) procedure (i). % ... that will be displayed in the part of the button defined here         setTextColor                 : (color)    procedure (i). % color of the text (Default is White)     setTextSize                   : (integer) procedure (i). % Size of the font     setTextFontName           : (string)   procedure (i). % Fontname         enableCenterText          : (). % if defined (default value) then the text is displayed at the center of the button     disableCenterText         :().    % if disable, then 'setTextPosition' is used to point the position     setTextPosition              : (pnt) procedure (i).               enableShadow               : (). % if used, then a shadow of the char is displayed - in the color of settextShadowcolor     disableShadow              : (). % disable the shadow display     setTextShadowColor      : (color)    procedure (i). % sets the color of the shadow (you may use a black text, with a white shadow on deep blue         enableTwoStates           :(). % if set, the button is a toggle button     disableTwoStates          :(). % (default) simple push button     getButtonState              :() -> boolean. % returns true if the button is pressed - false if not.     setButtonState              :(boolean). % sets the button state         setCallBack                  : (ebuttonCallback) procedure (i). % defines the predicate to evaluate on a click

Posted: 2 May 2007 23:10
by Thomas Linder Puls
Very interesting.

But I have two suggestions.

1. I can see that you set border=false in the about dialog, but I don't ever think that a button should have a border. So I would set the border false inside the button itself:

Code: Select all

clauses     new():-         userControlSupport::new(),         generatedInitialize(),         localInitialize(),         setBorder(false).
2. I also think it would be a good idea if your button supported the standard button interface:

Code: Select all

interface ebutton supports button     open core, vpiDomains ...
But this of course gives a little extra burden in supporting click responder, and the validateOnClick stuff. The code for this can most likely be taken directly from the standard button.

Posted: 3 May 2007 2:22
by Paul Cerkez
very interesting. I was looking at doing something similar. Looks like you beat me to it.

Back in he PDC 4.x days, I used a 3rd Party tool called WinWidgets to do the same thing. I got the idea to create a VIP version of the WinWidgets-like capabilities.

one capability that I was really interested in building was a so called photo button. Every time you clicked the button, the button's background photo would change. The developer built a list of photos associated with that button and each click would cycle the to the next one in the list. It was real handy for helping the user know what was selected or not. VIP does it now within the control but your are limited to depressed, up and disabled (unless you do owner draw). This tool allowed any number of photos.

Posted: 3 May 2007 6:12
by Gildas Menier
Hi Thomas,

The setBorder is a good idea, but as soon as you've decided you need a border at the object creation, you can't change it later. Since it can be interesting to have this choice (for the toggle button for instance), I had the feeling I should let the user decide.

I do agree with the support of the button interface. I am working on it. It is not fully functionnal yet - but since I do not know when it will be, I just post this quick-and-dirty package as it is. I think it is usable anyway.

I cannot remember exactly but at Faro, someone, somehow (sorry I cannot remember who) mentionned an interesting feature (for VP7 ?) : using a special convention for the naming of predicates (for instance 'setBackgroundColor') you can add an item into the property table in the IDE. And this is a good idea to let the user enter some property instead of 'calling' initialization predicates. Do you have more info ?

I think, the code expert should offer more mouse event handling. I think of 'mouse entering', 'mouse leaving'. This could be used for floating tooltip or kind-of rollover button. I should dig in the native message, but I think this could be added to the code expert.

Hi Paul,

Feel free to build on this code (and of course, share it with us :D ).

Best regards


Posted: 3 May 2007 11:41
by Paul Cerkez

Posted: 11 May 2007 9:00
by Gildas Menier
Updated custom Buttons :

- Click timeout : If you press a button, keep it pressed and leave the button area, no mouseUp event is generated. So I added a timer to provide a mouseUp event triggered if necessary.

- Effect callback :

Code: Select all

ebutton_effect1_ctl:setEffectCallBack(1000, effectTime),
you can now add animation to your button. The previous code line triggers an evaluation of 'effectTime' each 1000ms. The code can be used to change color or background (and animate the button's display).

- Styles : you can now use (and make your own) presets. For instance :

Code: Select all

make a button's label blink.

The project includes some style examples :
ebsyle_clock : use the time format in new("...") to get an animated clock in the button.
ebstyle_blink : make the button blink
ebstyle_scroll : scrolling text
ebstyle_pulse and rainbowpulse : make the background pulse.

Best Regards


Posted: 20 May 2007 22:01
by Gildas Menier
Updated - starting V1.0

- The main button interface is now supported (Not really 'validate' yet, but next release will include it). At least the clickresponder is fully supported.
- The predicates names have been changed.
- The property IDE is now used for most of the properties (see the screenshot).

Some suggestions : it seems that the compiler detects basic types such as string or boolean to add access to the property editor. It could be great to add a detection of 'color' and trigger a call to the color dialog editor - to fill the field with a color square (?). Samewise, a choice-list detecting a domain with functors of arity zero (a kind of enumerate) could be great for the IDE property box.
The code expert doesn't seems to be used for the customControls. There is perhaps something to think about there. What about adding an icon in the IDE toolbox for each new customControl detected ?

- added a 'configTo' predicate to 'clone' a button config.
- can make flat buttons (without borders)
- changed default to match the standard visual prolog button.

a more 'elaborate' (!...) documentation :



Posted: 21 May 2007 7:18
by Thomas Linder Puls
Good suggestions; we have considered most of them already, and we surely will do something in this area. When we do we will take your suggestions into account.

Posted: 3 Jun 2007 10:56
by Gildas Menier
V1.2. Now supports a different image/color when the mouse button is pressed (see the switch). More support for the property editor (for instance, some style preset can be set from within the UI editor). Added eLabel that provides the same for the labels. You can now include the pictures as ressources in the code. Some backgrounds included (etc...)



Posted: 10 Jun 2007 17:58
by Gildas Menier
V1.3. Thanks to the 'require' tip (thank you Thomas), you can now easily use this package in your project (just add the ui_ext.pack to your project and answer 'add all' for the ressources)

This version features a mask support : you can define buttons with different shapes - not only squares (see the green push-button and the 'aqua-like' styles) as well as pictures or label with 'transparent' parts - that let you see the background color. The default uses now the system background color. Fixed some minor bugs. I've added a small clock as custom control.

I don't think I will update this package soon, because it now has the features I was looking for;
but let me know if you find a bug so I can fix it (or try).

Best regards


Posted: 15 Jun 2007 13:53
by Gildas Menier
V1.4 : Fixed some bugs (and cleaned the code. This version should be ready if PDC decide to include the management of color attributes in the GUI wizard).

The new feature is that you can decide which part of the picture has to be resized (see the picture). Practically, you can now resize 'theme' button without having kind-of-distortion of the background image.

Posted: 12 Nov 2007 19:11
by Thomas Linder Puls
Hi, Gildas.

I think it would be a good idea if you created an article about this package in the wiki, in the "3rd" namespace.

eButton VP7.3

Posted: 23 Mar 2012 15:36
by Tonton Luc

I try to migrate my VP7.2 ebutton package to VP7.3 and I've this error :
see also c264 : No implementation for the property 'button::defauktHeight/0 (o)' in the class 'ebutton'
How to solve this problem ?

Posted: 25 Mar 2012 16:55
by Thomas Linder Puls
I believe you should mimic the corresponding code in button.

custom buttons

Posted: 18 Jul 2012 4:49
by David Harris
I'd really like to use the features described by Glidas Menier for custom buttons and labels. However, it seems not much has happened since 2004. The write-up suggests going to the site but if you try you get a message that the site is not available. Any suggestions.