nobody at rubyforge.org
2006-Dec-26 11:18 UTC
[Wxruby-development] [806] trunk/wxruby2/samples/treectrl: Restored demonstration of use of icons and fonts within TreeCtrl
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head><meta http-equiv="content-type" content="text/html; charset=utf-8" /><style type="text/css"><!-- #msg dl { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; } #msg dt { float: left; width: 6em; font-weight: bold; } #msg dt:after { content:'':'';} #msg dl, #msg dt, #msg ul, #msg li, #header, #footer { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; } #msg dl a { font-weight: bold} #msg dl a:link { color:#fc3; } #msg dl a:active { color:#ff0; } #msg dl a:visited { color:#cc6; } h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; } #msg pre { overflow: auto; background: #ffc; border: 1px #fc0 solid; padding: 6px; } #msg ul, pre { overflow: auto; } #header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; } #patch { width: 100%; } #patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;} #patch .propset h4, #patch .binary h4 {margin:0;} #patch pre {padding:0;line-height:1.2em;margin:0;} #patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;} #patch .propset .diff, #patch .binary .diff {padding:10px 0;} #patch span {display:block;padding:0 10px;} #patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;} #patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;} #patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;} #patch .lines, .info {color:#888;background:#fff;} --></style> <title>[806] trunk/wxruby2/samples/treectrl: Restored demonstration of use of icons and fonts within TreeCtrl</title> </head> <body> <div id="msg"> <dl> <dt>Revision</dt> <dd>806</dd> <dt>Author</dt> <dd>brokentoy</dd> <dt>Date</dt> <dd>2006-12-26 06:18:31 -0500 (Tue, 26 Dec 2006)</dd> </dl> <h3>Log Message</h3> <pre>Restored demonstration of use of icons and fonts within TreeCtrl</pre> <h3>Modified Paths</h3> <ul> <li><a href="#trunkwxruby2samplestreectrltreectrlrb">trunk/wxruby2/samples/treectrl/treectrl.rb</a></li> </ul> <h3>Added Paths</h3> <ul> <li><a href="#trunkwxruby2samplestreectrlicon1xpm">trunk/wxruby2/samples/treectrl/icon1.xpm</a></li> <li><a href="#trunkwxruby2samplestreectrlicon2xpm">trunk/wxruby2/samples/treectrl/icon2.xpm</a></li> <li><a href="#trunkwxruby2samplestreectrlicon3xpm">trunk/wxruby2/samples/treectrl/icon3.xpm</a></li> <li><a href="#trunkwxruby2samplestreectrlicon4xpm">trunk/wxruby2/samples/treectrl/icon4.xpm</a></li> <li><a href="#trunkwxruby2samplestreectrlicon5xpm">trunk/wxruby2/samples/treectrl/icon5.xpm</a></li> </ul> </div> <div id="patch"> <h3>Diff</h3> <a id="trunkwxruby2samplestreectrlicon1xpm"></a> <div class="addfile"><h4>Added: trunk/wxruby2/samples/treectrl/icon1.xpm (0 => 806)</h4> <pre class="diff"><span> <span class="info">--- trunk/wxruby2/samples/treectrl/icon1.xpm         (rev 0) +++ trunk/wxruby2/samples/treectrl/icon1.xpm        2006-12-26 11:18:31 UTC (rev 806) </span><span class="lines">@@ -0,0 +1,79 @@ </span><ins>+/* XPM */ +static char *icon1_xpm[] = { +/* columns rows colors chars-per-pixel */ +"32 32 41 1", +"> c #97C4E7", +"# c #4381AA", +"d c #FFFFFF", +"< c #71B2DE", +"+ c #538BB1", +"& c #D1E5F5", +"q c #63B3DE", +"6 c #F1F4F7", +"* c #CAE1F3", +"y c #7AC4E5", +"= c #C3DDF1", +"X c #74A1BD", +"- c #BCD9EF", +"5 c #619BC4", +"3 c #E6EAF1", +"2 c #4B8EBF", +"o c #6B97B6", +". c #4B82A8", +" c None", +"w c #54A6D8", +"1 c #71A8D1", +", c #85BBE2", +"t c #EFF6FC", +"7 c #DEEDF8", +"@ c #4388B4", +"a c #F7FBFD", +"$ c #D7E0E9", +"r c #FAFCFE", +"4 c #DAEAF7", +"e c #E9F3FA", +"0 c #76BAE2", +"% c #7FA6C0", +"s c #FDFDFE", +"O c #5896BE", +"p c #B6D5EE", +"8 c #87ABC3", +": c #A5CCEA", +"9 c #E5F0F9", +"; c #AFD1EC", +"i c #F4F9FD", +"u c #8FB0C3", +/* pixels */ +" ", +" ", +" ", +" ", +" ", +" .XXXooOO++@#$ ", +" %&*=-;:>>,<123 ", +" %4&*=-;:>>,1>56 ", +" %74&*=-;:>>1*>56 ", +" 89700qqqqwq1e*>X ", +" 8e974&*=-;:1re*>8 ", +" 8te974&*=-;11111# ", +" 8tty000qqqqqww>,+ ", +" uitte974&*=-p:>>+ ", +" uaitte974&*=-p:>O ", +" uaayyyy000qqqqp:O ", +" uraaitte974&*=-po ", +" urraaitte974&*=-o ", +" usryyyyyyy000q*=X ", +" ussrraaitte974&*X ", +" udssrraaitte974&X ", +" uddyyyyyyyyyy074% ", +" udddssrraaitte97% ", +" uddddssrraaitte9% ", +" udddddssrraaitte8 ", +" uddddddssrraaitt8 ", +" uuuuuuuuuuuuuu88u ", +" ", +" ", +" ", +" ", +" " +}; </ins></span></pre></div> <a id="trunkwxruby2samplestreectrlicon2xpm"></a> <div class="addfile"><h4>Added: trunk/wxruby2/samples/treectrl/icon2.xpm (0 => 806)</h4> <pre class="diff"><span> <span class="info">--- trunk/wxruby2/samples/treectrl/icon2.xpm         (rev 0) +++ trunk/wxruby2/samples/treectrl/icon2.xpm        2006-12-26 11:18:31 UTC (rev 806) </span><span class="lines">@@ -0,0 +1,53 @@ </span><ins>+/* XPM */ +static char *icon2_xpm[] = { +/* columns rows colors chars-per-pixel */ +"32 32 15 1", +". c Black", +"O c #97C4E7", +"$ c #63B3DE", +"@ c #CAE1F3", +"; c #7AC4E5", +"* c #74A1BD", +"+ c #619BC4", +"o c #4B8EBF", +" c None", +"% c #54A6D8", +"= c #FAFCFE", +"& c #E9F3FA", +"# c #76BAE2", +"X c #C00000", +"- c #87ABC3", +/* pixels */ +" ", +" ", +" ", +" ", +" ", +" ............. ", +" .XXXXXXXXXX.o. ", +" .XXXXXXXXXX.O+. ", +" .XXXXXXXXXX.@O+. ", +" .XX##$$$$%$.&@O* ", +" .XXXXXXXXXX.=&@O- ", +" .XXXXXXXXXX...... ", +" .XX;###$$$$$%%XX. ", +" .XXXXXXXXXXXXXXX. ", +" .XXXXXXXXXXXXXXX. ", +" .XX;;;;###$$$$XX. ", +" .XXXXXXXXXXXXXXX. ", +" .XXXXXXXXXXXXXXX. ", +" .XX;;;;;;;###$XX. ", +" .XXXXXXXXXXXXXXX. ", +" .XXXXXXXXXXXXXXX. ", +" .XX;;;;;;;;;;#XX. ", +" .XXXXXXXXXXXXXXX. ", +" .XXXXXXXXXXXXXXX. ", +" .XXXXXXXXXXXXXXX. ", +" .XXXXXXXXXXXXXXX. ", +" ................. ", +" ", +" ", +" ", +" ", +" " +}; </ins></span></pre></div> <a id="trunkwxruby2samplestreectrlicon3xpm"></a> <div class="addfile"><h4>Added: trunk/wxruby2/samples/treectrl/icon3.xpm (0 => 806)</h4> <pre class="diff"><span> <span class="info">--- trunk/wxruby2/samples/treectrl/icon3.xpm         (rev 0) +++ trunk/wxruby2/samples/treectrl/icon3.xpm        2006-12-26 11:18:31 UTC (rev 806) </span><span class="lines">@@ -0,0 +1,79 @@ </span><ins>+/* XPM */ +static char *icon3_xpm[] = { +/* columns rows colors chars-per-pixel */ +"32 32 41 1", +"6 c #EDF2FB", +"- c #AAC1E8", +": c #B9CDED", +"X c #295193", +", c #C6D6F0", +"a c #4A7CCE", +"u c #779DDB", +"y c #7FA2DD", +"$ c #3263B4", +"5 c #EAF0FA", +". c #2D59A3", +"o c #6E96D8", +"* c #356AC1", +"r c #F7F9FD", +"> c #BED0EE", +"3 c #E1E9F7", +"7 c #F0F5FC", +"< c #CBD9F1", +"2 c #DAE5F6", +"# c #3161B1", +" c None", +"0 c #FDFEFF", +"= c #9FB9E5", +"e c #AEC5EA", +"t c #89A9DF", +"q c #98B5E4", +"p c #5584D1", +"d c #3A70CA", +"@ c #305FAC", +"i c #5D89D3", +"1 c #D2DFF4", +"% c #3366B9", +"9 c #FAFCFE", +"8 c #F5F8FD", +"s c #4075CC", +"O c #638ED5", +"w c #90AFE2", +"& c #3467BC", +"+ c #2F5DA9", +"; c #B3C8EB", +"4 c #E5EDF9", +/* pixels */ +" ", +" ", +" ", +" ", +" ", +" ", +" ......X ", +" .oooooO+ ", +" .ooooooo. ", +" .+@@@##$%%&&&&&****. ", +" .=-;:>,<12345678900. ", +" .q=-;:>,<1234567890. ", +" .wq=-e:>,<12345678r. ", +" .twq=-e:>,<12345678. ", +" .ytwq=-e:>,<1234567. ", +" .uytwq=-e:>,<123456. ", +" .ouytwq=-e:>,<12345. ", +" .Oouytwq=-e;>,<1234. ", +" .iOouytwq=-e;>,<123. ", +" .piOouytwq=-e;>,<12. ", +" .apiOouytwq=-e;>,<1. ", +" .sapiOouytwq=-e;>,<. ", +" .dsapiOouytwq=-e;>,. ", +" ...................# ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" " +}; </ins></span></pre></div> <a id="trunkwxruby2samplestreectrlicon4xpm"></a> <div class="addfile"><h4>Added: trunk/wxruby2/samples/treectrl/icon4.xpm (0 => 806)</h4> <pre class="diff"><span> <span class="info">--- trunk/wxruby2/samples/treectrl/icon4.xpm         (rev 0) +++ trunk/wxruby2/samples/treectrl/icon4.xpm        2006-12-26 11:18:31 UTC (rev 806) </span><span class="lines">@@ -0,0 +1,43 @@ </span><ins>+/* XPM */ +static char *icon4_xpm[] = { +/* columns rows colors chars-per-pixel */ +"32 32 5 1", +". c Black", +"o c #8399B4", +"X c #8DA0B9", +" c None", +"O c #800000", +/* pixels */ +" ", +" ", +" ", +" ", +" ", +" ", +" ....... ", +" .XXXXXo. ", +" .XXXXXXX. ", +" .................... ", +" .OOOOOOOOOOOOOOOOOO. ", +" .OOOOOOOOOOOOOOOOOO. ", +" .OOOOOOOOOOOOOOOOOO. ", +" .OOOOOOOOOOOOOOOOOO. ", +" .OOOOOOOOOOOOOOOOOO. ", +" .OOOOOOOOOOOOOOOOOO. ", +" .OOOOOOOOOOOOOOOOOO. ", +" .OOOOOOOOOOOOOOOOOO. ", +" .OOOOOOOOOOOOOOOOOO. ", +" .OOOOOOOOOOOOOOOOOO. ", +" .OOOOOOOOOOOOOOOOOO. ", +" .OOOOOOOOOOOOOOOOOO. ", +" .OOOOOOOOOOOOOOOOOO. ", +" .................... ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" " +}; </ins></span></pre></div> <a id="trunkwxruby2samplestreectrlicon5xpm"></a> <div class="addfile"><h4>Added: trunk/wxruby2/samples/treectrl/icon5.xpm (0 => 806)</h4> <pre class="diff"><span> <span class="info">--- trunk/wxruby2/samples/treectrl/icon5.xpm         (rev 0) +++ trunk/wxruby2/samples/treectrl/icon5.xpm        2006-12-26 11:18:31 UTC (rev 806) </span><span class="lines">@@ -0,0 +1,79 @@ </span><ins>+/* XPM */ +static char *icon5_xpm[] = { +/* columns rows colors chars-per-pixel */ +"32 32 41 1", +"0 c #AAC1E8", +"q c #B9CDED", +"X c #295193", +"e c #C6D6F0", +"a c #4A7CCE", +"& c #779DDB", +"* c #7FA2DD", +"2 c #EAF0FA", +"@ c #2D59A3", +"o c #6E96D8", +"y c #356AC1", +"d c #214279", +"w c #BED0EE", +"= c #85A7DF", +"< c #E1E9F7", +"3 c #F0F5FC", +"s c #CBD9F1", +", c #DAE5F6", +"7 c #3161B1", +" c None", +". c #274D8B", +"6 c #FDFEFF", +"i c #E7EEF9", +"9 c #9FB9E5", +"- c #89A9DF", +"8 c #98B5E4", +"$ c #5584D1", +"+ c #3569BF", +"% c #305FAC", +"O c #5D89D3", +"> c #D2DFF4", +"p c #3366B9", +"5 c #FAFCFE", +"4 c #F5F8FD", +"t c #4075CC", +"u c #638ED5", +"r c #CEDCF2", +"; c #90AFE2", +"# c #2F5DA9", +": c #B3C8EB", +"1 c #E5EDF9", +/* pixels */ +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ......X ", +" XoooooO. ", +" Xoooooo+. ", +" Xooooooo@XXXXXXXXXX# ", +" Xoooooooooooooooooo# ", +" Xoooooooooooooooooo# ", +" Xoo$################### ", +" Xoo%O&*=-;:>,<123445667 ", +" XooX890:qwer>,<123445q# ", +" Xoty;890:qwer>,<12344# ", +" Xo%u-;890:qwer>,<i234# ", +" XoX&*-;890:qwer>,<i2r# ", +" Xtpo&*-;890:qwer>,<i# ", +" X%auo&*-;890:qwer>,<# ", +" XX$Ouo&*-;890:qwer>s# ", +" d%a$Ouo&*-;890:qwer# ", +" d+ta$Ouo&*-;890:qwe# ", +" d..................# ", +" ", +" ", +" ", +" ", +" ", +" ", +" " +}; </ins></span></pre></div> <a id="trunkwxruby2samplestreectrltreectrlrb"></a> <div class="modfile"><h4>Modified: trunk/wxruby2/samples/treectrl/treectrl.rb (805 => 806)</h4> <pre class="diff"><span> <span class="info">--- trunk/wxruby2/samples/treectrl/treectrl.rb        2006-12-26 01:44:30 UTC (rev 805) +++ trunk/wxruby2/samples/treectrl/treectrl.rb        2006-12-26 11:18:31 UTC (rev 806) </span><span class="lines">@@ -73,7 +73,7 @@ </span><span class="cx"> </span><span class="cx"> @reverse_sort = false </span><span class="cx"> </span><del>- create_image_list() </del><ins>+ create_image_list </ins><span class="cx"> </span><span class="cx"> # add some items to the tree </span><span class="cx"> add_test_items_to_tree(5, 2) </span><span class="lines">@@ -134,54 +134,28 @@ </span><span class="cx"> return get_item_parent(item) == get_root_item() && !get_prev_sibling(item) </span><span class="cx"> end </span><span class="cx"> </span><del>- # TEMPORARILY DISABLED - def set_item_image(*args) - end </del><ins>+ def create_image_list + @imageSize = 16 </ins><span class="cx"> </span><del>- # TEMPORARILY DISABLED - def create_image_list(size = 16) - return false - if size == -1 - set_image_list(nil) - return nil - end - if size == 0 - size = @imageSize - else - @imageSize = size - end - </del><span class="cx"> # Make an image list containing small icons </span><del>- images = Wx::ImageList.new(size, size, true) - </del><ins>+ images = Wx::ImageList.new(16, 16, true) </ins><span class="cx"> # should correspond to TreeCtrlIcon_xxx enum </span><del>- Wx::BusyCursor.busy do |x| - icons = [ - Wx::Icon.new("icon1.xpm"), - Wx::Icon.new("icon2.xpm"), - Wx::Icon.new("icon3.xpm"), - Wx::Icon.new("icon4.xpm"), - Wx::Icon.new("icon5.xpm")] - - orig_size = icons[0].get_width() - for i in 0 ... icons.length - if size == orig_size - images.add(icons[i]) - else - images.add(icons[i]) - end </del><ins>+ Wx::BusyCursor.busy do + icons = (1 .. 5).map do | i | + icon_file = File.join(File.dirname(__FILE__), "icon#{i}.xpm") + # Wx::Icon.new(icon_file, Wx::BITMAP_TYPE_XPM, 16, 16) + Wx::Bitmap.new(icon_file, Wx::BITMAP_TYPE_XPM) </ins><span class="cx"> end </span><del>- - assign_image_list(images) </del><ins>+ icons.each { | ic | images.add(ic) } + set_image_list(images) </ins><span class="cx"> end </span><span class="cx"> end </span><span class="cx"> </span><del>- def create_buttons_image_list(size = 11) - if size == -1 - set_buttons_image_list(nil) - return nil - end </del><ins>+ def unset_image_list + set_image_list(nil) + end </ins><span class="cx"> </span><ins>+ def create_buttons_image_list() </ins><span class="cx"> # Make an image list containing small icons </span><span class="cx"> images = Wx::ImageList.new(size, size, true) </span><span class="cx"> </span><span class="lines">@@ -193,12 +167,12 @@ </span><span class="cx"> Wx::Icon.new("icon5.xpm"), # open </span><span class="cx"> Wx::Icon.new("icon5.xpm")] # open, selected </span><span class="cx"> </span><del>- for i in 0 ... icons.length - orig_size = icons[i].get_width() </del><ins>+ icons.each do | ic | + orig_size = ic.get_width() </ins><span class="cx"> if size == orig_size </span><del>- images.add(icons[i]) </del><ins>+ images.add(ic) </ins><span class="cx"> else </span><del>- resized = icons[i].convert_to_image().rescale(size, size) </del><ins>+ resized = ic.convert_to_image().rescale(size, size) </ins><span class="cx"> images.add( Wx::Bitmap.new(resized) ) </span><span class="cx"> end </span><span class="cx"> end </span><span class="lines">@@ -254,17 +228,22 @@ </span><span class="cx"> end </span><span class="cx"> </span><span class="cx"> def add_test_items_to_tree(num_children,depth) </span><del>- image = Wx::get_app.show_images() ? TreeCtrlIcon_Folder : -1 </del><ins>+ image = Wx::get_app.show_images ? TreeCtrlIcon_Folder : -1 </ins><span class="cx"> root_id = add_root("Root",image, image) </span><span class="cx"> if image != -1 </span><span class="cx"> set_item_image(root_id, TreeCtrlIcon_FolderOpened, </span><del>- Wx::TREE_ITEM_ICON_EXPANDED) </del><ins>+ Wx::TREE_ITEM_ICON_EXPANDED) </ins><span class="cx"> end </span><span class="cx"> </span><span class="cx"> add_items_recursively(root_id, num_children, depth, 0) </span><span class="cx"> </span><span class="cx"> # set some colours/fonts for testing </span><del>- set_item_font(root_id, Wx::ITALIC_FONT) </del><ins>+ # note that font sizes can also be varied, but only on platforms + # that use the generic TreeCtrl - OS X and GTK, and only if + # Wx::TR_HAS_VARIABLE_ROW_HEIGHT style was used in the constructor + font = get_font + font.set_style(Wx::FONTSTYLE_ITALIC) + set_item_font(root_id, font) </ins><span class="cx"> </span><span class="cx"> id,cookie = get_first_child(root_id) </span><span class="cx"> set_item_text_colour(id, Wx::BLUE) </span><span class="lines">@@ -1121,11 +1100,11 @@ </span><span class="cx"> end </span><span class="cx"> </span><span class="cx"> def on_toggle_images(event) </span><del>- if Wx::get_app.show_images() - @treectrl.create_image_list(-1) </del><ins>+ if Wx::get_app.show_images + @treectrl.unset_image_list </ins><span class="cx"> Wx::get_app.show_images = false </span><span class="cx"> else </span><del>- @treectrl.create_image_list(0) </del><ins>+ @treectrl.create_image_list </ins><span class="cx"> Wx::get_app.show_images = true </span><span class="cx"> end </span><span class="cx"> end </span></span></pre> </div> </div> </body> </html>
Seemingly Similar Threads
- [928] branches/wxruby2/wxwidgets_282/samples/treectrl/treectrl.rb: Fixed on_insert_item, call to insert_item had arguments in wrong order/missing.
- [956] branches/wxruby2/wxwidgets_282: Additions to TreeCtrl API 2.6->2.8
- [1050] trunk/wxruby2/doc/textile: Delete doc references to remove assign_image_list methods in Tree/ListCtrl
- [800] trunk/wxruby2/doc/textile/treectrl.txtl: TreeCtrl#traverse has moved to wx sugar
- [779] trunk/wxruby2: Added TreeCtrl#traverse method and documentation