提交 6c4bf959 编写于 作者: yanghye's avatar yanghye

增加打包图形化配置v1.0.0

上级 d36f0dda
package cef
import (
"github.com/energye/energy/common"
"github.com/energye/golcl/lcl"
"github.com/energye/golcl/lcl/types"
)
func PanelBevelColor(panel *lcl.TPanel) types.TColor {
r1, _, _ := common.Proc(internale_Ext_Panel_GetBevelColor).Call(panel.Instance())
return types.TColor(r1)
}
func SetPanelBevelColor(panel *lcl.TPanel, colors types.TColor) {
common.Proc(internale_Ext_Panel_SetBevelColor).Call(panel.Instance(), uintptr(colors))
}
package ide
import (
"fmt"
"github.com/energye/golcl/lcl"
"github.com/energye/golcl/lcl/types"
)
type IDEButton struct {
*IDEComponent
Component *lcl.TButton
}
func (m *IDEForm) CreateButton() *IDEButton {
com := &IDEButton{}
com.IDEComponent = m.newIDEComponentContainer(false, 50, 50, 100, 24)
com.Component = lcl.NewButton(com.componentParentPanel)
com.Component.SetParent(com.componentParentPanel)
com.Component.SetAlign(types.AlClient)
com.Component.SetOnMouseMove(com.IDEComponent.mouseMove)
com.Component.SetOnMouseDown(com.IDEComponent.mouseDown)
com.Component.SetOnMouseUp(com.IDEComponent.mouseUp)
com.componentControl = com.Component
m.addComponent(com.IDEComponent)
com.name = fmt.Sprintf("Button%d", com.Id)
com.componentType = ctButton
com.Component.SetCaption(com.name)
com.createAfter()
return com
}
package ide
import (
"fmt"
"github.com/energye/golcl/lcl"
"github.com/energye/golcl/lcl/types"
)
type IDEEdit struct {
*IDEComponent
Component *lcl.TEdit
}
func (m *IDEForm) CreateEdit() *IDEEdit {
com := &IDEEdit{}
com.IDEComponent = m.newIDEComponentContainer(true, 50, 50, 150, 24)
com.Component = lcl.NewEdit(com.IDEComponent.componentParentPanel)
com.Component.SetParent(com.IDEComponent.componentParentPanel)
com.Component.SetAlign(types.AlClient)
com.Component.SetOnMouseMove(com.IDEComponent.mouseMove)
com.Component.SetOnMouseDown(com.IDEComponent.mouseDown)
com.Component.SetOnMouseUp(com.IDEComponent.mouseUp)
com.componentControl = com.Component
m.addComponent(com.IDEComponent)
com.componentType = ctLabel
com.name = fmt.Sprintf("Edit%d", com.Id)
com.componentParentPanel.SetCaption(com.name)
//com.createAnchor(m.componentParentPanel)
com.createAfter()
return com
}
package ide
import (
"github.com/energye/golcl/lcl"
"github.com/energye/golcl/lcl/types"
)
type IDEImage struct {
*IDEComponent
Component *lcl.TImage
}
func (m *IDEForm) CreateImage() *IDEImage {
com := &IDEImage{}
com.IDEComponent = m.newIDEComponentContainer(true, 50, 50, 170, 50)
com.Component = lcl.NewImage(com.IDEComponent.componentParentPanel)
com.Component.SetParent(com.IDEComponent.componentParentPanel)
com.Component.SetAlign(types.AlClient)
com.Component.SetOnMouseMove(com.IDEComponent.mouseMove)
com.Component.SetOnMouseDown(com.IDEComponent.mouseDown)
com.Component.SetOnMouseUp(com.IDEComponent.mouseUp)
com.componentControl = com.Component
m.addComponent(com.IDEComponent)
com.componentType = ctImage
com.createAfter()
//com.createAnchor(m.componentParentPanel)
return com
}
package ide
import (
"fmt"
"github.com/energye/golcl/lcl"
"github.com/energye/golcl/lcl/types"
)
type IDELabel struct {
*IDEComponent
Component *lcl.TLabel
}
func (m *IDEForm) CreateLabel() *IDELabel {
com := &IDELabel{}
com.IDEComponent = m.newIDEComponentContainer(true, 50, 50, 170, 50)
com.Component = lcl.NewLabel(com.IDEComponent.componentParentPanel)
com.Component.SetParent(com.IDEComponent.componentParentPanel)
com.Component.SetAlign(types.AlClient)
com.Component.SetOnMouseMove(com.IDEComponent.mouseMove)
com.Component.SetOnMouseDown(com.IDEComponent.mouseDown)
com.Component.SetOnMouseUp(com.IDEComponent.mouseUp)
com.componentControl = com.Component
m.addComponent(com.IDEComponent)
com.componentType = ctLabel
com.name = fmt.Sprintf("Label%d", com.Id)
com.createAfter()
//com.createAnchor(m.componentParentPanel)
return com
}
package ide
import (
"github.com/energye/energy/cef"
"github.com/energye/golcl/lcl"
"github.com/energye/golcl/lcl/types"
"github.com/energye/golcl/lcl/types/colors"
)
type IDEComponent struct {
form *IDEForm
Id int
name string
anchor *anchor
borderPanel *lcl.TPanel
isUseBorder bool
componentParentPanel *lcl.TPanel
componentControl lcl.IControl
componentType componentType
isBorder, isDown, isComponentArea bool
borderHT int32
ox, oy, ow, oh int32
dx, dy int32
}
type anchor struct {
top *lcl.TPanel
bottom *lcl.TPanel
left *lcl.TPanel
right *lcl.TPanel
topLeft *lcl.TPanel
topRight *lcl.TPanel
bottomLeft *lcl.TPanel
bottomRight *lcl.TPanel
}
func (m *IDEComponent) newAnchorPoint(owner lcl.IWinControl, ht int32) *lcl.TPanel {
point := lcl.NewPanel(owner)
point.SetParent(owner)
point.SetBevelInner(types.BvSpace)
point.SetBevelOuter(types.BvNone)
cef.SetPanelBevelColor(point, colors.ClBlack)
point.SetColor(colors.ClTeal)
point.SetOnMouseMove(func(sender lcl.IObject, shift types.TShiftState, x, y int32) {
m.borderHT = ht
switch ht {
case HTTOP, HTBOTTOM:
point.SetCursor(types.CrSizeN)
case HTLEFT, HTRIGHT:
point.SetCursor(types.CrSizeW)
case HTTOPRIGHT, HTBOTTOMLEFT:
point.SetCursor(types.CrSizeSW)
case HTTOPLEFT, HTBOTTOMRIGHT:
point.SetCursor(types.CrSizeSE)
default:
point.SetCursor(types.CrDefault)
}
m.mouseMove(sender, shift, x, y)
})
point.SetOnMouseDown(func(sender lcl.IObject, button types.TMouseButton, shift types.TShiftState, x, y int32) {
m.mouseDown(sender, button, shift, x, y)
})
point.SetOnMouseUp(func(sender lcl.IObject, button types.TMouseButton, shift types.TShiftState, x, y int32) {
m.mouseUp(sender, button, shift, x, y)
})
return point
}
func (m *IDEComponent) createAnchor(owner lcl.IWinControl) {
acr := &anchor{}
acr.top = m.newAnchorPoint(owner, HTTOP)
acr.bottom = m.newAnchorPoint(owner, HTBOTTOM)
acr.left = m.newAnchorPoint(owner, HTLEFT)
acr.right = m.newAnchorPoint(owner, HTRIGHT)
acr.topLeft = m.newAnchorPoint(owner, HTTOPLEFT)
acr.topRight = m.newAnchorPoint(owner, HTTOPRIGHT)
acr.bottomLeft = m.newAnchorPoint(owner, HTBOTTOMLEFT)
acr.bottomRight = m.newAnchorPoint(owner, HTBOTTOMRIGHT)
m.anchor = acr
m.refreshAnchorsPoint()
}
func (m *IDEComponent) refreshAnchorsPoint() {
if m.anchor == nil {
return
}
rect := m.componentParentPanel.BoundsRect()
m.anchor.top.SetBounds(rect.Left+rect.Width()/2-pointWC, rect.Top-pointWC, pointW, pointW)
m.anchor.bottom.SetBounds(rect.Left+rect.Width()/2-pointWC, rect.Bottom-pointWC, pointW, pointW)
m.anchor.left.SetBounds(rect.Left-pointWC, rect.Top+rect.Height()/2-pointWC, pointW, pointW)
m.anchor.right.SetBounds(rect.Right-pointWC, rect.Top+rect.Height()/2-pointWC, pointW, pointW)
}
func (m *IDEComponent) mouseMove(sender lcl.IObject, shift types.TShiftState, x, y int32) {
if m.isDown {
if m.isBorder { //mouse down borderMargin > resize
switch m.borderHT {
case HTRIGHT:
tmpWidth := m.ow + (x - m.dx)
if tmpWidth <= minW {
return
}
if m.borderPanel != nil {
m.borderPanel.SetWidth(tmpWidth + border)
}
m.componentParentPanel.SetWidth(tmpWidth)
case HTLEFT:
tmpX := m.componentParentPanel.Left() + (x - m.dx)
tmpWidth := m.ow + (m.ox - tmpX)
if tmpWidth <= minW {
return
}
m.borderPanel.SetLeft(tmpX - border/2)
m.componentParentPanel.SetLeft(tmpX)
m.borderPanel.SetWidth(tmpWidth + border)
m.componentParentPanel.SetWidth(tmpWidth)
case HTTOP:
tmpY := m.componentParentPanel.Top() + (y - m.dy)
tmpHeight := m.oh + (m.oy - tmpY)
if tmpHeight <= minH {
return
}
m.borderPanel.SetTop(tmpY - border/2)
m.componentParentPanel.SetTop(tmpY)
m.borderPanel.SetHeight(tmpHeight + border)
m.componentParentPanel.SetHeight(tmpHeight)
case HTBOTTOM:
tmpHeight := m.oh + (y - m.dy)
if tmpHeight <= minH {
return
}
m.borderPanel.SetHeight(tmpHeight + border)
m.componentParentPanel.SetHeight(m.oh + (y - m.dy))
case HTTOPRIGHT:
tmpY := m.componentParentPanel.Top() + (y - m.dy)
tmpHeight := m.oh + (m.oy - tmpY)
tmpWidth := m.ow + (x - m.dx)
if tmpWidth <= minW || tmpHeight <= minH {
return
}
m.borderPanel.SetTop(tmpY - border/2)
m.componentParentPanel.SetTop(tmpY)
m.borderPanel.SetHeight(tmpHeight + border)
m.componentParentPanel.SetHeight(tmpHeight)
m.borderPanel.SetWidth(tmpWidth + border)
m.componentParentPanel.SetWidth(tmpWidth)
case HTBOTTOMRIGHT:
tmpWidth := m.ow + (x - m.dx)
tmpHeight := m.oh + (y - m.dy)
if tmpWidth <= minW || tmpHeight <= minH {
return
}
m.borderPanel.SetWidth(tmpWidth + border)
m.componentParentPanel.SetWidth(tmpWidth)
m.borderPanel.SetHeight(tmpHeight + border)
m.componentParentPanel.SetHeight(tmpHeight)
case HTTOPLEFT:
tmpX := m.componentParentPanel.Left() + (x - m.dx)
tmpWidth := m.ow + (m.ox - tmpX)
tmpY := m.componentParentPanel.Top() + (y - m.dy)
tmpHeight := m.oh + (m.oy - tmpY)
if tmpWidth <= minW || tmpHeight <= minH {
return
}
m.borderPanel.SetLeft(tmpX - border/2)
m.borderPanel.SetWidth(tmpWidth + border)
m.componentParentPanel.SetLeft(tmpX)
m.componentParentPanel.SetWidth(tmpWidth)
m.borderPanel.SetTop(tmpY - border/2)
m.borderPanel.SetHeight(tmpHeight + border)
m.componentParentPanel.SetTop(tmpY)
m.componentParentPanel.SetHeight(tmpHeight)
case HTBOTTOMLEFT:
tmpX := m.componentParentPanel.Left() + (x - m.dx)
tmpWidth := m.ow + (m.ox - tmpX)
tmpHeight := m.oh + (y - m.dy)
if tmpWidth <= minW || tmpHeight <= minH {
return
}
m.borderPanel.SetLeft(tmpX - border/2)
m.borderPanel.SetWidth(tmpWidth + border)
m.borderPanel.SetHeight(tmpHeight + border)
m.componentParentPanel.SetLeft(tmpX)
m.componentParentPanel.SetWidth(tmpWidth)
m.componentParentPanel.SetHeight(tmpHeight)
}
//rect := m.componentParentPanel.BoundsRect()
//fx, fy, fw, fh = rect.Left, rect.Top, rect.Width(), rect.Height()
//Ide.formsSyncSize(m.Id)
//m.refreshAnchorsPoint()
return
} else if m.isComponentArea && m.componentType != ctForm { // mouse down componentControl area > move
tmpY := m.componentParentPanel.Top() + (y - m.dy)
tmpX := m.componentParentPanel.Left() + (x - m.dx)
m.borderPanel.SetLeft(tmpX - border/2)
m.borderPanel.SetTop(tmpY - border/2)
m.componentParentPanel.SetTop(tmpY)
m.componentParentPanel.SetLeft(tmpX)
//rect := m.componentParentPanel.BoundsRect()
//fx, fy, fw, fh = rect.Left, rect.Top, rect.Width(), rect.Height()
//Ide.formsSyncSize(m.Id)
//m.refreshAnchorsPoint()
return
}
}
if m.isBorder = x <= m.ow && x >= m.ow-borderRange && y <= borderRange; m.isBorder && m.componentType != ctForm { // 右上
m.componentParentPanel.SetCursor(types.CrSizeSW)
m.borderHT = HTTOPRIGHT
} else if m.isBorder = x <= m.ow && x >= m.ow-borderRange && y <= m.oh && y >= m.oh-borderRange; m.isBorder { // 右下
m.componentParentPanel.SetCursor(types.CrSizeSE)
m.borderHT = HTBOTTOMRIGHT
} else if m.isBorder = x <= borderRange && y <= borderRange; m.isBorder && m.componentType != ctForm { //左上
m.componentParentPanel.SetCursor(types.CrSizeSE)
m.borderHT = HTTOPLEFT
} else if m.isBorder = x <= borderRange && y >= m.oh-borderRange; m.isBorder && m.componentType != ctForm { //左下
m.componentParentPanel.SetCursor(types.CrSizeSW)
m.borderHT = HTBOTTOMLEFT
} else if m.isBorder = x <= m.ow && x >= m.ow-borderRange && y > borderRange && y < m.oh-borderRange; m.isBorder { //右
m.componentParentPanel.SetCursor(types.CrSizeW)
m.borderHT = HTRIGHT
} else if m.isBorder = x <= borderRange && y > borderRange && y < m.oh-borderRange; m.isBorder && m.componentType != ctForm { //左
m.componentParentPanel.SetCursor(types.CrSizeW)
m.borderHT = HTLEFT
} else if m.isBorder = x > borderRange && x < m.ow-borderRange && y <= borderRange; m.isBorder && m.componentType != ctForm { //上
m.componentParentPanel.SetCursor(types.CrSizeN)
m.borderHT = HTTOP
} else if m.isBorder = x > borderRange && x < m.ow-borderRange && y >= m.oh-borderRange; m.isBorder { //下
m.componentParentPanel.SetCursor(types.CrSizeN)
m.borderHT = HTBOTTOM
} else {
m.isBorder = false
m.componentParentPanel.SetCursor(types.CrDefault)
}
if m.componentControl != nil {
m.componentControl.SetCursor(m.componentParentPanel.Cursor())
}
}
func (m *IDEComponent) mouseDown(sender lcl.IObject, button types.TMouseButton, shift types.TShiftState, x, y int32) {
if button == types.MbLeft {
m.dx = x
m.dy = y
if m.componentType == ctForm {
for _, form := range Ide.forms {
if form.active != nil {
form.active.clearBorderColor()
}
}
} else {
m.form.active.clearBorderColor()
m.form.active = m
if m.isUseBorder {
m.form.active.setBorderColor(colors.ClBlack)
} else {
m.form.active.clearBorderColor()
}
}
if !m.isBorder && m.componentType != ctForm {
m.isComponentArea = true
m.componentParentPanel.SetCursor(types.CrSizeAll)
if m.componentControl != nil {
m.componentControl.SetCursor(m.componentParentPanel.Cursor())
}
}
m.isDown = true
}
}
func (m *IDEComponent) mouseUp(sender lcl.IObject, button types.TMouseButton, shift types.TShiftState, x, y int32) {
m.isDown = false
if m.isComponentArea {
m.isComponentArea = false
m.componentParentPanel.SetCursor(types.CrDefault)
if m.componentControl != nil {
m.componentControl.SetCursor(m.componentParentPanel.Cursor())
}
}
m.ox, m.oy, m.ow, m.oh = m.componentParentPanel.Left(), m.componentParentPanel.Top(), m.componentParentPanel.Width(), m.componentParentPanel.Height()
}
func (m *IDEComponent) setBorderColor(color types.TColor) {
if m == nil {
return
}
m.borderPanel.SetColor(color)
}
func (m *IDEComponent) clearBorderColor() {
if m == nil {
return
}
if m.componentType != ctForm {
if m.componentType == ctImage {
m.borderPanel.SetColor(colors.ClGray)
} else {
m.borderPanel.SetColor(colors.ClSysDefault)
}
}
}
func (m *IDEComponent) createAfter() {
m.componentParentPanel.SetCaption(m.name)
pm := lcl.NewPopupMenu(m.componentControl)
item := lcl.NewMenuItem(m.componentControl)
item.SetCaption("删除")
item.SetOnClick(func(lcl.IObject) {
m.form.RemoveComponent(m.Id)
})
pm.Items().Add(item)
m.componentControl.SetPopupMenu(pm)
}
package ide
import (
"github.com/energye/golcl/lcl"
"github.com/energye/golcl/lcl/types"
"github.com/energye/golcl/lcl/types/colors"
)
type IDEForm struct {
count int
IDEComponent
active *IDEComponent
components map[int]*IDEComponent
tabSheet *lcl.TTabSheet
}
func (m *IDEForm) addComponent(component *IDEComponent) int {
m.count++
m.components[m.count] = component
component.Id = m.count
return m.count
}
func (m *IDEForm) RemoveComponent(index int) {
if component, ok := m.components[index]; ok {
if component.borderPanel != nil {
m.componentFrees(component.borderPanel)
}
if component.componentParentPanel != nil {
m.componentFrees(component.componentParentPanel)
}
}
delete(m.components, index)
m.active = nil
println("剩余组件个数", len(m.components))
}
func (m *IDEForm) componentFrees(control lcl.IComponent) {
control.Free()
}
func (m *IDEForm) newIDEComponentContainer(useBorder bool, left, top, width, height int32) *IDEComponent {
ideComponent := &IDEComponent{}
ideComponent.borderPanel = lcl.NewPanel(m.componentParentPanel)
ideComponent.borderPanel.SetParent(m.componentParentPanel)
ideComponent.borderPanel.SetDoubleBuffered(true)
ideComponent.borderPanel.SetBevelInner(types.BvNone)
ideComponent.borderPanel.SetBevelOuter(types.BvNone)
ideComponent.borderPanel.SetBorderStyle(types.BsNone)
if useBorder {
ideComponent.borderPanel.SetBounds(left-border, top-border, width+border, height+border)
ideComponent.borderPanel.SetColor(colors.ClBlack)
} else {
ideComponent.borderPanel.SetBounds(left, top, width, height)
}
ideComponent.componentParentPanel = lcl.NewPanel(m.componentParentPanel)
ideComponent.componentParentPanel.SetParent(m.componentParentPanel)
ideComponent.componentParentPanel.SetDoubleBuffered(true)
ideComponent.componentParentPanel.SetBevelInner(types.BvNone)
ideComponent.componentParentPanel.SetBevelOuter(types.BvNone)
ideComponent.componentParentPanel.SetBorderStyle(types.BsNone)
if useBorder {
ideComponent.componentParentPanel.SetBounds(left-border/2, top-border/2, width, height)
} else {
ideComponent.componentParentPanel.SetBounds(left, top, width, height)
}
ideComponent.componentParentPanel.SetOnMouseMove(ideComponent.mouseMove)
ideComponent.componentParentPanel.SetOnMouseDown(ideComponent.mouseDown)
ideComponent.componentParentPanel.SetOnMouseUp(ideComponent.mouseUp)
ideComponent.ox, ideComponent.oy, ideComponent.ow, ideComponent.oh = ideComponent.componentParentPanel.Left(), ideComponent.componentParentPanel.Top(), ideComponent.componentParentPanel.Width(), ideComponent.componentParentPanel.Height()
ideComponent.form = m
ideComponent.isUseBorder = useBorder
return ideComponent
}
package ide
import (
"fmt"
"github.com/energye/golcl/lcl"
"github.com/energye/golcl/lcl/types"
"github.com/energye/golcl/lcl/types/colors"
)
const (
ide_title = "Energy 自定义安装程序图形化制作 - %s"
ide_version = "1.0.0"
)
const (
HTLEFT = 10
HTRIGHT = 11
HTTOP = 12
HTTOPLEFT = 13
HTTOPRIGHT = 14
HTBOTTOM = 15
HTBOTTOMLEFT = 16
HTBOTTOMRIGHT = 17
)
const (
borderRange int32 = 8
borderMargin = 4
border = borderMargin / 2
pointW = 10
pointWC = pointW / 2
minW, minH = 24, 8
)
type componentType int8
const (
ctForm componentType = iota
ctImage
ctButton
ctLabel
)
var (
Ide *IDE //= &IDE{forms: make([]*IDEForm, 0, 0)}
fx, fy, fw, fh int32
)
type IDE struct {
*lcl.TForm
statusBar *lcl.TStatusBar
topBox *lcl.TPanel
leftBox *lcl.TPanel
rightBox *lcl.TPanel
imageList *lcl.TImageList
actionList *lcl.TActionList
mainMenu *lcl.TMainMenu
topToolBar *lcl.TToolBar
topToolButton *lcl.TToolButton
forms []*IDEForm
active *IDEForm
pageControl *lcl.TPageControl
pageControlPopupMenu *lcl.TPopupMenu
}
func (m *IDE) addForm(form *IDEForm) int {
form.Id = int(m.pageControl.ControlCount()) - 1
m.forms = append(m.forms, form)
m.active = form
m.pageControl.SetActivePageIndex(int32(form.Id))
return form.Id
}
func (m *IDE) removeForm(index int) {
form := m.forms[index]
form.tabSheet.Free()
m.forms = append(m.forms[:index], m.forms[index+1:]...)
}
func (m *IDE) formsSyncSize(id int) {
for _, form := range m.forms {
if form.Id != id {
form.borderPanel.SetBounds(fx-border, fy-border, fw+border, fh+border)
form.componentParentPanel.SetBounds(fx-border/2, fy-border/2, fw, fh)
}
}
}
func (m *IDE) CreateForm() *IDEForm {
var left, top, width, height int32 = border, border, 600, 400
form := &IDEForm{components: map[int]*IDEComponent{}}
form.tabSheet = lcl.NewTabSheet(m.pageControl)
form.tabSheet.SetPageControl(m.pageControl)
form.tabSheet.SetAlign(types.AlClient)
form.borderPanel = lcl.NewPanel(form.tabSheet)
form.borderPanel.SetParent(form.tabSheet)
form.borderPanel.SetDoubleBuffered(true)
form.borderPanel.SetBevelInner(types.BvNone)
form.borderPanel.SetBevelOuter(types.BvNone)
form.borderPanel.SetBorderStyle(types.BsNone)
form.borderPanel.SetBounds(left-border, top-border, width+border, height+border)
form.borderPanel.SetColor(colors.ClBlack)
form.componentParentPanel = lcl.NewPanel(form.tabSheet)
form.componentParentPanel.SetParent(form.tabSheet)
form.componentParentPanel.SetDoubleBuffered(true)
form.componentParentPanel.SetBevelInner(types.BvNone)
form.componentParentPanel.SetBevelOuter(types.BvNone)
form.componentParentPanel.SetBorderStyle(types.BsNone)
form.componentParentPanel.SetBounds(left-border/2, top-border/2, width, height)
form.componentParentPanel.SetOnMouseMove(form.mouseMove)
form.componentParentPanel.SetOnMouseDown(form.mouseDown)
form.componentParentPanel.SetOnMouseUp(form.mouseUp)
form.ox, form.oy, form.ow, form.oh = form.componentParentPanel.Left(), form.componentParentPanel.Top(), form.componentParentPanel.Width(), form.componentParentPanel.Height()
m.addForm(form)
form.name = fmt.Sprintf("Form%d", form.Id)
form.componentType = ctForm
form.tabSheet.SetCaption(form.name)
return form
}
func (m *IDE) OnFormCreate(sender lcl.IObject) {
m.forms = make([]*IDEForm, 0, 0)
m.SetCaption(fmt.Sprintf(ide_title, ide_version))
m.SetPosition(types.PoScreenCenter)
m.SetWidth(1200)
m.SetHeight(800)
m.SetDoubleBuffered(true)
m.SetColor(colors.ClWhite)
m.SetShowHint(true)
m.statusBar = lcl.NewStatusBar(m)
m.statusBar.SetParent(m)
m.statusBar.SetAlign(types.AlBottom)
m.statusBar.SetAnchors(types.NewSet(types.AkLeft, types.AkBottom, types.AkRight))
m.statusBar.SetAutoHint(true)
m.statusBar.SetSimplePanel(true)
//ide top
m.topBox = lcl.NewPanel(m)
m.topBox.SetParent(m)
m.topBox.SetWidth(m.Width())
m.topBox.SetHeight(100)
m.topBox.SetAnchors(types.NewSet(types.AkLeft, types.AkTop, types.AkRight))
m.initTopMainMenu()
//ide left
m.leftBox = lcl.NewPanel(m)
m.leftBox.SetParent(m)
m.leftBox.SetTop(m.topBox.Height())
m.leftBox.SetWidth(250)
m.leftBox.SetHeight(m.Height() - m.leftBox.Top() - 20)
m.leftBox.SetColor(colors.ClAntiquewhite)
m.leftBox.SetAnchors(types.NewSet(types.AkLeft, types.AkTop, types.AkBottom))
//ide box
m.rightBox = lcl.NewPanel(m)
m.rightBox.SetParent(m)
m.rightBox.SetTop(m.topBox.Height())
m.rightBox.SetLeft(m.leftBox.Width())
m.rightBox.SetWidth(m.Width() - m.rightBox.Left())
m.rightBox.SetHeight(m.Height() - m.rightBox.Top() - 20)
m.rightBox.SetBevelInner(types.BvNone)
m.rightBox.SetBevelOuter(types.BvNone)
m.rightBox.SetBorderStyle(types.BsNone)
m.rightBox.SetColor(colors.ClBlanchedalmond)
m.rightBox.SetAnchors(types.NewSet(types.AkLeft, types.AkTop, types.AkBottom, types.AkRight))
m.pageControl = lcl.NewPageControl(m.rightBox)
m.pageControl.SetParent(m.rightBox)
m.pageControl.SetAlign(types.AlClient)
m.pageControlPopupMenu = lcl.NewPopupMenu(m.pageControl)
item := lcl.NewMenuItem(m.pageControl)
item.SetCaption("修改名称")
item.SetOnClick(func(lcl.IObject) {
fmt.Println("修改名称")
})
m.pageControlPopupMenu.Items().Add(item)
item = lcl.NewMenuItem(m.pageControl)
item.SetCaption("关闭")
item.SetOnClick(func(lcl.IObject) {
fmt.Println("关闭")
m.removeForm(m.active.Id)
})
m.pageControlPopupMenu.Items().Add(item)
m.pageControl.SetPopupMenu(m.pageControlPopupMenu)
m.pageControl.SetOnContextPopup(func(sender lcl.IObject, mousePos types.TPoint, handled *bool) {
pageIndex := m.pageControl.IndexOfPageAt(mousePos.X, mousePos.Y)
//sheet := Ide.pageControl.Pages(pageIndex)
if pageIndex >= 0 {
m.pageControl.SetActivePageIndex(pageIndex)
m.active = m.forms[int(pageIndex)]
m.active.Id = int(pageIndex)
} else {
*handled = true
}
})
}
func (m *IDE) initPopupMenu() {
pm := lcl.NewPopupMenu(m)
item := lcl.NewMenuItem(m)
item.SetCaption("退出(&E)")
item.SetOnClick(func(lcl.IObject) {
m.Close()
})
pm.Items().Add(item)
m.SetPopupMenu(pm)
}
func (m *IDE) initTopMainMenu() {
//创建Image Icon集合
m.imageList = lcl.NewImageList(m)
//加载图标
icon0 := lcl.NewIcon()
icon0.LoadFromFSFile("resources/icon.ico")
m.imageList.AddIcon(icon0)
m.actionList = lcl.NewActionList(m)
m.actionList.SetImages(m.imageList)
m.mainMenu = lcl.NewMainMenu(m)
m.mainMenu.SetImages(m.imageList)
//m.mainMenu.SetOnMeasureItem(func(sender lcl.IObject, aCanvas *lcl.TCanvas, width, height *int32) {
// //*height = 44
//})
m.topToolBar = lcl.NewToolBar(m)
m.topToolBar.SetParent(m)
m.topToolBar.SetImages(m.imageList)
action := lcl.NewAction(m)
action.SetCaption("新建(&F)")
action.SetImageIndex(0)
action.SetHint("新建Form窗口|新建一个Form窗口")
action.SetOnExecute(func(sender lcl.IObject) {
m.CreateForm()
})
m.topToolButton = lcl.NewToolButton(m)
m.topToolButton.SetParent(m.topToolBar)
m.topToolButton.SetAction(action)
fileMenuItem := lcl.NewMenuItem(m)
fileMenuItem.SetCaption("文件(&F)")
fileMenuItemSubNew := lcl.NewMenuItem(m)
fileMenuItemSubNew.SetCaption("新建(&N)")
fileMenuItemSubNew.SetAction(action)
fileMenuItemSubNew.SetShortCutFromString("Ctrl+N")
//fileMenuItemSubNew.SetOnClick(func(lcl.IObject) {
// fmt.Println("新建")
//})
fileMenuItem.Add(fileMenuItemSubNew)
fileMenuItemSubSave := lcl.NewMenuItem(m)
fileMenuItemSubSave.SetCaption("保存(&S)")
fileMenuItemSubSave.SetShortCutFromString("Ctrl+S")
fileMenuItemSubSave.SetOnClick(func(lcl.IObject) {
fmt.Println("保存")
})
fileMenuItem.Add(fileMenuItemSubSave)
separate := lcl.NewMenuItem(m)
separate.SetCaption("-")
fileMenuItem.Add(separate)
fileMenuItemSubExit := lcl.NewMenuItem(m)
fileMenuItemSubExit.SetCaption("退出(&E)")
fileMenuItemSubExit.SetOnClick(func(lcl.IObject) {
fmt.Println("退出")
})
fileMenuItem.Add(fileMenuItemSubExit)
//add file
m.mainMenu.Items().Add(fileMenuItem)
editMenuItem := lcl.NewMenuItem(m)
editMenuItem.SetCaption("编辑(&E)")
//add edit
m.mainMenu.Items().Add(editMenuItem)
configMenuItem := lcl.NewMenuItem(m)
configMenuItem.SetCaption("设置(&C)")
configMenuSubEnv := lcl.NewMenuItem(m)
configMenuSubEnv.SetCaption("环境配置")
configMenuSubEnv.SetOnClick(func(lcl.IObject) {
fmt.Println("环境配置")
})
configMenuItem.Add(configMenuSubEnv)
//add config
m.mainMenu.Items().Add(configMenuItem)
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册