FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister   ProfileProfile   Log inLog in 


Custom Buttons & custom Labels - updated 1.4

Post new topic   Reply to topic    discuss.visual-prolog.com Forum Index -> Visual Prolog Tips & Samples
View previous topic :: View next topic  
Author Message
Gildas Menier




Joined: 08 Jun 2004
Posts: 210

PostPosted: 2 May 2007 21:19    Post subject: Custom Buttons & custom Labels - updated 1.4 Reply with quote

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

Gildas

ps : As always (! Rolling Eyes), 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 : http://www.arsaniit.com/vp_tools/buttons.htm

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




buttons.jpg
 Description:
A screenshot of the included example
 Filesize:  154.56 KB
 Viewed:  20247 Time(s)

buttons.jpg




Last edited by Gildas Menier on 15 Jun 2007 13:48; edited 5 times in total
Back to top
View user's profile Send private message
Thomas Linder Puls



Copenhagen, Denmark
Joined: 28 Feb 2000
Posts: 3124

PostPosted: 2 May 2007 23:10    Post subject: Reply with quote

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:

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:

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.

_________________
Regards Thomas Linder Puls
Prolog Development Center
Back to top
View user's profile Send private message
Paul Cerkez



Lexington Park MD, USA
Joined: 06 Mar 2000
Posts: 619

PostPosted: 3 May 2007 2:22    Post subject: Reply with quote

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.

_________________
AI Rules!
P.
Back to top
View user's profile Send private message
Gildas Menier




Joined: 08 Jun 2004
Posts: 210

PostPosted: 3 May 2007 6:12    Post subject: Reply with quote

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

Best regards

Gildas
Back to top
View user's profile Send private message
Paul Cerkez



Lexington Park MD, USA
Joined: 06 Mar 2000
Posts: 619

PostPosted: 3 May 2007 11:41    Post subject: Reply with quote

Very Happy
_________________
AI Rules!
P.
Back to top
View user's profile Send private message
Gildas Menier




Joined: 08 Jun 2004
Posts: 210

PostPosted: 11 May 2007 9:00    Post subject: Reply with quote

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 :

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 :

ebutton12_ctl:setStyle(ebstyle_blink::new())

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

Gildas



buttons.jpg
 Description:
 Filesize:  126.42 KB
 Viewed:  20136 Time(s)

buttons.jpg


Back to top
View user's profile Send private message
Gildas Menier




Joined: 08 Jun 2004
Posts: 210

PostPosted: 20 May 2007 22:01    Post subject: Reply with quote

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 :

http://www.arsaniit.com/vp_tools/buttons.htm

Regards

Gildas



btn_5.jpg
 Description:
IDE
 Filesize:  82.88 KB
 Viewed:  19865 Time(s)

btn_5.jpg




Last edited by Gildas Menier on 21 May 2007 9:17; edited 2 times in total
Back to top
View user's profile Send private message
Thomas Linder Puls



Copenhagen, Denmark
Joined: 28 Feb 2000
Posts: 3124

PostPosted: 21 May 2007 7:18    Post subject: Reply with quote

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.
_________________
Regards Thomas Linder Puls
Prolog Development Center
Back to top
View user's profile Send private message
Gildas Menier




Joined: 08 Jun 2004
Posts: 210

PostPosted: 3 Jun 2007 10:56    Post subject: Reply with quote

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

Regards

Gildas



buttons.jpg
 Description:
 Filesize:  236.88 KB
 Viewed:  19474 Time(s)

buttons.jpg


Back to top
View user's profile Send private message
Gildas Menier




Joined: 08 Jun 2004
Posts: 210

PostPosted: 10 Jun 2007 17:58    Post subject: Reply with quote

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.

http://www.arsaniit.com/vp_tools/buttons.htm

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

Gildas



buttons.jpg
 Description:
 Filesize:  87.29 KB
 Viewed:  19282 Time(s)

buttons.jpg


Back to top
View user's profile Send private message
Gildas Menier




Joined: 08 Jun 2004
Posts: 210

PostPosted: 15 Jun 2007 13:53    Post subject: Reply with quote

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.



btn_offset.jpg
 Description:
 Filesize:  13.48 KB
 Viewed:  19121 Time(s)

btn_offset.jpg


Back to top
View user's profile Send private message
Thomas Linder Puls



Copenhagen, Denmark
Joined: 28 Feb 2000
Posts: 3124

PostPosted: 12 Nov 2007 19:11    Post subject: Reply with quote

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.

_________________
Regards Thomas Linder Puls
Prolog Development Center
Back to top
View user's profile Send private message
Tonton Luc



FRANCE (Le Touquet)
Joined: 16 Oct 2001
Posts: 1548

PostPosted: 23 Mar 2012 15:36    Post subject: eButton VP7.3 Reply with quote

Hi,

I try to migrate my VP7.2 ebutton package to VP7.3 and I've this error :
Quote:
ui_ext\ebutton\ebutton.pro(6,11)
see also c264 : No implementation for the property 'button::defauktHeight/0 (o)' in the class 'ebutton'

How to solve this problem ?
Back to top
View user's profile Send private message
Thomas Linder Puls



Copenhagen, Denmark
Joined: 28 Feb 2000
Posts: 3124

PostPosted: 25 Mar 2012 16:55    Post subject: Reply with quote

I believe you should mimic the corresponding code in button.
_________________
Regards Thomas Linder Puls
Prolog Development Center
Back to top
View user's profile Send private message
David Harris



Australia
Joined: 14 Jun 2012
Posts: 15

PostPosted: 18 Jul 2012 4:49    Post subject: custom buttons Reply with quote

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.

David

_________________
Delta the Cat
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    discuss.visual-prolog.com Forum Index -> Visual Prolog Tips & Samples All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum