external

package module
v0.0.0-...-a06dc2a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 28, 2025 License: BSD-3-Clause Imports: 9 Imported by: 3 modules, 4 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

external

GoDoc

External is a GUI library for Go (Golang), based on connection to external GUI server application. The connection can be esstablished via tcp/ip sockets or via regular files. To use it you need to have the GuiServer executable, which may be compiled from sources, hosted in https://github.com/alkresin/guiserver, or downloaded from http://www.kresin.ru/en/guisrv.html. Join the multilanguage group https://groups.google.com/d/forum/guiserver to discuss the GuiServer, External and related issues.

To get rid of a console window, use -ldflags "-H windowsgui" option in go build statement for your application.


Alexander S.Kresin http://www.kresin.ru/ mailto: alkresin@yahoo.com

Attention! Since October 6, 2023, we have been forced to use two-factor identification in order to log in to github.com under your account. I can still do git push from the command line, but I can't use other services, for example, to answer questions. That's why I'm opening new projects on https://gitflic.ru /, Sourceforge, or somewhere else. Follow the news on my website http://www.kresin.ru/

Внимание! С 6 октября 2023 года нас вынуждили использовать двухфакторную идентификацию для того, чтобы входить на github.com под своим аккаунтом. Я пока могу делать git push из командной строки, но не могу использовать другие сервисы, например, отвечать на вопросы. Поэтому новые проекты я открываю на https://gitflic.ru/, Sourceforge, или где-то еще. Следите за новостями на моем сайте http://www.kresin.ru/

Documentation

Overview

Copyright 2018 Alexander S.Kresin <alex@kresin.ru>, http://www.kresin.ru Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.

Package external is a GUI framework for Go language. External is a Go library to build GUI application, using a standalone GUI server application: https://github.com/alkresin/guiserver.

Index

Constants

View Source
const (
	VerProto = "1.1"
	Version  = "1.1"
	FileRoot = "gs"
)
View Source
const (
	A_TOPLEFT   = -1  // Anchors control to the top and left borders of the container and does not change the distance between the top and left borders. (Default)
	A_TOPABS    = 1   // Anchors control to top border of container and does not change the distance between the top border.
	A_LEFTABS   = 2   // Anchors control to left border of container and does not change the distance between the left border.
	A_BOTTOMABS = 4   // Anchors control to bottom border of container and does not change the distance between the bottom border.
	A_RIGHTABS  = 8   // Anchors control to right border of container and does not change the distance between the right border.
	A_TOPREL    = 16  // Anchors control to top border of container and maintains relative distance between the top border.
	A_LEFTREL   = 32  // Anchors control to left border of container and maintains relative distance between the left border.
	A_BOTTOMREL = 64  // Anchors control to bottom border of container and maintains relative distance between the bottom border.
	A_RIGHTREL  = 128 // Anchors control to right border of container and maintains relative distance between the right border.
	A_HORFIX    = 256 // Anchors center of control relative to left and right borders but remains fixed in size.
	A_VERTFIX   = 512 // Anchors center of control relative to top and bottom borders but remains fixed in size.
)

A set of constants of the anchor values

View Source
const (
	DT_LEFT   = 0
	DT_CENTER = 1
	DT_RIGHT  = 2

	ES_PASSWORD  = 32
	ES_MULTILINE = 4
	ES_READONLY  = 2048

	WS_HSCROLL = 2097152
	WS_VSCROLL = 1048576

	WND_NOTITLE   = -1
	WND_NOSYSMENU = -2
	WND_NOSIZEBOX = -4
)

A set of constants of Winstyle values

View Source
const (
	DMPAPER_A3 = 8  // A3 297 x 420 mm
	DMPAPER_A4 = 9  // A4 210 x 297 mm
	DMPAPER_A5 = 11 // A5 148 x 210 mm
	DMPAPER_A6 = 70 // A6 105 x 148 mm
)

A set of constants of the printer paper types

View Source
const (
	HILI_KEYW  = 1
	HILI_FUNC  = 2
	HILI_QUOTE = 3
	HILI_COMM  = 4
)

A set of constants of the code editor highliter

Variables

This section is empty.

Functions

func AddCheckMenuItem

func AddCheckMenuItem(sName string, id int, fu func([]string) string, sCode string, params ...string)

AddCheckMenuItem is the same as AddMenuItem, but it creates a menu item, which may be checked. In fact, it is needed in a GTK version only, but for the sake of compatibility it is recommended to use it in your code if this is a check menu item.

