From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on ip-172-31-65-14.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-3.2 required=3.0 tests=BAYES_00,NICE_REPLY_A, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 Path: eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail From: "Jeffrey R.Carter" Newsgroups: comp.lang.ada Subject: Re: Gtk in ada using radiobuttons Date: Mon, 17 Oct 2022 10:18:13 +0200 Organization: A noiseless patient Spider Message-ID: References: <875yglqdtj.fsf@samuel> <87sfjnpgak.fsf@samuel> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Mon, 17 Oct 2022 08:18:14 -0000 (UTC) Injection-Info: reader01.eternal-september.org; posting-host="55607fdfa719fa76daf25f21221b219d"; logging-data="3580822"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18HVQzIdj5IRxbFnXkQHdrYhJKyPvjTqr8=" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.2.2 Cancel-Lock: sha1:kXew2fDJlX7z/XE9u/ljS53EPEU= In-Reply-To: <87sfjnpgak.fsf@samuel> Content-Language: en-US Xref: reader01.eternal-september.org comp.lang.ada:64515 List-Id: On 2022-10-17 00:14, Ludovic Brenta wrote: > "Jeffrey R.Carter" 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