ui/winui/table.cpp

changeset 13
5a8762fcfecc
parent 3
f154867f54dc
child 18
af411868ab9b
equal deleted inserted replaced
12:3eb0cbab53db 13:5a8762fcfecc
408 408
409 // set the cell value 409 // set the cell value
410 // depending on the type, we create different cell controls 410 // depending on the type, we create different cell controls
411 UiModelType type = model->types[col]; 411 UiModelType type = model->types[col];
412 switch (type) { 412 switch (type) {
413 case UI_STRING_FREE:
413 case UI_STRING: { 414 case UI_STRING: {
414 TextBlock cell = TextBlock(); 415 TextBlock cell = TextBlock();
415 cell.Padding(cellpadding); 416 cell.Padding(cellpadding);
416 cell.VerticalAlignment(VerticalAlignment::Stretch); 417 cell.VerticalAlignment(VerticalAlignment::Stretch);
417 textblock_set_str(cell, (char*)getvalue(elm, model_col)); 418 char *val = (char*)getvalue(elm, model_col);
419 textblock_set_str(cell, val);
418 cellBorder.Child(cell); 420 cellBorder.Child(cell);
421 if (type == UI_STRING_FREE && val) {
422 free(val);
423 }
419 424
420 break; 425 break;
421 } 426 }
422 case UI_INTEGER: { 427 case UI_INTEGER: {
423 TextBlock cell = TextBlock(); 428 TextBlock cell = TextBlock();
436 IconElement icon = iconConstr->getIcon(); 441 IconElement icon = iconConstr->getIcon();
437 cellBorder.Child(icon); 442 cellBorder.Child(icon);
438 } 443 }
439 break; 444 break;
440 } 445 }
446 case UI_ICON_TEXT_FREE:
441 case UI_ICON_TEXT: { 447 case UI_ICON_TEXT: {
442 StackPanel cellPanel = StackPanel(); 448 StackPanel cellPanel = StackPanel();
443 cellPanel.Spacing(2); 449 cellPanel.Spacing(2);
444 cellPanel.Padding(cellpadding); 450 cellPanel.Padding(cellpadding);
445 cellPanel.VerticalAlignment(VerticalAlignment::Stretch); 451 cellPanel.VerticalAlignment(VerticalAlignment::Stretch);
453 } 459 }
454 TextBlock cell = TextBlock(); 460 TextBlock cell = TextBlock();
455 textblock_set_str(cell, str); 461 textblock_set_str(cell, str);
456 cellPanel.Children().Append(cell); 462 cellPanel.Children().Append(cell);
457 cellBorder.Child(cellPanel); 463 cellBorder.Child(cellPanel);
464 if (type == UI_ICON_TEXT_FREE && str) {
465 free(str);
466 }
458 break; 467 break;
459 } 468 }
460 } 469 }
461 470
462 // event handler 471 // event handler

mercurial