osoko / maxmods

Automatically exported from code.google.com/p/maxmods
2 stars 0 forks source link

Feature request: support for BUTTON_PUSH|BUTTON_CHECKBOX and BUTTON_PUSH|BUTTON_RADIOBUTTON styles #14

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Create a button with the style BUTTON_PUSH|BUTTON_CHECKBOX or
BUTTON_PUSH|BUTTON_RADIOBUTTON.
2. Click the button. It does not stay depressed as would be expected if the
style combination were supported.

What is the expected output? What do you see instead?
The button should look like a normal button (as it currently does) but stay
depressed when clicked, and if a radio button, other buttons in the group
should become deselected when it is selected.

What version of the product are you using? On what operating system?
Most recent GtkMaxGui, BlitzMax, and MaxGui on Arch Linux.

Original issue reported on code.google.com by beta.da...@gmail.com on 2 Jan 2010 at 1:56

GoogleCodeExporter commented 9 years ago
...yet again I fix it myself. 

In TGTKGUIDriver's CreateGadget method, change the case for GADGET_BUTTON to 
the following:

            Case GADGET_BUTTON
                gtkclass = GTK_BUTTON
                Select(style)
                    Case BUTTON_RADIO,BUTTON_RADIO|BUTTON_PUSH
                        gtkclass = GTK_RADIOBUTTON
                    Case BUTTON_CHECKBOX,BUTTON_CHECKBOX|BUTTON_PUSH
                        gtkclass = GTK_CHECKBUTTON
                    Case BUTTON_OK
                    Case BUTTON_CANCEL
                    Case BUTTON_PUSH
                End Select

And in gtkgadget.bmx, change TGTKButtonRadio;s CreateButton function to look 
like this:

    Function CreateButton:TGTKButtonRadio(x:Int, y:Int, w:Int, h:Int, label:String, group:TGadget, 
style:Int)
        Local this:TGTKButtonRadio = New TGTKButtonRadio

        this.initButton(x, y, w, h, label, group, style)
        If(style & BUTTON_PUSH)
            gtk_toggle_button_set_mode(this.handle,false)
        EndIf

        Return this
    End Function

and TGTKButtonCheckbox's CreateButton function to look like this:

    Function CreateButton:TGTKButtonCheckbox(x:Int, y:Int, w:Int, h:Int, label:String, group:TGadget, 
style:Int)
        Local this:TGTKButtonCheckbox = New TGTKButtonCheckbox

        this.initButton(x, y, w, h, label, group, style)
        If(style & BUTTON_PUSH)
            gtk_toggle_button_set_mode(this.handle,false)
        EndIf

        Return this
    End Function

One last this is to add the definition of gtk_toggle_button_set_mode to the 
file gtkcommon.bmx. The line 
to insert there (I put it on line 135) is:

    Function gtk_toggle_button_set_mode(widgetPtr:Byte Ptr, bool:Int)

The buttons now look and behave correctly.

Original comment by beta.da...@gmail.com on 20 Apr 2010 at 3:10