The Birdfont Source Code


All Repositories / birdfont.git / blob – RSS feed

MessageDialog.vala in libbirdfont

This file is a part of the Birdfont project.

Contributing

Send patches or pull requests to johan.mattsson.m@gmail.com.
Clone this repository: git clone https://github.com/johanmattssonm/birdfont.git

Revisions

View the latest version of libbirdfont/MessageDialog.vala.
Ignore case in key bindings
1 /* 2 Copyright (C) 2014 Johan Mattsson 3 4 This library is free software; you can redistribute it and/or modify 5 it under the terms of the GNU Lesser General Public License as 6 published by the Free Software Foundation; either version 3 of the 7 License, or (at your option) any later version. 8 9 This library is distributed in the hope that it will be useful, but 10 WITHOUT ANY WARRANTY; without even the implied warranty of 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 Lesser General Public License for more details. 13 */ 14 15 using Cairo; 16 17 namespace BirdFont { 18 19 public class MessageDialog : Dialog { 20 21 Button ok_button; 22 TextArea message; 23 24 public MessageDialog (string message) { 25 Color c = Theme.get_color ("Text Tool Box"); 26 this.message = new TextArea (20 * MainWindow.units, c); 27 this.message.set_text (message); 28 this.message.draw_border = false; 29 this.message.editable = false; 30 this.message.carret_is_visible = false; 31 this.message.min_width = 300 * MainWindow.units; 32 this.message.width = this.message.min_width; 33 this.message.min_height = 20 * MainWindow.units; 34 this.message.height = this.message.min_height; 35 36 ok_button = new Button (t_("Close")); 37 ok_button.action.connect (() => { 38 MainWindow.hide_dialog (); 39 }); 40 } 41 42 public override void draw (Context cr) { 43 double cx, cy; 44 double width, height; 45 46 message.layout (); 47 48 width = message.get_width (); 49 height = message.get_height (); 50 height += ok_button.get_height (); 51 height += 5 * MainWindow.units; 52 53 cx = (allocation.width - width) / 2.0; 54 cy = (allocation.height - height) / 2.0; 55 56 cr.save (); 57 Theme.color_opacity (cr, "Foreground 1", 0.3); 58 cr.rectangle (0, 0, allocation.width, allocation.height); 59 cr.fill (); 60 cr.restore (); 61 62 cr.save (); 63 Theme.color (cr, "Dialog Background"); 64 draw_rounded_rectangle (cr, cx, cy, width, height, 10 * MainWindow.units); 65 cr.fill (); 66 cr.restore (); 67 68 cr.save (); 69 Theme.color (cr, "Foreground 1"); 70 cr.set_line_width (1); 71 draw_rounded_rectangle (cr, cx, cy, width, height, 10 * MainWindow.units); 72 cr.stroke (); 73 cr.restore (); 74 75 cy += 5 * MainWindow.units; 76 message.widget_x = cx + 10 * MainWindow.units; 77 message.widget_y = cy; 78 message.allocation = allocation; 79 message.layout (); 80 message.draw (cr); 81 82 ok_button.widget_x = cx + 10 * MainWindow.units; 83 ok_button.widget_y = cy + message.get_height (); 84 ok_button.draw (cr); 85 } 86 87 public override void button_press (uint button, double x, double y) { 88 ok_button.button_press (button, x, y); 89 } 90 91 public override void button_release (uint button, double x, double y) { 92 ok_button.button_release (button, x, y); 93 } 94 } 95 96 } 97