123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081(*********************************************************************************)(* OCaml-Stk *)(* *)(* Copyright (C) 2023-2024 INRIA All rights reserved. *)(* Author: Maxence Guesdon, INRIA Saclay *)(* *)(* This program is free software; you can redistribute it and/or modify *)(* it under the terms of the GNU General Public License as *)(* published by the Free Software Foundation, version 3 of the License. *)(* *)(* This program is distributed in the hope that it will be useful, *)(* but WITHOUT ANY WARRANTY; without even the implied warranty of *)(* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *)(* GNU General Public License for more details. *)(* *)(* You should have received a copy of the GNU General Public *)(* License along with this program; if not, write to the Free Software *)(* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA *)(* 02111-1307 USA *)(* *)(* As a special exception, you have permission to link this program *)(* with the OCaml compiler and distribute executables, as long as you *)(* follow the requirements of the GNU GPL in regard to all of the *)(* software in the executable aside from the OCaml compiler. *)(* *)(* Contact: Maxence.Guesdon@inria.fr *)(* *)(*********************************************************************************)(** Fixed-size widget. *)(** A [fixed_size] widget is a {!Bin.class-bin} widget whose width and
height can be fixed. *)classfixed_size?classes?name?props?wdata?w?h()=object(self)inheritBin.bin?classes?name?props?wdata()assuper(**{3 Properties} *)methodset_heighth=self#set_pProps.heighthmethodset_widthw=self#set_pProps.widthw(**/**)methodkind="fixed_size"method!privatewidth_constraints_=letmin=self#widget_min_widthinmatchself#opt_pProps.widthwith|Somewwhenw>=0->Widget.size_constraints_fixed(min+w)|_->letc=self#child_width_constraintsinWidget.add_to_size_constraintscminmethod!privateheight_constraints_=letmin=self#widget_min_heightinmatchself#opt_pProps.heightwith|Somehwhenh>=0->Widget.size_constraints_fixed(min+h)|_->letc=self#child_height_constraintsinWidget.add_to_size_constraintscmininitializer(* modify props here rather than before object(self) so
that they have been duplicated in widget init *)let()=matchwwithNone->()|Somew->Props.setpropsProps.widthwinlet()=matchhwithNone->()|Someh->Props.setpropsProps.heighthin()endtypeWidget.widget_type+=Fixed_sizeoffixed_size(** Convenient function to create a {!class-fixed_size}.
[w] and [h] optional arguments specify width and height.
See {!Widget.widget_arguments} for other arguments. *)letfixed_size?classes?name?props?wdata?w?h?pack()=letw=newfixed_size?classes?name?props?wdata?w?h()inw#set_typ(Fixed_sizew);Widget.may_pack?packw#coerce;w