Changeset 528 for trunk/thune/gl/gui.c
- Timestamp:
- 05/30/08 18:36:20 (6 months ago)
- Files:
-
- 1 modified
-
trunk/thune/gl/gui.c (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/thune/gl/gui.c
r527 r528 29 29 [x] Layout 30 30 [/] Input 31 [ ] Replace old widget code (gx.t) with widget class for all-Thune code.32 [ ] Convert all demos.33 31 */ 34 32 … … 90 88 ms.x = ex; \ 91 89 ms.y = ey 90 92 91 93 92 #define SET_AREA(wp,rect) \ … … 201 200 static GWidget* base_parse( GUI* ui, GMakeState* ms, int classId ) 202 201 { 203 GWidget* wp = gui_allocWidget( ui, classId ); 204 if( wp ) 205 ++ms->it; 206 else 207 ms->error = "allocWidget failed"; 202 GWidget* wp; 203 GUI_PARSE_ALLOC( wp ) 204 ++ms->it; 208 205 return wp; 209 206 } … … 331 328 { 332 329 no_block: 333 ms->error = "box requires block!"; 334 return 0; 330 GUI_PARSE_ERR( "box requires block!" ); 335 331 } 336 332 if( ur_is(bc, UT_COORD) ) … … 343 339 goto no_block; 344 340 345 wp = gui_allocWidget( ui, classId );346 if( wp ) 341 GUI_PARSE_ALLOC( wp ) 342 347 343 { 348 344 GMakeState cms; … … 364 360 } 365 361 ms->it = bc + 1; 366 }367 else368 {369 ms->error = "allocWidget failed";370 362 } 371 363 return wp; … … 829 821 GWidget* wp; 830 822 ButtonData* wd; 831 //UThread* ut = ui->ut; 832 const UCell* sc = ms->it + 1; 833 const UCell* bc = ms->it + 2; 834 835 if( ((ms->end - ms->it) < 3) || 836 (! ur_is(sc, UT_STRING)) || 837 (! ur_is(bc, UT_BLOCK)) ) 838 { 839 ms->error = "button requires string! and block!"; 840 return 0; 841 } 842 843 wp = gui_allocWidget( ui, classId ); 844 if( ! wp ) 845 { 846 ms->error = "allocWidget failed"; 847 return 0; 848 } 849 850 wd = BUTTON_DATA(wp); 851 wd->labelN = sc->series.n; 852 wd->codeN = bc->series.n; 853 854 ms->it += 3; 855 return wp; 823 const UCell* arg0; 824 825 arg0 = gui_matchArgs( ms, 2, UT_STRING, UT_BLOCK ); 826 if( arg0 ) 827 { 828 GUI_PARSE_ALLOC( wp ) 829 830 wd = BUTTON_DATA(wp); 831 wd->labelN = arg0->series.n; 832 wd->codeN = (arg0 + 1)->series.n; 833 return wp; 834 } 835 836 GUI_PARSE_ERR( "button requires string! and block!" ); 856 837 } 857 838 … … 958 939 if( wd->codeN ) 959 940 { 960 if( UR_EVAL_ ERROR == ur_eval( ui->ut, wd->codeN, 0 ) )941 if( UR_EVAL_OK != ur_eval( ui->ut, wd->codeN, 0 ) ) 961 942 { 962 // TODO: Throw or catch error.943 UG_GUI_THROW; 963 944 } 964 945 } … … 1062 1043 1063 1044 #include "widgets/twidget.c" 1064 1065 1066 static int wclassCount = 6; 1045 #include "widgets/listw.c" 1046 1047 /* 1048 :tok 1049 'expand (tok make-widget) 1050 | 'hbox block! (tok make-widget) 1051 | 'vbox block! (tok make-widget) 1052 | 'window block! (tok make-widget) 1053 | 'button string! block! (tok make-widget) 1054 | 't-widget block! (tok make-widget) 1055 | 'list block! block! (tok make-widget) 1056 */ 1057 1058 static int wclassCount = 7; 1067 1059 1068 1060 static GWidgetClass wclass[ WCLASS_MAX ] = … … 1098 1090 0, 0, 0 }, 1099 1091 1092 { "list", // "block! block!" 1093 listw_parse, listw_init, listw_mark, listw_event, 1094 expand_sizeHint, listw_layout, listw_render, 1095 0, 0, 0 }, 1096 1100 1097 /* 1101 1098 { "option", 1102 1099 { "choice", 1103 { "list",1104 1100 { "menu", 1105 1101 { "data", // label … … 1588 1584 1589 1585 /* 1586 Returns pointer to first arg if all types match, or zero. 1587 */ 1588 const UCell* gui_matchArgs( GMakeState* ms, int argc, ... ) 1589 { 1590 va_list args; 1591 int type; 1592 const UCell* it; 1593 const UCell* first = ms->it + 1; 1594 1595 if( (ms->end - first) < argc ) 1596 return 0; 1597 it = first; 1598 1599 va_start( args, argc ); 1600 while( argc ) 1601 { 1602 type = va_arg( args, int ); 1603 if( ur_type(it) != type ) 1604 break; 1605 ++it; 1606 --argc; 1607 } 1608 va_end( args ); 1609 1610 if( argc ) 1611 return 0; 1612 ms->it = it; 1613 return first; 1614 } 1615 1616 1617 /* 1590 1618 Only mark and sweep on top-level (parent-less) widgets. 1591 1619 */
