comp.lang.ada
 help / color / mirror / Atom feed
From: "Jeffrey R.Carter" <spam.jrcarter.not@spam.acm.org.not>
Subject: Re: Gtk in ada using radiobuttons
Date: Mon, 17 Oct 2022 10:18:13 +0200	[thread overview]
Message-ID: <tij346$3d8sm$1@dont-email.me> (raw)
In-Reply-To: <87sfjnpgak.fsf@samuel>

On 2022-10-17 00:14, Ludovic Brenta wrote:
> "Jeffrey R.Carter" <spam.jrcarter.not@spam.acm.org.not> writes:
>>
>> I know of no reason why the client of a GUI library would ever create
>> a single, independent radio button.  A single radio button is useless.
>> One always wants to create a set of linked buttons.
> 
> Yes but you create the radio buttons one at a time, so one of the
> buttons must be the first you create.

This may be necessary at a low level in the GUI, but there's no reason why the 
client-interface pkg of a library can't provide a higher-level interface. 
Consider the equivalent from Ada GUI 
(https://github.com/jrcarter/Ada_GUI/blob/master/ada_gui.ads):

    type Text_List is array (Positive range <>) of
       Ada.Strings.Unbounded.Unbounded_String
    with
       Dynamic_Predicate => Text_List'First = 1;

    type Orientation_ID is (Horizontal, Vertical);

    function New_Radio_Buttons (Row          : Positive := 1;
                                Column       : Positive := 1;
                                Label        : Text_List;
                                Break_Before : Boolean        := False;
                                Orientation  : Orientation_ID := Vertical)
    return Widget_ID with Pre => Set_Up and Label'Length > 1;
    -- Creates Label'Length radio buttons; Label contains the labels for the
    -- buttons
    -- Orientation = Horizontal results in a row of buttons
    --             = Vertical   has each button after the 1st below the preceding
                                buttons
    -- The button for Label'First will be active
    -- The operations Set_Active and Active for radio buttons take an Index;
    -- Index will refer to the button for Label (Index)

An implementation based on, say, GTK, will have to create the buttons 
individually as the GUI requires, but the client doesn't have to deal with that.

-- 
Jeff Carter
"The men get one hot meal a day: a bowl of steam."
Take the Money and Run
145


  parent reply	other threads:[~2022-10-17  8:18 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-15 14:28 Gtk in ada using radiobuttons ldries46
2022-10-15 15:58 ` Ludovic Brenta
2022-10-16 20:09   ` Jeffrey R.Carter
2022-10-16 22:14     ` Ludovic Brenta
2022-10-17  7:27       ` ldries46
2022-10-17 11:18         ` Ludovic Brenta
2022-10-17 11:22         ` Ludovic Brenta
2022-10-17  8:18       ` Jeffrey R.Carter [this message]
2022-10-16 16:43 ` ldries46
2022-10-16 20:12   ` Jeffrey R.Carter
2022-10-17  6:56     ` ldries46
2022-10-17 11:17       ` Ludovic Brenta
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox