indexing description: "[ Exhibit box that shows how to use text-boxes ]" author: "" date: "$Date$" revision: "$Revision$" class EXHIBIT_TEXT_BOX inherit EXHIBIT_BOX create make feature -- Access title: STRING is -- Title of exhibit "Text Boxes" description: STRING is -- Description "The text inside a text box can be aligned vertically and horizontally. Additionally, % %line-wrapping can be disabled or enabled.%N% %It's probably useful to turn on debugging hints to show the bounding boxes. Just press `d' to do so.%N% %Also notice the effects of point-snapping (Toggle by pressing `p').%N% %" wrap, nowrap, align_tl, align_cc, align_br, align_uu: EM_VIZ_TEXT_BOX -- Text boxes feature -- Manufacturing create_exhibit is -- Create content for exhibit local vbox: EM_VIZ_VERTICAL_BOX [EM_VIZ_BOX] do create vbox.make create nowrap.make_auto_sized ( "This is a text box with line-wrapping disabled.%N% %Manual line breaks are still possible, though.%N% %Just insert a %Nnew-line character at the desired position in the string.", Viz_options.code_font_format ) create wrap.make ( [500.0, 0.0, 0.0], "This is a text box with line-wrapping enabled. The initial size is 500 points. % %Here's some more text to see how it breaks up. And some more and more and more. Still not enough? Here's more.", Viz_options.text_font_format ) create align_tl.make ( [exhibit_inner_width, 0.0, 0.0], "This text is aligned to the top and to the left, which is the default alignment for text.", Viz_options.code_font_format ) create align_cc.make ( [exhibit_inner_width, 0.0, 0.0], "This text is aligned to the center, both vertically and horizontally. % %Vertical alignment only makes sense if the height of the text box is set by % %the user. If the height is determined by the text, there's no difference.", Viz_options.text_font_format ) align_cc.set_alignment ([Align_center, Align_center, Align_front]) create align_br.make ( [exhibit_inner_width, 0.0, 0.0], "This text is aligned to the right and to the bottom.%N% %Right?", Viz_options.code_font_format ) align_br.set_alignment ([Align_right, Align_bottom, Align_front]) create align_uu.make ( [exhibit_inner_width, 0.0, 0.0], "Text aligned with Align_user_specified is usually left-justified horizontally.%N% %In the vertical direction, the first base-line is aligned with the upper bounding-line.", Viz_options.text_font_format ) align_uu.set_alignment ([Align_user_specified, Align_user_specified, Align_front]) -- Assemble vbox.put_last (nowrap) vbox.put_last (wrap) vbox.put_last (align_tl) vbox.put_last (align_cc) vbox.put_last (align_br) vbox.put_last (align_uu) -- Exhibit vertically grouped text-boxes exhibit := vbox end feature -- Animation animate_align_boxes (a_time: INTEGER) is -- Animate text boxes (set height dynamically) local cslow, c: DOUBLE do cslow := cosine (a_time / 10000.0) c := cosine (a_time / 1000.0) align_tl.set_width (exhibit_inner_width*(cslow+5)/6) align_cc.set_width (exhibit_inner_width*(cslow+5)/6) align_br.set_width (exhibit_inner_width*(cslow+5)/6) align_uu.set_width (exhibit_inner_width*(cslow+5)/6) align_tl.set_height (exhibit_inner_height*(c+2)/18) align_cc.set_height (exhibit_inner_height*(c+2)/18) align_br.set_height (exhibit_inner_height*(c+2)/18) align_uu.set_height (exhibit_inner_height*(c+2)/18) end go_to_time (a_time: INTEGER) is -- Animate exhibit do animate_align_boxes (a_time) end end