#![allow(dead_code)]
use crate::ui::ffi::{UiObject, UiListArgs, UiCallback, UiList, UiSourceListArgs};
-use crate::ui::{event, ffi, toolkit, ui_list_get, ui_list_get_data, EventWrapper};
+use crate::ui::{event, ffi, toolkit, ui_list_get, ui_list_get_data, Button, EventWrapper};
use std::ffi::{c_char, c_int, c_void};
use std::ffi::CString;
use std::marker::PhantomData;
use std::mem;
-use crate::ui::widget::{widget_typed_fn};
+use crate::ui::widget::{widget_typed_fn, Widget};
+
+
+pub struct ListView {
+ ptr: *mut c_void
+}
+
+impl Widget for ListView {
+ fn get_widget(&self) -> *mut c_void {
+ self.ptr
+ }
+}
pub enum ListValue<'a> {
None,
EditableBool = 7
}
-pub type ListBuilderCreate = fn(*const UiObject, *const UiListArgs);
+pub type ListBuilderCreate = fn(*const UiObject, *const UiListArgs) -> ListView;
impl<T> toolkit::UiObject<T> {
widget_typed_fn!(listview, listview_builder, ListViewBuilder);
}
}
-fn list_create(obj: *const UiObject, args: *const UiListArgs) {
+fn list_create(obj: *const UiObject, args: *const UiListArgs) -> ListView {
unsafe {
- ui_listview_create(obj, args);
+ ListView { ptr: ui_listview_create(obj, args) }
}
}
-fn dropdown_create(obj: *const UiObject, args: *const UiListArgs) {
+fn dropdown_create(obj: *const UiObject, args: *const UiListArgs) -> ListView {
unsafe {
- ui_dropdown_create(obj, args);
+ ListView { ptr: ui_dropdown_create(obj, args) }
}
}
-fn tableview_create(obj: *const UiObject, args: *const UiListArgs) {
+fn tableview_create(obj: *const UiObject, args: *const UiListArgs) -> ListView {
unsafe {
- ui_table_create(obj, args);
+ ListView { ptr: ui_table_create(obj, args) }
}
}
}
impl<'a, T, E> ListViewBuilder<'a, T, E> {
- pub fn create(&mut self) {
+ pub fn create(&mut self) -> ListView {
if !self.has_getvalue_func {
unsafe {
ui_list_args_set_getvalue_func2(self.args, null_getvalue_wrapper);
}
}
- (self.create)(self.obj.ptr, self.args);
+ (self.create)(self.obj.ptr, self.args)
}
pub fn fill(&mut self, fill: bool) -> &mut Self {
}
impl<'a, T, E> TableViewBuilder<'a, T, E> {
- pub fn create(&mut self) {
+ pub fn create(&mut self) -> ListView {
if !self.has_getvalue_func {
unsafe {
ui_list_args_set_getvalue_func2(self.args, null_getvalue_wrapper);
ui_model_ref(self.model);
}
}
- (self.create)(self.obj.ptr, self.args);
+ (self.create)(self.obj.ptr, self.args)
}
pub fn fill(&mut self, fill: bool) -> &mut Self {
extern "C" {
fn malloc(size: usize) -> *mut c_void;
- fn ui_listview_create(obj: *const UiObject, args: *const UiListArgs);
- fn ui_dropdown_create(obj: *const UiObject, args: *const UiListArgs);
- fn ui_table_create(obj: *const UiObject, args: *const UiListArgs);
- fn ui_sourcelist_create(obj: *const UiObject, args: *const UiSourceListArgs);
+ fn ui_listview_create(obj: *const UiObject, args: *const UiListArgs) -> *mut c_void;
+ fn ui_dropdown_create(obj: *const UiObject, args: *const UiListArgs)-> *mut c_void;
+ fn ui_table_create(obj: *const UiObject, args: *const UiListArgs)-> *mut c_void;
+ fn ui_sourcelist_create(obj: *const UiObject, args: *const UiSourceListArgs)-> *mut c_void;
fn ui_list_args_new() -> *mut UiListArgs;
fn ui_list_args_set_fill(args: *mut UiListArgs, fill: c_int);