SpecialButtons Library

derez

Expert
Licensed User
Longtime User
Here is a collection of special buttons, some new and some modified.
These are:
1. Circle button - new
2. Ellipse button - new
3. Poligon button - new
4. Rectangle button - new
5. Slide button - existing
6. State button - upgraded

The circle and ellipse buttons came out quite ugly so I added a constructor to eliminate the surrounding line.

The library works for desktop and device and tested on qvga and vga with autoscale compilation.

The package includes dll, cs file, demo program and help file.

Edit: ver. 1.1 includes transparency over images.
ver. 1.2 improves transparency, upgrades SlideButtonb to have graphics like RectangleButton, correct errors.
1.2A - added the forgottemn methods to change colors.
ver 1.3 - FillColor removed from New2
ver 1.4 - SetSliderWidth method added to SlideButton.
ver 1.5 - rounded corners are now set by int - 0 no rounding, 1- slightly, 2- cut.
- A converter program to convert regular buttons to RectangleButtons.
ver 1.61 - enables vertical text on Ellipse, Rectangle and State Buttons, see form4 picture here.

Edit: ver 1.7 corrected mulfunction of mousedown and mouseup events.

Enjoy :)
 

Attachments

  • converter.sbp
    1.8 KB · Views: 147
  • sb.jpg
    sb.jpg
    73.9 KB · Views: 246
  • SpecialButtons_1.7.zip
    28.1 KB · Views: 68
Last edited:

derez

Expert
Licensed User
Longtime User
Transparency over images

following a tip from Erel I updated the library so the rectangle holding the button is transparent if an image is set as background of a form.
 

tremara1

Active Member
Licensed User
Longtime User
array problem

Hi guys, I have been away for a while and have been getting back into it. This library looks cool and I am keen to try it on my new HTC Touch but I must have missed something in the update to 6.90 as my current ver 6.8 is not handling the dim of the array for poligon. If I comment out the 'as integer' it does not crash (cannot be null value) but the array is not working in the creation of the poligon button. I have probably missed something simple...DOH!!

ps. I will be excited to get my hands on a b4ppc for android....thanks

Trevor
Ballarat Victoria Australia
 

tremara1

Active Member
Licensed User
Longtime User
I see now

I just had a look at the 6.9 'essentials' and see that dim of variables has changed.....update coming soon...thanks
Trevor Smith
Ballarat Victoria Australia
 

derez

Expert
Licensed User
Longtime User
Ver 1.2

Version 1.2 is now loadable at the first post.
I corrected few errors, changed the SlideButton to have graphics like the RectangleButton and improved the transparency of Rectangle, Slide & State Buttons over images.

Please report problems if you see any, I'm sure there are still some.:)
 

derez

Expert
Licensed User
Longtime User
Ver 1.3 is updated.
I removed FillColor from New2, FillColor and EndColor are united.
 

derez

Expert
Licensed User
Longtime User
Ver 1.5 - two levels of rounded corners - 1 is new, 2 is as before. 0 for not rounded at all.

I think it is a stable version and I won't change it unless I hear comments or requests.
 

Attachments

  • Rounded 1.jpg
    Rounded 1.jpg
    33.8 KB · Views: 84
Last edited:

derez

Expert
Licensed User
Longtime User
a converter program, to convert regular buttons to RectangleButtons, is added to the first post.
It simplifies the visual design - you can place regular buttons using the IDE, then convert them to RectangleButtons using the converter.
The new definitions are stored in a "buttons.txt" file.
 

derez

Expert
Licensed User
Longtime User
Version 1.6 enables vertical text to be displayed on Ellipse, Rectangle and State buttons, with SetVertical method added.

Edit: Forgot about autoscale in the vertical buttons. Corrected in 1.61.
 

Attachments

  • vertical.jpg
    vertical.jpg
    13.5 KB · Views: 23
Last edited:

Sir Isaac

Member
Can you possibly split the cs file?

I wonder if the cs file (of some 100 kB) can be split into single functional units (say, just "rounded buttons", and no more additional beauties) and distributed along with the complete lib here. This seems quite reasonable, from minimalists' viewpoint.
 

pdabasic

Active Member
Licensed User
Hy Derez!

First of all, Thank you for this fantastic collection.

I tried to set my rectanglebutton width programaticaly:
B4X:
Object("doorCrtlProp").FromControl(Rectanglebutton("lblHelloRectangle").ControlRef)
Object("doorCrtlProp").SetProperty("Width","200")

But always get an error message:
!!!Invalied property!!!

Please tell me why!
 

pdabasic

Active Member
Licensed User
I think this is not the sexiest way ;) :
B4X:
Select ctrlType
      Case "Fggradientbuttons"
         Object("doorCrtlProp").FromControl(Fggradientbuttons(ctrlName).ControlRef) 'Everything works fine
      Case "Rectanglebutton"
         If propName="Text" Then
            Rectanglebutton(ctrlName).Text=propVal
         Else If propName="Left" Then
            Rectanglebutton(ctrlName).Left=propVal
         Else If propName="Top" Then
            Rectanglebutton(ctrlName).Top=propVal
         Else If propName="Width" Then
            Rectanglebutton(ctrlName).Width=propVal
         Else If propName="Height" Then
            Rectanglebutton(ctrlName).Height=propVal
         Else If propName="BringToFront"
            Rectanglebutton(ctrlName).BringToFront
         Else If propName="Visible"
            Rectanglebutton(ctrlName).Visible=propVal
         End If
...
 
MouseDown event not working?

I tried to add a "ButtonDown" event, which in this library is named "MouseDown".

What am I doing wrong, so that I have this message:

Object of type 'System.EventHandler' cannot be converted to type 'System.Windows.Forms.MouseEventHandler'.

The "click" event works ok, but this one works by you?

Thank you in advance for any helpful answer.

B4X:
Sub Globals
End Sub
Sub App_Start
 Form1.Show
 rb3.New1("form1","RB3",150,40,80,30,cWhite,cBlack,1)
End Sub
Sub rb3_mousedown
 Msgbox("Click")
End Sub

This one will give above mentioned error pointing the line "rb3.new1..."
 

agraham

Expert
Licensed User
Longtime User
I'm afraid it's a bug in the library. The Basic4ppc MouseDown and MouseUp events are incorrectly declared as MouseEventHandlers where they should be declared as plain EventHandlers.

The library itself has to have MouseEventHandlers to receive those events but it should pass them on to Basic4ppc as ordinary Events and not MouseEvents.
 

derez

Expert
Licensed User
Longtime User
Agraham
I understand but I don't know how to correct it.
I have event declarations under the class:
B4X:
public event EventHandler Click; 
private object[] eventObject; 
public event System.Windows.Forms.MouseEventHandler MouseDown;
private object[] eventObject1;
public event System.Windows.Forms.MouseEventHandler MouseUp; 
private object[] eventObject2;

and the events :
B4X:
private void gb_Click(Object sender, EventArgs e) 
{
   gb.Image = bmpup ;
   if (Click != null)
         Click(eventObject,null);
}

private void gb_MouseDown(Object sender, System.Windows.Forms.MouseEventArgs ed) 
{
   xpress =  width/2 - ed.X;
   ypress =  height/2 - ed.Y ;
   gb.Image = bmpdn ;
   if (MouseDown != null)
      MouseDown(eventObject1,null);
}

private void gb_MouseUp(Object sender, System.Windows.Forms.MouseEventArgs eu) 
{
   gb.Image = bmpup ;
   if (MouseUp != null)
      MouseUp(eventObject,null);
}

Can you show me how to correct it ?
Thanks
 
Top