PageRenderTime 27ms CodeModel.GetById 24ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

/src/wrappers/gtk/examples/style/style_demo.e

http://github.com/tybor/Liberty
Specman e | 114 lines | 58 code | 27 blank | 29 comment | 0 complexity | 372acc9fca4ed7e1d603f171024f9649 MD5 | raw file
  1class STYLE_DEMO
  2
  3insert
  4	ANY
  5	GTK
  6	GTK_STATE_TYPE
  7	PANGO_CONSTANTS
  8	PANGO_WRAP_MODE
  9
 10creation
 11	make
 12
 13feature
 14
 15	on_delete_event (a_gtk_object: GTK_OBJECT) is
 16		do
 17			gtk.quit
 18		end
 19
 20
 21
 22	make is
 23		local
 24			style: GTK_STYLE
 25			pixbuf: GDK_PIXBUF
 26			pixmap: GDK_PIXMAP
 27			gc: GDK_GC
 28			color: GDK_COLOR
 29			layout: PANGO_LAYOUT
 30			msg, font, fgcolor: STRING
 31			size: TUPLE [INTEGER, INTEGER]
 32			live_width, live_height: INTEGER
 33			scale: REAL
 34		do
 35			gtk.initialize
 36			create window.make
 37			window.set_default_size (280, 190)
 38			window.connect_agent_to_destroy_signal (agent on_delete_event)
 39
 40			create label.with_label ("Hello World!")
 41
 42			window.set_border_width (20)
 43
 44			window.add (label)
 45
 46			window.show_all
 47
 48			style := window.style
 49
 50			create pixbuf.from_file("cartman.png")
 51
 52			pixmap := pixbuf.render_pixmap_and_mask (0).first
 53
 54			create gc.make (pixmap)
 55
 56			pixmap.draw_line (gc, 5, 10, 10, 30)
 57			create color.make
 58			color.set_red (65535)
 59			gc.set_rgb_fg_color (color)
 60
 61			pixmap.draw_rectangle (gc, False, 35, 9, 10, 5)
 62
 63			color.set_green (5535)
 64			color.set_red (5535)
 65			gc.set_rgb_fg_color (color)
 66
 67			pixmap.draw_point (gc, 0, 0)
 68
 69			pixmap.draw_arc (gc, False, 5, 38, 38, 10, 0, 11520)
 70
 71			live_width := 1024
 72			live_height := 768
 73
 74			msg := "Arrepentidos ahora que estais a tiempo, hijos de Hebron"
 75
 76			font := "Arial 12 Bold"
 77
 78			fgcolor := "#ff0000"
 79
 80			layout := window.create_pango_layout ("")
 81
 82			layout.set_width (live_width)
 83
 84			layout.set_wrap (pango_wrap_word_char)
 85			layout.set_markup ("<span foreground='" + fgcolor + "' font_desc='" + font + "'>" + msg + "</span>")
 86
 87			size := layout.size
 88
 89			create pixbuf.make (True, size.first // pango_scale, size.second // pango_scale)
 90
 91			--pixbuf.fill (0)
 92
 93			pixmap := pixbuf.render_pixmap_and_mask (0).first
 94
 95			pixmap.draw_layout (gc, 0, 0, layout)
 96
 97			create pixbuf.from_drawable (pixmap, 0, 0, pixmap.width, pixmap.height)
 98			
 99			scale := (pixbuf.width * 100) / live_width -- Esto no funciona si el layout es m??s apaisado que el viewer
100			
101			-- previewer.set_overlay (pixbuf, scale, 50, 50)
102
103			style.set_background_pixmap (pixmap, gtk_state_normal)
104
105			gtk.run_main_loop
106
107		end
108
109	window: GTK_WINDOW
110
111	label: GTK_LABEL
112
113
114end -- class STYLE_DEMO