omq/ui_config_editior.go

81 lines
2.1 KiB
Go
Raw Normal View History

package main
import (
"github.com/ying32/govcl/vcl"
"github.com/ying32/govcl/vcl/types"
)
type TConfigEditorForm struct {
*vcl.TForm
loginLabel *vcl.TLabel
passwordLabel *vcl.TLabel
loginEdit *vcl.TEdit
passwordEdit *vcl.TEdit
buttonPanel *vcl.TPanel
confirmButton *vcl.TButton
}
func (f *TConfigEditorForm) OnFormCreate(sender vcl.IObject) {
f.SetWidth(640)
f.SetHeight(160)
f.Constraints().SetMinHeight(160) // to prevent wrong ordering of widgets for small windows sizes
f.SetPosition(types.PoOwnerFormCenter)
f.SetCaption("Настройки серверов")
f.SetDoubleBuffered(true)
f.SetBorderWidth(8)
f.loginLabel = vcl.NewLabel(f)
f.loginLabel.SetParent(f)
f.loginLabel.SetCaption("Логин:")
f.loginLabel.SetAlign(types.AlTop)
f.loginLabel.SetTop(0)
f.loginEdit = vcl.NewEdit(f)
f.loginEdit.SetParent(f)
f.loginEdit.SetAlign(types.AlTop)
f.loginEdit.SetTop(100)
f.passwordLabel = vcl.NewLabel(f)
f.passwordLabel.SetParent(f)
f.passwordLabel.SetCaption("Пароль:")
f.passwordLabel.SetAlign(types.AlTop)
f.passwordLabel.SetTop(200)
f.passwordLabel.BorderSpacing().SetTop(8)
f.passwordEdit = vcl.NewEdit(f)
f.passwordEdit.SetParent(f)
f.passwordEdit.SetAlign(types.AlTop)
f.passwordEdit.SetPasswordChar(uint16('*'))
f.passwordEdit.SetTop(300)
f.buttonPanel = vcl.NewPanel(f)
f.buttonPanel.SetParent(f)
f.buttonPanel.SetAlign(types.AlBottom)
f.buttonPanel.SetHeight(32)
f.buttonPanel.SetBevelOuter(types.BvNone)
f.confirmButton = vcl.NewButton(f)
f.confirmButton.SetParent(f.buttonPanel)
f.confirmButton.SetAlign(types.AlRight)
f.confirmButton.SetWidth(96)
f.confirmButton.SetCaption("Сохранить")
f.confirmButton.SetOnClick(f.OnConfirmButtonClick)
}
func (f *TConfigEditorForm) OnConfirmButtonClick(sender vcl.IObject) {
if f.loginEdit.Text() == "" {
vcl.MessageDlg("Логин не может быть пустым", types.MtError)
return
}
if f.passwordEdit.Text() == "" {
vcl.MessageDlg("Пароль не может быть пустым", types.MtError)
return
}
f.SetModalResult(types.IdOK)
}