func AddFuncToIdle

func AddFuncToIdle(fu func())

AddFuncToIdle adds a function to be executed while wait state.

func AddMenuItem

func AddMenuItem(sName string, id int, fu func([]string) string, sCode string, params ...string)

AddMenuItem adds a new item to the Window's menu or submenu, sName argument is a title of the item, id - menu item identifier; if 0 - it is created automatically fu - a function in the program, which must be called, when this menu item is selected, sCode - the identifier (name) of this function. If the fu value is nil, sCode contains the Harbour's code, which must be executed by the GuiServer when this menu item is selected. params - arguments for the fu function.

func AddMenuSeparator

func AddMenuSeparator()

AddMenuSeparator adds a separator to the Window's menu or submenu,

func BeginPacket

func BeginPacket()

BeginPacket begins a sequence of functions, which creates or modifies GUI elements, for to join messages to Guiserver to one packet.

func BrwDelColumn

func BrwDelColumn(p *Widget, ic int)

BrwDelColumn deletes a column with number ic of a browse widget p.

func BrwGetArray

func BrwGetArray(p *Widget) [][]string

BrwGetArray returns a two-dimensional slice from a browse widget p.

func BrwSetArray

func BrwSetArray(p *Widget, arr *[][]string)

BrwSetArray sets a two-dimensional slice to be represented in a browse widget p.

func BrwSetColumn

func BrwSetColumn(p *Widget, ic int, sHead string, iAlignHead int, iAlignData int,
	bEditable bool, iLength int)

BrwSetColumn defines options for a column with number ic of a browse widget p. The options are:

sHead string - a column title;
iAlignHead int - the alignment of a column title ( 0 - left, 1 - center, 2 - right );
iAlignData int - the alignment of a column data ( 0 - left, 1 - center, 2 - right );
bEditable bool - is the data in a column editable.
iLength - column width in characters;

func BrwSetColumnEx

func BrwSetColumnEx(p *Widget, ic int, sParam string, xParam interface{})

BrwSetColumnEx sets options for a column with number ic of a browse widget p - those, which can not be set via BrwSetColumn. sParam - option name, xParam - option value

func Choice

func Choice(arr []string, sTitle string, fu func([]string) string, sFunc string, sName string)

Choice creates a dialog with a "browse" inside, which allows to select one of items in a passed slice arr. fu, sFunc - a definition of a callback procedure; fu - function, sFunc - identifier; sName - a parameter, passed to a callback procedure.

func EndMenu

func EndMenu()

EndMenu completes a window's menu or submenu definition

func EndPacket

func EndPacket()

EndPacket completes a sequence of functions, started by BeginPacket

func EvalFunc

func EvalFunc(s string) []byte

EvalFunc sends a code fragment, written on Harbour to a GuiServer to execute and returns a result.

func EvalProc

func EvalProc(s string)

EvalProc sends a code fragment, written on Harbour to a GuiServer to execute and does not return a result.

func Exit

func Exit()

Exit closes the connection to Guiserver.

func GetValues

func GetValues(pWnd *Widget, aNames []string) []string

GetValues returns list of values from widgets of a pWnd window (main or a dialog), listed by names in aNames slice.

func GetVar

func GetVar(sVarName string) string

GetVar gets a variable value

func GetVersion

func GetVersion(i int) string

GetVersion returns the version string in different verbosity level, depending of i value i == 0 - GuiServer version only ("1.3", for example); i == 1 - GuiServer version with "GuiServer" word; i == 2 - GuiServer, Harbour and HwGUI versions.

func Init

func Init(sOpt string) int

Init runs, if needed, the Guiserver application, and connects to it. It returns 0, if the connection is successful, 1 - in other case, 2 -if a protocol version of a GuiServer isn't equal to a local protocol. The sOpt argument specifies connection details. It may contain following strings: guiserver=<full path to GuiServer executable> address=<ip address of a computer, where GuiServer runs> port=<tcp/ip port number> log=<0, 1 or 2> - logging level

func InitDialog

func InitDialog(pWnd *Widget) bool

Initialises a dialog window with parameters, defined in a structure, pointed by pWnd argument. To show this window on a screen it is necessary to use Activate() method.

func InitMainWindow

func InitMainWindow(pWnd *Widget) bool

Initialises a main window with parameters, defined in a structure, pointed by pWnd argument. To show this window on a screen it is necessary to use Activate() method.

func InitTray

func InitTray(sIcon string, sMenuName string, sTooltip string)

