Changeset 213
- Timestamp:
- 09/28/2007 18:13:45 (11 months ago)
- Location:
- trunk
- Files:
-
- 10 modified
-
samples/anim.rb (modified) (1 diff)
-
samples/book.rb (modified) (2 diffs)
-
samples/calc.rb (modified) (2 diffs)
-
samples/dialogs.rb (modified) (1 diff)
-
samples/edit.rb (modified) (2 diffs)
-
samples/form.rb (modified) (1 diff)
-
shoes/canvas.c (modified) (1 diff)
-
shoes/canvas.h (modified) (1 diff)
-
shoes/ruby.c (modified) (4 diffs)
-
shoes/ruby.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/samples/anim.rb
r96 r213 1 1 Shoes.app do 2 2 stack :top => 0.5, :left => 0.5 do 3 text"Counting up:"4 l = text"0"3 para "Counting up:" 4 l = para "0" 5 5 animate(24) do |i| 6 6 f = ['Arial 14px', 'Serif 34px', 'Monospace 18px', 'Arial 48px'][rand(3)] 7 l.replace " <span font_desc='#{f}'>#{i}</span>"7 l.replace "#{i}", :font => f 8 8 end 9 9 motion do |x, y| -
trunk/samples/book.rb
r194 r213 10 10 11 11 def table_of_contents 12 toc = "<span font_desc='Arial 11px'>"12 toc = [] 13 13 INCIDENTS.each_with_index do |(title, story), i| 14 toc += "(#{i + 1}) <a href='/incidents/#{i}'>#{title}</a> " 14 toc.push "(#{i + 1}) ", 15 link(title, :url => "/incidents/#{i}"), 16 " / " 15 17 end 16 toc + "</span>" 18 toc.pop 19 span *toc 17 20 end 18 21 … … 20 23 num = num.to_i 21 24 flow :margin => 10, :margin_left => 190, :margin_top => 20 do 22 text "<span font_desc='Arial 46px'>Incident</span>\n" +23 "<b>No. #{num + 1}: #{INCIDENTS[num][0]}</b>"25 banner "Incident\n" 26 para strong("No. #{num + 1}: #{INCIDENTS[num][0]}") 24 27 end 25 28 flow :width => 180, :margin_left => 10, :margin_top => 10 do 26 text table_of_contents29 para table_of_contents, :font => "Arial 12px" 27 30 end 28 31 flow :width => -190, :margin => 10 do 29 textINCIDENTS[num][1]32 para INCIDENTS[num][1] 30 33 end 31 34 end -
trunk/samples/calc.rb
r172 r213 46 46 47 47 stack :margin => 8 do 48 number_field = text "<b>#{number}</b>"48 number_field = para strong(number) 49 49 end 50 50 … … 63 63 64 64 number.send(method) 65 number_field.replace "<b>#{number} </b>"65 number_field.replace strong(number) 66 66 end 67 67 end -
trunk/samples/dialogs.rb
r24 r213 20 20 end 21 21 22 @answer = text"Answers appear here"22 @answer = para "Answers appear here" 23 23 end -
trunk/samples/edit.rb
r127 r213 3 3 background rgb(77, 77, 77) 4 4 stack :margin => 10 do 5 text "<span color='white'><span color='red' background='white'>TEXT EDITOR</span> * USE ALT-Q TO QUIT</span>"5 para span("TEXT EDITOR", :stroke => red, :fill => white), " * USE ALT-Q TO QUIT", :stroke => white 6 6 end 7 7 stack :margin => 10 do 8 t = text ""8 t = para "", :font => "Monospace 12px", :stroke => white 9 9 t.cursor = -1 10 10 end … … 24 24 str += self.clipboard 25 25 end 26 s = Shoes.escape(str).gsub(/^def /, "<span color='#FFDDAA'>def</span> ") 27 t.replace "<span font_desc='Monospace 12' color='white'>#{s}</span>" 26 t.replace str 28 27 end 29 28 end -
trunk/samples/form.rb
r186 r213 9 9 stack :margin => 40 do 10 10 stack :margin => 10 do 11 text"Name"11 para "Name" 12 12 @name = list_box :items => ["Yes, please!", "NO. No thankyou."] 13 13 end 14 14 stack :margin => 10 do 15 text"Address"15 para "Address" 16 16 @address = edit_line 17 17 end 18 18 stack :margin => 10 do 19 text"Phone"19 para "Phone" 20 20 @phone = edit_line 21 21 end -
trunk/shoes/canvas.c
r212 r213 579 579 MARKUP_DEF(ins, INLINE, cIns); 580 580 MARKUP_DEF(link, INLINE, cLinkText); 581 MARKUP_DEF(span, INLINE, cSpan); 581 582 MARKUP_DEF(strong, INLINE, cStrong); 582 583 -
trunk/shoes/canvas.h
r212 r213 206 206 VALUE shoes_canvas_ins(int argc, VALUE *argv, VALUE self); 207 207 VALUE shoes_canvas_link(int argc, VALUE *argv, VALUE self); 208 VALUE shoes_canvas_span(int argc, VALUE *argv, VALUE self); 208 209 VALUE shoes_canvas_strong(int argc, VALUE *argv, VALUE self); 209 210 VALUE shoes_canvas_background(int, VALUE *, VALUE); -
trunk/shoes/ruby.c
r212 r213 10 10 #include <math.h> 11 11 12 VALUE cShoes, cApp, cCanvas, cFlow, cStack, cMask, cPath, cImage, cAnim, cPattern, cBorder, cBackground, cTextBlock, cPara, cBanner, cTitle, cSubtitle, cTagline, cCaption, cInscription, cTextClass, cS trong, cCode, cEm, cIns, cLinkText, cNative, cButton, cEditLine, cEditBox, cListBox, cProgress, cColor, cColors, cLink;12 VALUE cShoes, cApp, cCanvas, cFlow, cStack, cMask, cPath, cImage, cAnim, cPattern, cBorder, cBackground, cTextBlock, cPara, cBanner, cTitle, cSubtitle, cTagline, cCaption, cInscription, cTextClass, cSpan, cStrong, cCode, cEm, cIns, cLinkText, cNative, cButton, cEditLine, cEditBox, cListBox, cProgress, cColor, cColors, cLink; 13 13 VALUE reHEX_SOURCE, reHEX3_SOURCE, reRGB_SOURCE, reRGBA_SOURCE, reGRAY_SOURCE, reGRAYA_SOURCE; 14 14 ID s_aref, s_perc, s_bind, s_new, s_run, s_to_pattern, s_to_i, s_to_s, s_angle, s_arrow, s_begin, s_call, s_center, s_change, s_click, s_corner, s_downcase, s_draw, s_end, s_font, s_hand, s_hidden, s_href, s_insert, s_items, s_scroll, s_match, s_text, s_title, s_top, s_right, s_bottom, s_left, s_height, s_resizable, s_remove, s_strokewidth, s_width, s_margin, s_margin_left, s_margin_right, s_margin_top, s_margin_bottom, s_radius; … … 1353 1353 shoes_textblock_replace(int argc, VALUE *argv, VALUE self) 1354 1354 { 1355 VALUE texts; 1355 long i; 1356 VALUE texts, attr; 1356 1357 shoes_textblock *self_t; 1357 1358 Data_Get_Struct(self, shoes_textblock, self_t); 1358 rb_scan_args(argc, argv, "*", &texts); 1359 1360 attr = Qnil; 1361 texts = rb_ary_new(); 1362 for (i = 0; i < argc; i++) 1363 { 1364 if (rb_obj_is_kind_of(argv[i], rb_cHash)) 1365 attr = argv[i]; 1366 else 1367 rb_ary_push(texts, argv[i]); 1368 } 1369 1359 1370 self_t->texts = texts; 1371 if (!NIL_P(attr)) self_t->attr = attr; 1372 1360 1373 shoes_canvas_repaint_all(self_t->parent); 1361 1374 return self; … … 1610 1623 else 1611 1624 { 1612 StringValue(v);1625 v = rb_funcall(v, s_to_s, 0); 1613 1626 k->len += RSTRING_LEN(v); 1614 1627 g_string_append_len(k->text, RSTRING_PTR(v), RSTRING_LEN(v)); … … 2629 2642 cLinkText = rb_define_class_under(cShoes, "LinkText", cTextClass); 2630 2643 cIns = rb_define_class_under(cShoes, "Ins", cTextClass); 2644 cSpan = rb_define_class_under(cShoes, "Span", cTextClass); 2631 2645 cStrong = rb_define_class_under(cShoes, "Strong", cTextClass); 2632 2646 -
trunk/shoes/ruby.h
r212 r213 23 23 #endif 24 24 25 extern VALUE cShoes, cApp, cCanvas, cFlow, cStack, cMask, cNative, cPath, cImage, cAnim, cPattern, cBorder, cBackground, cPara, cBanner, cTitle, cSubtitle, cTagline, cCaption, cInscription, cLinkText, cTextClass, cS trong, cCode, cEm, cIns, cButton, cEditLine, cEditBox, cListBox, cProgress, cColor, cColors, cLink;25 extern VALUE cShoes, cApp, cCanvas, cFlow, cStack, cMask, cNative, cPath, cImage, cAnim, cPattern, cBorder, cBackground, cPara, cBanner, cTitle, cSubtitle, cTagline, cCaption, cInscription, cLinkText, cTextClass, cSpan, cStrong, cCode, cEm, cIns, cButton, cEditLine, cEditBox, cListBox, cProgress, cColor, cColors, cLink; 26 26 extern VALUE reHEX_SOURCE, reHEX3_SOURCE, reRGB_SOURCE, reRGBA_SOURCE, reGRAY_SOURCE, reGRAYA_SOURCE; 27 27 extern ID s_aref, s_bind, s_new, s_run, s_to_pattern, s_to_i, s_to_s, s_angle, s_arrow, s_begin, s_call, s_center, s_change, s_click, s_corner, s_downcase, s_draw, s_end, s_font, s_hand, s_hidden, s_href, s_insert, s_items, s_match, s_scroll, s_text, s_title, s_top, s_right, s_bottom, s_left, s_height, s_remove, s_resizable, s_strokewidth, s_width, s_margin, s_margin_left, s_margin_right, s_margin_top, s_margin_bottom, s_radius; … … 115 115 f("ins", ins, -1); \ 116 116 f("link", link, -1); \ 117 f("span", span, -1); \ 117 118 f("strong", strong, -1); \ 118 119 f("background", background, -1); \
