300 current->container->Add(frame, true); |
300 current->container->Add(frame, true); |
301 |
301 |
302 UIElement elm = frame; |
302 UIElement elm = frame; |
303 UiWidget* widget = new UiWidget(elm); |
303 UiWidget* widget = new UiWidget(elm); |
304 |
304 |
|
305 // sub container |
|
306 UiContainer* ctn = nullptr; |
|
307 switch (args.subcontainer) { |
|
308 default: |
|
309 case UI_CONTAINER_VBOX: { |
|
310 ctn = new UiBoxContainer(workarea, UI_BOX_CONTAINER_VBOX, args.margin, args.spacing); |
|
311 break; |
|
312 } |
|
313 case UI_CONTAINER_HBOX: { |
|
314 ctn = new UiBoxContainer(workarea, UI_BOX_CONTAINER_HBOX, args.margin, args.spacing); |
|
315 break; |
|
316 } |
|
317 case UI_CONTAINER_GRID: { |
|
318 ctn = new UiGridContainer(workarea, args.margin, args.columnspacing, args.rowspacing); |
|
319 break; |
|
320 } |
|
321 } |
|
322 |
305 UiObject* newobj = uic_object_new(obj, widget); |
323 UiObject* newobj = uic_object_new(obj, widget); |
306 newobj->container = new UiBoxContainer(workarea, UI_CONTAINER_VBOX, 0, 0); |
324 newobj->container = ctn; |
307 uic_obj_add(obj, newobj); |
325 uic_obj_add(obj, newobj); |
308 |
326 |
309 return widget; |
327 return widget; |
310 } |
328 } |
311 |
329 |
|
330 // --------------------- UI Expander --------------------- |
|
331 |
|
332 UIWIDGET ui_expander_create(UiObject* obj, UiFrameArgs args) { |
|
333 Expander expander = Expander(); |
|
334 if (args.label) { |
|
335 wchar_t* wlabel = str2wstr(args.label, nullptr); |
|
336 expander.Header(box_value(wlabel)); |
|
337 free(wlabel); |
|
338 } |
|
339 expander.IsExpanded(args.isexpanded); |
|
340 |
|
341 // add frame to the parent container |
|
342 UiObject* current = uic_current_obj(obj); |
|
343 UI_APPLY_LAYOUT1(current, args); |
|
344 current->container->Add(expander, true); |
|
345 |
|
346 UIElement elm = expander; |
|
347 UiWidget* widget = new UiWidget(elm); |
|
348 |
|
349 Grid content = Grid(); |
|
350 expander.Content(content); |
|
351 |
|
352 UiContainer* ctn = nullptr; |
|
353 switch (args.subcontainer) { |
|
354 default: |
|
355 case UI_CONTAINER_VBOX: { |
|
356 ctn = new UiBoxContainer(content, UI_BOX_CONTAINER_VBOX, args.margin, args.spacing); |
|
357 break; |
|
358 } |
|
359 case UI_CONTAINER_HBOX: { |
|
360 ctn = new UiBoxContainer(content, UI_BOX_CONTAINER_HBOX, args.margin, args.spacing); |
|
361 break; |
|
362 } |
|
363 case UI_CONTAINER_GRID: { |
|
364 ctn = new UiGridContainer(content, args.margin, args.columnspacing, args.rowspacing); |
|
365 break; |
|
366 } |
|
367 } |
|
368 |
|
369 UiObject* newobj = uic_object_new(obj, widget); |
|
370 newobj->container = ctn; |
|
371 uic_obj_add(obj, newobj); |
|
372 |
|
373 return widget; |
|
374 } |
|
375 |
312 // --------------------- UI ScrolledWindow --------------------- |
376 // --------------------- UI ScrolledWindow --------------------- |
313 |
377 |
314 UIWIDGET ui_scrolledwindow_create(UiObject* obj, UiContainerArgs args) { |
378 UIWIDGET ui_scrolledwindow_create(UiObject* obj, UiFrameArgs args) { |
315 ScrollViewer scrollW = ScrollViewer(); |
379 ScrollViewer scrollW = ScrollViewer(); |
316 |
380 |
317 // add frame to the parent container |
381 // add frame to the parent container |
318 UiObject* current = uic_current_obj(obj); |
382 UiObject* current = uic_current_obj(obj); |
319 UI_APPLY_LAYOUT1(current, args); |
383 UI_APPLY_LAYOUT1(current, args); |
320 current->container->Add(scrollW, true); |
384 current->container->Add(scrollW, true); |
321 |
385 |
322 UIElement elm = scrollW; |
386 UIElement elm = scrollW; |
323 UiWidget* widget = new UiWidget(elm); |
387 UiWidget* widget = new UiWidget(elm); |
324 |
388 |
325 // create a vbox as child container |
389 // create child container |
326 Grid vbox = Grid(); |
390 Grid content = Grid(); |
327 scrollW.Content(vbox); |
391 scrollW.Content(content); |
|
392 |
|
393 UiContainer* ctn = nullptr; |
|
394 switch (args.subcontainer) { |
|
395 default: |
|
396 case UI_CONTAINER_VBOX: { |
|
397 ctn = new UiBoxContainer(content, UI_BOX_CONTAINER_VBOX, args.margin, args.spacing); |
|
398 break; |
|
399 } |
|
400 case UI_CONTAINER_HBOX: { |
|
401 ctn = new UiBoxContainer(content, UI_BOX_CONTAINER_HBOX, args.margin, args.spacing); |
|
402 break; |
|
403 } |
|
404 case UI_CONTAINER_GRID: { |
|
405 ctn = new UiGridContainer(content, args.margin, args.columnspacing, args.rowspacing); |
|
406 break; |
|
407 } |
|
408 } |
328 |
409 |
329 UiObject* newobj = uic_object_new(obj, widget); |
410 UiObject* newobj = uic_object_new(obj, widget); |
330 newobj->container = new UiBoxContainer(vbox, UI_CONTAINER_VBOX, args.margin, args.spacing); |
411 newobj->container = ctn; |
331 uic_obj_add(obj, newobj); |
412 uic_obj_add(obj, newobj); |
332 |
413 |
333 return widget; |
414 return widget; |
334 } |
415 } |
335 |
416 |