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
- func AddCheckMenuItem(sName string, id int, fu func([]string) string, sCode string, params ...string)
- func AddFuncToIdle(fu func())
- func AddMenuItem(sName string, id int, fu func([]string) string, sCode string, params ...string)
- func AddMenuSeparator()
- func BeginPacket()
- func BrwDelColumn(p *Widget, ic int)
- func BrwGetArray(p *Widget) [][]string
- func BrwSetArray(p *Widget, arr *[][]string)
- func BrwSetColumn(p *Widget, ic int, sHead string, iAlignHead int, iAlignData int, ...)
- func BrwSetColumnEx(p *Widget, ic int, sParam string, xParam interface{})
- func Choice(arr []string, sTitle string, fu func([]string) string, sFunc string, ...)
- func EndMenu()
- func EndPacket()
- func EvalFunc(s string) []byte
- func EvalProc(s string)
- func Exit()
- func GetValues(pWnd *Widget, aNames []string) []string
- func GetVar(sVarName string) string
- func GetVersion(i int) string
- func Init(sOpt string) int
- func InitDialog(pWnd *Widget) bool
- func InitMainWindow(pWnd *Widget) bool
- func InitTray(sIcon string, sMenuName string, sTooltip string)
- func InsertNode(pTree *Widget, sNodeName string, sNodeNew string, sTitle string, ...)
- func Menu(sTitle string)
- func MenuContext(sName string)
- func MenuItemCheck(sWndName string, sMenuName string, iItem int, bValue bool)
- func MenuItemEnable(sWndName string, sMenuName string, iItem int, bValue bool)
- func ModifyTrayIcon(sIcon string)
- func MsgGet(sMessage string, sTitle string, iStyle int32, fu func([]string) string, ...)
- func MsgInfo(sMessage string, sTitle string, fu func([]string) string, sFunc string, ...)
- func MsgStop(sMessage string, sTitle string, fu func([]string) string, sFunc string, ...)
- func MsgYesNo(sMessage string, sTitle string, fu func([]string) string, sFunc string, ...)
- func OpenForm(sForm string) bool
- func OpenMainForm(sForm string) bool
- func OpenReport(sForm string) bool
- func PBarSet(pPBar *Widget, iPos int)
- func PBarStep(pPBar *Widget)
- func RadioEnd(p *Widget, iSel int)
- func RegFunc(sName string, fu func([]string) string)
- func SelectColor(iColor int32, fu func([]string) string, sFunc string, sName string)
- func SelectFile(sPath string, fu func([]string) string, sFunc string, sName string)
- func SelectFolder(fu func([]string) string, sFunc string, sName string)
- func SelectFont(fu func([]string) string, sFunc string, sName string)
- func SelectNode(pTree *Widget, sNodeName string)
- func SetDateFormat(sValue string)
- func SetHighliter(pEdit *Widget, p *Highlight)
- func SetHiliOpt(pEdit *Widget, iGroup int, pFont *Font, tColor int32, bColor int32)
- func SetImagePath(sValue string)
- func SetPath(sValue string)
- func SetVar(sVarName string, sValue string)
- func ShowMenuContext(sName string, pWnd *Widget)
- func TabPage(pTab *Widget, sCaption string)
- func TabPageEnd(pTab *Widget)
- func ToString(xParam ...interface{}) string
- func Wait()
- func WriteLog(sText string)
- type CodeBlock
- type ConnEx
- type Font
- type Highlight
- type Printer
- func (p *Printer) AddFont(pFont *Font) *Font
- func (p *Printer) Box(iTop, iLeft, iRight, iBottom int32)
- func (p *Printer) End()
- func (p *Printer) EndPage()
- func (p *Printer) Line(iTop, iLeft, iRight, iBottom int32)
- func (p *Printer) Say(iTop, iLeft, iRight, iBottom int32, sText string, iOpt int32)
- func (p *Printer) SetFont(pFont *Font)
- func (p *Printer) StartPage()
- type Style
- type Widget
- func (o *Widget) Activate() bool
- func (o *Widget) AddWidget(pWidg *Widget) *Widget
- func (o *Widget) Close() bool
- func (o *Widget) Enable(bEnable bool)
- func (o *Widget) GetText() string
- func (o *Widget) Hide(bHide bool)
- func (o *Widget) Move(iLeft, iTop, iWidth, iHeight int32)
- func (o *Widget) SetCallBackFunc(sbName string, fu func([]string) string, sCode string, params ...string)
- func (o *Widget) SetCallBackProc(sbName string, fu func([]string) string, sCode string, params ...string)
- func (o *Widget) SetColor(tColor int32, bColor int32)
- func (o *Widget) SetFont(pFont *Font)
- func (o *Widget) SetImage(sImage string)
- func (o *Widget) SetParam(sParam string, xParam interface{})
- func (o *Widget) SetText(sText string)
Constants ¶
const ( VerProto = "1.1" Version = "1.1" FileRoot = "gs" )
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
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
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
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 ¶
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 ¶
BrwDelColumn deletes a column with number ic of a browse widget p.
func BrwGetArray ¶
BrwGetArray returns a two-dimensional slice from a browse widget p.
func BrwSetArray ¶
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 ¶
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 ¶
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 EndPacket ¶
func EndPacket()
EndPacket completes a sequence of functions, started by BeginPacket
func EvalFunc ¶
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 GetValues ¶
GetValues returns list of values from widgets of a pWnd window (main or a dialog), listed by names in aNames slice.
func GetVersion ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
func Menu(sTitle string)
Menu starts a window's menu or submenu definition, sTitle is a menu title.
func MenuContext ¶
func MenuContext(sName string)
MenuContext starts a context menu, sName is a menu identifier
func MenuItemEnable ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
OpenReport reads a report description from a xml file, prepared by HwGUI's Designer and prints this report
func PBarStep ¶
func PBarStep(pPBar *Widget)
PBarStep does a next step for a pPBar progress bar widget
func RegFunc ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 SetDateFormat ¶
func SetDateFormat(sValue string)
SetDateFormat sets a date display format, for example, "DD.MM.YYYY"
func SetHighliter ¶
SetHighliter sets or unsets (if p == nil) a given Highliter to a "cedit" widget.
func SetHiliOpt ¶
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 ShowMenuContext ¶
Show context menu on the screen
func TabPageEnd ¶
func TabPageEnd(pTab *Widget)
TabPageEnd completes a description of a page of a tab widget.
Types ¶
type CodeBlock ¶
type CodeBlock string
The CodeBlock type for Harbour scripts, which are set via SetParam() method and BrwSetColumnEx()
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 ¶
CreateFont creates a font with parameters, defined in a structure, pointed by pFont argument.
type Highlight ¶
type Highlight struct {
Name string
}
The Highlight structure serves to create a highlight rules for a code editor
type Printer ¶
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 ¶
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) Say ¶
Say method prints s text string sText in a rectangle with iTop, iLeft, iRight, iBottom coordinates, iOpt defines an alignment.
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 ¶
CreateStyle creates a style with parameters, defined in a structure, pointed by pStyle 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 ¶
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 ¶
Wnd returns a pointer to a Widget structure (a window or a dialog) with a Name member equal to sName argument.
func (*Widget) AddWidget ¶
Method AddWidget adds new child widget o - parent window or widget pWidg - a Widget structure with definition of a new widget
func (*Widget) SetCallBackFunc ¶
func (*Widget) SetCallBackProc ¶
func (*Widget) SetColor ¶
Method SetColor sets a text color tColor and background color bColor to a widget, pointed by o.
func (*Widget) SetImage ¶
Method SetImage sets an image widget, pointed by o, sImage - a path to an image