Skip to content

Commit

Permalink
Dialog: Add support for fixed size
Browse files Browse the repository at this point in the history
  • Loading branch information
lxn committed Aug 19, 2015
1 parent 9e6db05 commit 355b16e
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
15 changes: 13 additions & 2 deletions declarative/dialog.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,19 @@ type Dialog struct {
Children []Widget
DefaultButton **walk.PushButton
CancelButton **walk.PushButton
FixedSize bool
}

func (d Dialog) Create(owner walk.Form) error {
w, err := walk.NewDialog(owner)
var w *walk.Dialog
var err error

if d.FixedSize {
w, err = walk.NewDialogWithFixedSize(owner)
} else {
w, err = walk.NewDialog(owner)
}

if err != nil {
return err
}
Expand Down Expand Up @@ -86,7 +95,9 @@ func (d Dialog) Create(owner walk.Form) error {
}

if db := *d.DataBinder.AssignTo; db != nil {
(*d.DefaultButton).SetEnabled(db.CanSubmit())
if db.DataSource() != nil {
(*d.DefaultButton).SetEnabled(db.CanSubmit())
}

db.CanSubmitChanged().Attach(func() {
(*d.DefaultButton).SetEnabled(db.CanSubmit())
Expand Down
10 changes: 9 additions & 1 deletion dialog.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,14 @@ type Dialog struct {
}

func NewDialog(owner Form) (*Dialog, error) {
return newDialogWithStyle(owner, win.WS_THICKFRAME)
}

func NewDialogWithFixedSize(owner Form) (*Dialog, error) {
return newDialogWithStyle(owner, 0)
}

func newDialogWithStyle(owner Form, style uint32) (*Dialog, error) {
dlg := &Dialog{
FormBase: FormBase{
owner: owner,
Expand All @@ -59,7 +67,7 @@ func NewDialog(owner Form) (*Dialog, error) {
dlg,
owner,
dialogWindowClass,
win.WS_CAPTION|win.WS_SYSMENU|win.WS_THICKFRAME,
win.WS_CAPTION|win.WS_SYSMENU|style,
win.WS_EX_DLGMODALFRAME); err != nil {
return nil, err
}
Expand Down

0 comments on commit 355b16e

Please sign in to comment.