From bbec7ae3af3839c11bbdacbf847a5b5c71557b78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E7=BA=A2=E5=B2=A9?= Date: Sat, 11 Feb 2023 18:30:56 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=89=93=E5=8C=85=E5=9B=BE?= =?UTF-8?q?=E5=BD=A2=E5=8C=96=E9=85=8D=E7=BD=AE=20v1.0.0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cmd/internal/ide/ide-component-drag.go | 225 +++++++++++++ cmd/internal/ide/ide-component-edit.go | 2 +- cmd/internal/ide/ide-component-open-dialog.go | 2 +- cmd/internal/ide/ide-component.go | 301 +++++------------- cmd/internal/ide/ide-form.go | 6 +- cmd/internal/ide/ide.go | 5 +- 6 files changed, 315 insertions(+), 226 deletions(-) create mode 100644 cmd/internal/ide/ide-component-drag.go diff --git a/cmd/internal/ide/ide-component-drag.go b/cmd/internal/ide/ide-component-drag.go new file mode 100644 index 00000000..8691cdf6 --- /dev/null +++ b/cmd/internal/ide/ide-component-drag.go @@ -0,0 +1,225 @@ +package ide + +import ( + "fmt" + "github.com/energye/golcl/lcl" + "github.com/energye/golcl/lcl/types" + "github.com/energye/golcl/lcl/types/colors" + "time" +) + +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 component 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) + m.isDClick = false + //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.component != nil { + switch m.component.(type) { + case lcl.IControl: + m.component.(lcl.IControl).SetCursor(m.componentParentPanel.Cursor()) + default: + m.componentParentPanel.SetCursor(m.componentParentPanel.Cursor()) + } + } +} + +func (m *IDEComponent) mouseDown(sender lcl.IObject, button types.TMouseButton, shift types.TShiftState, x, y int32) { + if button == types.MbLeft { + if time.Now().UnixMilli()-m.clickTime.UnixMilli() < 500 { + m.isDClick = true + } else { + m.isDClick = false + } + m.clickTime = time.Now() + 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.anchor.hide() + m.componentParentPanel.SetCursor(types.CrSizeAll) + if m.component != nil { + switch m.component.(type) { + case lcl.IControl: + m.component.(lcl.IControl).SetCursor(m.componentParentPanel.Cursor()) + default: + m.componentParentPanel.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 + m.isBorder = false + if m.isComponentArea { + m.anchor.show() + m.isComponentArea = false + if m.isDClick { + fmt.Println("双击自定义组件", m.Id, m.name) + return + } + m.componentParentPanel.SetCursor(types.CrDefault) + if m.component != nil { + switch m.component.(type) { + case lcl.IControl: + m.component.(lcl.IControl).SetCursor(m.componentParentPanel.Cursor()) + default: + m.componentParentPanel.SetCursor(m.componentParentPanel.Cursor()) + } + } + } + m.ox, m.oy, m.ow, m.oh = m.componentParentPanel.Left(), m.componentParentPanel.Top(), m.componentParentPanel.Width(), m.componentParentPanel.Height() +} diff --git a/cmd/internal/ide/ide-component-edit.go b/cmd/internal/ide/ide-component-edit.go index be2696d1..3e264484 100644 --- a/cmd/internal/ide/ide-component-edit.go +++ b/cmd/internal/ide/ide-component-edit.go @@ -13,7 +13,7 @@ type IDEEdit struct { func (m *IDEForm) CreateEdit() *IDEEdit { com := &IDEEdit{} - com.IDEComponent = m.newIDEComponentContainer(true, 50, 50, 150, 24) + 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) diff --git a/cmd/internal/ide/ide-component-open-dialog.go b/cmd/internal/ide/ide-component-open-dialog.go index de81c1b8..d3d8e1a6 100644 --- a/cmd/internal/ide/ide-component-open-dialog.go +++ b/cmd/internal/ide/ide-component-open-dialog.go @@ -16,7 +16,7 @@ func (m *IDEForm) CreateDialogOpen() *IDEOpenDialog { com.Component = lcl.NewOpenDialog(com.IDEComponent.componentParentPanel) com.component = com.Component m.addComponent(com.IDEComponent) - com.componentType = ctLabel + com.componentType = ctOpenDialog com.name = fmt.Sprintf("DialogOpen%d", com.Id) com.componentParentPanel.SetCaption(com.name) //com.createAnchor(m.componentParentPanel) diff --git a/cmd/internal/ide/ide-component.go b/cmd/internal/ide/ide-component.go index 388ead93..2a59e636 100644 --- a/cmd/internal/ide/ide-component.go +++ b/cmd/internal/ide/ide-component.go @@ -1,7 +1,6 @@ package ide import ( - "fmt" "github.com/energye/energy/cef" "github.com/energye/golcl/lcl" "github.com/energye/golcl/lcl/types" @@ -36,6 +35,29 @@ type anchor struct { topRight *lcl.TPanel bottomLeft *lcl.TPanel bottomRight *lcl.TPanel + dx, dy int32 +} + +func (m *anchor) hide() { + m.top.Hide() + m.bottom.Hide() + m.left.Hide() + m.right.Hide() + m.topLeft.Hide() + m.topRight.Hide() + m.bottomLeft.Hide() + m.bottomRight.Hide() +} + +func (m *anchor) show() { + m.top.Show() + m.bottom.Show() + m.left.Show() + m.right.Show() + m.topLeft.Show() + m.topRight.Show() + m.bottomLeft.Show() + m.bottomRight.Show() } func (m *IDEComponent) newAnchorPoint(owner lcl.IWinControl, ht int32) *lcl.TPanel { @@ -59,18 +81,67 @@ func (m *IDEComponent) newAnchorPoint(owner lcl.IWinControl, ht int32) *lcl.TPan default: point.SetCursor(types.CrDefault) } - m.mouseMove(sender, shift, x, y) + //m.mouseMove(sender, shift, x, y) + if m.isDown { + var ( + x, y = x - m.anchor.dx, y - m.anchor.dy + rect = m.componentParentPanel.BoundsRect() + ) + switch ht { + case HTRIGHT: + tmpWidth := rect.Width() + x + if tmpWidth <= minW { + return + } + if m.borderPanel != nil { + m.borderPanel.SetWidth(tmpWidth + border) + } + m.componentParentPanel.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) + 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) + case HTBOTTOM: + tmpHeight := rect.Height() + y + if tmpHeight <= minH { + return + } + m.borderPanel.SetHeight(tmpHeight + border) + m.componentParentPanel.SetHeight(tmpHeight) + default: + return + } + m.refreshAnchorsPoint() + } }) point.SetOnMouseDown(func(sender lcl.IObject, button types.TMouseButton, shift types.TShiftState, x, y int32) { - m.mouseDown(sender, button, shift, x, y) + m.isDown = true + m.anchor.dx, m.anchor.dy = x, y }) point.SetOnMouseUp(func(sender lcl.IObject, button types.TMouseButton, shift types.TShiftState, x, y int32) { - m.mouseUp(sender, button, shift, x, y) + m.isDown = false }) return point } -func (m *IDEComponent) createAnchor(owner lcl.IWinControl) { +func (m *IDEComponent) createAnchor() { + owner := m.componentParentPanel.Parent() acr := &anchor{} acr.top = m.newAnchorPoint(owner, HTTOP) acr.bottom = m.newAnchorPoint(owner, HTBOTTOM) @@ -89,223 +160,14 @@ func (m *IDEComponent) refreshAnchorsPoint() { return } rect := m.componentParentPanel.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) - 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 component 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) - m.isDClick = false - //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.component != nil { - switch m.component.(type) { - case lcl.IControl: - m.component.(lcl.IControl).SetCursor(m.componentParentPanel.Cursor()) - default: - m.componentParentPanel.SetCursor(m.componentParentPanel.Cursor()) - } - } -} - -func (m *IDEComponent) mouseDown(sender lcl.IObject, button types.TMouseButton, shift types.TShiftState, x, y int32) { - if button == types.MbLeft { - if time.Now().UnixMilli()-m.clickTime.UnixMilli() < 500 { - m.isDClick = true - } else { - m.isDClick = false - } - m.clickTime = time.Now() - 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.component != nil { - switch m.component.(type) { - case lcl.IControl: - m.component.(lcl.IControl).SetCursor(m.componentParentPanel.Cursor()) - default: - m.componentParentPanel.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 { - if m.isDClick { - fmt.Println("双击自定义组件", m.Id, m.name) - return - } - m.isComponentArea = false - m.componentParentPanel.SetCursor(types.CrDefault) - if m.component != nil { - switch m.component.(type) { - case lcl.IControl: - m.component.(lcl.IControl).SetCursor(m.componentParentPanel.Cursor()) - default: - m.componentParentPanel.SetCursor(m.componentParentPanel.Cursor()) - } - } - } - m.ox, m.oy, m.ow, m.oh = m.componentParentPanel.Left(), m.componentParentPanel.Top(), m.componentParentPanel.Width(), m.componentParentPanel.Height() + m.anchor.topLeft.SetBounds(rect.Left-pointWC, rect.Top-pointWC, pointW, pointW) + m.anchor.topRight.SetBounds(rect.Right-pointWC, rect.Top-pointWC, pointW, pointW) + m.anchor.bottomLeft.SetBounds(rect.Left-pointWC, rect.Bottom-pointWC, pointW, pointW) + m.anchor.bottomRight.SetBounds(rect.Right-pointWC, rect.Bottom-pointWC, pointW, pointW) } func (m *IDEComponent) setBorderColor(color types.TColor) { @@ -329,6 +191,7 @@ func (m *IDEComponent) clearBorderColor() { } func (m *IDEComponent) createAfter() { + m.createAnchor() m.componentParentPanel.SetCaption(m.name) m.component.SetName(m.name) pm := lcl.NewPopupMenu(m.component) diff --git a/cmd/internal/ide/ide-form.go b/cmd/internal/ide/ide-form.go index 8d581eb2..49da60a8 100644 --- a/cmd/internal/ide/ide-form.go +++ b/cmd/internal/ide/ide-form.go @@ -65,9 +65,9 @@ func (m *IDEForm) newIDEComponentContainer(useBorder bool, left, top, width, hei } else { ideComponent.componentParentPanel.SetBounds(left, top, width, height) } - ideComponent.componentParentPanel.SetOnMouseMove(ideComponent.mouseMove) - ideComponent.componentParentPanel.SetOnMouseDown(ideComponent.mouseDown) - ideComponent.componentParentPanel.SetOnMouseUp(ideComponent.mouseUp) + //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 diff --git a/cmd/internal/ide/ide.go b/cmd/internal/ide/ide.go index a66b58df..b7aa9cf2 100644 --- a/cmd/internal/ide/ide.go +++ b/cmd/internal/ide/ide.go @@ -38,6 +38,7 @@ const ( ctImage ctButton ctLabel + ctOpenDialog ) var ( @@ -200,8 +201,8 @@ func (m *IDE) initTopMainMenu() { action.SetHint("新建Form窗口|新建一个Form窗口") action.SetOnExecute(func(sender lcl.IObject) { form := m.CreateForm() - form.CreateDialogOpen() - form.CreateEdit() + //form.CreateDialogOpen() + //form.CreateEdit() form.CreateImage() })