InitTray forces the main window to be placed in a tray, sIcon - a path to icon file, sMenuName - a name of a context menu, sTooltip - a tooltip for an icon in tray.

func InsertNode

func InsertNode(pTree *Widget, sNodeName string, sNodeNew string, sTitle string,
	sNodeNext string, aImages []string, fu func([]string) string, sCode string)

InsertNode inserts a node to a tree widget pTree. sNodeName - a name of a parent node, or empty, if it is root node; sNodeNew - a name of an inserted node; sTitle - a caption of an inserted node; sNodeNext - a name of a node, you want to insert the new before; aImages - path to images for the node ( unselected, selected ); fu, sCode - a definition of a callback procedure; fu - function, sCode - identifier or Harbour script.

func Menu(sTitle string)

Menu starts a window's menu or submenu definition, sTitle is a menu title.

func MenuContext(sName string)

MenuContext starts a context menu, sName is a menu identifier

func MenuItemCheck(sWndName string, sMenuName string, iItem int, bValue bool)
func MenuItemEnable(sWndName string, sMenuName string, iItem int, bValue bool)

MenuItemEnable enables (bValue == true) or disables a menu item. If this is a window menu (main or a dialog), you need to pass the appropriate window name via sWndName parameter, if context - the menu name via sMenuName. iItem is a menu item id.

func ModifyTrayIcon

func ModifyTrayIcon(sIcon string)

ModifyTrayIcon changes a tray icon of a main window, sIcon - a path to icon file.

func MsgGet

func MsgGet(sMessage string, sTitle string, iStyle int32, fu func([]string) string, sFunc string, sName string)

MsgGet creates a messagebox, which allows to input a string sTitle - box title, sMessage - text in a box, iStyle - a Winstyle for an "edit" widget (ES_PASSWORD, for example). fu, sFunc - a definition of a callback procedure; fu - function, sFunc - identifier; sName - a parameter, passed to a callback procedure.

func MsgInfo

func MsgInfo(sMessage string, sTitle string, fu func([]string) string, sFunc string, sName string)

MsgInfo creates a standard nessagebox sTitle - box title, sMessage - text in a box fu, sFunc - a definition of a callback procedure; fu - function, sFunc - identifier; sName - a parameter, passed to a callback procedure.

func MsgStop

func MsgStop(sMessage string, sTitle string, fu func([]string) string, sFunc string, sName string)

MsgStop creates a standard nessagebox sTitle - box title, sMessage - text in a box fu, sFunc - a definition of a callback procedure; fu - function, sFunc - identifier; sName - a parameter, passed to a callback procedure.

func MsgYesNo

func MsgYesNo(sMessage string, sTitle string, fu func([]string) string, sFunc string, sName string)

MsgYesNo creates a standard nessagebox sTitle - box title, sMessage - text in a box fu, sFunc - a definition of a callback procedure; fu - function, sFunc - identifier; sName - a parameter, passed to a callback procedure.

func OpenForm

func OpenForm(sForm string) bool

OpenForm reads a dialog window description from a xml file, prepared by HwGUI's Designer, initialises and activates this dialog with all its widgets

func OpenMainForm

func OpenMainForm(sForm string) bool

OpenMainForm reads a main window description from a xml file, prepared by HwGUI's Designer, initialises and activates this window with all its widgets

func OpenReport

func OpenReport(sForm string) bool

OpenReport reads a report description from a xml file, prepared by HwGUI's Designer and prints this report

func PBarSet

func PBarSet(pPBar *Widget, iPos int)

PBarSet sets a progress bar position

func PBarStep

func PBarStep(pPBar *Widget)

PBarStep does a next step for a pPBar progress bar widget

func RadioEnd

func RadioEnd(p *Widget, iSel int)

RadioEnd completes a group of radio buttons, started with a "radiogr" widget

func RegFunc

func RegFunc(sName string, fu func([]string) string)

RegFunc adds the fu func to a map of functions, sName argument is a function identifier - a key of this map. You may need to call this function in case of using HWGui's xml forms.

func SelectColor

func SelectColor(iColor int32, fu func([]string) string, sFunc string, sName string)

SelectColor creates a standard dialog to select color iColor - base color; fu, sFunc - a definition of a callback procedure; fu - function, sFunc - identifier; sName - a parameter, passed to a callback procedure.

func SelectFile

func SelectFile(sPath string, fu func([]string) string, sFunc string, sName string)

