Example #1
0
func mainform_OnPaint(arg *gform.EventArg) {
	var mf *Mainform
	var ok bool
	var data *gform.PaintEventData

	if mf, ok = arg.Sender().(*Mainform); ok {
		if data, ok = arg.Data().(*gform.PaintEventData); ok {
			gResMainformBkColor := gform.RGB(255, 255, 255)
			bkBrush := gform.NewSolidColorBrush(gResMainformBkColor)
			defer bkBrush.Dispose()
			borderBrush := gform.NewSolidColorBrush(gform.RGB(154, 154, 154))
			defer borderBrush.Dispose()
			borderPen := gform.NewPen(w32.PS_COSMETIC|w32.PS_SOLID, 1, borderBrush)
			defer borderPen.Dispose()
			data.Canvas.DrawRect(mf.ClientRect(), borderPen, bkBrush)

			// Draw title bar
			w := mf.Width()
			titleRect := gform.NewRect(1, 1, w-1, 22)
			titleBrush := gform.NewSolidColorBrush(gMainformTitleBarColor)
			defer titleBrush.Dispose()
			data.Canvas.FillRect(titleRect, titleBrush)

			// Draw title text
			f := gform.NewFont("Bauhaus 93", 9, 0)
			defer f.Dispose()
			titleRect.Inflate(-5, 0)
			data.Canvas.DrawText(mf.Caption(), titleRect, w32.DT_LEFT|w32.DT_VCENTER|w32.DT_SINGLELINE, f, gResMainformBkColor)

			// Draw "Drop Here"
			f = gform.NewFont("Bauhaus 93", 25, gform.FontBold)
			defer f.Dispose()
			bodyRect := gform.NewRect(1, 50, w-1, 120)
			data.Canvas.DrawText("Drop Here", bodyRect, w32.DT_CENTER|w32.DT_VCENTER|w32.DT_SINGLELINE, f, gform.RGB(187, 187, 187))

			// Draw drop arrow
			if bmp, err := gform.NewBitmapFromResource(gform.GetAppInstance(), w32.MakeIntResource(IDR_DROPARROW), gResPNG, gResMainformBkColor); err == nil {
				data.Canvas.DrawBitmap(bmp, (w-bmp.Width())/2, 110)
				bmp.Dispose()
			}

			// Draw bottom panel
			h := mf.Height()
			bottomRect := gform.NewRect(1, 150, w-1, h-1)
			data.Canvas.FillRect(bottomRect, titleBrush)
		}
	}
}
Example #2
0
func onpaint(arg *gform.EventArg) {
	if data, ok := arg.Data().(*gform.PaintEventData); ok {
		if bmp, err := gform.NewBitmapFromResource(
			gform.GetAppInstance(),
			w32.MakeIntResource(IDR_PNG1),
			syscall.StringToUTF16Ptr("PNG"),
			gform.RGB(255, 0, 0)); err == nil {
			data.Canvas.DrawBitmap(bmp, 10, 10)
			bmp.Dispose()
		} else {
			println(err.Error())
		}
	}
}
Example #3
0
func NewProgressButton(parent gform.Controller, bgColor, foreColor gform.Color) *ProgressButton {
	pb := new(ProgressButton)
	pb.Init(parent)
	pb.bgColor, pb.foreColor, pb.highlightColor = bgColor, foreColor, gform.RGB(150, 150, 150)
	pb.tempColor = pb.bgColor

	gform.RegMsgHandler(pb)

	pb.OnPaint().Attach(progressButton_OnPaint)
	pb.OnMouseHover().Attach(progressButton_OnMouseHover)
	pb.OnMouseLeave().Attach(progressButton_OnMouseLeave)

	return pb
}
Example #4
0
File: vars.go Project: pkf/dropdot
	IDR_CLOSE            = 103
	IDR_CLOSE_MOUSEHOVER = 113
	IDR_CLOSE_CLICK      = 106
	IDR_DROPARROW        = 108
	IDR_PIN              = 110
	IDR_PIN_CHECKED      = 112
	IDR_LOAD             = 118
	IDR_LOAD_CLICK       = 120
	IDR_LOAD_MOUSEHOVER  = 121
	IDR_SAVE             = 123
	IDR_SAVE_CLICK       = 125
	IDR_SAVE_MOUSEHOVER  = 127
)

var (
	gMainformTitleBarColor = gform.RGB(139, 190, 37)
	gMainformBkColor       = gform.RGB(255, 255, 255)

	gResPNG = syscall.StringToUTF16Ptr("PNG")

	gResCloseNormal    = ResBmpInfo{gResPNG, w32.MakeIntResource(IDR_CLOSE), gMainformTitleBarColor}
	gResCloseMouseOver = ResBmpInfo{gResPNG, w32.MakeIntResource(IDR_CLOSE_MOUSEHOVER), gMainformTitleBarColor}
	gResCloseClick     = ResBmpInfo{gResPNG, w32.MakeIntResource(IDR_CLOSE_CLICK), gMainformTitleBarColor}

	gResPinNormal  = ResBmpInfo{gResPNG, w32.MakeIntResource(IDR_PIN), gMainformTitleBarColor}
	gResPinChecked = ResBmpInfo{gResPNG, w32.MakeIntResource(IDR_PIN_CHECKED), gMainformTitleBarColor}

	gResLoadNormal    = ResBmpInfo{gResPNG, w32.MakeIntResource(IDR_LOAD), gMainformBkColor}
	gResLoadMouseOver = ResBmpInfo{gResPNG, w32.MakeIntResource(IDR_LOAD_MOUSEHOVER), gMainformBkColor}
	gResLoadClick     = ResBmpInfo{gResPNG, w32.MakeIntResource(IDR_LOAD_CLICK), gMainformBkColor}