1# 2# Demo: Outlook Express folder list 3# 4def demoOutlookFolders(t) 5 init_pics('outlook-*') 6 7 height = t.font.metrics(:linespace) + 2 8 height = 18 if height < 18 9 10 t.configure(:itemheight=>height, :selectmode=>:browse, :showlines=>true, 11 :showroot=>true, :showrootbutton=>false, :showbuttons=>true) 12 13 if $HasColumnCreate 14 t.column_create(:text=>'Folders') 15 else 16 t.column_configure(0, :text=>'Folders') 17 end 18 19 t.element_create('e1', :image) 20 t.element_create('e2', :text, :lines=>1, 21 :fill=>[@SystemHighlightText, ['selected', 'focus']]) 22 t.element_create('e3', :text, :lines=>1, :font=>t.font.dup.weight(:bold), 23 :fill=>[@SystemHighlightText, ['selected', 'focus']]) 24 t.element_create('e4', :text, :fill=>'blue') 25 t.element_create('e5', :image, :image=>@images['outlook-folder']) 26 t.element_create('e6', :rect, :showfocus=>true, 27 :fill=>[ 28 @SystemHighlight, ['selected', 'focus'], 29 'gray', ['selected', '!focus'] 30 ]) 31 32 # image + text 33 s = t.style_create('s1') 34 t.style_elements(s, ['e6', 'e1', 'e2']) 35 t.style_layout(s, 'e1', :expand=>:ns) 36 t.style_layout(s, 'e2', :padx=>[4,0], :expand=>:ns, :squeeze=>:x) 37 t.style_layout(s, 'e6', :union=>['e2'], :iexpand=>:ns, :ipadx=>2) 38 39 # image + text + text 40 s = t.style_create('s2') 41 t.style_elements(s, ['e6', 'e1', 'e3', 'e4']) 42 t.style_layout(s, 'e1', :expand=>:ns) 43 t.style_layout(s, 'e3', :padx=>4, :expand=>:ns, :squeeze=>:x) 44 t.style_layout(s, 'e4', :expand=>:ns) 45 t.style_layout(s, 'e6', :union=>['e3'], :iexpand=>:ns, :ipadx=>2) 46 47 # folder + text 48 s = t.style_create('s3') 49 t.style_elements(s, ['e6', 'e5', 'e2']) 50 t.style_layout(s, 'e5', :expand=>:ns) 51 t.style_layout(s, 'e2', :padx=>[4,0], :expand=>:ns, :squeeze=>:x) 52 t.style_layout(s, 'e6', :union=>['e2'], :iexpand=>:ns, :ipadx=>2) 53 54 # folder + text + text 55 s = t.style_create('s4') 56 t.style_elements(s, ['e6', 'e5', 'e3', 'e4']) 57 t.style_layout(s, 'e5', :expand=>:ns) 58 t.style_layout(s, 'e3', :padx=>4, :expand=>:ns, :squeeze=>:x) 59 t.style_layout(s, 'e4', :expand=>:ns) 60 t.style_layout(s, 'e6', :union=>['e3'], :iexpand=>:ns, :ipadx=>2) 61 62 t.item_style_set(:root, 0, 's1') 63 t.item_complex(:root, 64 [ 65 ['e1', {:image=>@images['outlook-main']}], 66 ['e2', {:text=>'Outlook Express'}] 67 ]) 68 69 parentList = [:root, '', '', '', '', '', ''] 70 parent = :root 71 [ 72 [0, :local, "Local Folders", true, 0], 73 [1, :inbox, 'Inbox', false, 5], 74 [1, :outbox, 'Outbox', false, 0], 75 [1, :sent, "Sent Items", false, 0], 76 [1, :deleted, "Deleted Items", false, 50], 77 [1, :draft, 'Drafts', false, 0], 78 [1, :folder, "Messages to Dad", false, 0], 79 [1, :folder, "Messages to Sis", false, 0], 80 [1, :folder, "Messages to Me", false, 0], 81 [2, :folder, "2001", false, 0], 82 [2, :folder, "2000", false, 0], 83 [2, :folder, "1999", false, 0], 84 [0, :server, "news.gmane.org", true, 0], 85 [1, :group, "gmane.comp.lang.lua.general", false, 498] 86 ].each{|depth, img, text, button, unread| 87 if $Version_1_1_OrLater 88 item = t.item_create(:button=>button) 89 else 90 item = t.item_create 91 t.item_hasbutton(item, button) 92 end 93 if img == :folder 94 if unread != 0 95 t.item_style_set(item, 0, 's4') 96 t.item_complex(item, 97 [['e3', {:text=>text}], ['e4', {:text=>"(#{unread})"}]]) 98 else 99 t.item_style_set(item, 0, 's3') 100 t.item_complex(item, [['e2', {:text=>text}]]) 101 end 102 else 103 if unread != 0 104 t.item_style_set(item, 0, 's2') 105 t.item_complex(item, 106 [ 107 ['e1', {:image=>@images["outlook-#{img}"]}], 108 ['e3', {:text=>text}], 109 ['e4', {:text=>"(#{unread})"}] 110 ]) 111 else 112 t.item_style_set(item, 0, 's1') 113 t.item_complex(item, 114 [ 115 ['e1', {:image=>@images["outlook-#{img}"]}], 116 ['e2', {:text=>text}] 117 ]) 118 end 119 end 120 t.item_lastchild(parentList[depth], item) 121 depth += 1 122 parentList[depth] = item 123 } 124end 125