changeset 1873:cf38353d77bd default tip

swing
author Franklin Schmidt <fschmidt@gmail.com>
date Thu, 03 Apr 2025 16:17:56 -0600
parents 29a1e9bde185
children
files src/luan/modules/swing/Abstract_button.luan src/luan/modules/swing/Color.luan src/luan/modules/swing/Component.luan src/luan/modules/swing/List.luan src/luan/modules/swing/Scroll_pane.luan src/luan/modules/swing/Text_component.luan
diffstat 6 files changed, 58 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/luan/modules/swing/Abstract_button.luan	Thu Apr 03 14:33:37 2025 -0600
+++ b/src/luan/modules/swing/Abstract_button.luan	Thu Apr 03 16:17:56 2025 -0600
@@ -3,6 +3,8 @@
 local Utils = require "luan:swing/Utils.luan"
 local fail = Utils.fail or error()
 local Component = require "luan:swing/Component.luan"
+local super__index = Component.__index or error()
+local super__new_index = Component.__new_index or error()
 local super = Component.new or error()
 require "java"
 
@@ -10,6 +12,8 @@
 local Abstract_button = {}
 
 function Abstract_button.__index(abstract_button,key)
+	local rtn = super__index(abstract_button,key)
+	if rtn ~= fail then return rtn end
 	if key == "text" then
 		return abstract_button.java.getText()
 	end
@@ -17,6 +21,8 @@
 end
 
 function Abstract_button.__new_index(abstract_button,key,value)
+	local rtn = super__new_index(abstract_button,key,value)
+	if rtn ~= fail then return end
 	if key == "text" then
 		abstract_button.java.setText(value)
 		return
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/luan/modules/swing/Color.luan	Thu Apr 03 16:17:56 2025 -0600
@@ -0,0 +1,15 @@
+local Luan = require "luan:Luan.luan"
+local error = Luan.error
+local Number = require "luan:Number.luan"
+local integer = Number.integer or error()
+require "java"
+local JColor = require "java:java.awt.Color"
+
+
+local Color = {}
+
+function Color.int_to_color(c)
+	return JColor.new(integer(c))
+end
+
+return Color
--- a/src/luan/modules/swing/Component.luan	Thu Apr 03 14:33:37 2025 -0600
+++ b/src/luan/modules/swing/Component.luan	Thu Apr 03 16:17:56 2025 -0600
@@ -1,12 +1,29 @@
 local Luan = require "luan:Luan.luan"
 local error = Luan.error
 local type = Luan.type or error()
+local Utils = require "luan:swing/Utils.luan"
+local fail = Utils.fail or error()
 local get_font = require("luan:swing/Font.luan").get or error()
 require "java"
 
 
 local Component = {}
 
+function Component.__index(component,key)
+	if key == "foreground_color" then
+		return component.java.getForeground()
+	end
+	return fail
+end
+
+function Component.__new_index(component,key,value)
+	if key == "foreground_color" then
+		component.java.setForeground(value)
+		return
+	end
+	return fail
+end
+
 function Component.new(component)
 	local jcomponent = component.java
 	jcomponent.putClientProperty("luan",component)  -- don't gc
--- a/src/luan/modules/swing/List.luan	Thu Apr 03 14:33:37 2025 -0600
+++ b/src/luan/modules/swing/List.luan	Thu Apr 03 16:17:56 2025 -0600
@@ -5,6 +5,8 @@
 local fail = Utils.fail or error()
 local make_metatable = Utils.make_metatable or error()
 local Component = require "luan:swing/Component.luan"
+local super__index = Component.__index or error()
+local super__new_index = Component.__new_index or error()
 local super = Component.new or error()
 require "java"
 local JList = require "java:javax.swing.JList"
@@ -15,6 +17,8 @@
 local List = {}
 
 function List.__index(list,key)
+	local rtn = super__index(list,key)
+	if rtn ~= fail then return rtn end
 	if key == "size" then
 		return list.model.getSize()
 	end
@@ -22,6 +26,8 @@
 end
 
 function List.__new_index(list,key,value)
+	local rtn = super__new_index(list,key,value)
+	if rtn ~= fail then return end
 	local model = list.model
 	if model.instanceof(DefaultListModel) then
 		if key == "size" then
--- a/src/luan/modules/swing/Scroll_pane.luan	Thu Apr 03 14:33:37 2025 -0600
+++ b/src/luan/modules/swing/Scroll_pane.luan	Thu Apr 03 16:17:56 2025 -0600
@@ -1,6 +1,10 @@
 local Luan = require "luan:Luan.luan"
 local error = Luan.error
 local set_metatable = Luan.set_metatable or error()
+local Component = require "luan:swing/Component.luan"
+local super__index = Component.__index or error()
+local super__new_index = Component.__new_index or error()
+local super = Component.new or error()
 require "java"
 local JScrollPane = require "java:javax.swing.JScrollPane"
 
@@ -20,6 +24,7 @@
 function Scroll_pane.new(view)
 	local jscroll_pane = JScrollPane.new(view.java)
 	local scroll_pane = { java = jscroll_pane }
+	super(scroll_pane)
 	function scroll_pane.set_row_header_view(view)
 		jscroll_pane.setRowHeaderView(view.java)
 	end
--- a/src/luan/modules/swing/Text_component.luan	Thu Apr 03 14:33:37 2025 -0600
+++ b/src/luan/modules/swing/Text_component.luan	Thu Apr 03 16:17:56 2025 -0600
@@ -3,7 +3,10 @@
 local raw_set = Luan.raw_set or error()
 local Utils = require "luan:swing/Utils.luan"
 local fail = Utils.fail or error()
-local new_component = require("luan:swing/Component.luan").new or error()
+local Component = require "luan:swing/Component.luan"
+local super__index = Component.__index or error()
+local super__new_index = Component.__new_index or error()
+local super = Component.new or error()
 local new_document = require("luan:swing/Document.luan").new or error()
 require "java"
 local SwingLuan = require "java:luan.modules.swing.SwingLuan"
@@ -15,6 +18,8 @@
 local Text_component = {}
 
 function Text_component.__index(text_component,key)
+	local rtn = super__index(text_component,key)
+	if rtn ~= fail then return rtn end
 	if key == "text" then
 		return text_component.java.getText()
 	end
@@ -30,6 +35,8 @@
 end
 
 function Text_component.__new_index(text_component,key,value)
+	local rtn = super__new_index(text_component,key,value)
+	if rtn ~= fail then return end
 	if key == "text" then
 		text_component.java.setText(value)
 		return
@@ -47,7 +54,7 @@
 end
 
 function Text_component.new(component)
-	new_component(component)
+	super(component)
 	local jcomponent = component.java
 	fixTextComponent(jcomponent)
 	component.cut = jcomponent.cut