SelectFile creates a standard dialog to select file sPath - initial path; fu, sFunc - a definition of a callback procedure; fu - function, sFunc - identifier; sName - a parameter, passed to a callback procedure.

func SelectFolder

func SelectFolder(fu func([]string) string, sFunc string, sName string)

SelectFolder creates a standard dialog to select folder fu, sFunc - a definition of a callback procedure; fu - function, sFunc - identifier; sName - a parameter, passed to a callback procedure.

func SelectFont

func SelectFont(fu func([]string) string, sFunc string, sName string)

SelectFont creates a standard dialog to select font fu, sFunc - a definition of a callback procedure; fu - function, sFunc - identifier; sName - a parameter, passed to a callback procedure.

func SelectNode

func SelectNode(pTree *Widget, sNodeName string)

func SetDateFormat

func SetDateFormat(sValue string)

SetDateFormat sets a date display format, for example, "DD.MM.YYYY"

func SetHighliter

func SetHighliter(pEdit *Widget, p *Highlight)

SetHighliter sets or unsets (if p == nil) a given Highliter to a "cedit" widget.

func SetHiliOpt

func SetHiliOpt(pEdit *Widget, iGroup int, pFont *Font, tColor int32, bColor int32)

SetHili defines highlighting options for a code editor ("cedit" widget): a font, text color and background color

func SetImagePath

func SetImagePath(sValue string)

SetImagePath sets a directory where GuiServer should look for image files.

func SetPath

func SetPath(sValue string)

SetPath sets a directory where GuiServer should write files and look for files to read.

func SetVar

func SetVar(sVarName string, sValue string)

SetVar sets a variable value

func ShowMenuContext

func ShowMenuContext(sName string, pWnd *Widget)

Show context menu on the screen

func TabPage

func TabPage(pTab *Widget, sCaption string)

TabPage initialises a new page of a tab widget.

func TabPageEnd

func TabPageEnd(pTab *Widget)

TabPageEnd completes a description of a page of a tab widget.

func ToString

func ToString(xParam ...interface{}) string

ToString converts function arguments to a json string

func Wait

func Wait()

func WriteLog

func WriteLog(sText string)

WriteLog writes the sText to a log file egui.log.

Types

type CodeBlock

type CodeBlock string

The CodeBlock type for Harbour scripts, which are set via SetParam() method and BrwSetColumnEx()

type ConnEx

type ConnEx struct {
	// contains filtered or unexported fields
}

func (*ConnEx) Close

func (p *ConnEx) Close()

func (*ConnEx) Connect

func (p *ConnEx) Connect() bool

func (*ConnEx) Read

func (p *ConnEx) Read(pBuff *[]byte) (int, error)

func (*ConnEx) Write

func (p *ConnEx) Write(s string) (int, error)

type Font

type Font struct {
	Family    string
	Name      string
	Height    int
	Bold      bool
	Italic    bool
	Underline bool
	Strikeout bool
	Charset   int16
}

The Font structure prepares data to create a new font

func CreateFont

func CreateFont(pFont *Font) *Font

CreateFont creates a font with parameters, defined in a structure, pointed by pFont argument.

func GetFont

func GetFont(sName string) *Font

Returns a pointer to a Font structure with a Name member equal to sName argument.

func (*Font) FillFont

func (p *Font) FillFont(arr []string)

type Highlight

type Highlight struct {
	Name string
}

The Highlight structure serves to create a highlight rules for a code editor

func CreateHighliter

func CreateHighliter(sName string, sCommands string, sFuncs string,
	sSingleLineComm string, sMultiLineComm string, bCase bool) *Highlight

CreateHighliter creates a highlight rules for a code editor ("cedit" widget)

type Printer

type Printer struct {
	Name       string
	SPrinter   string
	BPreview   bool
	IFormType  int
	BLandscape bool
}

The Printer structure prepares data to initialize a printer

var PLastPrinter *Printer

PLastPrinter is a pointer to a last used printer structure (*Printer)

func InitPrinter

func InitPrinter(pPrinter *Printer, sFunc string, fu func([]string) string, sMark string) *Printer

InitPrinter initializes a printer, the name of a printer is passed in SPrinter member of a pPrinter structure. If it is an empty string, the default printer will be used, if it is defined as "...", printer setup dialog will be opened.

func (*Printer) AddFont

func (p *Printer) AddFont(pFont *Font) *Font

AddFont method adds a font, described in Font structure, to the printer.

func (*Printer) Box

