예제 #1
0
파일: mainwindow.go 프로젝트: gooops/goqt
func NewMainWindow() *MainWindow {
	w := &MainWindow{}
	w.QMainWindow = ui.NewQMainWindow()
	w.InstallEventFilter(w)

	w.edit = ui.NewQPlainTextEdit()
	w.SetCentralWidget(w.edit)

	w.createActions()

	w.readSettings()

	w.edit.Document().OnContentsChanged(w.documentWasModified)
	w.setCurrentFile("")

	return w
}
예제 #2
0
파일: main.go 프로젝트: gooops/goqt
func main_ui() {
	btn := ui.NewQPushButton()
	btn.SetText("Async")

	clear := ui.NewQPushButton()
	clear.SetText("Clear")

	edit := ui.NewQPlainTextEdit()
	edit.SetReadOnly(true)

	btn.OnClicked(func() {
		for i := 0; i < 10; i++ {
			go func(i int) {
				start := time.Now()
				<-time.After(1e7)
				offset := time.Now().Sub(start)
				ui.Async(func() {
					edit.AppendPlainText(fmt.Sprintf("Task %v %v", i, offset))
				})
			}(i)
		}
	})

	clear.OnClicked(func() {
		edit.Clear()
	})

	hbox := ui.NewQHBoxLayout()
	hbox.AddWidget(btn)
	hbox.AddWidget(clear)

	vbox := ui.NewQVBoxLayout()
	vbox.AddLayout(hbox)
	vbox.AddWidget(edit)

	widget := ui.NewQWidget()
	widget.SetLayout(vbox)
	widget.Show()
}
예제 #3
0
파일: codeedit.go 프로젝트: gooops/goqt
func NewCodeEdit() *CodeEdit {
	w := &CodeEdit{}
	w.QWidget = ui.NewQWidget()
	w.edit = ui.NewQPlainTextEdit()
	w.edit.SetLineWrapMode(ui.QPlainTextEdit_NoWrap)
	w.syntax = ui.NewQSyntaxHighlighterHookWithDoc(w.edit.Document())
	w.lineArea = ui.NewQWidget()
	w.lineArea.SetFixedWidth(0)

	hbox := ui.NewQHBoxLayout()
	hbox.SetMargin(0)
	hbox.SetSpacing(0)
	hbox.AddWidget(w.lineArea)
	hbox.AddWidget(w.edit)
	w.SetLayout(hbox)

	w.lineArea.InstallEventFilter(w)

	w.edit.OnBlockCountChanged(func(int32) {
		w.UpdateLineNumberAreaWidth()
		w.lineArea.Update()
	})
	w.edit.OnUpdateRequest(func(*ui.QRect, int32) {
		w.lineArea.Update()
	})

	w.UpdateLineNumberAreaWidth()

	w.MakeRules()

	w.syntax.OnHighlightBlock(w.OnHighlightBlock)

	font := w.edit.Font()
	font.SetPointSize(12)
	w.edit.SetFont(font)
	w.lineArea.SetFont(font)

	return w
}