diff --git a/win/events_windows.go b/win/events_windows.go
index 3e36b62..5aea7ab 100644
--- a/win/events_windows.go
+++ b/win/events_windows.go
@@ -31,10 +31,10 @@ type EventData struct {
trackMouse bool
}
-func (this *EventData) InitEventData() {
- this.noX = 1<<31 - 1
- this.noX++
- this.lastX = this.noX
+func (e *EventData) InitEventData() {
+ e.noX = 1<<31 - 1
+ e.noX++
+ e.lastX = e.noX
}
func buttonForDetail(button uint32) wde.Button {
diff --git a/win/win_windows.go b/win/win_windows.go
index bba76ee..d3826a0 100644
--- a/win/win_windows.go
+++ b/win/win_windows.go
@@ -116,17 +116,17 @@ func NewWindow(width, height int) (w *Window, err error) {
return
}
-func (this *Window) SetTitle(title string) {
- w32.SetWindowText(this.hwnd, title)
+func (w *Window) SetTitle(title string) {
+ w32.SetWindowText(w.hwnd, title)
}
-func (this *Window) SetSize(width, height int) {
- x, y := this.Pos()
- w32.MoveWindow(this.hwnd, x, y, width, height, true)
+func (w *Window) SetSize(width, height int) {
+ x, y := w.Pos()
+ w32.MoveWindow(w.hwnd, x, y, width, height, true)
}
-func (this *Window) Size() (width, height int) {
- bounds := this.buffer.Bounds()
+func (w *Window) Size() (width, height int) {
+ bounds := w.buffer.Bounds()
return bounds.Dx(), bounds.Dy()
}
@@ -140,30 +140,30 @@ func (w *Window) LockSize(lock bool) {
w32.SetWindowLongPtr(w.hwnd, w32.GWL_STYLE, uintptr(prevStyle))
}
-func (this *Window) Show() {
- w32.ShowWindow(this.hwnd, w32.SW_SHOWDEFAULT)
+func (w *Window) Show() {
+ w32.ShowWindow(w.hwnd, w32.SW_SHOWDEFAULT)
}
-func (this *Window) Screen() wde.Image {
- return this.buffer
+func (w *Window) Screen() wde.Image {
+ return w.buffer
}
-func (this *Window) FlushImage(bounds ...image.Rectangle) {
- this.bufferback = NewDIB(this.buffer.Bounds())
- *this.bufferback = *this.buffer
+func (w *Window) FlushImage(bounds ...image.Rectangle) {
+ w.bufferback = NewDIB(w.buffer.Bounds())
+ *w.bufferback = *w.buffer
- hdc := w32.GetDC(this.hwnd)
- this.blitImage(hdc, this.buffer)
+ hdc := w32.GetDC(w.hwnd)
+ w.blitImage(hdc, w.buffer)
w32.DeleteDC(hdc)
}
-func (this *Window) EventChan() <-chan interface{} {
- return this.events
+func (w *Window) EventChan() <-chan interface{} {
+ return w.events
}
-func (this *Window) Close() error {
- UnRegMsgHandler(this.hwnd)
- err := w32.DestroyWindow(this.hwnd)
+func (w *Window) Close() error {
+ UnRegMsgHandler(w.hwnd)
+ err := w32.DestroyWindow(w.hwnd)
if err == false {
return errors.New("Error closing window")
}
@@ -174,7 +174,7 @@ func (this *Window) Close() error {
// Non - interface methods
/////////////////////////////
-func (this *Window) blitImage(hdc w32.HDC, buffer *DIB) {
+func (w *Window) blitImage(hdc w32.HDC, buffer *DIB) {
bounds := buffer.Bounds()
width := bounds.Dx()
height := bounds.Dy()
@@ -197,43 +197,43 @@ func (this *Window) blitImage(hdc w32.HDC, buffer *DIB) {
)
}
-func (this *Window) HandleWndMessages() {
+func (w *Window) HandleWndMessages() {
var m w32.MSG
- for w32.GetMessage(&m, this.hwnd, 0, 0) != 0 {
+ for w32.GetMessage(&m, w.hwnd, 0, 0) != 0 {
w32.TranslateMessage(&m)
w32.DispatchMessage(&m)
}
}
-func (this *Window) Pos() (x, y int) {
- rect := w32.GetWindowRect(this.hwnd)
+func (w *Window) Pos() (x, y int) {
+ rect := w32.GetWindowRect(w.hwnd)
return int(rect.Left), int(rect.Top)
}
-func (this *Window) SetPos(x, y int) {
- w, h := this.Size()
+func (w *Window) SetPos(x, y int) {
+ w, h := w.Size()
if w == 0 {
w = 100
}
if h == 0 {
h = 25
}
- w32.MoveWindow(this.hwnd, x, y, w, h, true)
+ w32.MoveWindow(w.hwnd, x, y, w, h, true)
}
-func (this *Window) Center() {
+func (w *Window) Center() {
sWidth := w32.GetSystemMetrics(w32.SM_CXFULLSCREEN)
sHeight := w32.GetSystemMetrics(w32.SM_CYFULLSCREEN)
if sWidth != 0 && sHeight != 0 {
- w, h := this.Size()
- this.SetPos((sWidth/2)-(w/2), (sHeight/2)-(h/2))
+ w, h := w.Size()
+ w.SetPos((sWidth/2)-(w/2), (sHeight/2)-(h/2))
}
}
-func (this *Window) Repaint() {
- hdc := w32.GetDC(this.hwnd)
- this.blitImage(hdc, this.bufferback)
+func (w *Window) Repaint() {
+ hdc := w32.GetDC(w.hwnd)
+ w.blitImage(hdc, w.bufferback)
w32.DeleteDC(hdc)
}
When looking in http://godoc.org/github.com/skelterjohn/go.wde/win I noticed that type Window has methods with pointers that are named "this", and only with method LockSize it is "w". It just doesn't look good.
The suggestion is to use an one letter abbr of the type name e.g. "func (w *Window) ..."
This is the diff: