From b73a8aaa3ee41fc0ce359deef41097428f01ad15 Mon Sep 17 00:00:00 2001 From: Nuno Cruces Date: Wed, 23 Mar 2022 13:52:52 +0000 Subject: [PATCH] Renames. --- entry_windows.go | 30 +++++++++++++++--------------- list_windows.go | 20 ++++++++++---------- progress_windows.go | 34 +++++++++++++++++----------------- util_windows.go | 10 +++++----- 4 files changed, 47 insertions(+), 47 deletions(-) diff --git a/entry_windows.go b/entry_windows.go index 4e0916d..c6d5429 100644 --- a/entry_windows.go +++ b/entry_windows.go @@ -17,29 +17,29 @@ func entry(text string, opts options) (out string, err error) { defer setup()() font := getFont() - defer font.Delete() + defer font.delete() defWindowProc := defWindowProc.Addr() var wnd, textCtl, editCtl uintptr var okBtn, cancelBtn, extraBtn uintptr layout := func(dpi dpi) { - hfont := font.ForDPI(dpi) - sendMessage.Call(textCtl, 0x0030 /* WM_SETFONT */, hfont, 1) - sendMessage.Call(editCtl, 0x0030 /* WM_SETFONT */, hfont, 1) - sendMessage.Call(okBtn, 0x0030 /* WM_SETFONT */, hfont, 1) - sendMessage.Call(cancelBtn, 0x0030 /* WM_SETFONT */, hfont, 1) - sendMessage.Call(extraBtn, 0x0030 /* WM_SETFONT */, hfont, 1) - setWindowPos.Call(wnd, 0, 0, 0, dpi.Scale(281), dpi.Scale(141), 0x6) // SWP_NOZORDER|SWP_NOMOVE - setWindowPos.Call(textCtl, 0, dpi.Scale(12), dpi.Scale(10), dpi.Scale(241), dpi.Scale(16), 0x4) // SWP_NOZORDER - setWindowPos.Call(editCtl, 0, dpi.Scale(12), dpi.Scale(30), dpi.Scale(241), dpi.Scale(24), 0x4) // SWP_NOZORDER + font := font.forDPI(dpi) + sendMessage.Call(textCtl, 0x0030 /* WM_SETFONT */, font, 1) + sendMessage.Call(editCtl, 0x0030 /* WM_SETFONT */, font, 1) + sendMessage.Call(okBtn, 0x0030 /* WM_SETFONT */, font, 1) + sendMessage.Call(cancelBtn, 0x0030 /* WM_SETFONT */, font, 1) + sendMessage.Call(extraBtn, 0x0030 /* WM_SETFONT */, font, 1) + setWindowPos.Call(wnd, 0, 0, 0, dpi.scale(281), dpi.scale(141), 0x6) // SWP_NOZORDER|SWP_NOMOVE + setWindowPos.Call(textCtl, 0, dpi.scale(12), dpi.scale(10), dpi.scale(241), dpi.scale(16), 0x4) // SWP_NOZORDER + setWindowPos.Call(editCtl, 0, dpi.scale(12), dpi.scale(30), dpi.scale(241), dpi.scale(24), 0x4) // SWP_NOZORDER if extraBtn == 0 { - setWindowPos.Call(okBtn, 0, dpi.Scale(95), dpi.Scale(66), dpi.Scale(75), dpi.Scale(24), 0x4) // SWP_NOZORDER - setWindowPos.Call(cancelBtn, 0, dpi.Scale(178), dpi.Scale(66), dpi.Scale(75), dpi.Scale(24), 0x4) // SWP_NOZORDER + setWindowPos.Call(okBtn, 0, dpi.scale(95), dpi.scale(66), dpi.scale(75), dpi.scale(24), 0x4) // SWP_NOZORDER + setWindowPos.Call(cancelBtn, 0, dpi.scale(178), dpi.scale(66), dpi.scale(75), dpi.scale(24), 0x4) // SWP_NOZORDER } else { - setWindowPos.Call(okBtn, 0, dpi.Scale(12), dpi.Scale(66), dpi.Scale(75), dpi.Scale(24), 0x4) // SWP_NOZORDER - setWindowPos.Call(extraBtn, 0, dpi.Scale(95), dpi.Scale(66), dpi.Scale(75), dpi.Scale(24), 0x4) // SWP_NOZORDER - setWindowPos.Call(cancelBtn, 0, dpi.Scale(178), dpi.Scale(66), dpi.Scale(75), dpi.Scale(24), 0x4) // SWP_NOZORDER + setWindowPos.Call(okBtn, 0, dpi.scale(12), dpi.scale(66), dpi.scale(75), dpi.scale(24), 0x4) // SWP_NOZORDER + setWindowPos.Call(extraBtn, 0, dpi.scale(95), dpi.scale(66), dpi.scale(75), dpi.scale(24), 0x4) // SWP_NOZORDER + setWindowPos.Call(cancelBtn, 0, dpi.scale(178), dpi.scale(66), dpi.scale(75), dpi.scale(24), 0x4) // SWP_NOZORDER } } diff --git a/list_windows.go b/list_windows.go index f8d4576..36afb19 100644 --- a/list_windows.go +++ b/list_windows.go @@ -30,29 +30,29 @@ func listDlg(text string, items []string, multiple bool, opts options) (out []st defer setup()() font := getFont() - defer font.Delete() + defer font.delete() defWindowProc := defWindowProc.Addr() var wnd, textCtl, listCtl uintptr var okBtn, cancelBtn, extraBtn uintptr layout := func(dpi dpi) { - hfont := font.ForDPI(dpi) + hfont := font.forDPI(dpi) sendMessage.Call(textCtl, 0x0030 /* WM_SETFONT */, hfont, 1) sendMessage.Call(listCtl, 0x0030 /* WM_SETFONT */, hfont, 1) sendMessage.Call(okBtn, 0x0030 /* WM_SETFONT */, hfont, 1) sendMessage.Call(cancelBtn, 0x0030 /* WM_SETFONT */, hfont, 1) sendMessage.Call(extraBtn, 0x0030 /* WM_SETFONT */, hfont, 1) - setWindowPos.Call(wnd, 0, 0, 0, dpi.Scale(281), dpi.Scale(281), 0x6) // SWP_NOZORDER|SWP_NOMOVE - setWindowPos.Call(textCtl, 0, dpi.Scale(12), dpi.Scale(10), dpi.Scale(241), dpi.Scale(16), 0x4) // SWP_NOZORDER - setWindowPos.Call(listCtl, 0, dpi.Scale(12), dpi.Scale(30), dpi.Scale(241), dpi.Scale(164), 0x4) // SWP_NOZORDER + setWindowPos.Call(wnd, 0, 0, 0, dpi.scale(281), dpi.scale(281), 0x6) // SWP_NOZORDER|SWP_NOMOVE + setWindowPos.Call(textCtl, 0, dpi.scale(12), dpi.scale(10), dpi.scale(241), dpi.scale(16), 0x4) // SWP_NOZORDER + setWindowPos.Call(listCtl, 0, dpi.scale(12), dpi.scale(30), dpi.scale(241), dpi.scale(164), 0x4) // SWP_NOZORDER if extraBtn == 0 { - setWindowPos.Call(okBtn, 0, dpi.Scale(95), dpi.Scale(206), dpi.Scale(75), dpi.Scale(24), 0x4) // SWP_NOZORDER - setWindowPos.Call(cancelBtn, 0, dpi.Scale(178), dpi.Scale(206), dpi.Scale(75), dpi.Scale(24), 0x4) // SWP_NOZORDER + setWindowPos.Call(okBtn, 0, dpi.scale(95), dpi.scale(206), dpi.scale(75), dpi.scale(24), 0x4) // SWP_NOZORDER + setWindowPos.Call(cancelBtn, 0, dpi.scale(178), dpi.scale(206), dpi.scale(75), dpi.scale(24), 0x4) // SWP_NOZORDER } else { - setWindowPos.Call(okBtn, 0, dpi.Scale(12), dpi.Scale(206), dpi.Scale(75), dpi.Scale(24), 0x4) // SWP_NOZORDER - setWindowPos.Call(extraBtn, 0, dpi.Scale(95), dpi.Scale(206), dpi.Scale(75), dpi.Scale(24), 0x4) // SWP_NOZORDER - setWindowPos.Call(cancelBtn, 0, dpi.Scale(178), dpi.Scale(206), dpi.Scale(75), dpi.Scale(24), 0x4) // SWP_NOZORDER + setWindowPos.Call(okBtn, 0, dpi.scale(12), dpi.scale(206), dpi.scale(75), dpi.scale(24), 0x4) // SWP_NOZORDER + setWindowPos.Call(extraBtn, 0, dpi.scale(95), dpi.scale(206), dpi.scale(75), dpi.scale(24), 0x4) // SWP_NOZORDER + setWindowPos.Call(cancelBtn, 0, dpi.scale(178), dpi.scale(206), dpi.scale(75), dpi.scale(24), 0x4) // SWP_NOZORDER } } diff --git a/progress_windows.go b/progress_windows.go index 154027b..7350eab 100644 --- a/progress_windows.go +++ b/progress_windows.go @@ -48,33 +48,33 @@ func progressDlg(opts options, dlg *progressDialog) (err error) { defer dlg.init.Done() defer setup()() font := getFont() - defer font.Delete() + defer font.delete() defWindowProc := defWindowProc.Addr() layout := func(dpi dpi) { - hfont := font.ForDPI(dpi) - sendMessage.Call(dlg.textCtl, 0x0030 /* WM_SETFONT */, hfont, 1) - sendMessage.Call(dlg.okBtn, 0x0030 /* WM_SETFONT */, hfont, 1) - sendMessage.Call(dlg.cancelBtn, 0x0030 /* WM_SETFONT */, hfont, 1) - sendMessage.Call(dlg.extraBtn, 0x0030 /* WM_SETFONT */, hfont, 1) - setWindowPos.Call(dlg.wnd, 0, 0, 0, dpi.Scale(281), dpi.Scale(133), 0x6) // SWP_NOZORDER|SWP_NOMOVE - setWindowPos.Call(dlg.textCtl, 0, dpi.Scale(12), dpi.Scale(10), dpi.Scale(241), dpi.Scale(16), 0x4) // SWP_NOZORDER - setWindowPos.Call(dlg.progCtl, 0, dpi.Scale(12), dpi.Scale(30), dpi.Scale(241), dpi.Scale(16), 0x4) // SWP_NOZORDER + font := font.forDPI(dpi) + sendMessage.Call(dlg.textCtl, 0x0030 /* WM_SETFONT */, font, 1) + sendMessage.Call(dlg.okBtn, 0x0030 /* WM_SETFONT */, font, 1) + sendMessage.Call(dlg.cancelBtn, 0x0030 /* WM_SETFONT */, font, 1) + sendMessage.Call(dlg.extraBtn, 0x0030 /* WM_SETFONT */, font, 1) + setWindowPos.Call(dlg.wnd, 0, 0, 0, dpi.scale(281), dpi.scale(133), 0x6) // SWP_NOZORDER|SWP_NOMOVE + setWindowPos.Call(dlg.textCtl, 0, dpi.scale(12), dpi.scale(10), dpi.scale(241), dpi.scale(16), 0x4) // SWP_NOZORDER + setWindowPos.Call(dlg.progCtl, 0, dpi.scale(12), dpi.scale(30), dpi.scale(241), dpi.scale(16), 0x4) // SWP_NOZORDER if dlg.extraBtn == 0 { if dlg.cancelBtn == 0 { - setWindowPos.Call(dlg.okBtn, 0, dpi.Scale(178), dpi.Scale(58), dpi.Scale(75), dpi.Scale(24), 0x4) // SWP_NOZORDER + setWindowPos.Call(dlg.okBtn, 0, dpi.scale(178), dpi.scale(58), dpi.scale(75), dpi.scale(24), 0x4) // SWP_NOZORDER } else { - setWindowPos.Call(dlg.okBtn, 0, dpi.Scale(95), dpi.Scale(58), dpi.Scale(75), dpi.Scale(24), 0x4) // SWP_NOZORDER - setWindowPos.Call(dlg.cancelBtn, 0, dpi.Scale(178), dpi.Scale(58), dpi.Scale(75), dpi.Scale(24), 0x4) // SWP_NOZORDER + setWindowPos.Call(dlg.okBtn, 0, dpi.scale(95), dpi.scale(58), dpi.scale(75), dpi.scale(24), 0x4) // SWP_NOZORDER + setWindowPos.Call(dlg.cancelBtn, 0, dpi.scale(178), dpi.scale(58), dpi.scale(75), dpi.scale(24), 0x4) // SWP_NOZORDER } } else { if dlg.cancelBtn == 0 { - setWindowPos.Call(dlg.okBtn, 0, dpi.Scale(95), dpi.Scale(58), dpi.Scale(75), dpi.Scale(24), 0x4) // SWP_NOZORDER - setWindowPos.Call(dlg.extraBtn, 0, dpi.Scale(178), dpi.Scale(58), dpi.Scale(75), dpi.Scale(24), 0x4) // SWP_NOZORDER + setWindowPos.Call(dlg.okBtn, 0, dpi.scale(95), dpi.scale(58), dpi.scale(75), dpi.scale(24), 0x4) // SWP_NOZORDER + setWindowPos.Call(dlg.extraBtn, 0, dpi.scale(178), dpi.scale(58), dpi.scale(75), dpi.scale(24), 0x4) // SWP_NOZORDER } else { - setWindowPos.Call(dlg.okBtn, 0, dpi.Scale(12), dpi.Scale(58), dpi.Scale(75), dpi.Scale(24), 0x4) // SWP_NOZORDER - setWindowPos.Call(dlg.extraBtn, 0, dpi.Scale(95), dpi.Scale(58), dpi.Scale(75), dpi.Scale(24), 0x4) // SWP_NOZORDER - setWindowPos.Call(dlg.cancelBtn, 0, dpi.Scale(178), dpi.Scale(58), dpi.Scale(75), dpi.Scale(24), 0x4) // SWP_NOZORDER + setWindowPos.Call(dlg.okBtn, 0, dpi.scale(12), dpi.scale(58), dpi.scale(75), dpi.scale(24), 0x4) // SWP_NOZORDER + setWindowPos.Call(dlg.extraBtn, 0, dpi.scale(95), dpi.scale(58), dpi.scale(75), dpi.scale(24), 0x4) // SWP_NOZORDER + setWindowPos.Call(dlg.cancelBtn, 0, dpi.scale(178), dpi.scale(58), dpi.scale(75), dpi.scale(24), 0x4) // SWP_NOZORDER } } } diff --git a/util_windows.go b/util_windows.go index 016c9a2..b6c81df 100644 --- a/util_windows.go +++ b/util_windows.go @@ -287,7 +287,7 @@ func getDPI(wnd uintptr) dpi { return dpi(res) } -func (d dpi) Scale(dim uintptr) uintptr { +func (d dpi) scale(dim uintptr) uintptr { if d == 0 { return dim } @@ -307,16 +307,16 @@ func getFont() font { return font{logical: metrics.MessageFont} } -func (f *font) ForDPI(dpi dpi) uintptr { - if h := -int32(dpi.Scale(12)); f.handle == 0 || f.logical.Height != h { - f.Delete() +func (f *font) forDPI(dpi dpi) uintptr { + if h := -int32(dpi.scale(12)); f.handle == 0 || f.logical.Height != h { + f.delete() f.logical.Height = h f.handle, _, _ = createFontIndirect.Call(uintptr(unsafe.Pointer(&f.logical))) } return f.handle } -func (f *font) Delete() { +func (f *font) delete() { if f.handle != 0 { deleteObject.Call(f.handle) f.handle = 0