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

Attachments

A screenshot of the included example

buttons.jpg (154.56 KiB) Viewed 22404 times

Last edited by Gildas Menier on 15 Jun 2007 13:48, edited 5 times in total.

Gildas,
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.

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.

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 :

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.

- 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 ?

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...)

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.

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.

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 http://www.arsaniit.com/vp_tools/buttons.htm but if you try you get a message that the site is not available. Any suggestions.