Mercurial > repos > IBBoard.GtkSharp
comparison NotebookUtil.cs @ 30:c9e1ad81afbe
Re #26: Add GTK wrapper methods
* Make notebook tabs closable with middle-click
* Add extra util class with enumerations in - mouse buttons in events are just uint, not enumerated
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Sat, 08 Jan 2011 16:37:41 +0000 |
parents | 0a466c011016 |
children | 50d774f164dd |
comparison
equal
deleted
inserted
replaced
29:bcb437c04685 | 30:c9e1ad81afbe |
---|---|
45 /// <returns> | 45 /// <returns> |
46 /// A <see cref="Widget"/> that can be used as a tab label that contains the label with the title text and a close button | 46 /// A <see cref="Widget"/> that can be used as a tab label that contains the label with the title text and a close button |
47 /// </returns> | 47 /// </returns> |
48 public static Widget CreateNotebookTabLabelWithClose(Notebook notebook, Widget page, String title) | 48 public static Widget CreateNotebookTabLabelWithClose(Notebook notebook, Widget page, String title) |
49 { | 49 { |
50 EventBox eventBox = new EventBox(); | |
50 HBox hbox = new HBox(); | 51 HBox hbox = new HBox(); |
52 eventBox.Add(hbox); | |
53 eventBox.ButtonPressEvent += delegate(object o, ButtonPressEventArgs args) { | |
54 if (args.Event.Button == (uint)MouseButton.Middle) | |
55 { | |
56 notebook.Remove(page); | |
57 } | |
58 }; | |
51 hbox.PackStart(new Label(title)); | 59 hbox.PackStart(new Label(title)); |
52 Button close = new Button(); | 60 Button close = new Button(); |
53 Gtk.Rc.ParseString("style \"NotebookTab.CloseButton\" {\n GtkWidget::focus-padding = 0\n GtkWidget::focus-line-width = 0\n xthickness = 0\n ythickness = 0\n GtkButton::inner-border = {0,0,0,0}\n }\n"); | 61 Gtk.Rc.ParseString("style \"NotebookTab.CloseButton\" {\n GtkWidget::focus-padding = 0\n GtkWidget::focus-line-width = 0\n xthickness = 0\n ythickness = 0\n GtkButton::inner-border = {0,0,0,0}\n }\n"); |
54 Gtk.Rc.ParseString("widget \"*.NotebookTab.CloseButton\" style \"NotebookTab.CloseButton\"\n"); | 62 Gtk.Rc.ParseString("widget \"*.NotebookTab.CloseButton\" style \"NotebookTab.CloseButton\"\n"); |
55 Image icon = Image.NewFromIconName("gtk-close", IconSize.Menu); | 63 Image icon = Image.NewFromIconName("gtk-close", IconSize.Menu); |
60 close.BorderWidth = 0; | 68 close.BorderWidth = 0; |
61 close.Name = "NotebookTab.CloseButton"; | 69 close.Name = "NotebookTab.CloseButton"; |
62 close.Clicked += delegate { | 70 close.Clicked += delegate { |
63 notebook.Remove(page); | 71 notebook.Remove(page); |
64 }; | 72 }; |
73 | |
65 hbox.PackStart(close); | 74 hbox.PackStart(close); |
66 hbox.ShowAll(); | 75 hbox.ShowAll(); |
67 return hbox; | 76 return eventBox; |
68 } | 77 } |
69 } | 78 } |
70 } | 79 } |