本文整理匯總了Golang中github.com/lxn/walk.RGB函數的典型用法代碼示例。如果您正苦於以下問題:Golang RGB函數的具體用法?Golang RGB怎麽用?Golang RGB使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了RGB函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: createBitmap
func createBitmap() *walk.Bitmap {
bounds := walk.Rectangle{Width: 200, Height: 200}
bmp, _ := walk.NewBitmap(bounds.Size())
succeeded := false
defer func() {
if !succeeded {
bmp.Dispose()
}
}()
canvas, _ := walk.NewCanvasFromImage(bmp)
defer canvas.Dispose()
brushBmp, _ := walk.NewBitmapFromFile("../img/plus.png")
defer brushBmp.Dispose()
brush, _ := walk.NewBitmapBrush(brushBmp)
defer brush.Dispose()
canvas.FillRectangle(brush, bounds)
font, _ := walk.NewFont("Times New Roman", 40, walk.FontBold|walk.FontItalic)
defer font.Dispose()
canvas.DrawText("Walk Drawing Example", font, walk.RGB(0, 0, 0), bounds, walk.TextWordbreak)
succeeded = true
return bmp
}
示例2: drawStuff
func (mw *MainWindow) drawStuff(canvas *walk.Canvas, updateBounds walk.Rectangle) error {
bmp := createBitmap()
defer bmp.Dispose()
bounds := mw.paintWidget.ClientBounds()
rectPen, _ := walk.NewCosmeticPen(walk.PenSolid, walk.RGB(255, 0, 0))
defer rectPen.Dispose()
canvas.DrawRectangle(rectPen, bounds)
ellipseBrush, _ := walk.NewHatchBrush(walk.RGB(0, 255, 0), walk.HatchCross)
defer ellipseBrush.Dispose()
canvas.FillEllipse(ellipseBrush, bounds)
linesBrush, _ := walk.NewSolidColorBrush(walk.RGB(0, 0, 255))
defer linesBrush.Dispose()
linesPen, _ := walk.NewGeometricPen(walk.PenDash, 8, linesBrush)
defer linesPen.Dispose()
canvas.DrawLine(linesPen, walk.Point{bounds.X, bounds.Y}, walk.Point{bounds.Width, bounds.Height})
canvas.DrawLine(linesPen, walk.Point{bounds.X, bounds.Height}, walk.Point{bounds.Width, bounds.Y})
bmpSize := bmp.Size()
canvas.DrawImage(bmp, walk.Point{(bounds.Width - bmpSize.Width) / 2, (bounds.Height - bmpSize.Height) / 2})
return nil
}
示例3: main
func main() {
rand.Seed(time.Now().UnixNano())
model := NewFooModel()
MainWindow{
Title: "Walk TableView Example",
Size: Size{800, 600},
Layout: VBox{},
Children: []Widget{
PushButton{
Text: "Reset Rows",
OnClicked: model.ResetRows,
},
TableView{
AlternatingRowBGColor: walk.RGB(255, 255, 224),
CheckBoxes: true,
ColumnsOrderable: true,
Columns: []TableViewColumn{
{Title: "#"},
{Title: "Bar"},
{Title: "Baz", Format: "%.2f", Alignment: AlignFar},
{Title: "Quux", Format: "2006-01-02 15:04:05", Width: 150},
},
Model: model,
},
},
}.Run()
}
示例4: main
func main() {
walk.Initialize(walk.InitParams{PanicOnError: true})
defer walk.Shutdown()
rand.Seed(time.Now().UnixNano())
mainWnd, _ := walk.NewMainWindow()
mw := &MainWindow{
MainWindow: mainWnd,
model: NewFooModel(),
}
mw.SetLayout(walk.NewVBoxLayout())
mw.SetTitle("Walk TableView Example")
resetRowsButton, _ := walk.NewPushButton(mw)
resetRowsButton.SetText("Reset Rows")
resetRowsButton.Clicked().Attach(func() {
// Get some fresh data.
mw.model.ResetRows()
})
tableView, _ := walk.NewTableView(mw)
tableView.SetAlternatingRowBGColor(walk.RGB(255, 255, 224))
tableView.SetReorderColumnsEnabled(true)
// Everybody loves check boxes.
tableView.SetCheckBoxes(true)
// Don't forget to set the model.
tableView.SetModel(mw.model)
mw.SetMinMaxSize(walk.Size{320, 240}, walk.Size{})
mw.SetSize(walk.Size{800, 600})
mw.Show()
mw.Run()
}
示例5: RunMainWindow
func RunMainWindow() error {
if _, err := (MainWindow{
Name: "mainWindow", // Name is needed for settings persistence
Title: "Walk Settings Example",
MinSize: Size{800, 600},
Layout: VBox{},
Children: []Widget{
TableView{
Name: "tableView", // Name is needed for settings persistence
AlternatingRowBGColor: walk.RGB(255, 255, 200),
ColumnsOrderable: true,
Columns: []TableViewColumn{
{DataMember: "Index"},
{DataMember: "Bar"},
{DataMember: "Baz", Format: "%.2f", Alignment: AlignFar},
{DataMember: "Quux", Format: "2006-01-02 15:04:05", Width: 150},
},
Model: NewFooModel(),
}},
}.Run()); err != nil {
return err
}
return nil
}
示例6: main
func main() {
model := NewClipsModel()
MainWindow{
Title: "VitecTV",
Size: Size{800, 600},
Layout: VBox{},
Children: []Widget{
PushButton{
Text: "Actualizar Lista",
OnClicked: model.ResetRows,
},
TableView{
AlternatingRowBGColor: walk.RGB(255, 255, 224),
CheckBoxes: true,
ColumnsOrderable: true,
Columns: []TableViewColumn{
{Title: "ID"},
{Title: "Titulo"},
{Title: "Duração"},
{Title: "Data", Format: "2006-01-02 15:04:05", Width: 150},
},
Model: model,
},
PushButton{
Text: "Converter",
OnClicked: model.Select,
},
TextEdit{AssignTo: &model.output, ReadOnly: true},
},
}.Run()
}
示例7: main
func main() {
var mw *walk.MainWindow
var c1 *walk.Composite
var c2 *walk.Composite
bmp, err := walk.NewBitmapFromFile("../../img/plus.png")
if err != nil {
panic(err)
}
defer bmp.Dispose()
MainWindow{
AssignTo: &mw,
Title: "Background Example",
Layout: VBox{MarginsZero: true},
MinSize: Size{300, 400},
Children: []Widget{
Composite{
AssignTo: &c1,
Layout: VBox{},
Children: []Widget{
TextEdit{},
},
},
Composite{
AssignTo: &c2,
Layout: VBox{},
Children: []Widget{
TextEdit{},
},
},
ImageView{
Image: bmp,
},
},
}.Create()
scb, err := walk.NewSolidColorBrush(walk.RGB(255, 0, 0))
if err != nil {
panic(err)
}
defer scb.Dispose()
c1.SetBackground(scb)
bmb, err := walk.NewBitmapBrush(bmp)
if err != nil {
panic(err)
}
defer bmb.Dispose()
c2.SetBackground(bmb)
mw.Show()
mw.Run()
}
示例8: CreateProj_Query
/**
** 查看所有項目的方法
**/
func CreateProj_Query(owner walk.Form) {
var dlg *walk.Dialog
var tv *walk.TableView
var dialog = Dialog{}
model := xorm.NewProjectModel()
dialog.AssignTo = &dlg
dialog.Title = "項目管理"
dialog.Layout = VBox{}
dialog.MinSize = Size{650, 300}
dialog.Children = []Widget{
TableView{
AssignTo: &tv,
AlternatingRowBGColor: walk.RGB(255, 255, 224),
ColumnsOrderable: true,
Columns: []TableViewColumn{
{Title: "編號", Width: 50},
{Title: "名稱"},
{Title: "創建者"},
{Title: "創建時間", Format: "2006-01-02 15:04:05", Width: 130},
{Title: "描述", Width: 200},
},
Model: model,
},
Composite{
Layout: HBox{},
Children: []Widget{
HSpacer{},
PushButton{
Text: "創建",
OnClicked: func() {
CreateProj_Triggered(owner, model)
},
},
PushButton{
Text: "刪除",
OnClicked: func() {
indexs := tv.SelectedIndexes()
if indexs.Len() == 0 {
walk.MsgBox(owner, "提示", "請選擇要刪除的數據", walk.MsgBoxIconError)
return
}
walk.MsgBox(owner, "提示", "確認是否刪除此工程", walk.MsgBoxOKCancel)
obj := model.GetItemByindex(int64(indexs.At(0)))
xorm.DeleteProjectByObj(obj)
model.ResetRows()
},
},
},
},
}
dialog.Run(owner)
}
示例9: main
func main() {
mw := new(MyWindow)
if err := (MainWindow{
AssignTo: &mw.MainWindow,
MinSize: Size{800, 600},
Layout: HBox{},
Children: []Widget{
TabWidget{
MinSize: Size{700, 500},
Pages: []TabPage{
TabPage{
Title: "測試1",
MinSize: Size{500, 300},
Layout: HBox{},
Children: []Widget{
TableView{
AlternatingRowBGColor: walk.RGB(255, 255, 224),
CheckBoxes: true,
ColumnsOrderable: true,
Columns: []TableViewColumn{
{Title: "#"},
{Title: "Bar"},
{Title: "Baz", Format: "%.2f", Alignment: AlignFar},
{Title: "Quux", Format: "2006-01-02 15:04:05", Width: 150},
},
},
},
},
TabPage{
Title: "測試2",
MinSize: Size{500, 300},
Layout: HBox{},
Children: []Widget{
Label{
Text: "測試",
},
PushButton{
Text: "提交",
},
},
},
},
},
},
}.Create()); err != nil {
log.Fatal(err)
}
mw.Run()
}
示例10: main
func main() {
defer SqlDisConnect(conn)
_, ex := SqlExec(conn, `select * from dbo.product`, "product")
Browse("product")
if ex != nil {
fmt.Println("can not load product:", ex)
return
}
model := new(productModel)
MainWindow{
Title: "VFP data and Walk table view Example",
Size: Size{800, 600},
Layout: VBox{},
Children: []Widget{
PushButton{
Text: "Reset Rows",
OnClicked: func() {
Usein("product")
_, ex := SqlExec(conn, `select * from dbo.product`, "product")
if ex != nil {
fmt.Println("can not reload product:", ex)
return
}
model.ResetRows()
},
},
TableView{
AlternatingRowBGColor: walk.RGB(255, 255, 224),
CheckBoxes: true,
ReorderColumnsEnabled: true,
Columns: []TableViewColumn{
{Title: "產品編號"},
{Title: "產品名稱"},
{Title: "產品價格", Format: "%.2f", Alignment: AlignFar},
{Title: "類別"},
},
Model: model,
},
},
}.Run()
}
示例11: main
func main() {
rand.Seed(time.Now().UnixNano())
model := NewFooModel()
var tv *walk.TableView
MainWindow{
Title: "Walk TableView Example",
Size: Size{800, 600},
Layout: VBox{MarginsZero: true},
Children: []Widget{
PushButton{
Text: "Reset Rows",
OnClicked: model.ResetRows,
},
PushButton{
Text: "Select first 5 even Rows",
OnClicked: func() {
tv.SetSelectedIndexes([]int{0, 2, 4, 6, 8})
},
},
TableView{
AssignTo: &tv,
AlternatingRowBGColor: walk.RGB(255, 255, 224),
CheckBoxes: true,
ColumnsOrderable: true,
MultiSelection: true,
Columns: []TableViewColumn{
{Title: "#"},
{Title: "Bar"},
{Title: "Baz", Format: "%.2f", Alignment: AlignFar},
{Title: "Quux", Format: "2006-01-02 15:04:05", Width: 150},
},
Model: model,
OnSelectedIndexesChanged: func() {
fmt.Printf("SelectedIndexes: %v\n", tv.SelectedIndexes())
},
},
},
}.Run()
}
示例12: NewMyWidget
func NewMyWidget(parent walk.Container) (*MyWidget, error) {
w := new(MyWidget)
if err := walk.InitChildWidget(
w,
parent,
myWidgetWindowClass,
winapi.WS_VISIBLE,
0); err != nil {
return nil, err
}
bg, err := walk.NewSolidColorBrush(walk.RGB(0, 255, 0))
if err != nil {
return nil, err
}
w.SetBackground(bg)
return w, nil
}
示例13: main
func main() {
font := Font{
Family: "Times New Roman",
PointSize: 13,
Bold: true,
}
usr, _ := user.Current()
usrModel := env.NewModel(0)
sysModel := env.NewModel(1)
var usrTableView, sysTableView *walk.TableView
var mw *walk.MainWindow
MainWindow{
Title: "Enviroment Variable",
Size: Size{600, 700},
Layout: VBox{},
AssignTo: &mw,
Font: font,
Children: []Widget{
VSplitter{
Children: []Widget{
GroupBox{
Title: "User variables for " + usr.Username,
Font: font,
Layout: VBox{},
Children: []Widget{
TableView{
AssignTo: &usrTableView,
AlternatingRowBGColor: walk.RGB(255, 255, 224),
ColumnsOrderable: true,
Columns: []TableViewColumn{
{Title: "name", Width: 200},
{Title: "value"},
},
LastColumnStretched: true,
Model: usrModel,
OnItemActivated: func() {
index := usrTableView.CurrentIndex()
if index != -1 {
EditVariable(mw, usrModel, usrModel.GetVariable(index).Name, usrModel.GetVariable(index).Value)
}
},
},
Composite{
Layout: HBox{},
Children: []Widget{
HSpacer{},
PushButton{
Text: "New...",
OnClicked: func() {
NewVariable(mw, usrModel)
},
},
PushButton{
Text: "Edit...",
OnClicked: func() {
index := usrTableView.CurrentIndex()
if index != -1 {
EditVariable(mw, usrModel, usrModel.GetVariable(index).Name, usrModel.GetVariable(index).Value)
}
},
},
PushButton{
Text: "Delete",
OnClicked: func() {
index := usrTableView.CurrentIndex()
if index != -1 {
DeleteVariable(mw, usrModel, usrModel.GetVariable(index).Name)
}
},
},
},
},
},
},
GroupBox{
Title: "System variables",
Font: font,
Layout: VBox{},
Children: []Widget{
TableView{
AssignTo: &sysTableView,
AlternatingRowBGColor: walk.RGB(255, 255, 224),
ColumnsOrderable: true,
Columns: []TableViewColumn{
{Title: "Variable", Width: 200},
{Title: "Value"},
},
LastColumnStretched: true,
Model: sysModel,
OnItemActivated: func() {
index := sysTableView.CurrentIndex()
if index != -1 {
EditVariable(mw, sysModel, sysModel.GetVariable(index).Name, sysModel.GetVariable(index).Value)
}
},
},
Composite{
Layout: HBox{},
Children: []Widget{
HSpacer{},
//.........這裏部分代碼省略.........
示例14: serverWindow
func serverWindow() {
mw.Close()
if err := (MainWindow{
AssignTo: &mw,
DataBinder: DataBinder{
AssignTo: &db,
DataSource: Input,
ErrorPresenter: ErrorPresenterRef{&ep},
},
Title: config.APP_NAME + " 【 運行模式 -> 服務器 】",
MinSize: Size{1100, 700},
Layout: VBox{ /*MarginsZero: true*/ },
Children: []Widget{
Composite{
AssignTo: &setting,
Layout: Grid{Columns: 2},
Children: []Widget{
// 任務列表
TableView{
ColumnSpan: 1,
MinSize: Size{550, 350},
AlternatingRowBGColor: walk.RGB(255, 255, 224),
CheckBoxes: true,
ColumnsOrderable: true,
Columns: []TableViewColumn{
{Title: "#", Width: 45},
{Title: "任務", Width: 110 /*, Format: "%.2f", Alignment: AlignFar*/},
{Title: "描述", Width: 370},
},
Model: spiderMenu,
},
VSplitter{
ColumnSpan: 1,
MinSize: Size{550, 0},
Children: []Widget{
VSplitter{
Children: []Widget{
Label{
Text: "自定義輸入:(多任務之間以 | 隔開,選填)",
},
LineEdit{
Text: Bind("Keywords"),
},
},
},
VSplitter{
Children: []Widget{
Label{
Text: "*並發協程:(1~99999)",
},
NumberEdit{
Value: Bind("ThreadNum", Range{1, 99999}),
Suffix: "",
Decimals: 0,
},
},
},
VSplitter{
Children: []Widget{
Label{
Text: "采集頁數:(選填)",
},
NumberEdit{
Value: Bind("MaxPage"),
Suffix: "",
Decimals: 0,
},
},
},
VSplitter{
Children: []Widget{
Label{
Text: "*分批輸出大小:(1~5,000,000 條數據)",
},
NumberEdit{
Value: Bind("DockerCap", Range{1, 5000000}),
Suffix: "",
Decimals: 0,
},
},
},
VSplitter{
Children: []Widget{
Label{
Text: "*間隔基準:",
},
ComboBox{
Value: Bind("BaseSleeptime", SelRequired{}),
BindingMember: "Uint",
DisplayMember: "Key",
Model: GuiOpt.SleepTime,
},
//.........這裏部分代碼省略.........
示例15: serverWindow
func serverWindow() {
mw.Close()
if err := (MainWindow{
AssignTo: &mw,
DataBinder: DataBinder{
AssignTo: &db,
DataSource: Input,
ErrorPresenter: ErrorPresenterRef{&ep},
},
Title: config.FULL_NAME + " 【 運行模式 -> 服務器 】",
MinSize: Size{1100, 700},
Layout: VBox{MarginsZero: true},
Children: []Widget{
Composite{
AssignTo: &setting,
Layout: Grid{Columns: 2},
Children: []Widget{
// 任務列表
TableView{
ColumnSpan: 1,
MinSize: Size{550, 450},
AlternatingRowBGColor: walk.RGB(255, 255, 224),
CheckBoxes: true,
ColumnsOrderable: true,
Columns: []TableViewColumn{
{Title: "#", Width: 45},
{Title: "任務", Width: 110 /*, Format: "%.2f", Alignment: AlignFar*/},
{Title: "描述", Width: 370},
},
Model: spiderMenu,
},
VSplitter{
ColumnSpan: 1,
MinSize: Size{550, 450},
Children: []Widget{
VSplitter{
Children: []Widget{
Label{
Text: "自定義配置(多任務請分別多包一層“<>”)",
},
LineEdit{
Text: Bind("Keyins"),
},
},
},
VSplitter{
Children: []Widget{
Label{
Text: "*采集上限(默認限製URL數):",
},
NumberEdit{
Value: Bind("Limit"),
Suffix: "",
Decimals: 0,
},
},
},
VSplitter{
Children: []Widget{
Label{
Text: "*並發協程:(1~99999)",
},
NumberEdit{
Value: Bind("ThreadNum", Range{1, 99999}),
Suffix: "",
Decimals: 0,
},
},
},
VSplitter{
Children: []Widget{
Label{
Text: "*分批輸出大小:(1~5,000,000 條數據)",
},
NumberEdit{
Value: Bind("DockerCap", Range{1, 5000000}),
Suffix: "",
Decimals: 0,
},
},
},
VSplitter{
Children: []Widget{
Label{
Text: "*暫停時長參考:",
},
ComboBox{
Value: Bind("Pausetime", SelRequired{}),
DisplayMember: "Key",
BindingMember: "Int64",
Model: GuiOpt.Pausetime,
},
//.........這裏部分代碼省略.........