class RotatedTextDemo
Pango/Rotated Text¶ ↑
This demo shows how to use PangoCairo to draw rotated and transformed text. The right pane shows a rotated GtkLabel widget. In both cases, a custom PangoCairo shape renderer is installed to draw a red heard using cairo drawing operations instead of the Unicode heart character.
Constants
- FONT
- HEART
- N_WORDS
- RADIUS
- TEXT
Public Class Methods
new(main_window)
click to toggle source
# File gtk3/sample/gtk-demo/rotated_text.rb, line 21 def initialize(main_window) @window = Gtk::Window.new(:toplevel) @window.screen = main_window.screen @window.title = "Rotated Text" @window.set_default_size(4 * RADIUS, 2 * RADIUS) box = Gtk::Box.new(:horizontal, 0) box.homogeneous = true @window.add(box) # Add adrawing area drawing_area = Gtk::DrawingArea.new box.add(drawing_area) drawing_area.style_context.add_class("view") drawing_area.signal_connect "draw" do |widget, cr| translate_and_scale(widget, cr) add_gradient(cr) layout = initialize_da_pango_layout(widget) draw_the_rotated_texts(cr, layout) false end # And a label label = Gtk::Label.new(TEXT) box.add(label) label.angle = 45 # Set up fancy stuff on the label layout = label.layout layout.context.set_shape_renderer do |cr, attr, do_path| fancy_shape_renderer(cr, attr, do_path) end label.attributes = create_fancy_attr_list_for_layout(layout) end
Public Instance Methods
run()
click to toggle source
# File gtk3/sample/gtk-demo/rotated_text.rb, line 62 def run if !@window.visible? @window.show_all else @window.destroy end @window end