2024-09-22 19:23:06 +05:30
|
|
|
import Widget from "../../../canvas/widgets/base"
|
2024-09-22 22:24:35 +05:30
|
|
|
import Tools from "../../../canvas/constants/tools"
|
2024-09-22 19:23:06 +05:30
|
|
|
|
|
|
|
|
|
|
|
|
|
class MainWindow extends Widget{
|
|
|
|
|
|
|
|
|
|
static widgetType = "main_window"
|
|
|
|
|
|
|
|
|
|
constructor(props) {
|
|
|
|
|
super(props)
|
|
|
|
|
|
|
|
|
|
this.droppableTags = {
|
2024-09-22 22:24:35 +05:30
|
|
|
exclude: ["image", "video", "media", "main_window", "toplevel"]
|
2024-09-22 19:23:06 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.state = {
|
|
|
|
|
...this.state,
|
2024-09-22 22:24:35 +05:30
|
|
|
size: { width: 700, height: 400 },
|
|
|
|
|
attrs: {
|
|
|
|
|
...this.state.attrs,
|
2024-09-27 16:04:03 +05:30
|
|
|
widgetName: "main",
|
2024-09-22 22:24:35 +05:30
|
|
|
title: {
|
|
|
|
|
label: "Window Title",
|
|
|
|
|
tool: Tools.INPUT, // the tool to display, can be either HTML ELement or a constant string
|
|
|
|
|
toolProps: {placeholder: "Window title", maxLength: 40},
|
|
|
|
|
value: "Main Window",
|
|
|
|
|
onChange: (value) => this.setAttrValue("title", value)
|
|
|
|
|
}
|
2024-09-22 19:23:06 +05:30
|
|
|
|
2024-09-22 22:24:35 +05:30
|
|
|
}
|
2024-09-22 19:23:06 +05:30
|
|
|
}
|
2024-09-22 22:24:35 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
|
|
componentDidMount(){
|
|
|
|
|
super.componentDidMount()
|
2024-09-22 19:23:06 +05:30
|
|
|
this.setAttrValue("styling.backgroundColor", "#E4E2E2")
|
2024-09-27 16:04:03 +05:30
|
|
|
// this.setWidgetName("main") // Don't do this as this will cause conflicts while loading names
|
2024-09-22 19:23:06 +05:30
|
|
|
}
|
|
|
|
|
|
2024-09-26 18:53:21 +05:30
|
|
|
generateCode(variableName, parent){
|
2024-09-26 11:59:24 +05:30
|
|
|
|
2024-09-26 18:53:21 +05:30
|
|
|
return [
|
|
|
|
|
`${variableName} = tk.Tk()`,
|
|
|
|
|
`${variableName}.title("${this.getAttrValue("title")}")`
|
|
|
|
|
]
|
2024-09-26 11:59:24 +05:30
|
|
|
}
|
|
|
|
|
|
2024-09-22 22:24:35 +05:30
|
|
|
getToolbarAttrs(){
|
2024-09-23 12:31:01 +05:30
|
|
|
const toolBarAttrs = super.getToolbarAttrs()
|
|
|
|
|
|
2024-09-22 22:24:35 +05:30
|
|
|
return ({
|
|
|
|
|
id: this.__id,
|
2024-09-23 12:31:01 +05:30
|
|
|
widgetName: toolBarAttrs.widgetName,
|
2024-09-22 22:24:35 +05:30
|
|
|
title: this.state.attrs.title,
|
2024-09-23 12:31:01 +05:30
|
|
|
size: toolBarAttrs.size,
|
2024-09-22 22:24:35 +05:30
|
|
|
|
|
|
|
|
...this.state.attrs,
|
|
|
|
|
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
2024-09-22 19:23:06 +05:30
|
|
|
renderContent(){
|
|
|
|
|
return (
|
|
|
|
|
<div className="tw-w-flex tw-flex-col tw-w-full tw-h-full tw-rounded-md tw-overflow-hidden">
|
2024-09-22 22:24:35 +05:30
|
|
|
<div className="tw-flex tw-w-full tw-h-[25px] tw-bg-[#c7c7c7] tw-p-1
|
|
|
|
|
tw-overflow-hidden tw-shadow-xl tw-place-items-center">
|
|
|
|
|
<div className="tw-text-sm">{this.getAttrValue("title")}</div>
|
|
|
|
|
<div className="tw-ml-auto tw-flex tw-gap-1 tw-place-items-center">
|
2024-09-22 19:23:06 +05:30
|
|
|
<div className="tw-bg-yellow-400 tw-rounded-full tw-w-[15px] tw-h-[15px]">
|
|
|
|
|
</div>
|
|
|
|
|
<div className="tw-bg-blue-400 tw-rounded-full tw-w-[15px] tw-h-[15px]">
|
|
|
|
|
</div>
|
|
|
|
|
<div className="tw-bg-red-400 tw-rounded-full tw-w-[15px] tw-h-[15px]">
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2024-09-25 17:27:12 +05:30
|
|
|
<div className="tw-p-2 tw-w-full tw-relative tw-h-full tw-overflow-hidden tw-content-start" style={this.state.widgetInnerStyling}>
|
2024-09-22 19:23:06 +05:30
|
|
|
{this.props.children}
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export default MainWindow
|