var currentFeedIndex = -1
init {
- window = sidebarWindow("RSS Reader") {
+ window = sidebarWindow(title = "RSS Reader", width = 1600, height = 1000) {
sidebar {
vbox(fill = true) {
sourcelist(
}
}
- hsplitpane(fill = true, initialPosition = 300) {
+ hsplitpane(fill = true, initialPosition = 600) {
vbox(fill = true) {
val model = TableModel()
model.addColumn("Title", ColumnType.STRING, -1)
}
}
+ public void setSize(int width, int height) {
+ UiObjectFuncs tk = UiObjectFuncs.instance;
+ try {
+ tk.ui_window_size.invoke(ptr, width, height);
+ } catch (Throwable e) {
+ throw new RuntimeException(e);
+ }
+ }
+
public void addCloseHandler(ObjectDestroyHandler handler) {
closeHandlers.add(handler);
}
public MethodHandle ui_openfiledialog;
public MethodHandle ui_savefiledialog;
+ public MethodHandle ui_window_size;
+
private UiObjectFuncs(Linker linker, SymbolLookup lib) {
// void* func(void*, void*)
FunctionDescriptor sigv_mm = FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS);
FunctionDescriptor sigv_mimm = FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_INT, ValueLayout.ADDRESS, ValueLayout.ADDRESS);
FunctionDescriptor sigv_mmmm = FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS);
+ FunctionDescriptor sigv_mii = FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_INT, ValueLayout.JAVA_INT);
MemorySegment ui_show_addr = lib.find("ui_show").orElseThrow();
MemorySegment ui_close_addr = lib.find("ui_close").orElseThrow();
MemorySegment ui_openfiledialog_addr = lib.find("ui_openfiledialog").orElseThrow();
MemorySegment ui_savefiledialog_addr = lib.find("ui_savefiledialog").orElseThrow();
+ MemorySegment ui_window_size_addr = lib.find("ui_window_size").orElseThrow();
+
ui_show = linker.downcallHandle(ui_show_addr, sigv_m);
ui_close = linker.downcallHandle(ui_close_addr, sigv_m);
ui_window = linker.downcallHandle(ui_window_addr, sigm_mm);
ui_dialog_create = linker.downcallHandle(ui_dialog_create_addr, sigv_mm);
ui_openfiledialog = linker.downcallHandle(ui_openfiledialog_addr, sigv_mimm);
ui_savefiledialog = linker.downcallHandle(ui_savefiledialog_addr, sigv_mmmm);
+
+ ui_window_size = linker.downcallHandle(ui_window_size_addr, sigv_mii);
}
// must be called by the Toolkit constructor
import de.unixwork.ui.EventHandler
import de.unixwork.ui.UiObject
-fun window(title: String, ui: (Toplevel.() -> Unit)? = null): Toplevel {
+fun window(title: String, width: Int = 0, height: Int = 0, ui: (Toplevel.() -> Unit)? = null): Toplevel {
val obj = UiObject.createWindow(title)
+ if(width > 0 && height > 0) {
+ obj.setSize(width, height)
+ }
val toplevel = Toplevel(obj)
ui?.invoke(toplevel)
return toplevel
}
-fun simpleWindow(title: String, ui: (Toplevel.() -> Unit)? = null): Toplevel {
+fun simpleWindow(title: String, width: Int = 0, height: Int = 0, ui: (Toplevel.() -> Unit)? = null): Toplevel {
val obj = UiObject.createSimpleWindow(title)
+ if(width > 0 && height > 0) {
+ obj.setSize(width, height)
+ }
val toplevel = Toplevel(obj)
ui?.invoke(toplevel)
return toplevel
}
-fun sidebarWindow(title: String, ui: (Toplevel.() -> Unit)? = null): Toplevel {
+fun sidebarWindow(title: String, width: Int = 0, height: Int = 0, ui: (Toplevel.() -> Unit)? = null): Toplevel {
val obj = UiObject.createSidebarWindow(title)
+ if(width > 0 && height > 0) {
+ obj.setSize(width, height)
+ }
val toplevel = Toplevel(obj)
ui?.invoke(toplevel)
return toplevel