annotate NotebookUtil.cs @ 18:9b3c4fd0b191

Re #26: GTK# wrappers * Remove debugging Console.WriteLine call
author IBBoard <dev@ibboard.co.uk>
date Sat, 18 Dec 2010 15:53:01 +0000
parents 0a466c011016
children c9e1ad81afbe
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4
10df433db2ac Re #23: Add easy creation of "tab with close"
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
1 // This file (NotebookUtil.cs) is a part of the IBBoard.Gtk project and is copyright 2009 IBBoard
10df433db2ac Re #23: Add easy creation of "tab with close"
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
2 //
10df433db2ac Re #23: Add easy creation of "tab with close"
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
3 // The file and the library/program it is in are licensed under the GNU LGPL license, either version 3 of the License or (at your option) any later version. Please see COPYING.LGPL for more information and the full license.
10df433db2ac Re #23: Add easy creation of "tab with close"
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
4 //
10df433db2ac Re #23: Add easy creation of "tab with close"
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
5
10df433db2ac Re #23: Add easy creation of "tab with close"
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
6 using System;
10df433db2ac Re #23: Add easy creation of "tab with close"
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
7 using Gtk;
10df433db2ac Re #23: Add easy creation of "tab with close"
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
8
10df433db2ac Re #23: Add easy creation of "tab with close"
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
9 namespace IBBoard.GtkSharp
10df433db2ac Re #23: Add easy creation of "tab with close"
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
10 {
10df433db2ac Re #23: Add easy creation of "tab with close"
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
11 public class NotebookUtil
10df433db2ac Re #23: Add easy creation of "tab with close"
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
12 {
10df433db2ac Re #23: Add easy creation of "tab with close"
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
13 /// <summary>
10df433db2ac Re #23: Add easy creation of "tab with close"
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
14 /// Adds a page to a notebook, but also includes a close button in the tab. Returns the page number added
10df433db2ac Re #23: Add easy creation of "tab with close"
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
15 /// </summary>
10df433db2ac Re #23: Add easy creation of "tab with close"
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
16 /// <param name="notebook">
10df433db2ac Re #23: Add easy creation of "tab with close"
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
17 /// The <see cref="Notebook"/> to add a page to
10df433db2ac Re #23: Add easy creation of "tab with close"
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
18 /// </param>
10df433db2ac Re #23: Add easy creation of "tab with close"
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
19 /// <param name="page">
10df433db2ac Re #23: Add easy creation of "tab with close"
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
20 /// The <see cref="Widget"/> to use as the content of the page
10df433db2ac Re #23: Add easy creation of "tab with close"
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
21 /// </param>
10df433db2ac Re #23: Add easy creation of "tab with close"
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
22 /// <param name="title">
10df433db2ac Re #23: Add easy creation of "tab with close"
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
23 /// The title of the tab
10df433db2ac Re #23: Add easy creation of "tab with close"
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
24 /// </param>
10df433db2ac Re #23: Add easy creation of "tab with close"
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
25 /// <returns>
10df433db2ac Re #23: Add easy creation of "tab with close"
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
26 /// The page number created
10df433db2ac Re #23: Add easy creation of "tab with close"
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
27 /// </returns>
10df433db2ac Re #23: Add easy creation of "tab with close"
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
28 public static int AddPageToNotebookWithCloseButton(Notebook notebook, Widget page, string title)
10df433db2ac Re #23: Add easy creation of "tab with close"
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
29 {
7
d92d11bd4808 * Refactor out "label with close button" creation to new method (useful for warfoundry:ticket:125)
IBBoard <dev@ibboard.co.uk>
parents: 6
diff changeset
30 return notebook.AppendPage(page, CreateNotebookTabLabelWithClose(notebook, page, title));
d92d11bd4808 * Refactor out "label with close button" creation to new method (useful for warfoundry:ticket:125)
IBBoard <dev@ibboard.co.uk>
parents: 6
diff changeset
31 }
d92d11bd4808 * Refactor out "label with close button" creation to new method (useful for warfoundry:ticket:125)
IBBoard <dev@ibboard.co.uk>
parents: 6
diff changeset
32
d92d11bd4808 * Refactor out "label with close button" creation to new method (useful for warfoundry:ticket:125)
IBBoard <dev@ibboard.co.uk>
parents: 6
diff changeset
33 /// <summary>
d92d11bd4808 * Refactor out "label with close button" creation to new method (useful for warfoundry:ticket:125)
IBBoard <dev@ibboard.co.uk>
parents: 6
diff changeset
34 /// Creates a widget to be used as the label for a notebook tab with text and a close button
d92d11bd4808 * Refactor out "label with close button" creation to new method (useful for warfoundry:ticket:125)
IBBoard <dev@ibboard.co.uk>
parents: 6
diff changeset
35 /// </summary>
d92d11bd4808 * Refactor out "label with close button" creation to new method (useful for warfoundry:ticket:125)
IBBoard <dev@ibboard.co.uk>
parents: 6
diff changeset
36 /// <param name="notebook">
d92d11bd4808 * Refactor out "label with close button" creation to new method (useful for warfoundry:ticket:125)
IBBoard <dev@ibboard.co.uk>
parents: 6
diff changeset
37 /// The <see cref="Notebook"/> the page is on
d92d11bd4808 * Refactor out "label with close button" creation to new method (useful for warfoundry:ticket:125)
IBBoard <dev@ibboard.co.uk>
parents: 6
diff changeset
38 /// </param>
d92d11bd4808 * Refactor out "label with close button" creation to new method (useful for warfoundry:ticket:125)
IBBoard <dev@ibboard.co.uk>
parents: 6
diff changeset
39 /// <param name="page">
d92d11bd4808 * Refactor out "label with close button" creation to new method (useful for warfoundry:ticket:125)
IBBoard <dev@ibboard.co.uk>
parents: 6
diff changeset
40 /// The <see cref="Widget"/> that is the content of the page
d92d11bd4808 * Refactor out "label with close button" creation to new method (useful for warfoundry:ticket:125)
IBBoard <dev@ibboard.co.uk>
parents: 6
diff changeset
41 /// </param>
d92d11bd4808 * Refactor out "label with close button" creation to new method (useful for warfoundry:ticket:125)
IBBoard <dev@ibboard.co.uk>
parents: 6
diff changeset
42 /// <param name="title">
d92d11bd4808 * Refactor out "label with close button" creation to new method (useful for warfoundry:ticket:125)
IBBoard <dev@ibboard.co.uk>
parents: 6
diff changeset
43 /// The text to display on the tab
d92d11bd4808 * Refactor out "label with close button" creation to new method (useful for warfoundry:ticket:125)
IBBoard <dev@ibboard.co.uk>
parents: 6
diff changeset
44 /// </param>
d92d11bd4808 * Refactor out "label with close button" creation to new method (useful for warfoundry:ticket:125)
IBBoard <dev@ibboard.co.uk>
parents: 6
diff changeset
45 /// <returns>
d92d11bd4808 * Refactor out "label with close button" creation to new method (useful for warfoundry:ticket:125)
IBBoard <dev@ibboard.co.uk>
parents: 6
diff changeset
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
d92d11bd4808 * Refactor out "label with close button" creation to new method (useful for warfoundry:ticket:125)
IBBoard <dev@ibboard.co.uk>
parents: 6
diff changeset
47 /// </returns>
13
245677d0d47e Re #26: Add GTK wrapper methods
IBBoard <dev@ibboard.co.uk>
parents: 7
diff changeset
48 public static Widget CreateNotebookTabLabelWithClose(Notebook notebook, Widget page, String title)
7
d92d11bd4808 * Refactor out "label with close button" creation to new method (useful for warfoundry:ticket:125)
IBBoard <dev@ibboard.co.uk>
parents: 6
diff changeset
49 {
4
10df433db2ac Re #23: Add easy creation of "tab with close"
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
50 HBox hbox = new HBox();
13
245677d0d47e Re #26: Add GTK wrapper methods
IBBoard <dev@ibboard.co.uk>
parents: 7
diff changeset
51 hbox.PackStart(new Label(title));
4
10df433db2ac Re #23: Add easy creation of "tab with close"
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
52 Button close = new Button();
13
245677d0d47e Re #26: Add GTK wrapper methods
IBBoard <dev@ibboard.co.uk>
parents: 7
diff changeset
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");
245677d0d47e Re #26: Add GTK wrapper methods
IBBoard <dev@ibboard.co.uk>
parents: 7
diff changeset
54 Gtk.Rc.ParseString("widget \"*.NotebookTab.CloseButton\" style \"NotebookTab.CloseButton\"\n");
6
49307b998555 Re #23: Add easy creation of "tab with close"
IBBoard <dev@ibboard.co.uk>
parents: 4
diff changeset
55 Image icon = Image.NewFromIconName("gtk-close", IconSize.Menu);
49307b998555 Re #23: Add easy creation of "tab with close"
IBBoard <dev@ibboard.co.uk>
parents: 4
diff changeset
56 icon.SetPadding(0, 0);
49307b998555 Re #23: Add easy creation of "tab with close"
IBBoard <dev@ibboard.co.uk>
parents: 4
diff changeset
57 close.Image = icon;
4
10df433db2ac Re #23: Add easy creation of "tab with close"
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
58 close.Relief = ReliefStyle.None;
10df433db2ac Re #23: Add easy creation of "tab with close"
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
59 close.FocusOnClick = false;
6
49307b998555 Re #23: Add easy creation of "tab with close"
IBBoard <dev@ibboard.co.uk>
parents: 4
diff changeset
60 close.BorderWidth = 0;
13
245677d0d47e Re #26: Add GTK wrapper methods
IBBoard <dev@ibboard.co.uk>
parents: 7
diff changeset
61 close.Name = "NotebookTab.CloseButton";
4
10df433db2ac Re #23: Add easy creation of "tab with close"
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
62 close.Clicked += delegate {
7
d92d11bd4808 * Refactor out "label with close button" creation to new method (useful for warfoundry:ticket:125)
IBBoard <dev@ibboard.co.uk>
parents: 6
diff changeset
63 notebook.Remove(page);
4
10df433db2ac Re #23: Add easy creation of "tab with close"
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
64 };
10df433db2ac Re #23: Add easy creation of "tab with close"
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
65 hbox.PackStart(close);
7
d92d11bd4808 * Refactor out "label with close button" creation to new method (useful for warfoundry:ticket:125)
IBBoard <dev@ibboard.co.uk>
parents: 6
diff changeset
66 hbox.ShowAll();
d92d11bd4808 * Refactor out "label with close button" creation to new method (useful for warfoundry:ticket:125)
IBBoard <dev@ibboard.co.uk>
parents: 6
diff changeset
67 return hbox;
4
10df433db2ac Re #23: Add easy creation of "tab with close"
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
68 }
10df433db2ac Re #23: Add easy creation of "tab with close"
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
69 }
10df433db2ac Re #23: Add easy creation of "tab with close"
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
70 }