diff --git a/.gitignore b/.gitignore index 396cff3f5..46129bb89 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ .hgignore .svn .dub +.vscode/ diff --git a/demos/gtkD/TestWindow/TTextView.d b/demos/gtkD/TestWindow/TTextView.d index 50e493795..efa2d3170 100644 --- a/demos/gtkD/TestWindow/TTextView.d +++ b/demos/gtkD/TestWindow/TTextView.d @@ -24,17 +24,17 @@ private import gtk.Widget; private import gtk.TextView; private import gtk.TextBuffer; private import gtk.TextIter; -private import gtk.VPaned; +private import gtk.Paned; private import gtk.ScrolledWindow; private import gtk.TextChildAnchor; private import gtk.Button; -private import gtk.Menu; -private import gtk.MenuItem; -private import gtk.HScale; +// private import gtk.Menu; +// private import gtk.MenuItem; +private import gtk.Scale; private import gtk.Image; private import gtk.Entry; -private import gdk.Pixbuf; +private import gdkpixbuf.Pixbuf; private import gtk.ComboBoxText; @@ -47,8 +47,7 @@ private import std.stdio; * \bug the output shows erros like (DUITest.exe:5012): GLib-GObject-WARNING **: [Invalid UTF-8] gobject.c:882: object class `GtkTextTag' has no property named `l┌E' */ -public: -class TTextView : Window +public class TTextView : Window { TextView view1; TextBuffer buffer; @@ -59,9 +58,10 @@ class TTextView : Window */ this() { - super("TextView"); + super(); + setTitle("Window"); setDefaultSize(450,450); - setBorderWidth(0); + // setBorderWidth(0); createTextViews(); @@ -73,7 +73,8 @@ class TTextView : Window attachWidgets(view1); attachWidgets(view2); - showAll(); + // showAll(); + show(); } // bit windowDeleteCallback(Window window, Event event) @@ -102,16 +103,20 @@ class TTextView : Window */ void setupWidgets() { - VPaned vPaned = new VPaned(); - vPaned.setBorderWidth(5); - add(vPaned); - - ScrolledWindow sw = new ScrolledWindow(PolicyType.AUTOMATIC, PolicyType.AUTOMATIC); - sw.add(view1); - vPaned.add1(sw); - sw = new ScrolledWindow(PolicyType.AUTOMATIC, PolicyType.AUTOMATIC); - sw.add(view2); - vPaned.add2(sw); + auto vPaned = new Paned(GtkOrientation.VERTICAL); + // vPaned.setBorderWidth(5); + // vPaned.set + setChild(vPaned); + + ScrolledWindow sw = new ScrolledWindow(); + sw.setPolicy(PolicyType.AUTOMATIC, PolicyType.AUTOMATIC); + sw.setChild(view1); + // sw.add(view1); + vPaned.setStartChild(sw); + sw = new ScrolledWindow(); + sw.setPolicy(PolicyType.AUTOMATIC, PolicyType.AUTOMATIC); + // sw.add(view2); + vPaned.setEndChild(sw); } /** @@ -139,88 +144,98 @@ class TTextView : Window * gtk_text_tag_set_priority(). */ - buffer.createTag("heading", - "weight", PangoWeight.BOLD, - "size", 15 * PANGO_SCALE); - buffer.createTag("italic", - "style", cast(int)PangoStyle.ITALIC); + import gtk.TextTag; - buffer.createTag("bold", - "weight", cast(int)PangoWeight.BOLD); - buffer.createTag("big", - /* points times the PANGO_SCALE factor */ - "size", 20 * PANGO_SCALE); + auto tagTable = buffer.getTagTable(); - buffer.createTag("xx-small", - "scale", PANGO_SCALE_XX_SMALL); + auto headingTag = new TextTag("heading"); + headingTag.setProperty("weight", PangoWeight.BOLD); + headingTag.setProperty("size", 15*PANGO_SCALE); + tagTable.add(headingTag); - buffer.createTag("x-large", - "scale", PANGO_SCALE_X_LARGE); + // buffer.createTag("heading", + // "weight", PangoWeight.BOLD, + // "size", 15 * PANGO_SCALE); + // buffer.createTag("italic", + // "style", cast(int)PangoStyle.ITALIC); - buffer.createTag("monospace", - "family", "monospace"); + // buffer.createTag("bold", + // "weight", cast(int)PangoWeight.BOLD); - buffer.createTag("blue_foreground", - "foreground", "blue"); + // buffer.createTag("big", + // /* points times the PANGO_SCALE factor */ + // "size", 20 * PANGO_SCALE); - buffer.createTag("red_background", - "background", "red"); + // buffer.createTag("xx-small", + // "scale", PANGO_SCALE_XX_SMALL); - buffer.createTag("big_gap_before_line", - "pixels_above_lines", 30); + // buffer.createTag("x-large", + // "scale", PANGO_SCALE_X_LARGE); - buffer.createTag("big_gap_after_line", - "pixels_below_lines", 30); + // buffer.createTag("monospace", + // "family", "monospace"); - buffer.createTag("double_spaced_line", - "pixels_inside_wrap", 10); + // buffer.createTag("blue_foreground", + // "foreground", "blue"); - buffer.createTag("not_editable", - "editable", cast(int)false); + // buffer.createTag("red_background", + // "background", "red"); - buffer.createTag("word_wrap", - "wrap_mode", cast(int)WrapMode.WORD); + // buffer.createTag("big_gap_before_line", + // "pixels_above_lines", 30); - buffer.createTag("char_wrap", - "wrap_mode", cast(int)WrapMode.CHAR); + // buffer.createTag("big_gap_after_line", + // "pixels_below_lines", 30); - buffer.createTag("no_wrap", - "wrap_mode", cast(int)WrapMode.NONE); + // buffer.createTag("double_spaced_line", + // "pixels_inside_wrap", 10); - buffer.createTag("center", - "justification", cast(int)Justification.CENTER); + // buffer.createTag("not_editable", + // "editable", cast(int)false); - buffer.createTag("right_justify", - "justification", cast(int)Justification.RIGHT); + // buffer.createTag("word_wrap", + // "wrap_mode", cast(int)WrapMode.WORD); - buffer.createTag("wide_margins", - "left_margin", 50, "right_margin", 50); + // buffer.createTag("char_wrap", + // "wrap_mode", cast(int)WrapMode.CHAR); - buffer.createTag("strikethrough", - "strikethrough", cast(int)true); + // buffer.createTag("no_wrap", + // "wrap_mode", cast(int)WrapMode.NONE); - buffer.createTag("underline", - "underline", cast(int)PangoUnderline.SINGLE); + // buffer.createTag("center", + // "justification", cast(int)Justification.CENTER); - buffer.createTag("double_underline", - "underline", cast(int)PangoUnderline.DOUBLE); + // buffer.createTag("right_justify", + // "justification", cast(int)Justification.RIGHT); - buffer.createTag("superscript", - "rise", 10 * PANGO_SCALE, /* 10 pixels */ - "size", 8 * PANGO_SCALE); /* 8 points */ + // buffer.createTag("wide_margins", + // "left_margin", 50, "right_margin", 50); - buffer.createTag("subscript", - "rise", -10 * PANGO_SCALE, /* 10 pixels */ - "size", 8 * PANGO_SCALE); /* 8 points */ + // buffer.createTag("strikethrough", + // "strikethrough", cast(int)true); + // buffer.createTag("underline", + // "underline", cast(int)PangoUnderline.SINGLE); - buffer.createTag("rtl_quote", - "wrap_mode", WrapMode.WORD, - "direction", TextDirection.RTL, - "indent", 30, - "left_margin", 20, - "right_margin", 20); + // buffer.createTag("double_underline", + // "underline", cast(int)PangoUnderline.DOUBLE); + + // buffer.createTag("superscript", + // "rise", 10 * PANGO_SCALE, /* 10 pixels */ + // "size", 8 * PANGO_SCALE); /* 8 points */ + + // buffer.createTag("subscript", + // "rise", -10 * PANGO_SCALE, /* 10 pixels */ + // "size", 8 * PANGO_SCALE); /* 8 points */ + + + // buffer.createTag("rtl_quote", + // "wrap_mode", WrapMode.WORD, + // "direction", TextDirection.RTL, + // "indent", 30, + // "left_margin", 20, + // "right_margin", 20); } /** @@ -231,9 +246,12 @@ class TTextView : Window { //version(Tango) {} else { - TextIter iter = new TextIter(); - TextIter start = new TextIter(); - TextIter end = new TextIter(); + TextIter iter; + TextIter start; + TextIter end; + // auto start = buffer.getStartIter(); + // auto iter = buffer.getStartIter(); + // auto end = buffer.getEndIter(); Pixbuf pixbuf; Pixbuf scaled; TextChildAnchor anchor; @@ -265,132 +283,132 @@ class TTextView : Window buffer.insert(iter, "The text widget can display text with all kinds of nifty attributes. It also supports multiple views of the same buffer; this demo is showing the same buffer in two places.\n\n"); - buffer.insertWithTagsByName(iter, "Font styles. ","heading"); - - buffer.insert(iter, "For example, you can have "); - buffer.insertWithTagsByName(iter, "italic", "italic"); - buffer.insert(iter, ", "); - buffer.insertWithTagsByName(iter, "bold", "bold"); - buffer.insert(iter, ", or "); - buffer.insertWithTagsByName(iter, "monospace (typewriter)", "monospace"); - buffer.insert(iter, ", or "); - buffer.insertWithTagsByName(iter, "big", "big"); - buffer.insert(iter, " text. "); - buffer.insert(iter, "It's best not to hardcode specific text sizes; you can use relative sizes as with CSS, such as "); - buffer.insertWithTagsByName(iter, "xx-small", "xx-small"); - buffer.insert(iter, " or "); - buffer.insertWithTagsByName(iter, "x-large", "x-large"); - buffer.insert(iter, " to ensure that your program properly adapts if the user changes the default font size.\n\n"); - - buffer.insertWithTagsByName(iter, "Colors. ", "heading"); - - buffer.insert(iter, "Colors such as "); - buffer.insertWithTagsByName(iter, "a blue foreground", "blue_foreground"); - buffer.insert(iter, " or "); - buffer.insertWithTagsByName(iter, "a red background", "red_background"); - buffer.insert(iter, " can be used.\n\n"); - - buffer.insertWithTagsByName(iter, "Underline, strikethrough, and rise. ", "heading"); - - buffer.insertWithTagsByName(iter, "Strikethrough", "strikethrough"); - buffer.insert(iter, ", "); - buffer.insertWithTagsByName(iter, "underline", "underline"); - buffer.insert(iter, ", "); - buffer.insertWithTagsByName(iter, "double underline", "double_underline"); - buffer.insert(iter, ", "); - buffer.insertWithTagsByName(iter, "superscript", "superscript"); - buffer.insert(iter, ", and "); - buffer.insertWithTagsByName(iter, "subscript", "subscript"); - buffer.insert(iter, " are all supported.\n\n"); - - buffer.insertWithTagsByName(iter, "Images. ", "heading"); - - buffer.insert(iter, "The buffer can have images in it: "); - if ( pixbuf !is null ) - { - buffer.insertPixbuf(iter, scaled); - buffer.insertPixbuf(iter, pixbuf); - buffer.insertPixbuf(iter, scaled); - } - else - { - buffer.insert(iter,"Sorry can't find the images"); - } - buffer.insert(iter, " for example.\n\n"); - - buffer.insertWithTagsByName(iter, "Spacing. ", "heading"); - - buffer.insert(iter, "You can adjust the amount of space before each line.\n"); - - buffer.insertWithTagsByName(iter, "This line has a whole lot of space before it.\n", - "big_gap_before_line", "wide_margins"); - buffer.insertWithTagsByName(iter, - "You can also adjust the amount of space after each line; this line has a whole lot of space after it.\n", - "big_gap_after_line", "wide_margins"); - - buffer.insertWithTagsByName(iter, - "You can also adjust the amount of space between wrapped lines; this line has extra space between each wrapped line in the same paragraph. To show off wrapping, some filler text: the quick brown fox jumped over the lazy dog. Blah blah blah blah blah blah blah blah blah.\n", - "double_spaced_line", "wide_margins"); - - buffer.insert(iter, "Also note that those lines have extra-wide margins.\n\n"); - - buffer.insertWithTagsByName(iter, "Editability. ", "heading"); - - buffer.insertWithTagsByName(iter, - "This line is 'locked down' and can't be edited by the user - just try it! You can't delete this line.\n\n", - "not_editable"); - - buffer.insertWithTagsByName(iter, "Wrapping. ", "heading"); - - buffer.insert(iter, - "This line (and most of the others in this buffer) is word-wrapped, using the proper Unicode algorithm. Word wrap should work in all scripts and languages that GTK+ supports. Let's make this a long paragraph to demonstrate: blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah\n\n"); - - buffer.insertWithTagsByName(iter, - "This line has character-based wrapping, and can wrap between any two character glyphs. Let's make this a long paragraph to demonstrate: blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah\n\n", - "char_wrap"); - - buffer.insertWithTagsByName(iter, - "This line has all wrapping turned off, so it makes the horizontal scrollbar appear.\n\n\n", - "no_wrap"); - - buffer.insertWithTagsByName(iter, "Justification. ", "heading"); - - buffer.insertWithTagsByName(iter, - "\nThis line has center justification.\n", "center"); - - buffer.insertWithTagsByName(iter, - "This line has right justification.\n", "right_justify"); - - buffer.insertWithTagsByName(iter, - "\nThis line has big wide margins. Text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text.\n", - "wide_margins"); - - buffer.insertWithTagsByName(iter, "Internationalization. ", "heading"); - - buffer.insert(iter, - "You can put all sorts of Unicode text in the buffer.\n\nGerman (Deutsch S\303\274d) Gr\303\274\303\237 Gott\nGreek (\316\225\316\273\316\273\316\267\316\275\316\271\316\272\316\254) \316\223\316\265\316\271\316\254 \317\203\316\261\317\202\nHebrew \327\251\327\234\327\225\327\235\nJapanese (\346\227\245\346\234\254\350\252\236)\n\nThe widget properly handles bidirectional text, word wrapping, DOS/UNIX/Unicode paragraph separators, grapheme boundaries, and so on using the Pango internationalization framework.\n"); - - buffer.insert(iter, "Here's a word-wrapped quote in a right-to-left language:\n"); - buffer.insertWithTagsByName(iter, "\331\210\331\202\330\257 \330\250\330\257\330\243 \330\253\331\204\330\247\330\253 \331\205\331\206 \330\243\331\203\330\253\330\261 \330\247\331\204\331\205\330\244\330\263\330\263\330\247\330\252 \330\252\331\202\330\257\331\205\330\247 \331\201\331\212 \330\264\330\250\331\203\330\251 \330\247\331\203\330\263\331\212\331\210\331\206 \330\250\330\261\330\247\331\205\330\254\331\207\330\247 \331\203\331\205\331\206\330\270\331\205\330\247\330\252 \331\204\330\247 \330\252\330\263\330\271\331\211 \331\204\331\204\330\261\330\250\330\255\330\214 \330\253\331\205 \330\252\330\255\331\210\331\204\330\252 \331\201\331\212 \330\247\331\204\330\263\331\206\331\210\330\247\330\252 \330\247\331\204\330\256\331\205\330\263 \330\247\331\204\331\205\330\247\330\266\331\212\330\251 \330\245\331\204\331\211 \331\205\330\244\330\263\330\263\330\247\330\252 \331\205\330\247\331\204\331\212\330\251 \331\205\331\206\330\270\331\205\330\251\330\214 \331\210\330\250\330\247\330\252\330\252 \330\254\330\262\330\241\330\247 \331\205\331\206 \330\247\331\204\331\206\330\270\330\247\331\205 \330\247\331\204\331\205\330\247\331\204\331\212 \331\201\331\212 \330\250\331\204\330\257\330\247\331\206\331\207\330\247\330\214 \331\210\331\204\331\203\331\206\331\207\330\247 \330\252\330\252\330\256\330\265\330\265 \331\201\331\212 \330\256\330\257\331\205\330\251 \331\202\330\267\330\247\330\271 \330\247\331\204\331\205\330\264\330\261\331\210\330\271\330\247\330\252 \330\247\331\204\330\265\330\272\331\212\330\261\330\251. \331\210\330\243\330\255\330\257 \330\243\331\203\330\253\330\261 \331\207\330\260\331\207 \330\247\331\204\331\205\330\244\330\263\330\263\330\247\330\252 \331\206\330\254\330\247\330\255\330\247 \331\207\331\210 \302\273\330\250\330\247\331\206\331\203\331\210\330\263\331\210\331\204\302\253 \331\201\331\212 \330\250\331\210\331\204\331\212\331\201\331\212\330\247.\n\n", - "rtl_quote"); - - buffer.insert(iter, "You can put widgets in the buffer: Here's a button: "); - anchor = buffer.createChildAnchor(iter); - buffer.insert(iter, " and a menu: "); - anchor = buffer.createChildAnchor(iter); - buffer.insert(iter, " and a scale: "); - anchor = buffer.createChildAnchor(iter); - buffer.insert(iter, " and an animation: "); - anchor = buffer.createChildAnchor(iter); - buffer.insert(iter, " finally a text entry: "); - anchor = buffer.createChildAnchor(iter); - buffer.insert(iter, ".\n"); - - buffer.insert(iter, "\n\nThis demo doesn't demonstrate all the GtkTextBuffer features; it leaves out, for example: invisible/hidden text (doesn't work in GTK 2, but planned), tab stops, application-drawn areas on the sides of the widget for displaying breakpoints and such..."); + // buffer.insertWithTagsByName(iter, "Font styles. ","heading"); - /* Apply word_wrap tag to whole buffer */ - buffer.getBounds(start, end); - buffer.applyTagByName("word_wrap", start, end); + // buffer.insert(iter, "For example, you can have "); + // buffer.insertWithTagsByName(iter, "italic", "italic"); + // buffer.insert(iter, ", "); + // buffer.insertWithTagsByName(iter, "bold", "bold"); + // buffer.insert(iter, ", or "); + // buffer.insertWithTagsByName(iter, "monospace (typewriter)", "monospace"); + // buffer.insert(iter, ", or "); + // buffer.insertWithTagsByName(iter, "big", "big"); + // buffer.insert(iter, " text. "); + // buffer.insert(iter, "It's best not to hardcode specific text sizes; you can use relative sizes as with CSS, such as "); + // buffer.insertWithTagsByName(iter, "xx-small", "xx-small"); + // buffer.insert(iter, " or "); + // buffer.insertWithTagsByName(iter, "x-large", "x-large"); + // buffer.insert(iter, " to ensure that your program properly adapts if the user changes the default font size.\n\n"); + + // buffer.insertWithTagsByName(iter, "Colors. ", "heading"); + + // buffer.insert(iter, "Colors such as "); + // buffer.insertWithTagsByName(iter, "a blue foreground", "blue_foreground"); + // buffer.insert(iter, " or "); + // buffer.insertWithTagsByName(iter, "a red background", "red_background"); + // buffer.insert(iter, " can be used.\n\n"); + + // buffer.insertWithTagsByName(iter, "Underline, strikethrough, and rise. ", "heading"); + + // buffer.insertWithTagsByName(iter, "Strikethrough", "strikethrough"); + // buffer.insert(iter, ", "); + // buffer.insertWithTagsByName(iter, "underline", "underline"); + // buffer.insert(iter, ", "); + // buffer.insertWithTagsByName(iter, "double underline", "double_underline"); + // buffer.insert(iter, ", "); + // buffer.insertWithTagsByName(iter, "superscript", "superscript"); + // buffer.insert(iter, ", and "); + // buffer.insertWithTagsByName(iter, "subscript", "subscript"); + // buffer.insert(iter, " are all supported.\n\n"); + + // buffer.insertWithTagsByName(iter, "Images. ", "heading"); + + // buffer.insert(iter, "The buffer can have images in it: "); + // if ( pixbuf !is null ) + // { + // buffer.insertPixbuf(iter, scaled); + // buffer.insertPixbuf(iter, pixbuf); + // buffer.insertPixbuf(iter, scaled); + // } + // else + // { + // buffer.insert(iter,"Sorry can't find the images"); + // } + // buffer.insert(iter, " for example.\n\n"); + + // buffer.insertWithTagsByName(iter, "Spacing. ", "heading"); + + // buffer.insert(iter, "You can adjust the amount of space before each line.\n"); + + // buffer.insertWithTagsByName(iter, "This line has a whole lot of space before it.\n", + // "big_gap_before_line", "wide_margins"); + // buffer.insertWithTagsByName(iter, + // "You can also adjust the amount of space after each line; this line has a whole lot of space after it.\n", + // "big_gap_after_line", "wide_margins"); + + // buffer.insertWithTagsByName(iter, + // "You can also adjust the amount of space between wrapped lines; this line has extra space between each wrapped line in the same paragraph. To show off wrapping, some filler text: the quick brown fox jumped over the lazy dog. Blah blah blah blah blah blah blah blah blah.\n", + // "double_spaced_line", "wide_margins"); + + // buffer.insert(iter, "Also note that those lines have extra-wide margins.\n\n"); + + // buffer.insertWithTagsByName(iter, "Editability. ", "heading"); + + // buffer.insertWithTagsByName(iter, + // "This line is 'locked down' and can't be edited by the user - just try it! You can't delete this line.\n\n", + // "not_editable"); + + // buffer.insertWithTagsByName(iter, "Wrapping. ", "heading"); + + // buffer.insert(iter, + // "This line (and most of the others in this buffer) is word-wrapped, using the proper Unicode algorithm. Word wrap should work in all scripts and languages that GTK+ supports. Let's make this a long paragraph to demonstrate: blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah\n\n"); + + // buffer.insertWithTagsByName(iter, + // "This line has character-based wrapping, and can wrap between any two character glyphs. Let's make this a long paragraph to demonstrate: blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah\n\n", + // "char_wrap"); + + // buffer.insertWithTagsByName(iter, + // "This line has all wrapping turned off, so it makes the horizontal scrollbar appear.\n\n\n", + // "no_wrap"); + + // buffer.insertWithTagsByName(iter, "Justification. ", "heading"); + + // buffer.insertWithTagsByName(iter, + // "\nThis line has center justification.\n", "center"); + + // buffer.insertWithTagsByName(iter, + // "This line has right justification.\n", "right_justify"); + + // buffer.insertWithTagsByName(iter, + // "\nThis line has big wide margins. Text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text.\n", + // "wide_margins"); + + // buffer.insertWithTagsByName(iter, "Internationalization. ", "heading"); + + // buffer.insert(iter, + // "You can put all sorts of Unicode text in the buffer.\n\nGerman (Deutsch S\303\274d) Gr\303\274\303\237 Gott\nGreek (\316\225\316\273\316\273\316\267\316\275\316\271\316\272\316\254) \316\223\316\265\316\271\316\254 \317\203\316\261\317\202\nHebrew \327\251\327\234\327\225\327\235\nJapanese (\346\227\245\346\234\254\350\252\236)\n\nThe widget properly handles bidirectional text, word wrapping, DOS/UNIX/Unicode paragraph separators, grapheme boundaries, and so on using the Pango internationalization framework.\n"); + + // buffer.insert(iter, "Here's a word-wrapped quote in a right-to-left language:\n"); + // buffer.insertWithTagsByName(iter, "\331\210\331\202\330\257 \330\250\330\257\330\243 \330\253\331\204\330\247\330\253 \331\205\331\206 \330\243\331\203\330\253\330\261 \330\247\331\204\331\205\330\244\330\263\330\263\330\247\330\252 \330\252\331\202\330\257\331\205\330\247 \331\201\331\212 \330\264\330\250\331\203\330\251 \330\247\331\203\330\263\331\212\331\210\331\206 \330\250\330\261\330\247\331\205\330\254\331\207\330\247 \331\203\331\205\331\206\330\270\331\205\330\247\330\252 \331\204\330\247 \330\252\330\263\330\271\331\211 \331\204\331\204\330\261\330\250\330\255\330\214 \330\253\331\205 \330\252\330\255\331\210\331\204\330\252 \331\201\331\212 \330\247\331\204\330\263\331\206\331\210\330\247\330\252 \330\247\331\204\330\256\331\205\330\263 \330\247\331\204\331\205\330\247\330\266\331\212\330\251 \330\245\331\204\331\211 \331\205\330\244\330\263\330\263\330\247\330\252 \331\205\330\247\331\204\331\212\330\251 \331\205\331\206\330\270\331\205\330\251\330\214 \331\210\330\250\330\247\330\252\330\252 \330\254\330\262\330\241\330\247 \331\205\331\206 \330\247\331\204\331\206\330\270\330\247\331\205 \330\247\331\204\331\205\330\247\331\204\331\212 \331\201\331\212 \330\250\331\204\330\257\330\247\331\206\331\207\330\247\330\214 \331\210\331\204\331\203\331\206\331\207\330\247 \330\252\330\252\330\256\330\265\330\265 \331\201\331\212 \330\256\330\257\331\205\330\251 \331\202\330\267\330\247\330\271 \330\247\331\204\331\205\330\264\330\261\331\210\330\271\330\247\330\252 \330\247\331\204\330\265\330\272\331\212\330\261\330\251. \331\210\330\243\330\255\330\257 \330\243\331\203\330\253\330\261 \331\207\330\260\331\207 \330\247\331\204\331\205\330\244\330\263\330\263\330\247\330\252 \331\206\330\254\330\247\330\255\330\247 \331\207\331\210 \302\273\330\250\330\247\331\206\331\203\331\210\330\263\331\210\331\204\302\253 \331\201\331\212 \330\250\331\210\331\204\331\212\331\201\331\212\330\247.\n\n", + // "rtl_quote"); + + // buffer.insert(iter, "You can put widgets in the buffer: Here's a button: "); + // anchor = buffer.createChildAnchor(iter); + // buffer.insert(iter, " and a menu: "); + // anchor = buffer.createChildAnchor(iter); + // buffer.insert(iter, " and a scale: "); + // anchor = buffer.createChildAnchor(iter); + // buffer.insert(iter, " and an animation: "); + // anchor = buffer.createChildAnchor(iter); + // buffer.insert(iter, " finally a text entry: "); + // anchor = buffer.createChildAnchor(iter); + // buffer.insert(iter, ".\n"); + + // buffer.insert(iter, "\n\nThis demo doesn't demonstrate all the GtkTextBuffer features; it leaves out, for example: invisible/hidden text (doesn't work in GTK 2, but planned), tab stops, application-drawn areas on the sides of the widget for displaying breakpoints and such..."); + + // /* Apply word_wrap tag to whole buffer */ + // buffer.getBounds(start, end); + // buffer.applyTagByName("word_wrap", start, end); } } @@ -400,7 +418,7 @@ class TTextView : Window */ void attachWidgets(TextView view) { - TextIter iter = new TextIter(); + TextIter iter; TextBuffer buffer; int i; @@ -432,7 +450,7 @@ class TTextView : Window } else if (i == 2) { - HScale hScale = new HScale(0.0,100.0,5.0); + auto hScale = new Scale(GtkOrientation.HORIZONTAL, 0.0, 100.0, 5.0); hScale.setSizeRequest(70, -1); widget = hScale; } diff --git a/demos/gtkD/TestWindow/TestAspectFrame.d b/demos/gtkD/TestWindow/TestAspectFrame.d index 6d9f26b94..599da4c3d 100644 --- a/demos/gtkD/TestWindow/TestAspectFrame.d +++ b/demos/gtkD/TestWindow/TestAspectFrame.d @@ -20,7 +20,7 @@ module TestAspectFrame; private import gtk.AspectFrame; -private import TestDrawingArea; +private import TestDrawingArea : TestDrawingArea; /** * This tests the DUI aspect frame @@ -30,7 +30,7 @@ class TestAspectFrame : AspectFrame this() { // string label, gfloat xalign, gfloat yalign, gfloat ratio, bit obeyChild) - super("Aspect 3x1", .5, .5, 3.0, false); - add(new TestDrawingArea()); + super(.5, .5, 3.0, false); + setChild(new TestDrawingArea()); } } diff --git a/demos/gtkD/TestWindow/TestDrawingArea.d b/demos/gtkD/TestWindow/TestDrawingArea.d index 98a3058e9..91611c532 100644 --- a/demos/gtkD/TestWindow/TestDrawingArea.d +++ b/demos/gtkD/TestWindow/TestDrawingArea.d @@ -23,7 +23,7 @@ module TestDrawingArea; private import cairo.Context; private import cairo.ImageSurface; -private import gtk.VBox; +private import gtk.Box; private import pango.PgContext; private import pango.PgLayout; @@ -31,15 +31,15 @@ private import std.stdio; private import std.math; private import gtk.Widget; -private import gtk.MenuItem; +// private import gtk.MenuItem; private import gtk.ComboBox; private import gtk.ComboBoxText; -private import gtk.Menu; +// private import gtk.Menu; private import gtk.Adjustment; -private import gtk.HBox; -private import gdk.Pixbuf; -private import gdk.Cairo; -private import gdk.Color; +// private import gtk.HBox; +private import gdkpixbuf.Pixbuf; +// private import gdk.Color; +private import gdk.RGBA; private import gdk.Event; private import pango.PgCairo; @@ -50,15 +50,21 @@ private import gtk.Image; private import gtk.SpinButton; +struct Point { + int x; + int y; +} + + /** * This tests the gtkD drawing area widget */ -class TestDrawingArea : VBox +class TestDrawingArea : Box { this() { - super(false,4); + super(GtkOrientation.VERTICAL, 4); TestDrawing drawingArea = new TestDrawing(); @@ -93,7 +99,7 @@ class TestDrawingArea : VBox operators.appendText("HSL_COLOR"); operators.appendText("HSL_LUMINOSITY"); operators.setActive(1); - operators.addOnChanged(&drawingArea.onOperatorsChanged); + // operators.addOnChanged(&drawingArea.onOperatorsChanged); ComboBoxText primOption = new ComboBoxText(); primOption.appendText("Filled Arc"); @@ -109,23 +115,23 @@ class TestDrawingArea : VBox primOption.setActive(0); primOption.addOnChanged(&drawingArea.onPrimOptionChanged); - packStart(drawingArea,true,true,0); + prepend(drawingArea); - HBox hbox = new HBox(false,4); - hbox.packStart(operators,false,false,2); - hbox.packStart(primOption,false,false,2); - hbox.packStart(drawingArea.spin,false,false,2); - hbox.packStart(drawingArea.backSpin,false,false,2); + Box hbox = new Box(GtkOrientation.HORIZONTAL, 4); + hbox.prepend(operators); + hbox.prepend(primOption); + hbox.prepend(drawingArea.spin); + hbox.prepend(drawingArea.backSpin); - packStart(hbox, false, false, 0); + prepend(hbox); } class TestDrawing : DrawingArea { CairoOperator operator = CairoOperator.OVER; ImageSurface surface; - Color paintColor; - Color black; + RGBA paintColor; + RGBA black; int width; int height; @@ -139,16 +145,16 @@ class TestDrawingArea : VBox SpinButton spin; SpinButton backSpin; - static GdkPoint[] polygonStar = [ - {0,4}, - {1,1}, - {4,0}, - {1,-1}, - {0,-4}, - {-1,-1}, - {-4,0}, - {-1,1} - ]; + static Point[] polygonStar = [ + {0, 4}, + {1, 1}, + {4, 0}, + {1, -1}, + {0, -4}, + {-1, -1}, + {-4, 0}, + {-1, 1} + ]; this() { @@ -160,26 +166,26 @@ class TestDrawingArea : VBox font = PgFontDescription.fromString("Courier 48"); image = new Image("images/gtkDlogo_a_small.png"); - scaledPixbuf = image.getPixbuf(); - if (scaledPixbuf is null) - { - writeln("\nFailed to load image file gtkDlogo_a_small.png"); - } + // scaledPixbuf = image.getPixbuf(); + // if (scaledPixbuf is null) + // { + // writeln("\nFailed to load image file gtkDlogo_a_small.png"); + // } - paintColor = new Color(cast(ubyte)0,cast(ubyte)0,cast(ubyte)0); - black = new Color(cast(ubyte)0,cast(ubyte)0,cast(ubyte)0); + paintColor = new RGBA(new GdkRGBA(0, 0, 0)); + black = new RGBA(new GdkRGBA(0, 0, 0)); spin = new SpinButton(new Adjustment(30, 1, 400, 1, 10, 0),1,0); - sizeSpinChanged(spin); - spin.addOnValueChanged(&sizeSpinChanged); + // sizeSpinChanged(spin); + // spin.addOnValueChanged(&sizeSpinChanged); backSpin = new SpinButton(new Adjustment(5, 4, 100, 1, 10, 0),1,0); backSpin.addOnValueChanged(&backSpinChanged); - addOnDraw(&drawCallback); - addOnMotionNotify(&onMotionNotify); - addOnSizeAllocate(&onSizeAllocate); - addOnButtonPress(&onButtonPress); - addOnButtonRelease(&onButtonRelease); + // addOnDraw(&drawCallback); + // addOnMotionNotify(&onMotionNotify); + // addOnSizeAllocate(&onSizeAllocate); + // addOnButtonPress(&onButtonPress); + // addOnButtonRelease(&onButtonRelease); } void onSizeAllocate(GtkAllocation* allocation, Widget widget) @@ -188,32 +194,32 @@ class TestDrawingArea : VBox height = allocation.height; surface = ImageSurface.create(CairoFormat.ARGB32, width, height); - drawPoints(Context.create(surface)); + // drawPoints(Context.create(surface)); } - public bool onButtonPress(Event event, Widget widget) - { - debug(trace) writeln("button DOWN"); - if ( event.type == EventType.BUTTON_PRESS && event.button.button == 1 ) - { - debug(trace) writeln("Button 1 down"); - buttonIsDown = true; - - drawPrimitive(cast(int)event.button.x, cast(int)event.button.y); - } - return false; - } - - public bool onButtonRelease(Event event, Widget widget) - { - debug(trace) writeln("button UP"); - if ( event.type == EventType.BUTTON_RELEASE && event.button.button == 1 ) - { - debug(trace) writeln("Button 1 UP"); - buttonIsDown = false; - } - return false; - } + // public bool onButtonPress(Event event, Widget widget) + // { + // debug(trace) writeln("button DOWN"); + // if ( event.getEventType() == EventType.BUTTON_PRESS && event.get.button == 1 ) + // { + // debug(trace) writeln("Button 1 down"); + // buttonIsDown = true; + + // drawPrimitive(cast(int)event.button.x, cast(int)event.button.y); + // } + // return false; + // } + + // public bool onButtonRelease(Event event, Widget widget) + // { + // debug(trace) writeln("button UP"); + // if ( event.type == EventType.BUTTON_RELEASE && event.button.button == 1 ) + // { + // debug(trace) writeln("Button 1 UP"); + // buttonIsDown = false; + // } + // return false; + // } /** * This will be called from the expose event call back. @@ -228,16 +234,16 @@ class TestDrawingArea : VBox return true; } - public bool onMotionNotify(Event event, Widget widget) - { - //writeln("testWindow.mouseMoved -----------------------------"); - if ( buttonIsDown && event.type == EventType.MOTION_NOTIFY ) - { - drawPrimitive(cast(int)event.motion.x, cast(int)event.motion.y); - } + // public bool onMotionNotify(Event event, Widget widget) + // { + // //writeln("testWindow.mouseMoved -----------------------------"); + // if ( buttonIsDown && event.type == EventType.MOTION_NOTIFY ) + // { + // drawPrimitive(cast(int)event.motion.x, cast(int)event.motion.y); + // } - return true; - } + // return true; + // } static int backSpinCount = 0; @@ -246,221 +252,221 @@ class TestDrawingArea : VBox debug(trace) writefln("backSpinChanged - entry %s", ++backSpinCount); - drawPoints(Context.create(surface)); + // drawPoints(Context.create(surface)); this.queueDraw(); debug(trace) writeln("backSpinChanged - exit"); } - public void sizeSpinChanged(SpinButton spinButton) - { - if ( !(scaledPixbuf is null)) - { - int width = spinButton.getValueAsInt(); - scaledPixbuf = image.getPixbuf(); - - float ww = width * scaledPixbuf.getWidth() / 30; - float hh = width * scaledPixbuf.getHeight() / 30; - - scaledPixbuf = scaledPixbuf.scaleSimple(cast(int)ww, cast(int)hh, GdkInterpType.HYPER); - } - } - - public void drawPrimitive(int x, int y) - { - int width = spin.getValueAsInt(); - int height = width * 3 / 4; - - Context context = Context.create(surface); - context.setOperator(operator); - - debug(trace) writefln("primitiveType = %s", primitiveType); - - switch ( primitiveType ) - { - case "Arc": - context.arc(x-width/2,y-width/2,width,0,2*PI); - context.stroke(); - break; - - case "Filled Arc": - context.arc(x-width/4,y-width/4,width/2,0,2*PI); - context.fill(); - break; - - case "Line": - context.moveTo(x, y); - context.lineTo(x+width, y); - context.stroke(); - break; - - case "Point": - context.rectangle(x, y, 1, 1); - context.fill(); - break; - - case "Rectangle": - context.rectangle(x-width/2, y-width/4, width, height); - context.stroke(); - break; - - case "Filled Rectangle": - context.rectangle(x-width/2, y-width/4, width, height); - context.fill(); - break; - - case "Text": - context.selectFontFace("FreeMono", CairoFontSlant.NORMAL, CairoFontWeight.NORMAL); - context.setFontSize(12); - context.moveTo(x, y); - context.showText("gtkD toolkit"); - break; - - case "Pango text": - PgLayout l = PgCairo.createLayout(context); - PgFontDescription fd = new PgFontDescription("Sans", width); - - l.setText("Gtk+ with D"); - l.setFontDescription(fd); - - context.moveTo(x, y); - PgCairo.showLayout(context, l); - break; - - case "Image": - if ( !(scaledPixbuf is null)) - { - context.setSourcePixbuf(scaledPixbuf, x, y); - context.paint(); - } - break; - - case "Polygon": - //TODO: Use Context.scale and transform ? - for ( int scale = 10 ; scale<= 300; scale+=15) - { - context.save(); - context.moveTo(polygonStar[0].x*scale/2+x, polygonStar[0].y*scale/2+y); - - foreach(p; polygonStar[1 .. $]) - { - context.lineTo(p.x*scale/2+x, p.y*scale/2+y); - } - context.closePath(); - context.stroke(); - context.restore(); - } - break; - - default: - context.arcNegative(x-2,y-2,4,0,6); - context.fill(); - break; - } - - //Redraw the Widget. - this.queueDraw(); - } - - private void drawPoints(Context context) - { - int square = backSpin.getValueAsInt(); - int totalcount = 0; - int count = 0; - Color color = new Color(); - int width = this.width; - int height = this.height; - int x = 0; - int y = 0; - - debug(trace) writefln("w,h = %s %s",width ,height); - - float dx = 256.0 / width; - float dy = 256.0 / height ; - float xx; - float yy; - while ( x < width || y 1 ) - { - context.rectangle(x, y, square, square); - context.fill(); - } - else - { - context.moveTo(x, y); - context.stroke(); - } - x +=square; - if ( x > width) - { - if ( y>height) - { - //y=0; - } - else - { - x = 0; - y+=square; - } - } - ++totalcount; - - context.restore(); - } - color.destroy(); - } - - void onOperatorsChanged(ComboBoxText comboBoxText) - { - debug(trace) writefln("CairoOperator = %s", comboBoxText.getActiveText()); - switch ( comboBoxText.getActiveText() ) - { - case "CLEAR": operator = CairoOperator.CLEAR; break; - case "SOURCE": operator = CairoOperator.SOURCE; break; - case "OVER": operator = CairoOperator.OVER; break; - case "IN": operator = CairoOperator.IN; break; - case "OUT": operator = CairoOperator.OUT; break; - case "ATOP": operator = CairoOperator.ATOP; break; - case "DEST": operator = CairoOperator.DEST; break; - case "DEST_OVER": operator = CairoOperator.DEST_OVER; break; - case "DEST_IN": operator = CairoOperator.DEST_IN; break; - case "DEST_OUT": operator = CairoOperator.DEST_OUT; break; - case "DEST_ATOP": operator = CairoOperator.DEST_ATOP; break; - case "XOR": operator = CairoOperator.XOR; break; - case "ADD": operator = CairoOperator.ADD; break; - case "SATURATE": operator = CairoOperator.SATURATE; break; - case "MULTIPLY": operator = CairoOperator.MULTIPLY; break; - case "SCREEN": operator = CairoOperator.SCREEN; break; - case "OVERLAY": operator = CairoOperator.OVERLAY; break; - case "DARKEN": operator = CairoOperator.DARKEN; break; - case "LIGHTEN": operator = CairoOperator.LIGHTEN; break; - case "COLOR_DODGE": operator = CairoOperator.COLOR_DODGE; break; - case "COLOR_BURN": operator = CairoOperator.COLOR_BURN; break; - case "HARD_LIGHT": operator = CairoOperator.HARD_LIGHT; break; - case "SOFT_LIGHT": operator = CairoOperator.SOFT_LIGHT; break; - case "DIFFERENCE": operator = CairoOperator.DIFFERENCE; break; - case "EXCLUSION": operator = CairoOperator.EXCLUSION; break; - case "HSL_HUE": operator = CairoOperator.HSL_HUE; break; - case "HSL_SATURATION": operator = CairoOperator.HSL_SATURATION; break; - case "HSL_COLOR": operator = CairoOperator.HSL_COLOR; break; - case "HSL_LUMINOSITY": operator = CairoOperator.HSL_LUMINOSITY; break; - default: operator = CairoOperator.OVER; break; - } - } - - void onPrimOptionChanged(ComboBoxText comboBoxText) + // public void sizeSpinChanged(SpinButton spinButton) + // { + // if ( !(scaledPixbuf is null)) + // { + // int width = spinButton.getValueAsInt(); + // scaledPixbuf = image.getPixbuf(); + + // float ww = width * scaledPixbuf.getWidth() / 30; + // float hh = width * scaledPixbuf.getHeight() / 30; + + // scaledPixbuf = scaledPixbuf.scaleSimple(cast(int)ww, cast(int)hh, GdkInterpType.HYPER); + // } + // } + + // public void drawPrimitive(int x, int y) + // { + // int width = spin.getValueAsInt(); + // int height = width * 3 / 4; + + // Context context = Context.create(surface); + // context.setOperator(operator); + + // debug(trace) writefln("primitiveType = %s", primitiveType); + + // switch ( primitiveType ) + // { + // case "Arc": + // context.arc(x-width/2,y-width/2,width,0,2*PI); + // context.stroke(); + // break; + + // case "Filled Arc": + // context.arc(x-width/4,y-width/4,width/2,0,2*PI); + // context.fill(); + // break; + + // case "Line": + // context.moveTo(x, y); + // context.lineTo(x+width, y); + // context.stroke(); + // break; + + // case "Point": + // context.rectangle(x, y, 1, 1); + // context.fill(); + // break; + + // case "Rectangle": + // context.rectangle(x-width/2, y-width/4, width, height); + // context.stroke(); + // break; + + // case "Filled Rectangle": + // context.rectangle(x-width/2, y-width/4, width, height); + // context.fill(); + // break; + + // case "Text": + // context.selectFontFace("FreeMono", CairoFontSlant.NORMAL, CairoFontWeight.NORMAL); + // context.setFontSize(12); + // context.moveTo(x, y); + // context.showText("gtkD toolkit"); + // break; + + // case "Pango text": + // PgLayout l = PgCairo.createLayout(context); + // PgFontDescription fd = new PgFontDescription("Sans", width); + + // l.setText("Gtk+ with D"); + // l.setFontDescription(fd); + + // context.moveTo(x, y); + // PgCairo.showLayout(context, l); + // break; + + // case "Image": + // if ( !(scaledPixbuf is null)) + // { + // context.setSourcePixbuf(scaledPixbuf, x, y); + // context.paint(); + // } + // break; + + // case "Polygon": + // //TODO: Use Context.scale and transform ? + // for ( int scale = 10 ; scale<= 300; scale+=15) + // { + // context.save(); + // context.moveTo(polygonStar[0].x*scale/2+x, polygonStar[0].y*scale/2+y); + + // foreach(p; polygonStar[1 .. $]) + // { + // context.lineTo(p.x*scale/2+x, p.y*scale/2+y); + // } + // context.closePath(); + // context.stroke(); + // context.restore(); + // } + // break; + + // default: + // context.arcNegative(x-2,y-2,4,0,6); + // context.fill(); + // break; + // } + + // //Redraw the Widget. + // this.queueDraw(); + // } + + // private void drawPoints(Context context) + // { + // int square = backSpin.getValueAsInt(); + // int totalcount = 0; + // int count = 0; + // Color color = new Color(); + // int width = this.width; + // int height = this.height; + // int x = 0; + // int y = 0; + + // debug(trace) writefln("w,h = %s %s",width ,height); + + // float dx = 256.0 / width; + // float dy = 256.0 / height ; + // float xx; + // float yy; + // while ( x < width || y 1 ) + // { + // context.rectangle(x, y, square, square); + // context.fill(); + // } + // else + // { + // context.moveTo(x, y); + // context.stroke(); + // } + // x +=square; + // if ( x > width) + // { + // if ( y>height) + // { + // //y=0; + // } + // else + // { + // x = 0; + // y+=square; + // } + // } + // ++totalcount; + + // context.restore(); + // } + // color.destroy(); + // } + + // void onOperatorsChanged(ComboBox comboBox) + // { + // debug(trace) writefln("CairoOperator = %s", comboBox.getActiveId()); + // switch ( comboBoxText.getActiveId() ) + // { + // case "CLEAR": operator = CairoOperator.CLEAR; break; + // case "SOURCE": operator = CairoOperator.SOURCE; break; + // case "OVER": operator = CairoOperator.OVER; break; + // case "IN": operator = CairoOperator.IN; break; + // case "OUT": operator = CairoOperator.OUT; break; + // case "ATOP": operator = CairoOperator.ATOP; break; + // case "DEST": operator = CairoOperator.DEST; break; + // case "DEST_OVER": operator = CairoOperator.DEST_OVER; break; + // case "DEST_IN": operator = CairoOperator.DEST_IN; break; + // case "DEST_OUT": operator = CairoOperator.DEST_OUT; break; + // case "DEST_ATOP": operator = CairoOperator.DEST_ATOP; break; + // case "XOR": operator = CairoOperator.XOR; break; + // case "ADD": operator = CairoOperator.ADD; break; + // case "SATURATE": operator = CairoOperator.SATURATE; break; + // case "MULTIPLY": operator = CairoOperator.MULTIPLY; break; + // case "SCREEN": operator = CairoOperator.SCREEN; break; + // case "OVERLAY": operator = CairoOperator.OVERLAY; break; + // case "DARKEN": operator = CairoOperator.DARKEN; break; + // case "LIGHTEN": operator = CairoOperator.LIGHTEN; break; + // case "COLOR_DODGE": operator = CairoOperator.COLOR_DODGE; break; + // case "COLOR_BURN": operator = CairoOperator.COLOR_BURN; break; + // case "HARD_LIGHT": operator = CairoOperator.HARD_LIGHT; break; + // case "SOFT_LIGHT": operator = CairoOperator.SOFT_LIGHT; break; + // case "DIFFERENCE": operator = CairoOperator.DIFFERENCE; break; + // case "EXCLUSION": operator = CairoOperator.EXCLUSION; break; + // case "HSL_HUE": operator = CairoOperator.HSL_HUE; break; + // case "HSL_SATURATION": operator = CairoOperator.HSL_SATURATION; break; + // case "HSL_COLOR": operator = CairoOperator.HSL_COLOR; break; + // case "HSL_LUMINOSITY": operator = CairoOperator.HSL_LUMINOSITY; break; + // default: operator = CairoOperator.OVER; break; + // } + // } + + void onPrimOptionChanged(ComboBox comboBox) { - primitiveType = comboBoxText.getActiveText(); + primitiveType = comboBox.getActiveId(); } } } diff --git a/demos/gtkD/TestWindow/TestEntries.d b/demos/gtkD/TestWindow/TestEntries.d index b47cb7884..a508e2d9c 100644 --- a/demos/gtkD/TestWindow/TestEntries.d +++ b/demos/gtkD/TestWindow/TestEntries.d @@ -18,12 +18,13 @@ module TestEntries; -private import gtk.Table; +// private import gtk.Table; private import gtk.Entry; private import gtk.CheckButton; private import gtk.Button; private import gtk.Label; +private import gtk.Box; private import glib.Str; @@ -31,7 +32,7 @@ private import std.stdio; /** * This tests the GtkD Entry widget */ -class TestEntries : Table +class TestEntries : Box { /** * Out main widget to test @@ -43,28 +44,42 @@ class TestEntries : Table */ this() { - super(3,2,false); + // super(3,2,false); + super(GtkOrientation.VERTICAL, 3); // create the main test widget - entry = new Entry("Change me!"); - attach(new Label("Input text"),0,1,0,1,AttachOptions.SHRINK,AttachOptions.SHRINK,4,4); - attach(entry,1,2,0,1,AttachOptions.EXPAND,AttachOptions.EXPAND,4,4); + auto box1 = new Box(GtkOrientation.HORIZONTAL, 10); + box1.setHomogeneous(true); + entry = new Entry(); + entry.setPlaceholderText("Change me!"); + box1.append(entry); + box1.append(new Label("Input text")); + append(box1); + // entry = new Entry("Change me!"); + // attach(new Label("Input text"),0,1,0,1,AttachOptions.SHRINK,AttachOptions.SHRINK,4,4); + // attach(entry,1,2,0,1,AttachOptions.EXPAND,AttachOptions.EXPAND,4,4); // create a button that will print the content of the entry to stdout - Button testButton = new Button("Show entry", &showEntry); - attach(testButton,2,3,0,1,AttachOptions.SHRINK,AttachOptions.SHRINK,4,4); + Button testButton = new Button("Show entry"); + testButton.addOnClicked(&this.showEntry); + // attach(testButton,2,3,0,1,AttachOptions.SHRINK,AttachOptions.SHRINK,4,4); + append(testButton); //testButton.setTooltip("This is just a test",null); // create a button that will change the entry display mode to invisible // i.e. like a password entry - CheckButton entryVisible = new CheckButton("Visible", &entryVisible); + CheckButton entryVisible = new CheckButton("Visible"); + entryVisible.addOnToggled(&this.entryVisible); entryVisible.setActive(true); - attach(entryVisible,2,3,1,2,AttachOptions.SHRINK,AttachOptions.SHRINK,4,4); + append(entryVisible); + // attach(entryVisible,2,3,1,2,AttachOptions.SHRINK,AttachOptions.SHRINK,4,4); // create a button that will change the entry mode to not editable - CheckButton entryEditable = new CheckButton("Editable", &entryEditable); + CheckButton entryEditable = new CheckButton("Editable"); + entryEditable.addOnToggled(&this.entryEditable); entryEditable.setActive(true); - attach(entryEditable,1,2,1,2,AttachOptions.SHRINK,AttachOptions.SHRINK,4,4); + append(entryEditable); + // attach(entryEditable,1,2,1,2,AttachOptions.SHRINK,AttachOptions.SHRINK,4,4); } void showEntry(Button button) @@ -79,6 +94,7 @@ class TestEntries : Table void entryVisible(CheckButton button) { + writeln(entry); entry.setVisibility(button.getActive()); } diff --git a/demos/gtkD/TestWindow/TestIdle.d b/demos/gtkD/TestWindow/TestIdle.d index b0abc3735..00414d610 100644 --- a/demos/gtkD/TestWindow/TestIdle.d +++ b/demos/gtkD/TestWindow/TestIdle.d @@ -23,8 +23,6 @@ module TestIdle; private import cairo.Context; private import cairo.ImageSurface; -private import gtk.VBox; -private import gtk.HBox; private import gtk.Box; private import gtk.DrawingArea; @@ -33,8 +31,8 @@ private import gtk.Widget; private import gtk.ComboBox; private import gtk.ComboBoxText; -private import gdk.Color; -private import gdk.Cairo; +// private import gdk.Color; +// private import gdk.Cairo; private import gtk.SpinButton; private import gtk.Adjustment; @@ -48,7 +46,7 @@ private import glib.Timeout; /** * This tests the gtkD drawing area widget */ -class TestIdle : VBox +class TestIdle : Box { SpinButton timeoutSpin; @@ -61,7 +59,7 @@ class TestIdle : VBox writeln("instantiating TestTimeout"); } - super(false,7); + super(GtkOrientation.VERTICAL, 7); TestDrawing drawingArea = new TestDrawing(); @@ -106,14 +104,14 @@ class TestIdle : VBox timeoutSpin = new SpinButton(new Adjustment(200.0, 1.0, 1000.0, 1.0, 100.0, 0),1,0); timeoutSpin.addOnValueChanged(&drawingArea.onTimeoutSpinValueChanged); - Box controlBox = new HBox(false, 7); + Box controlBox = new Box(GtkOrientation.HORIZONTAL, 7); - controlBox.packStart(operators, false, false, 2); - controlBox.packStart(callType, false, false, 2); - controlBox.packStart(timeoutSpin, false, false, 2); + controlBox.prepend(operators); + controlBox.prepend(callType); + controlBox.prepend(timeoutSpin); - packStart(drawingArea,true,true,0); - packStart(controlBox,false,false,0); + prepend(drawingArea); + prepend(controlBox); } class TestDrawing : DrawingArea @@ -143,8 +141,8 @@ class TestIdle : VBox addOnMap(&onMap); addOnUnmap(&onUnmap); - addOnSizeAllocate(&onSizeAllocate); - addOnDraw(&onDraw); + // addOnSizeAllocate(&onSizeAllocate); + // addOnDraw(&onDraw); } public void onMap(Widget widget) @@ -245,10 +243,10 @@ class TestIdle : VBox return continueIdleCallback; } - void onCallTypeChanged(ComboBoxText comboBoxText) + void onCallTypeChanged(ComboBox comboBoxText) { - debug(trace) writefln("gcOptions = %s", comboBoxText.getActiveText()); - switch ( comboBoxText.getActiveText() ) + debug(trace) writefln("gcOptions = %s", comboBoxText.getActiveId()); + switch ( comboBoxText.getActiveId() ) { case "Idle": callType = CallType.Idle; break; case "Timeout": callType = CallType.Timeout; break; @@ -257,10 +255,10 @@ class TestIdle : VBox resetCallType(); } - void onOperatorChanged(ComboBoxText comboBoxText) + void onOperatorChanged(ComboBox comboBoxText) { - debug(trace) writefln("CairoOperator = %s", comboBoxText.getActiveText()); - switch ( comboBoxText.getActiveText() ) + debug(trace) writefln("CairoOperator = %s", comboBoxText.getActiveId()); + switch ( comboBoxText.getActiveId() ) { case "CLEAR": operator = CairoOperator.CLEAR; break; case "SOURCE": operator = CairoOperator.SOURCE; break; diff --git a/demos/gtkD/TestWindow/TestImage.d b/demos/gtkD/TestWindow/TestImage.d index d97c83139..69c6d92f4 100644 --- a/demos/gtkD/TestWindow/TestImage.d +++ b/demos/gtkD/TestWindow/TestImage.d @@ -20,15 +20,20 @@ module TestImage; //debug = trace -private import gtk.VBox; +// private import gtk.VBox; -private import gtk.Table; +// private import gtk.Table; +private import gtk.Box; private import gtk.FileChooserDialog; +private import gtk.Dialog; private import gtk.Button; private import gtk.Widget; private import gtk.ScrolledWindow; -private import gtk.ButtonBox; -private import gtk.HButtonBox; +private import gtk.Viewport; +private import gtk.Adjustment; +private import gtk.Grid; +// private import gtk.ButtonBox; +// private import gtk.HButtonBox; private import gtk.Image; private import gtk.Window; @@ -40,10 +45,12 @@ private import glib.Str; /** * This tests the GtkD loading and display and image file */ -class TestImage : VBox +class TestImage : Box { - Table table; - FileChooserDialog fs; + // Table table; + Grid table; + // FileChooserDialog fs; + Dialog fs; ScrolledWindow sw; Window window; @@ -56,22 +63,23 @@ class TestImage : VBox writeln("instantiating TestImage"); } - super(false,8); + super(GtkOrientation.VERTICAL, 8); - sw = new ScrolledWindow(null,null); + sw = new ScrolledWindow(); + auto vp = new Viewport(null, null); + vp.setChild(initTable()); + sw.setChild(vp); - sw.addWithViewport(initTable()); - - ButtonBox hBox = HButtonBox.createActionBox(); - Button loadDir = new Button("Load Files", &loadImages); - hBox.packStart(loadDir,false,false,0); - - packStart(sw,true,true,0); - packStart(hBox,false,false,0); + auto hBox = new Box(GtkOrientation.HORIZONTAL, 0); + Button loadDir = new Button("Load Files"); + loadDir.addOnClicked(&this.loadImages); + hBox.prepend(loadDir); + prepend(sw); + prepend(hBox); } - Table initTable() + Grid initTable() { string[] pngs; @@ -89,17 +97,11 @@ class TestImage : VBox return loadTable(pngs); } - private Table loadTable(string[] imageFiles) + private Grid loadTable(string[] imageFiles) { //Table table = new Table(1,1,false); - if ( table is null ) - { - table = new Table(1,1,false); - } - else - { - table.removeAll(); - } + if (table !is null) remove(table); + table = new Grid(); int row = 0; @@ -115,7 +117,7 @@ class TestImage : VBox // progressWindow.show(); - for ( int i=0 ; i 0 ) - { - MessageDialog d = new MessageDialog(this, - GtkDialogFlags.MODAL, - MessageType.WARNING, - ButtonsType.OK, - "GtkD : Gtk+ version missmatch\n" ~ versionCompare ~ - "\nYou might run into problems!"~ - "\n\nPress OK to continue"); - d.run(); - d.destroy(); - } + // showAll(); + show(); + + // gtk.Version missing + // string versionCompare = Version.checkVersion(3,0,0); + + // if ( versionCompare.length > 0 ) + // { + // MessageDialog d = new MessageDialog(this, + // GtkDialogFlags.MODAL, + // MessageType.WARNING, + // ButtonsType.OK, + // "GtkD : Gtk+ version missmatch\n" ~ versionCompare ~ + // "\nYou might run into problems!"~ + // "\n\nPress OK to continue"); + // d.run(); + // d.destroy(); + // } } void setup() { //Frame.defaultBorder = 7; - VBox mainBox = new VBox(false,0); - mainBox.packStart(getMenuBar(),false,false,0); - mainBox.packStart(getToolbar(),false,false,0); + auto mainBox = new Box(GtkOrientation.VERTICAL, 0); + // mainBox.prepend(getMenuBar()); + mainBox.prepend(getToolbar()); Notebook notebook = setNotebook(); - notebook.setBorderWidth(10); - mainBox.packStart(notebook,true,true,0); + // notebook.setBorderWidth(10); + // mainBox.packStart(notebook,true,true,0); + mainBox.prepend(notebook); - Button cancelButton = new Button(StockID.CANCEL, &anyButtonExits); - Button exitButton = new Button(StockID.QUIT, &anyButtonExits); - Button quitButton = new Button(StockID.OK, &anyButtonExits); + // Button cancelButton = new Button(StockID.CANCEL, &anyButtonExits); + auto cancelButton = new Button(); + cancelButton.setIconName("cancel"); + cancelButton.addOnClicked(&anyButtonExits); - ButtonBox bBox = HButtonBox.createActionBox(); + Button exitButton = new Button(); + cancelButton.setIconName("quit"); + exitButton.addOnClicked(&anyButtonExits); + // kButton exitButton = new Button(StockID.QUIT, &anyButtonExits); - bBox.packEnd(exitButton,0,0,10); - bBox.packEnd(cancelButton,0,0,10); - bBox.packEnd(quitButton,0,0,10); - mainBox.packStart(bBox,false,false,0); + // Button quitButton = new Button(StockID.OK, &anyButtonExits); + Button quitButton = new Button(); + cancelButton.setIconName("ok"); + quitButton.addOnClicked(&anyButtonExits); - Statusbar statusbar = new Statusbar(); + // Box bBox = HButtonBox.createActionBox(); + Box bBox = new Box(GtkOrientation.HORIZONTAL, 0); - mainBox.packStart(statusbar,false,true,0); - add(mainBox); + bBox.append(exitButton); + bBox.append(cancelButton); + bBox.append(quitButton); + mainBox.prepend(bBox); - notebook.appendPage(new TestEntries,"Entry"); + Statusbar statusbar = new Statusbar(); + + mainBox.prepend(statusbar); + setChild(mainBox); + + notebook.appendPage(new TestEntries, new Label("Entry")); testEventBox(notebook); testButtons(notebook); - notebook.appendPage(new TestStock,"Stock"); + notebook.appendPage(new TestStock, new Label("Stock")); testLists(notebook); testNotebook(notebook); testPaned(notebook); testDialogs(notebook); testViewport(notebook); - notebook.appendPage(new TestScales,"Scales"); + notebook.appendPage(new TestScales, new Label("Scales")); testSpinButton(notebook); - notebook.appendPage(new TestTreeView,"TreeView"); + notebook.appendPage(new TestTreeView, new Label("TreeView")); // notebook.appendPage(new TestTreeView1,"TreeView 1"); // testList(notebook); version(linux) { // this block crashes gtk+ on win32 for some reason - notebook.appendPage(new Frame(new TestDrawingArea,"Drawing Area"),"Drawing"); - notebook.appendPage(new TestText,"Text"); - notebook.appendPage(new TestImage(this),"Image"); + auto frm = new Frame("Drawing Area"); + frm.setChild(new TestDrawingArea); + notebook.appendPage(frm, new Label("Drawing")); + notebook.appendPage(new TestText, new Label("Text")); + notebook.appendPage(new TestImage(this), new Label("Image")); //TestThemes seems to be unfinished. //notebook.appendPage(new TestThemes(this),"Themes"); - notebook.appendPage(new TestAspectFrame(),"Aspect Frame"); - notebook.appendPage(new TestIdle(),"Idle"); - version(cairo)notebook.appendPage(new Clock(), "Cairo"); + notebook.appendPage(new TestAspectFrame(), new Label("Aspect Frame")); + notebook.appendPage(new TestIdle(), new Label("Idle")); + version(cairo)notebook.appendPage(new Clock(), new Label("Cairo")); gtkDemo(notebook); } } - MenuBar getMenuBar() + PopoverMenuBar getMenuBar() { - AccelGroup accelGroup = new AccelGroup(); - - addAccelGroup(accelGroup); - + import gio.MenuModel; - MenuBar menuBar = new MenuBar(); + // THis probably won't work + auto menuBarModel = new MenuModel(new GMenuModel()); + auto menuBar = new PopoverMenuBar(menuBarModel); - Menu menu = menuBar.append("_File"); + // AccelGroup accelGroup = new AccelGroup(); - MenuItem item = new MenuItem(&onMenuActivate, "_New","file.new", true, accelGroup, 'n'); - //item.addAccelerator("activate",accelGroup,'n',GdkModifierType.CONTROL_MASK,GtkAccelFlags.VISIBLE); + // addAccelGroup(accelGroup); - menu.append(item); - menu.append(new MenuItem(&onMenuActivate, "_Open","file.open", true, accelGroup, 'o')); - menu.append(new MenuItem(&onMenuActivate, "_Close","file.close", true, accelGroup, 'c')); - menu.append(new MenuItem(&onMenuActivate, "E_xit","file.exit", true, accelGroup, 'x')); + // MenuBar menuBar = new MenuBar(); + // Menu menu = menuBar.append("_File"); - menu = menuBar.append("_Edit"); + // MenuItem item = new MenuItem(&onMenuActivate, "_New","file.new", true, accelGroup, 'n'); + // //item.addAccelerator("activate",accelGroup,'n',GdkModifierType.CONTROL_MASK,GtkAccelFlags.VISIBLE); - menu.append(new MenuItem(&onMenuActivate,"_Find","edit.find", true, accelGroup, 'f')); - menu.append(new MenuItem(&onMenuActivate,"_Search","edit.search", true, accelGroup, 's')); + // menu.append(item); + // menu.append(new MenuItem(&onMenuActivate, "_Open","file.open", true, accelGroup, 'o')); + // menu.append(new MenuItem(&onMenuActivate, "_Close","file.close", true, accelGroup, 'c')); + // menu.append(new MenuItem(&onMenuActivate, "E_xit","file.exit", true, accelGroup, 'x')); - menu = menuBar.append("_Help"); - menu.append(new MenuItem(&onMenuActivate,"_About","help.about", true, accelGroup, 'a',GdkModifierType.CONTROL_MASK|GdkModifierType.SHIFT_MASK)); + // menu = menuBar.append("_Edit"); + // menu.append(new MenuItem(&onMenuActivate,"_Find","edit.find", true, accelGroup, 'f')); + // menu.append(new MenuItem(&onMenuActivate,"_Search","edit.search", true, accelGroup, 's')); + // menu = menuBar.append("_Help"); + // menu.append(new MenuItem(&onMenuActivate,"_About","help.about", true, accelGroup, 'a',GdkModifierType.CONTROL_MASK|GdkModifierType.SHIFT_MASK)); return menuBar; } @@ -281,36 +310,35 @@ class TestWindow : ApplicationWindow names ~= "www.gtk.org (base C library)"; setAuthors( names ); - setDocumenters( names ); + setDocumenters(names); setArtists( names ); setLicense("License is LGPL"); setWebsite("http://lisdev.com"); } } - void onMenuActivate(MenuItem menuItem) - { - string action = menuItem.getActionName(); - switch( action ) - { - case "help.about": - GtkDAbout dlg = new GtkDAbout(); - dlg.addOnResponse(&onDialogResponse); - dlg.showAll(); - break; - default: - MessageDialog d = new MessageDialog( - this, - GtkDialogFlags.MODAL, - MessageType.INFO, - ButtonsType.OK, - "You pressed menu item "~action); - d.run(); - d.destroy(); - break; - } - - } + // void onMenuActivate(MenuItem menuItem) + // { + // string action = menuItem.getActionName(); + // switch( action ) + // { + // case "help.about": + // GtkDAbout dlg = new GtkDAbout(); + // dlg.addOnResponse(&onDialogResponse); + // dlg.showAll(); + // break; + // default: + // MessageDialog d = new MessageDialog( + // this, + // GtkDialogFlags.MODAL, + // MessageType.INFO, + // ButtonsType.OK, + // "You pressed menu item "~action); + // d.run(); + // d.destroy(); + // break; + // } + // } void onDialogResponse(int response, Dialog dlg) { @@ -318,25 +346,53 @@ class TestWindow : ApplicationWindow dlg.destroy(); } - Widget getToolbar() + Box getToolbar() { - HandleBox handleBox = new HandleBox(); - Toolbar toolbar = new Toolbar(); - toolbar.insert(new ToolButton(StockID.OPEN)); - toolbar.insert(new ToolButton(StockID.CLOSE)); - toolbar.insert(new SeparatorToolItem()); - toolbar.insert(new ToolButton(StockID.SAVE)); - toolbar.insert(new ToolButton(StockID.SAVE_AS)); + // HandleBox handleBox = new HandleBox(); + // Toolbar toolbar = new Toolbar(); + // auto handleBox = new Box(GtkOrientation.VERTICAL, 0); + auto toolbar = new Box(GtkOrientation.HORIZONTAL, 3); + + auto toolbarLeft = new Box(GtkOrientation.HORIZONTAL, 3); - handleBox.add(toolbar); + Button btn; + btn = new Button(); + btn.setIconName("open"); + toolbarLeft.append(btn); - return handleBox; + // toolbar.append(new ToolButton(StockID.CLOSE)); + btn = new Button(); + btn.setIconName("open"); + toolbarLeft.append(btn); + toolbar.append(toolbarLeft); + toolbar.append(new Separator(GtkOrientation.VERTICAL)); + + // toolbar.append(new SeparatorToolItem()); + // btn = new Button(); + // btn.setIconName(""); + // toolbar.append(btn); + + // toolbar.append(new ToolButton(StockID.SAVE)); + auto toolbarRight = new Box(GtkOrientation.HORIZONTAL, 3); + btn = new Button(); + btn.setIconName("save"); + toolbarRight.append(btn); + + // toolbar.append(new ToolButton(StockID.SAVE_AS)); + btn = new Button(); + btn.setIconName("save_as"); + toolbarRight.append(btn); + + toolbar.append(toolbarRight); + + return toolbar; } Notebook setNotebook() { Notebook notebook = new Notebook(); + notebook.setScrollable(true); notebook.addOnSwitchPage(&onNotebookSwitchPage); notebook.setTabPos(PositionType.LEFT); return notebook; @@ -368,39 +424,48 @@ class TestWindow : ApplicationWindow void testButtons(Notebook notebook) { - Table table = new Table(2,12,0); + auto table = new Grid(); //ListSG listSG = new ListSG(); - RadioButton radio1Button = new RadioButton(cast(ListSG)null,"Option 1"); - RadioButton radio2Button = new RadioButton(radio1Button,"Option 2"); - RadioButton radio3Button = new RadioButton(radio2Button,"Option 3"); - RadioButton radio4Button = new RadioButton(radio3Button,"Option 4"); - RadioButton radio5Button = new RadioButton(radio4Button,"Option 5"); - RadioButton radio6Button = new RadioButton(radio5Button,"Option 6"); - RadioButton radio7Button = new RadioButton(radio6Button,"Option 7"); - RadioButton radio8Button = new RadioButton(radio7Button,"Option 8"); - RadioButton radio9Button = new RadioButton(radio8Button,"Option 9"); - table.attach(radio1Button,0,1,0,1,AttachOptions.FILL,AttachOptions.FILL,4,4); - table.attach(radio2Button,0,1,1,2,AttachOptions.FILL,AttachOptions.FILL,4,4); - table.attach(radio3Button,0,1,2,3,AttachOptions.FILL,AttachOptions.FILL,4,4); - table.attach(radio4Button,0,1,3,4,AttachOptions.FILL,AttachOptions.FILL,4,4); - table.attach(radio5Button,0,1,4,5,AttachOptions.FILL,AttachOptions.FILL,4,4); - table.attach(radio6Button,0,1,5,6,AttachOptions.FILL,AttachOptions.FILL,4,4); - table.attach(radio7Button,0,1,6,7,AttachOptions.FILL,AttachOptions.FILL,4,4); - table.attach(radio8Button,0,1,7,8,AttachOptions.FILL,AttachOptions.FILL,4,4); - table.attach(radio9Button,0,1,8,9,AttachOptions.FILL,AttachOptions.FILL,4,4); + auto radio1Button = new CheckButton("Option 1"); + auto radio2Button = new CheckButton("Option 2"); + radio2Button.setGroup(radio1Button); + auto radio3Button = new CheckButton("Option 3"); + radio3Button.setGroup(radio2Button); + auto radio4Button = new CheckButton("Option 4"); + radio4Button.setGroup(radio3Button); + auto radio5Button = new CheckButton("Option 5"); + radio5Button.setGroup(radio4Button); + auto radio6Button = new CheckButton("Option 6"); + radio6Button.setGroup(radio5Button); + auto radio7Button = new CheckButton("Option 7"); + radio7Button.setGroup(radio6Button); + auto radio8Button = new CheckButton("Option 8"); + radio8Button.setGroup(radio7Button); + auto radio9Button = new CheckButton("Option 9"); + radio9Button.setGroup(radio8Button); + + table.attach(radio1Button,0,1,4,4); + table.attach(radio2Button,1,2,4,4); + table.attach(radio3Button,2,3,4,4); + table.attach(radio4Button,3,4,4,4); + table.attach(radio5Button,4,5,4,4); + table.attach(radio6Button,5,6,4,4); + table.attach(radio7Button,6,7,4,4); + table.attach(radio8Button,7,8,4,4); + table.attach(radio9Button,8,9,4,4); CheckButton editableButton = new CheckButton("editable"); CheckButton visibleButton = new CheckButton("visible"); - table.attach(editableButton,0,1,9,10,AttachOptions.FILL,AttachOptions.FILL,4,4); - table.attach(visibleButton,0,1,10,11,AttachOptions.FILL,AttachOptions.FILL,4,4); + table.attach(editableButton,9,10,4,4); + table.attach(visibleButton,10,11,4,4); ToggleButton toggleButton = new ToggleButton("Toggle this"); - table.attach(toggleButton,0,1,11,12,AttachOptions.FILL,AttachOptions.FILL,4,4); + table.attach(toggleButton,11,12,4,4); Button button = new Button("test events"); - table.attach(button,0,1,12,13,AttachOptions.FILL,AttachOptions.FILL,4,4); + table.attach(button,12,13,4,4); void bActivate(Button button) { @@ -428,10 +493,10 @@ class TestWindow : ApplicationWindow } button.addOnActivate(&bActivate); button.addOnClicked(&bClicked); - button.addOnEnter(&bEnter); - button.addOnLeave(&bLeave); - button.addOnPressed(&bPressed); - button.addOnReleased(&bReleased); + // button.addOnEnter(&bEnter); + // button.addOnLeave(&bLeave); + // button.addOnPressed(&bPressed); + // button.addOnReleased(&bReleased); // for ( ShadowType shadow = 0; shadow<=ShadowType.max ; shadow ++) // { @@ -443,10 +508,9 @@ class TestWindow : ApplicationWindow // table.attach(new Arrow(direction,shadow),direction+1,direction+2,shadow,shadow+1,AttachOptions.FILL,AttachOptions.FILL,4,4); // } // } - - - notebook.appendPage(new Frame(table,"Buttons"),"Buttons"); - + auto frm = new Frame("Buttons"); + frm.setChild(table); + notebook.appendPage(frm, new Label("Buttons")); } class ComboStore : TreeStore @@ -466,10 +530,10 @@ class TestWindow : ApplicationWindow void testLists(Notebook notebook) { - VBox mainBox = new VBox(false,3); + Box mainBox = new Box(GtkOrientation.VERTICAL,3); // comboBoxTextEntry from a list of strings - mainBox.packStart(new Label("String combo"),false,true,0); + mainBox.prepend(new Label("String combo")); static string[] cbList = ["item 1","item 2","item 3","item 4","item 5","item 6","item 7","item 8","item 9"]; comboText = new ComboBoxText(); string entry3 = "Combo box text entry 3"; @@ -480,15 +544,16 @@ class TestWindow : ApplicationWindow comboText.appendText("Combo box text entry 5"); comboText.setActive(2); - ButtonBox actionBox1 = HButtonBox.createActionBox(); - actionBox1.packStart(comboText,false,false,0); - - Button showCombo1 = new Button("ShowCombo", &showTextCombo); - actionBox1.packStart(showCombo1,false,false,0); - - mainBox.packStart(new Frame(actionBox1, "Text entry ComboBox"),false,false,0); + Box actionBox1 = new Box(GtkOrientation.HORIZONTAL, 0); + actionBox1.prepend(comboText); + Button showCombo1 = new Button("ShowCombo"); + showCombo1.addOnClicked(&showTextCombo); + actionBox1.prepend(showCombo1); + auto frm = new Frame("Text entry ComboBox"); + frm.setChild(actionBox1); + mainBox.prepend(frm); // TODO combo with widgets @@ -499,34 +564,36 @@ class TestWindow : ApplicationWindow TreeIter iterFirst; // to set the first active iter TreeIter iterChild; - TreeIter iterTop = comboStore.append(null); - comboStore.setValue(iterTop, 0, "Paganini" ); - iterFirst = comboStore.append(iterTop); - comboStore.setValue(iterFirst, 0, "Nicolo" ); - - iterTop = comboStore.append(null); - comboStore.setValue(iterTop, 0, "List" ); - iterChild = comboStore.append(iterTop); - comboStore.setValue(iterChild, 0, "Franz" ); - - iterTop = comboStore.append(null); - comboStore.setValue(iterTop, 0, "Beethoven" ); - iterChild = comboStore.append(iterTop); - comboStore.setValue(iterChild, 0, "Ludwic" ); - iterChild = comboStore.append(iterTop); - comboStore.setValue(iterChild, 0, "Maria" ); - iterChild = comboStore.append(iterTop); - comboStore.setValue(iterChild, 0, "Van" ); - - iterTop = comboStore.append(null); - comboStore.setValue(iterTop, 0, "Bach" ); - iterChild = comboStore.append(iterTop); - comboStore.setValue(iterChild, 0, "Johann" ); - iterChild = comboStore.append(iterTop); - comboStore.setValue(iterChild, 0, "Sebastian" ); + TreeIter iterTop; + comboStore.append(iterTop, null); + comboStore.setValue(iterTop, 0, new Value("Paganini")); + + comboStore.append(iterTop, iterTop); + comboStore.setValue(iterTop, 0, new Value("Nicolo")); + + comboStore.append(iterTop, null); + comboStore.setValue(iterTop, 0, new Value("List")); + comboStore.append(iterChild, iterTop); + comboStore.setValue(iterChild, 0, new Value("Franz")); + + comboStore.append(iterTop, null); + comboStore.setValue(iterTop, 0, new Value("Beethoven")); + comboStore.append(iterChild, iterTop); + comboStore.setValue(iterChild, 0, new Value("Ludwic")); + comboStore.append(iterChild, iterTop); + comboStore.setValue(iterChild, 0, new Value("Maria")); + comboStore.append(iterChild, iterTop); + comboStore.setValue(iterChild, 0, new Value("Van")); + + comboStore.append(iterTop, null); + comboStore.setValue(iterTop, 0, new Value("Bach")); + comboStore.append(iterChild, iterTop); + comboStore.setValue(iterChild, 0, new Value("Johann")); + comboStore.append(iterChild, iterTop); + comboStore.setValue(iterChild, 0, new Value("Sebastian")); ComboBox treeCombo = new ComboBox(comboStore); - treeCombo.setWrapWidth(1); + // treeCombo.setWrapWidth(1); treeCombo.setProperty("entry-text-column", 0); // TODO something is wrong gettign the ier from the path @@ -535,8 +602,9 @@ class TestWindow : ApplicationWindow //treeCombo.setActiveIter(iterChild); // use a previously set iter treeCombo.setActiveIter(iterFirst); - - mainBox.packStart(new Frame(treeCombo,"Tree Combo box"),false,true,0); + auto treeComboFrame = new Frame("Tree Combo box"); + treeComboFrame.setChild(treeCombo); + mainBox.prepend(treeComboFrame); simpleCombo = new ComboBoxText(); simpleCombo.appendText("Top"); @@ -547,15 +615,21 @@ class TestWindow : ApplicationWindow // actions - ButtonBox actionBox = HButtonBox.createActionBox(); - actionBox.packStart(simpleCombo,false,false,0); + // ButtonBox actionBox = HButtonBox.createActionBox(); + Box actionBox = new Box(GtkOrientation.HORIZONTAL, 0); + actionBox.prepend(simpleCombo); - Button showCombo = new Button("ShowCombo", &showSimpleCombo); - actionBox.packStart(showCombo,false,false,0); + Button showCombo = new Button("ShowCombo"); + showCombo.addOnClicked(&showSimpleCombo); + actionBox.prepend(showCombo); - mainBox.packStart(new Frame(actionBox, "Simple text list"),false,false,0); + auto frame1 = new Frame("Simple text list"); + frm.setChild(actionBox); + mainBox.prepend(frame1); - notebook.appendPage(new Frame(mainBox,"Lists"),"Lists"); + auto frame2 = new Frame("Lists"); + frame2.setChild(mainBox); + notebook.appendPage(frame2, new Label("Lists")); } ComboBoxText simpleCombo; @@ -573,7 +647,7 @@ class TestWindow : ApplicationWindow class NB : Notebook { - void itemActivated(MenuItem menu_item) + void itemActivated(Widget menu_item) { writeln("NB.activateCallback"); } @@ -619,7 +693,7 @@ class TestWindow : ApplicationWindow nb.setTabPos(PositionType.min); nb.popupEnable(); nb.setShowBorder(false); - nb.setBorderWidth(0); + // nb.setBorderWidth(0); class PageMove { @@ -646,7 +720,8 @@ class TestWindow : ApplicationWindow for( char i = '1' ; i<'5' ; i++ ) { - Table table = new Table(2,2,true); + // Table table = new Table(2,2,true); + Grid table = new Grid(); Button left = new Button("Left "~ i); left.addOnClicked(&posLeft); Button right = new Button("Right "~ i); @@ -656,10 +731,10 @@ class TestWindow : ApplicationWindow Button bottom = new Button("bottom "~ i); bottom.addOnClicked(&posBottom); - table.attach(top,0,1,0,1,AttachOptions.SHRINK,AttachOptions.SHRINK,4,4); - table.attach(right,1,2,0,1,AttachOptions.SHRINK,AttachOptions.SHRINK,4,4); - table.attach(left,0,1,1,2,AttachOptions.SHRINK,AttachOptions.SHRINK,4,4); - table.attach(bottom,1,2,1,2,AttachOptions.SHRINK,AttachOptions.SHRINK,4,4); + table.attach(top,0,0,4,4); + table.attach(right,1,0,4,4); + table.attach(left,0,1,4,4); + table.attach(bottom,1,1,4,4); if ( i == 3 ) { @@ -673,16 +748,16 @@ class TestWindow : ApplicationWindow // // menuItem.setSubmenu(menu); - HBox box = new HBox(false,0); - box.setBorderWidth(0); + Box box = new Box(GtkOrientation.HORIZONTAL, 0); + // box.setBorderWidth(0); Button button = new Button("Page " ~ i ~ "\0"); button.addOnClicked(&nb.buttonClicked); - button.setBorderWidth(0); - button.setRelief(ReliefStyle.NONE); + // button.setBorderWidth(0); + // button.setRelief(ReliefStyle.NONE); CheckButton checkButton = new CheckButton(); - checkButton.setBorderWidth(0); - box.packStart(checkButton,false,false,0); - box.packStart(button,false,false,0); + // checkButton.setBorderWidth(0); + box.prepend(checkButton); + box.prepend(button); //nb.appendPageMenu(table,box,menuItem); //nb.appendPage(table,box); } @@ -697,7 +772,7 @@ class TestWindow : ApplicationWindow void testPaned(Notebook notebook) { - Paned mainPaned = new VPaned(); + Paned mainPaned = new Paned(GtkOrientation.VERTICAL); Paned p0 = mainPaned; Button p1; Paned p2; @@ -706,11 +781,11 @@ class TestWindow : ApplicationWindow for ( char c='1' ; c<='5' ; c++ ) { p1 = new Button("Pane "~c); - if ( h ) p2 = new HPaned(); - else p2 = new VPaned(); + if ( h ) p2 = new Paned(GtkOrientation.HORIZONTAL); + else p2 = new Paned(GtkOrientation.VERTICAL); - p0.add1(p1); - p0.add2(p2); + p0.setStartChild(p1); + p0.setEndChild(p2); p0 = p2; h = !h; } @@ -720,8 +795,8 @@ class TestWindow : ApplicationWindow } FileChooserDialog fcd; - FontSelectionDialog f; - ColorSelectionDialog d; + FontChooserDialog f; + ColorChooserDialog d; void showFileChooser(Button button) { @@ -733,85 +808,99 @@ class TestWindow : ApplicationWindow r ~= ResponseType.CANCEL; if ( fcd is null ) { - fcd = new FileChooserDialog("File Chooser", this, FileChooserAction.OPEN, a, r); + // fcd = new FileChooserDialog("File Chooser", this, FileChooserAction.OPEN, a, r); + // fcd = new FileChooserDialog(); } - fcd.setSelectMultiple(true); - fcd.run(); + // fcd.setSelectMultiple(true); + // fcd.run(); + // writefln("file selected = %s",fcd.getFileName()); // // foreach ( int i, string selection ; fs.getSelections()) // { // writefln("File(s) selected [%d] %s",i,selection); // } - fcd.hide(); + // fcd.hide(); } void showColor(Button button) { if ( d is null ) { - d = new ColorSelectionDialog("Select the color"); + d = new ColorChooserDialog("Select the color", this); } - d.run(); - d.hide(); + d.show(); + // d.run(); + // d.hide(); } void showCalendar(Button button) { - Window calWin = new Window("Calendar"); + Window calWin = new Window(); + calWin.setTitle("Calendar"); Calendar calendar = new Calendar(); //calendar.setTitle("No Title"); - calWin.add(calendar); - calWin.showAll(); + calWin.setChild(calendar); + calWin.show(); } void showFont(Button button) { - if ( f is null ) + import gtk.FontChooserIF; + + if (f is null) { - f = new FontSelectionDialog("Select the font"); + f = new FontChooserDialog("Select the font", this); + f.addOnFontActivated(delegate(string font, FontChooserIF fc) { + writeln("Selected font %s", font); + }); } - f.run(); - string fontName = f.getFontName(); - f.hide(); + f.show(); } Button fontButton; void testDialogs(Notebook notebook) { + // ButtonBox bBox = VButtonBox.createActionBox(); + auto bBox = new Box(GtkOrientation.VERTICAL, 0); - ButtonBox bBox = VButtonBox.createActionBox(); + // if ( fcd is null ) + // { + // // fcd = new FileChooserDialog("File Chooser", this, FileChooserAction.OPEN); + // fcd = new FileChooserDialog(); + // } - if ( fcd is null ) - { - fcd = new FileChooserDialog("File Chooser", this, FileChooserAction.OPEN); - } + Button fileChooser = new Button("File Chooser"); + fileChooser.addOnClicked(&showFileChooser); - Button fileChooser = new Button("File Chooser", &showFileChooser); - FileChooserButton fcb = new FileChooserButton(fcd); - - Button color = new Button("Color Dialog", &showColor); - Button calendar = new Button("Calendar Dialog", &showCalendar); - fontButton = new Button("Font Dialog", &showFont); + Button color = new Button("Color Dialog"); + color.addOnClicked(&showColor); + Button calendar = new Button("Calendar Dialog"); + calendar.addOnClicked(&showCalendar); + fontButton = new Button("Font Dialog"); + fontButton.addOnClicked(&showFont); //fontButton.modifyFont("[Newspaper][16]"); - bBox.packStart(fileChooser,0,0,10); - bBox.packStart(fcb,0,0,10); - bBox.packStart(color,0,0,10); - bBox.packStart(calendar,0,0,10); - bBox.packStart(fontButton,0,0,10); + bBox.prepend(fileChooser); + // bBox.prepend(fcb); + bBox.prepend(color); + bBox.prepend(calendar); + bBox.prepend(fontButton); - notebook.appendPage(new Frame(bBox,"Dialogs"),new Label("Dialogs")); + auto frm = new Frame("Dialogs"); + frm.setChild(bBox); + notebook.appendPage(frm, new Label("Dialogs")); } void testViewport(Notebook notebook) { - Table grid = new Table(21,21,0); + // Should we be using a GridView? + Grid grid = new Grid(); for ( int i = 0 ; i<21 ; i++) { for ( int j = 0 ; j<21; j++) @@ -820,28 +909,28 @@ class TestWindow : ApplicationWindow { grid.attach( new Button("Button"), - i,i+1, - j,j+1, - AttachOptions.SHRINK,AttachOptions.SHRINK,4,4); + i, j, 4,4); } } } - ScrolledWindow sw = new ScrolledWindow(null,null); - sw.addWithViewport(grid); + ScrolledWindow sw = new ScrolledWindow(); + auto vp = new Viewport(null, null); + sw.setChild(vp); + vp.setChild(grid); + // sw.addWithViewport(grid); notebook.appendPage(sw,new Label("Viewport")); } void testSpinButton(Notebook notebook) { - Table table = new Table(2,1,false); + auto table = new Grid(); SpinButton spin = new SpinButton(new Adjustment(1.0, 0.0, 100.0, 1.0, 10.0, 0),1,0); - table.attach(new Label("Spin this:"),0,1,0,1,AttachOptions.FILL,AttachOptions.FILL,4,4); - table.attach(spin,1,2,0,1,AttachOptions.FILL,AttachOptions.FILL,4,4); - - notebook.appendPage(table,"Spin Buttons"); + table.attach(new Label("Spin this:"),0,0,4,4); + table.attach(spin,1,0,4,4); + notebook.appendPage(table, new Label("Spin Buttons")); } void testList(Notebook notebook) @@ -861,56 +950,65 @@ class TestWindow : ApplicationWindow TestListStore testListStore = new TestListStore(); - TreeIter iterTop = testListStore.createIter(); + TreeIter iterTop; + testListStore.getIterFirst(iterTop); static int [3] cols = [0,1,2]; - string[] vals; - vals ~= "Antonio"; - vals ~= "Canada"; - vals ~= "Ontario"; - testListStore.set(iterTop,cols,vals); + Value[] vals; + vals ~= new Value("Antonio"); + vals ~= new Value("Canada"); + vals ~= new Value("Ontario"); + testListStore.setValuesv(iterTop, cols, vals); + // testListStore.set(iterTop,cols,vals); testListStore.append(iterTop); - string[] vals1; - vals1 ~= "John Reimer"; - vals1 ~= "Canada"; - vals1 ~= "BC"; - testListStore.set(iterTop,cols,vals1); + Value[] vals1; + vals1 ~= new Value("John Reimer"); + vals1 ~= new Value("Canada"); + vals1 ~= new Value("BC"); + testListStore.setValuesv(iterTop,cols,vals1); testListStore.append(iterTop); - string[] vals2; - vals2 ~= "Friend of GtkD 2"; - vals2 ~= "Poland"; - vals2 ~= "Torun"; - testListStore.set(iterTop,cols,vals2); + Value[] vals2; + vals2 ~= new Value("Friend of GtkD 2"); + vals2 ~= new Value( "Poland"); + vals2 ~= new Value("Torun"); + testListStore.setValuesv(iterTop,cols,vals2); testListStore.append(iterTop); - string[] vals3; - vals3 ~= "Friend of GtkD 3"; - vals3 ~= "Norway"; - vals3 ~= "Norway"; - testListStore.set(iterTop,cols,vals3); + Value[] vals3; + vals3 ~= new Value("Friend of GtkD 3"); + vals3 ~= new Value("Norway"); + vals3 ~= new Value("Norway"); + testListStore.setValuesv(iterTop,cols,vals3); TreeView treeView = new TreeView(testListStore); treeView.setHeadersClickable(true); - treeView.setRulesHint(true); + // treeView.setRulesHint(true); //CellRendererText cellText = new CellRendererText(); - TreeViewColumn column = new TreeViewColumn("Author",new CellRendererText(),"text", 0); + // TreeViewColumn column = new TreeViewColumn("Author",new CellRendererText(),"text", 0); + TreeViewColumn column = new TreeViewColumn(); + column.setTitle("Author"); + column.addAttribute(new CellRendererText(), "text", 0); treeView.appendColumn(column); column.setResizable(true); column.setReorderable(true); column.setSortColumnId(0); column.setSortIndicator(true); - column = new TreeViewColumn("Country",new CellRendererText(),"text", 1); + column = new TreeViewColumn(); + column.setTitle("Country"); + column.addAttribute(new CellRendererText(), "text", 1); treeView.appendColumn(column); column.setResizable(true); column.setReorderable(true); column.setSortColumnId(1); column.setSortIndicator(true); - column = new TreeViewColumn("Province",new CellRendererText(),"text", 2); + column = new TreeViewColumn(); + column.setTitle("Province"); + column.addAttribute(new CellRendererText(), "text", 2); treeView.appendColumn(column); column.setResizable(true); column.setReorderable(true); @@ -918,9 +1016,12 @@ class TestWindow : ApplicationWindow column.setSortIndicator(true); //notebook.appendPage(treeView,"ListView"); - ScrolledWindow sw = new ScrolledWindow(null,null); - sw.addWithViewport(treeView); - notebook.appendPage(sw,"ListView"); + ScrolledWindow sw = new ScrolledWindow(); + auto vp = new Viewport(null, null); + sw.setChild(vp); + vp.setChild(treeView); + // sw.addWithViewport(treeView); + notebook.appendPage(sw, new Label("ListView")); } void testDelete(Notebook notebook) @@ -954,17 +1055,17 @@ class TestWindow : ApplicationWindow // new TEditableCells(); } - ButtonBox vBBox = VButtonBox.createActionBox(); + auto vBBox = new Box(GtkOrientation.VERTICAL, 0); Button button = new Button("Text View"); button.addOnClicked(&showTTextView); - vBBox.packStart(button,false,false,4); + vBBox.prepend(button); button = new Button("Editable Cells"); button.addOnClicked(&showTEditableCells); - vBBox.packStart(button,false,false,4); + vBBox.prepend(button); - notebook.appendPage(vBBox,"gtk-demo"); + notebook.appendPage(vBBox, new Label("gtk-demo")); } } diff --git a/generated/gstreamer/gstreamer/DateTime.d b/generated/gstreamer/gstreamer/DateTime.d index 779cf104a..956a992b7 100644 --- a/generated/gstreamer/gstreamer/DateTime.d +++ b/generated/gstreamer/gstreamer/DateTime.d @@ -254,17 +254,17 @@ public class DateTime * * Throws: ConstructionException GTK+ fails to create the object. */ - public this(long usecs) - { - auto __p = gst_date_time_new_from_unix_epoch_local_time_usecs(usecs); + // public this(long usecs) + // { + // auto __p = gst_date_time_new_from_unix_epoch_local_time_usecs(usecs); - if(__p is null) - { - throw new ConstructionException("null returned by new_from_unix_epoch_local_time_usecs"); - } + // if(__p is null) + // { + // throw new ConstructionException("null returned by new_from_unix_epoch_local_time_usecs"); + // } - this(cast(GstDateTime*) __p); - } + // this(cast(GstDateTime*) __p); + // } /** * Creates a new #GstDateTime using the time since Jan 1, 1970 specified by diff --git a/wrap b/wrap index baf648807..296174212 160000 --- a/wrap +++ b/wrap @@ -1 +1 @@ -Subproject commit baf648807c9609c6d5725a988c1ed03155984f67 +Subproject commit 296174212f257cf7cfb1a80fa698749b382511e9