mirror of
https://gitee.com/energye/energy.git
synced 2024-11-30 18:57:39 +08:00
图形化设计工具 v1.0.0.1
This commit is contained in:
parent
df2d1fca76
commit
4620d25e45
@ -3,7 +3,6 @@ package ide
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/energye/golcl/lcl"
|
||||
"github.com/energye/golcl/lcl/types"
|
||||
)
|
||||
|
||||
type IDEButton struct {
|
||||
@ -14,9 +13,8 @@ type IDEButton struct {
|
||||
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 = lcl.NewButton(m.parentToPanel())
|
||||
com.Component.SetParent(m.parentToPanel())
|
||||
com.Component.SetOnMouseMove(com.IDEComponent.mouseMove)
|
||||
com.Component.SetOnMouseDown(com.IDEComponent.mouseDown)
|
||||
com.Component.SetOnMouseUp(com.IDEComponent.mouseUp)
|
||||
|
@ -9,8 +9,11 @@ import (
|
||||
|
||||
func (m *IDEComponent) mouseMove(sender lcl.IObject, shift types.TShiftState, x, y int32) {
|
||||
if m.isDown {
|
||||
borderRect := m.borderPanel.BoundsRect()
|
||||
componentParentRect := m.componentParentPanel.BoundsRect()
|
||||
var borderRect types.TRect
|
||||
if m.borderPanel != nil {
|
||||
borderRect = m.borderPanel.BoundsRect()
|
||||
}
|
||||
componentParentRect := m.parentToControl().BoundsRect()
|
||||
if m.isBorder && m.componentType == ctForm { //mouse down borderMargin > resize
|
||||
switch m.borderHT {
|
||||
case HTRIGHT:
|
||||
@ -21,34 +24,40 @@ func (m *IDEComponent) mouseMove(sender lcl.IObject, shift types.TShiftState, x,
|
||||
if m.borderPanel != nil {
|
||||
m.borderPanel.SetWidth(tmpWidth + border)
|
||||
}
|
||||
m.componentParentPanel.SetWidth(tmpWidth)
|
||||
m.parentToControl().SetWidth(tmpWidth)
|
||||
case HTLEFT:
|
||||
tmpX := m.componentParentPanel.Left() + (x - m.dx)
|
||||
tmpX := m.parentToControl().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)
|
||||
if m.borderPanel != nil {
|
||||
m.borderPanel.SetLeft(tmpX - border/2)
|
||||
m.borderPanel.SetWidth(tmpWidth + border)
|
||||
}
|
||||
m.parentToControl().SetLeft(tmpX)
|
||||
m.parentToControl().SetWidth(tmpWidth)
|
||||
case HTTOP:
|
||||
tmpY := m.componentParentPanel.Top() + (y - m.dy)
|
||||
tmpY := m.parentToControl().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)
|
||||
if m.borderPanel != nil {
|
||||
m.borderPanel.SetTop(tmpY - border/2)
|
||||
m.borderPanel.SetHeight(tmpHeight + border)
|
||||
}
|
||||
m.parentToControl().SetTop(tmpY)
|
||||
m.parentToControl().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))
|
||||
if m.borderPanel != nil {
|
||||
m.borderPanel.SetHeight(tmpHeight + border)
|
||||
}
|
||||
m.parentToControl().SetHeight(m.oh + (y - m.dy))
|
||||
case HTTOPRIGHT:
|
||||
tmpY := componentParentRect.Top + (y - m.dy)
|
||||
tmpHeight := m.oh + (m.oy - tmpY)
|
||||
@ -56,16 +65,20 @@ func (m *IDEComponent) mouseMove(sender lcl.IObject, shift types.TShiftState, x,
|
||||
if tmpWidth <= minW || tmpHeight <= minH {
|
||||
return
|
||||
}
|
||||
m.borderPanel.SetBounds(borderRect.Left, tmpY-border/2, tmpWidth+border, tmpHeight+border)
|
||||
m.componentParentPanel.SetBounds(componentParentRect.Left, tmpY, tmpWidth, tmpHeight)
|
||||
if m.borderPanel != nil {
|
||||
m.borderPanel.SetBounds(borderRect.Left, tmpY-border/2, tmpWidth+border, tmpHeight+border)
|
||||
}
|
||||
m.parentToControl().SetBounds(componentParentRect.Left, tmpY, tmpWidth, tmpHeight)
|
||||
case HTBOTTOMRIGHT:
|
||||
tmpWidth := m.ow + (x - m.dx)
|
||||
tmpHeight := m.oh + (y - m.dy)
|
||||
if tmpWidth <= minW || tmpHeight <= minH {
|
||||
return
|
||||
}
|
||||
m.borderPanel.SetBounds(borderRect.Left, borderRect.Top, tmpWidth+border, tmpHeight+border)
|
||||
m.componentParentPanel.SetBounds(componentParentRect.Left, componentParentRect.Top, tmpWidth, tmpHeight)
|
||||
if m.borderPanel != nil {
|
||||
m.borderPanel.SetBounds(borderRect.Left, borderRect.Top, tmpWidth+border, tmpHeight+border)
|
||||
}
|
||||
m.parentToControl().SetBounds(componentParentRect.Left, componentParentRect.Top, tmpWidth, tmpHeight)
|
||||
case HTTOPLEFT:
|
||||
tmpX := componentParentRect.Left + (x - m.dx)
|
||||
tmpWidth := m.ow + (m.ox - tmpX)
|
||||
@ -74,8 +87,10 @@ func (m *IDEComponent) mouseMove(sender lcl.IObject, shift types.TShiftState, x,
|
||||
if tmpWidth <= minW || tmpHeight <= minH {
|
||||
return
|
||||
}
|
||||
m.borderPanel.SetBounds(tmpX-border/2, tmpY-border/2, tmpWidth+border, tmpHeight+border)
|
||||
m.componentParentPanel.SetBounds(tmpX, tmpY, tmpWidth, tmpHeight)
|
||||
if m.borderPanel != nil {
|
||||
m.borderPanel.SetBounds(tmpX-border/2, tmpY-border/2, tmpWidth+border, tmpHeight+border)
|
||||
}
|
||||
m.parentToControl().SetBounds(tmpX, tmpY, tmpWidth, tmpHeight)
|
||||
case HTBOTTOMLEFT:
|
||||
tmpX := componentParentRect.Left + (x - m.dx)
|
||||
tmpWidth := m.ow + (m.ox - tmpX)
|
||||
@ -83,60 +98,59 @@ func (m *IDEComponent) mouseMove(sender lcl.IObject, shift types.TShiftState, x,
|
||||
if tmpWidth <= minW || tmpHeight <= minH {
|
||||
return
|
||||
}
|
||||
m.componentParentPanel.SetLeft(tmpX)
|
||||
m.componentParentPanel.SetWidth(tmpWidth)
|
||||
m.componentParentPanel.SetHeight(tmpHeight)
|
||||
|
||||
m.borderPanel.SetBounds(tmpX-border/2, borderRect.Top, tmpWidth+border, tmpHeight+border)
|
||||
m.componentParentPanel.SetBounds(tmpX, componentParentRect.Top, tmpWidth, tmpHeight)
|
||||
if m.borderPanel != nil {
|
||||
m.borderPanel.SetBounds(tmpX-border/2, borderRect.Top, tmpWidth+border, tmpHeight+border)
|
||||
}
|
||||
m.parentToControl().SetBounds(tmpX, componentParentRect.Top, tmpWidth, tmpHeight)
|
||||
}
|
||||
return
|
||||
} else if m.isComponentArea && m.componentType != ctForm { // mouse down component area > move
|
||||
m.isDClick = false
|
||||
tmpY := componentParentRect.Top + (y - m.dy)
|
||||
tmpX := componentParentRect.Left + (x - m.dx)
|
||||
|
||||
m.borderPanel.SetBounds(tmpX-border/2, tmpY-border/2, borderRect.Width(), borderRect.Height())
|
||||
m.componentParentPanel.SetBounds(tmpX, tmpY, componentParentRect.Width(), componentParentRect.Height())
|
||||
if m.borderPanel != nil {
|
||||
m.borderPanel.SetBounds(tmpX-border/2, tmpY-border/2, borderRect.Width(), borderRect.Height())
|
||||
}
|
||||
m.parentToControl().SetBounds(tmpX, tmpY, componentParentRect.Width(), componentParentRect.Height())
|
||||
return
|
||||
}
|
||||
}
|
||||
if m.componentType == ctForm {
|
||||
if m.isBorder = x <= m.ow && x >= m.ow-borderRange && y <= borderRange; m.isBorder && m.componentType != ctForm { // 右上
|
||||
m.componentParentPanel.SetCursor(types.CrSizeSW)
|
||||
m.parentToControl().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.parentToControl().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.parentToControl().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.parentToControl().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.parentToControl().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.parentToControl().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.parentToControl().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.parentToControl().SetCursor(types.CrSizeN)
|
||||
m.borderHT = HTBOTTOM
|
||||
} else {
|
||||
m.isBorder = false
|
||||
m.componentParentPanel.SetCursor(types.CrDefault)
|
||||
m.parentToControl().SetCursor(types.CrDefault)
|
||||
}
|
||||
}
|
||||
if m.component != nil {
|
||||
switch m.component.(type) {
|
||||
case lcl.IControl:
|
||||
m.component.(lcl.IControl).SetCursor(m.componentParentPanel.Cursor())
|
||||
m.component.(lcl.IControl).SetCursor(m.parentToControl().Cursor())
|
||||
default:
|
||||
m.componentParentPanel.SetCursor(m.componentParentPanel.Cursor())
|
||||
m.parentToControl().SetCursor(m.parentToControl().Cursor())
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -163,13 +177,13 @@ func (m *IDEComponent) mouseDown(sender lcl.IObject, button types.TMouseButton,
|
||||
if !m.isBorder && m.componentType != ctForm {
|
||||
m.isComponentArea = true
|
||||
m.anchor.hide()
|
||||
m.componentParentPanel.SetCursor(types.CrSizeAll)
|
||||
m.parentToControl().SetCursor(types.CrSizeAll)
|
||||
if m.component != nil {
|
||||
switch m.component.(type) {
|
||||
case lcl.IControl:
|
||||
m.component.(lcl.IControl).SetCursor(m.componentParentPanel.Cursor())
|
||||
m.component.(lcl.IControl).SetCursor(m.parentToControl().Cursor())
|
||||
default:
|
||||
m.componentParentPanel.SetCursor(m.componentParentPanel.Cursor())
|
||||
m.parentToControl().SetCursor(m.parentToControl().Cursor())
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -188,15 +202,15 @@ func (m *IDEComponent) mouseUp(sender lcl.IObject, button types.TMouseButton, sh
|
||||
return
|
||||
}
|
||||
m.refreshAnchorsPoint()
|
||||
m.componentParentPanel.SetCursor(types.CrDefault)
|
||||
m.parentToControl().SetCursor(types.CrDefault)
|
||||
if m.component != nil {
|
||||
switch m.component.(type) {
|
||||
case lcl.IControl:
|
||||
m.component.(lcl.IControl).SetCursor(m.componentParentPanel.Cursor())
|
||||
m.component.(lcl.IControl).SetCursor(m.parentToControl().Cursor())
|
||||
default:
|
||||
m.componentParentPanel.SetCursor(m.componentParentPanel.Cursor())
|
||||
m.parentToControl().SetCursor(m.parentToControl().Cursor())
|
||||
}
|
||||
}
|
||||
}
|
||||
m.ox, m.oy, m.ow, m.oh = m.componentParentPanel.Left(), m.componentParentPanel.Top(), m.componentParentPanel.Width(), m.componentParentPanel.Height()
|
||||
m.ox, m.oy, m.ow, m.oh = m.parentToControl().Left(), m.parentToControl().Top(), m.parentToControl().Width(), m.parentToControl().Height()
|
||||
}
|
||||
|
@ -3,7 +3,6 @@ package ide
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/energye/golcl/lcl"
|
||||
"github.com/energye/golcl/lcl/types"
|
||||
)
|
||||
|
||||
type IDEEdit struct {
|
||||
@ -14,14 +13,13 @@ type IDEEdit struct {
|
||||
func (m *IDEForm) CreateEdit() *IDEEdit {
|
||||
com := &IDEEdit{}
|
||||
com.IDEComponent = m.newIDEComponentContainer(false, 50, 50, 150, 24)
|
||||
com.Component = lcl.NewEdit(com.IDEComponent.componentParentPanel)
|
||||
com.Component.SetParent(com.IDEComponent.componentParentPanel)
|
||||
com.Component.SetAlign(types.AlClient)
|
||||
com.Component = lcl.NewEdit(m.parentToPanel())
|
||||
com.Component.SetParent(m.parentToPanel())
|
||||
com.Component.SetOnMouseMove(com.IDEComponent.mouseMove)
|
||||
com.Component.SetOnMouseDown(com.IDEComponent.mouseDown)
|
||||
com.Component.SetOnMouseUp(com.IDEComponent.mouseUp)
|
||||
com.component = com.Component
|
||||
com.componentType = ctLabel
|
||||
com.componentType = ctEdit
|
||||
m.addComponent(com.IDEComponent)
|
||||
com.name = fmt.Sprintf("Edit%d", com.Id)
|
||||
com.createAfter()
|
||||
|
@ -14,8 +14,8 @@ type IDEImage struct {
|
||||
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 = lcl.NewImage(com.IDEComponent.parentToPanel())
|
||||
com.Component.SetParent(com.IDEComponent.parentToPanel())
|
||||
com.Component.SetAlign(types.AlClient)
|
||||
com.Component.SetOnMouseMove(com.IDEComponent.mouseMove)
|
||||
com.Component.SetOnMouseDown(com.IDEComponent.mouseDown)
|
||||
|
@ -3,7 +3,6 @@ package ide
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/energye/golcl/lcl"
|
||||
"github.com/energye/golcl/lcl/types"
|
||||
)
|
||||
|
||||
type IDELabel struct {
|
||||
@ -14,9 +13,8 @@ type IDELabel struct {
|
||||
func (m *IDEForm) CreateLabel() *IDELabel {
|
||||
com := &IDELabel{}
|
||||
com.IDEComponent = m.newIDEComponentContainer(false, 50, 50, 100, 24)
|
||||
com.Component = lcl.NewLabel(com.IDEComponent.componentParentPanel)
|
||||
com.Component.SetParent(com.IDEComponent.componentParentPanel)
|
||||
com.Component.SetAlign(types.AlClient)
|
||||
com.Component = lcl.NewLabel(m.parentToPanel())
|
||||
com.Component.SetParent(m.parentToPanel())
|
||||
com.Component.SetOnMouseMove(com.IDEComponent.mouseMove)
|
||||
com.Component.SetOnMouseDown(com.IDEComponent.mouseDown)
|
||||
com.Component.SetOnMouseUp(com.IDEComponent.mouseUp)
|
||||
|
@ -14,8 +14,8 @@ type IDEOpenDialog struct {
|
||||
func (m *IDEForm) CreateDialogOpen() *IDEOpenDialog {
|
||||
com := &IDEOpenDialog{}
|
||||
com.IDEComponent = m.newIDEComponentContainer(true, 50, 50, 28, 28)
|
||||
com.Component = lcl.NewImage(com.IDEComponent.componentParentPanel)
|
||||
com.Component.SetParent(com.IDEComponent.componentParentPanel)
|
||||
com.Component = lcl.NewImage(com.IDEComponent.parentToPanel())
|
||||
com.Component.SetParent(com.IDEComponent.parentToPanel())
|
||||
com.Component.SetAlign(types.AlClient)
|
||||
com.Component.SetOnMouseMove(com.IDEComponent.mouseMove)
|
||||
com.Component.SetOnMouseDown(com.IDEComponent.mouseDown)
|
||||
|
@ -13,9 +13,9 @@ type IDEComponent struct {
|
||||
Id int
|
||||
name string
|
||||
anchor *anchor
|
||||
borderPanel *lcl.TPanel
|
||||
isUseBorder bool
|
||||
componentParentPanel *lcl.TPanel
|
||||
borderPanel *lcl.TPanel
|
||||
componentParentPanel lcl.IComponent
|
||||
component lcl.IComponent
|
||||
componentType componentType
|
||||
isBorder, isDown, isComponentArea bool
|
||||
@ -84,6 +84,14 @@ func (m *anchor) remove() {
|
||||
m.bottomRight.Free()
|
||||
}
|
||||
|
||||
func (m *IDEComponent) parentToPanel() *lcl.TPanel {
|
||||
return m.componentParentPanel.(*lcl.TPanel)
|
||||
}
|
||||
|
||||
func (m *IDEComponent) parentToControl() lcl.IControl {
|
||||
return m.componentParentPanel.(lcl.IControl)
|
||||
}
|
||||
|
||||
func (m *IDEComponent) newAnchorPoint(owner lcl.IWinControl, ht int32) *lcl.TPanel {
|
||||
point := lcl.NewPanel(owner)
|
||||
point.SetParent(owner)
|
||||
@ -109,7 +117,7 @@ func (m *IDEComponent) newAnchorPoint(owner lcl.IWinControl, ht int32) *lcl.TPan
|
||||
if m.isDown && m.isResize {
|
||||
var (
|
||||
x, y = x - m.anchor.dx, y - m.anchor.dy
|
||||
rect = m.componentParentPanel.BoundsRect()
|
||||
rect = m.parentToControl().BoundsRect()
|
||||
)
|
||||
switch ht {
|
||||
case HTRIGHT:
|
||||
@ -120,34 +128,40 @@ func (m *IDEComponent) newAnchorPoint(owner lcl.IWinControl, ht int32) *lcl.TPan
|
||||
if m.borderPanel != nil {
|
||||
m.borderPanel.SetWidth(tmpWidth + border)
|
||||
}
|
||||
m.componentParentPanel.SetWidth(tmpWidth)
|
||||
m.parentToControl().SetWidth(tmpWidth)
|
||||
case HTLEFT:
|
||||
tmpX := rect.Left + x
|
||||
tmpWidth := rect.Width() + (rect.Left - tmpX)
|
||||
if tmpWidth <= minW {
|
||||
return
|
||||
}
|
||||
m.borderPanel.SetLeft(tmpX - border/2)
|
||||
m.componentParentPanel.SetLeft(tmpX)
|
||||
m.borderPanel.SetWidth(tmpWidth + border)
|
||||
m.componentParentPanel.SetWidth(tmpWidth)
|
||||
if m.borderPanel != nil {
|
||||
m.borderPanel.SetLeft(tmpX - border/2)
|
||||
m.borderPanel.SetWidth(tmpWidth + border)
|
||||
}
|
||||
m.parentToControl().SetLeft(tmpX)
|
||||
m.parentToControl().SetWidth(tmpWidth)
|
||||
case HTTOP:
|
||||
tmpY := rect.Top + y
|
||||
tmpHeight := rect.Height() + (rect.Top - tmpY)
|
||||
if tmpHeight <= minH {
|
||||
return
|
||||
}
|
||||
m.borderPanel.SetTop(tmpY - border/2)
|
||||
m.borderPanel.SetHeight(tmpHeight + border)
|
||||
m.componentParentPanel.SetTop(tmpY)
|
||||
m.componentParentPanel.SetHeight(tmpHeight)
|
||||
if m.borderPanel != nil {
|
||||
m.borderPanel.SetTop(tmpY - border/2)
|
||||
m.borderPanel.SetHeight(tmpHeight + border)
|
||||
}
|
||||
m.parentToControl().SetTop(tmpY)
|
||||
m.parentToControl().SetHeight(tmpHeight)
|
||||
case HTBOTTOM:
|
||||
tmpHeight := rect.Height() + y
|
||||
if tmpHeight <= minH {
|
||||
return
|
||||
}
|
||||
m.borderPanel.SetHeight(tmpHeight + border)
|
||||
m.componentParentPanel.SetHeight(tmpHeight)
|
||||
if m.borderPanel != nil {
|
||||
m.borderPanel.SetHeight(tmpHeight + border)
|
||||
}
|
||||
m.parentToControl().SetHeight(tmpHeight)
|
||||
case HTTOPRIGHT:
|
||||
tmpY := rect.Top + y
|
||||
tmpHeight := rect.Height() + (rect.Top - tmpY)
|
||||
@ -155,12 +169,14 @@ func (m *IDEComponent) newAnchorPoint(owner lcl.IWinControl, ht int32) *lcl.TPan
|
||||
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)
|
||||
if m.borderPanel != nil {
|
||||
m.borderPanel.SetTop(tmpY - border/2)
|
||||
m.borderPanel.SetHeight(tmpHeight + border)
|
||||
m.borderPanel.SetWidth(tmpWidth + border)
|
||||
}
|
||||
m.parentToControl().SetTop(tmpY)
|
||||
m.parentToControl().SetHeight(tmpHeight)
|
||||
m.parentToControl().SetWidth(tmpWidth)
|
||||
case HTTOPLEFT:
|
||||
tmpX := rect.Left + x
|
||||
tmpWidth := rect.Width() + (rect.Left - tmpX)
|
||||
@ -169,24 +185,28 @@ func (m *IDEComponent) newAnchorPoint(owner lcl.IWinControl, ht int32) *lcl.TPan
|
||||
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)
|
||||
if m.borderPanel != nil {
|
||||
m.borderPanel.SetLeft(tmpX - border/2)
|
||||
m.borderPanel.SetWidth(tmpWidth + border)
|
||||
m.borderPanel.SetTop(tmpY - border/2)
|
||||
m.borderPanel.SetHeight(tmpHeight + border)
|
||||
}
|
||||
m.parentToControl().SetLeft(tmpX)
|
||||
m.parentToControl().SetWidth(tmpWidth)
|
||||
m.parentToControl().SetTop(tmpY)
|
||||
m.parentToControl().SetHeight(tmpHeight)
|
||||
case HTBOTTOMRIGHT:
|
||||
tmpWidth := rect.Width() + x
|
||||
tmpHeight := rect.Height() + y
|
||||
if tmpWidth <= minW || tmpHeight <= minH {
|
||||
return
|
||||
}
|
||||
m.borderPanel.SetWidth(tmpWidth + border)
|
||||
m.componentParentPanel.SetWidth(tmpWidth)
|
||||
m.borderPanel.SetHeight(tmpHeight + border)
|
||||
m.componentParentPanel.SetHeight(tmpHeight)
|
||||
if m.borderPanel != nil {
|
||||
m.borderPanel.SetWidth(tmpWidth + border)
|
||||
m.borderPanel.SetHeight(tmpHeight + border)
|
||||
}
|
||||
m.parentToControl().SetWidth(tmpWidth)
|
||||
m.parentToControl().SetHeight(tmpHeight)
|
||||
case HTBOTTOMLEFT:
|
||||
tmpX := rect.Left + x
|
||||
tmpWidth := rect.Width() + (rect.Left - tmpX)
|
||||
@ -194,12 +214,14 @@ func (m *IDEComponent) newAnchorPoint(owner lcl.IWinControl, ht int32) *lcl.TPan
|
||||
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)
|
||||
if m.borderPanel != nil {
|
||||
m.borderPanel.SetLeft(tmpX - border/2)
|
||||
m.borderPanel.SetWidth(tmpWidth + border)
|
||||
m.borderPanel.SetHeight(tmpHeight + border)
|
||||
}
|
||||
m.parentToControl().SetLeft(tmpX)
|
||||
m.parentToControl().SetWidth(tmpWidth)
|
||||
m.parentToControl().SetHeight(tmpHeight)
|
||||
default:
|
||||
return
|
||||
}
|
||||
@ -217,7 +239,7 @@ func (m *IDEComponent) newAnchorPoint(owner lcl.IWinControl, ht int32) *lcl.TPan
|
||||
}
|
||||
|
||||
func (m *IDEComponent) createAnchor() {
|
||||
owner := m.componentParentPanel.Parent()
|
||||
owner := m.parentToControl().Parent()
|
||||
acr := &anchor{}
|
||||
acr.isShow = true
|
||||
acr.top = m.newAnchorPoint(owner, HTTOP)
|
||||
@ -237,7 +259,7 @@ func (m *IDEComponent) refreshAnchorsPoint() {
|
||||
return
|
||||
}
|
||||
if m.anchor.isShow {
|
||||
rect := m.componentParentPanel.BoundsRect()
|
||||
rect := m.parentToControl().BoundsRect()
|
||||
m.anchor.left.SetBounds(rect.Left-pointWC, rect.Top+rect.Height()/2-pointWC, pointW, pointW)
|
||||
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)
|
||||
@ -250,7 +272,7 @@ func (m *IDEComponent) refreshAnchorsPoint() {
|
||||
}
|
||||
|
||||
func (m *IDEComponent) setBorderColor(color types.TColor) {
|
||||
if m == nil {
|
||||
if m == nil || m.borderPanel == nil {
|
||||
return
|
||||
}
|
||||
m.borderPanel.SetColor(color)
|
||||
@ -261,7 +283,7 @@ func (m *IDEComponent) clearBorderColor() {
|
||||
return
|
||||
}
|
||||
m.form.active.anchor.hide()
|
||||
if m.componentType != ctForm {
|
||||
if m.componentType != ctForm && m.borderPanel != nil {
|
||||
if m.componentType == ctImage {
|
||||
m.borderPanel.SetColor(colors.ClGray)
|
||||
} else {
|
||||
@ -271,9 +293,17 @@ func (m *IDEComponent) clearBorderColor() {
|
||||
}
|
||||
|
||||
func (m *IDEComponent) createAfter() {
|
||||
if !m.isUseBorder {
|
||||
m.componentParentPanel = m.component
|
||||
}
|
||||
m.createAnchor()
|
||||
m.componentParentPanel.SetCaption(m.name)
|
||||
m.component.SetName(m.name)
|
||||
switch m.componentType {
|
||||
case ctEdit:
|
||||
m.parentToControl().SetName(m.name)
|
||||
default:
|
||||
m.component.SetName(m.name)
|
||||
m.parentToControl().SetCaption(m.name)
|
||||
}
|
||||
pm := lcl.NewPopupMenu(m.component)
|
||||
item := lcl.NewMenuItem(m.component)
|
||||
item.SetCaption("删除")
|
||||
@ -287,9 +317,9 @@ func (m *IDEComponent) createAfter() {
|
||||
m.component.(lcl.IControl).SetHint(m.name)
|
||||
m.component.(lcl.IControl).SetShowHint(true)
|
||||
default:
|
||||
m.componentParentPanel.SetPopupMenu(pm)
|
||||
m.componentParentPanel.SetHint(m.name)
|
||||
m.componentParentPanel.SetShowHint(true)
|
||||
m.parentToControl().SetPopupMenu(pm)
|
||||
m.parentToControl().SetHint(m.name)
|
||||
m.parentToControl().SetShowHint(true)
|
||||
}
|
||||
m.switchActive(m)
|
||||
}
|
||||
|
@ -43,37 +43,38 @@ func (m *IDEForm) componentFrees(control lcl.IComponent) {
|
||||
func (m *IDEForm) newIDEComponentContainer(useBorder bool, left, top, width, height int32) *IDEComponent {
|
||||
ideComponent := &IDEComponent{}
|
||||
ideComponent.isResize = true
|
||||
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.borderPanel = lcl.NewPanel(m.parentToPanel())
|
||||
ideComponent.borderPanel.SetParent(m.parentToPanel())
|
||||
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)
|
||||
ideComponent.componentParentPanel.SetColor(colors.ClSysDefault)
|
||||
if useBorder {
|
||||
ideComponent.componentParentPanel.SetBounds(left-border/2, top-border/2, width, height)
|
||||
} else {
|
||||
ideComponent.componentParentPanel.SetBounds(left, top, width, height)
|
||||
ideComponent.componentParentPanel = lcl.NewPanel(m.parentToPanel())
|
||||
ideComponent.parentToPanel().SetParent(m.parentToPanel())
|
||||
ideComponent.parentToPanel().SetDoubleBuffered(true)
|
||||
ideComponent.parentToPanel().SetBevelInner(types.BvNone)
|
||||
ideComponent.parentToPanel().SetBevelOuter(types.BvNone)
|
||||
ideComponent.parentToPanel().SetBorderStyle(types.BsNone)
|
||||
ideComponent.parentToPanel().SetColor(colors.ClSysDefault)
|
||||
if useBorder {
|
||||
ideComponent.parentToPanel().SetBounds(left-border/2, top-border/2, width, height)
|
||||
} else {
|
||||
ideComponent.parentToPanel().SetBounds(left, top, width, height)
|
||||
}
|
||||
//ideComponent.parentToPanel().SetOnMouseMove(ideComponent.mouseMove)
|
||||
//ideComponent.parentToPanel().SetOnMouseDown(ideComponent.mouseDown)
|
||||
//ideComponent.parentToPanel().SetOnMouseUp(ideComponent.mouseUp)
|
||||
ideComponent.ox, ideComponent.oy, ideComponent.ow, ideComponent.oh = ideComponent.parentToPanel().Left(), ideComponent.parentToPanel().Top(), ideComponent.parentToPanel().Width(), ideComponent.parentToPanel().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
|
||||
}
|
||||
|
@ -38,6 +38,7 @@ const (
|
||||
ctImage
|
||||
ctButton
|
||||
ctLabel
|
||||
ctEdit
|
||||
ctOpenDialog
|
||||
)
|
||||
|
||||
@ -161,7 +162,7 @@ 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)
|
||||
form.parentToPanel().SetBounds(fx-border/2, fy-border/2, fw, fh)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -208,6 +209,8 @@ func (m *IDE) initTopMainMenu() {
|
||||
form.CreateImage()
|
||||
form.CreateLabel()
|
||||
form.CreateButton()
|
||||
|
||||
println(form)
|
||||
})
|
||||
|
||||
m.topToolButton = lcl.NewToolButton(m)
|
||||
@ -279,16 +282,17 @@ func (m *IDE) CreateForm() *IDEForm {
|
||||
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()
|
||||
form.parentToPanel().SetParent(form.tabSheet)
|
||||
form.parentToPanel().SetDoubleBuffered(true)
|
||||
form.parentToPanel().SetBevelInner(types.BvNone)
|
||||
form.parentToPanel().SetBevelOuter(types.BvNone)
|
||||
form.parentToPanel().SetBorderStyle(types.BsNone)
|
||||
form.parentToPanel().SetBounds(left-border/2, top-border/2, width, height)
|
||||
form.parentToPanel().SetOnMouseMove(form.mouseMove)
|
||||
form.parentToPanel().SetOnMouseDown(form.mouseDown)
|
||||
form.parentToPanel().SetOnMouseUp(form.mouseUp)
|
||||
|
||||
form.ox, form.oy, form.ow, form.oh = form.parentToPanel().Left(), form.parentToPanel().Top(), form.parentToPanel().Width(), form.parentToPanel().Height()
|
||||
m.addForm(form)
|
||||
form.name = fmt.Sprintf("Form%d", m.formCount)
|
||||
form.componentType = ctForm
|
||||
|
Loading…
Reference in New Issue
Block a user