func (p *Printer) Box(iTop, iLeft, iRight, iBottom int32)

Box method prints a rectangle with iTop, iLeft, iRight, iBottom coordinates

func (*Printer) End

func (p *Printer) End()

End method closes a printer

func (*Printer) EndPage

func (p *Printer) EndPage()

StartPage method ends a page printed

func (*Printer) Line

func (p *Printer) Line(iTop, iLeft, iRight, iBottom int32)

Line methods prints a line from iTop, iLeft to iRight, iBottom

func (*Printer) Say

func (p *Printer) Say(iTop, iLeft, iRight, iBottom int32, sText string, iOpt int32)

Say method prints s text string sText in a rectangle with iTop, iLeft, iRight, iBottom coordinates, iOpt defines an alignment.

func (*Printer) SetFont

func (p *Printer) SetFont(pFont *Font)

SetFont method sets a font, previously added with AddFont, as current while printing

func (*Printer) StartPage

func (p *Printer) StartPage()

StartPage method begins a new page printed

type Style

type Style struct {
	Name      string
	Orient    int16
	Colors    []int32
	Corners   []int32
	BorderW   int8
	BorderClr int32
	Bitmap    string
}

The Style structure prepares data to create a new style

func CreateStyle

func CreateStyle(pStyle *Style) *Style

CreateStyle creates a style with parameters, defined in a structure, pointed by pStyle argument.

func GetStyle

func GetStyle(sName string) *Style

Returns a pointer to a Style structure with a Name member equal to sName argument.

type Widget

type Widget struct {
	Parent   *Widget
	Type     string
	Name     string
	X        int
	Y        int
	W        int
	H        int
	Title    string
	Winstyle int32
	TColor   int32
	BColor   int32
	Tooltip  string
	Anchor   int32
	Font     *Font
	AProps   map[string]string
	// contains filtered or unexported fields
}

The Widget structure prepares data to create a new widget or window

var PLastWidget *Widget

PLastWidget is a pointer to a last used widget structure (*Widget)

var PLastWindow *Widget

PLastWindow is a pointer to a last used window structure (*Widget)

func Widg

func Widg(sName string) *Widget

Widg returns a pointer to a Widget structure (a widget) with a Name member corresponding to sName argument. The sName must be compound name, containing a names of all parent widgets and windows, defined by dots.

func Wnd

func Wnd(sName string) *Widget

Wnd returns a pointer to a Widget structure (a window or a dialog) with a Name member equal to sName argument.

func (*Widget) Activate

func (o *Widget) Activate() bool

Method Activate shows on the screen a main window or a dialog

func (*Widget) AddWidget

func (o *Widget) AddWidget(pWidg *Widget) *Widget

Method AddWidget adds new child widget o - parent window or widget pWidg - a Widget structure with definition of a new widget

func (*Widget) Close

func (o *Widget) Close() bool

Method Close closes a main window or a dialog

func (*Widget) Enable

func (o *Widget) Enable(bEnable bool)

Method Enable enables or disables a widget, pointed by o.

func (*Widget) GetText

func (o *Widget) GetText() string

Method GetText gets the text from a widget, pointed by o.

func (*Widget) Hide

func (o *Widget) Hide(bHide bool)

Method Hide hides or shows a widget, pointed by o.

func (*Widget) Move

func (o *Widget) Move(iLeft, iTop, iWidth, iHeight int32)

func (*Widget) SetCallBackFunc

func (o *Widget) SetCallBackFunc(sbName string, fu func([]string) string, sCode string, params ...string)

func (*Widget) SetCallBackProc

func (o *Widget) SetCallBackProc(sbName string, fu func([]string) string, sCode string, params ...string)

func (*Widget) SetColor

func (o *Widget) SetColor(tColor int32, bColor int32)

Method SetColor sets a text color tColor and background color bColor to a widget, pointed by o.

func (*Widget) SetFont

func (o *Widget) SetFont(pFont *Font)

Method SetFont sets a font pFont to a widget, pointed by o.

func (*Widget) SetImage

func (o *Widget) SetImage(sImage string)

Method SetImage sets an image widget, pointed by o, sImage - a path to an image

func (*Widget) SetParam

func (o *Widget) SetParam(sParam string, xParam interface{})

Method SetParam sets a property to a widget, pointed by o, sParam - a name of a property, xParam - a value of a property.

func (*Widget) SetText

func (o *Widget) SetText(sText string)

Method SetText sets a text aText to a widget, pointed by o.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL