| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512 |
- // Copyright 2018 visualfc. All rights reserved.
- package tk
- type Pos struct {
- X int
- Y int
- }
- type Pad struct {
- X int
- Y int
- }
- type Size struct {
- Width int
- Height int
- }
- type Geometry struct {
- X int
- Y int
- Width int
- Height int
- }
- type Orient int
- const (
- Vertical Orient = iota
- Horizontal
- )
- var (
- orientName = []string{"vertical", "horizontal"}
- )
- func (v Orient) String() string {
- if v >= 0 && int(v) < len(orientName) {
- return orientName[v]
- }
- return ""
- }
- func parserOrientResult(r string, err error) Orient {
- if err != nil {
- return -1
- }
- for n, s := range orientName {
- if s == r {
- return Orient(n)
- }
- }
- return -1
- }
- type Justify int
- const (
- JustifyCenter Justify = iota
- JustifyLeft
- JustifyRight
- )
- var (
- alignmentName = []string{"center", "left", "right"}
- )
- func (v Justify) String() string {
- if v >= 0 && int(v) < len(alignmentName) {
- return alignmentName[v]
- }
- return ""
- }
- func parserJustifyResult(r string, err error) Justify {
- if err != nil {
- return -1
- }
- for n, s := range alignmentName {
- if s == r {
- return Justify(n)
- }
- }
- return -1
- }
- type Side int
- const (
- SideLeft Side = iota
- SideRight
- SideTop
- SideBottom
- )
- var (
- sideName = []string{"left", "right", "top", "bottom"}
- )
- func (v Side) String() string {
- if v >= 0 && int(v) < len(sideName) {
- return sideName[v]
- }
- return ""
- }
- func parserSideResult(r string, err error) Side {
- if err != nil {
- return -1
- }
- for n, s := range sideName {
- if s == r {
- return Side(n)
- }
- }
- return -1
- }
- type BorderMode int
- const (
- BorderModeInside BorderMode = iota
- BorderModeOutside
- BorderModeIgnore
- )
- var (
- borderModeName = []string{"inside", "outside", "ignore"}
- )
- func (v BorderMode) String() string {
- if v >= 0 && int(v) < len(borderModeName) {
- return borderModeName[v]
- }
- return ""
- }
- func parserBorderModeResult(r string, err error) BorderMode {
- if err != nil {
- return -1
- }
- for n, s := range borderModeName {
- if s == r {
- return BorderMode(n)
- }
- }
- return -1
- }
- type Fill int
- const (
- FillNone Fill = iota
- FillX
- FillY
- FillBoth
- )
- var (
- fillName = []string{"none", "x", "y", "both"}
- )
- func (v Fill) String() string {
- if v >= 0 && int(v) < len(fillName) {
- return fillName[v]
- }
- return ""
- }
- func parserFillResult(r string, err error) Fill {
- if err != nil {
- return -1
- }
- for n, s := range fillName {
- if s == r {
- return Fill(n)
- }
- }
- return -1
- }
- type ReliefStyle int
- const (
- ReliefStyleFlat ReliefStyle = iota
- ReliefStyleGroove
- ReliefStyleRaised
- ReliefStyleRidge
- ReliefStyleSolid
- ReliefStyleSunken
- )
- var (
- borderStyleName = []string{"flat", "groove", "raised", "ridge", "solid", "sunken"}
- )
- func (v ReliefStyle) String() string {
- if v >= 0 && int(v) < len(borderStyleName) {
- return borderStyleName[v]
- }
- return ""
- }
- func parserReliefStyleResult(r string, err error) ReliefStyle {
- if err != nil {
- return -1
- }
- for n, s := range borderStyleName {
- if s == r {
- return ReliefStyle(n)
- }
- }
- return -1
- }
- type Anchor int
- const (
- AnchorCenter Anchor = iota
- AnchorNorth
- AnchorEast
- AnchorSouth
- AnchorWest
- AnchorNorthEast
- AnchorNorthWest
- AnchorSouthEast
- AnchorSouthWest
- )
- var (
- anchorName = []string{"center", "n", "e", "s", "w", "ne", "nw", "se", "sw"}
- )
- func (v Anchor) String() string {
- if v >= 0 && int(v) < len(anchorName) {
- return anchorName[v]
- }
- return ""
- }
- func parserAnchorResult(r string, err error) Anchor {
- if err != nil {
- return -1
- }
- for n, s := range anchorName {
- if s == r {
- return Anchor(n)
- }
- }
- return -1
- }
- type Sticky int
- const (
- StickyCenter Sticky = 1 << iota
- StickyN
- StickyS
- StickyE
- StickyW
- StickyNS = StickyN | StickyS
- StickyEW = StickyE | StickyW
- StickyAll = StickyN | StickyS | StickyE | StickyW
- )
- func (v Sticky) String() string {
- var s string
- if v&StickyN == StickyN {
- s += "n"
- }
- if v&StickyS == StickyS {
- s += "s"
- }
- if v&StickyE == StickyE {
- s += "e"
- }
- if v&StickyW == StickyW {
- s += "w"
- }
- return s
- }
- type Direction int
- const (
- DirectionBelow Direction = iota
- DirectionAbove
- DirectionLeft
- DirectionRight
- )
- var (
- directionName = []string{"below", "above", "left", "right"}
- )
- func (v Direction) String() string {
- if v >= 0 && int(v) < len(directionName) {
- return directionName[v]
- }
- return ""
- }
- func parserDirectionResult(r string, err error) Direction {
- if err != nil {
- return 0
- }
- for n, s := range directionName {
- if s == r {
- return Direction(n)
- }
- }
- return 0
- }
- type Compound int
- const (
- CompoundNone Compound = iota
- CompoundTop
- CompoundBottom
- CompoundLeft
- CompoundRight
- CompoundCenter
- )
- var (
- compoundName = []string{"none", "top", "bottom", "left", "right", "center"}
- )
- func (v Compound) String() string {
- if v >= 0 && int(v) < len(compoundName) {
- return compoundName[v]
- }
- return ""
- }
- func parserCompoundResult(r string, err error) Compound {
- if err != nil {
- return 0
- }
- for n, s := range compoundName {
- if s == r {
- return Compound(n)
- }
- }
- return 0
- }
- type State int
- const (
- StateNormal State = iota
- StateActive
- StateDisable
- StateReadOnly
- )
- var (
- stateName = []string{"normal", "active", "disabled", "readonly"}
- )
- func (v State) String() string {
- if v >= 0 && int(v) < len(stateName) {
- return stateName[v]
- }
- return ""
- }
- func parserStateResult(r string, err error) State {
- if err != nil {
- return 0
- }
- for n, s := range stateName {
- if s == r {
- return State(n)
- }
- }
- return 0
- }
- type ListSelectMode int
- const (
- ListSelectSingle ListSelectMode = iota
- ListSelectBrowse
- ListSelectMultiple
- ListSelectExtended
- )
- var (
- listSelectName = []string{"single", "browse", "multiple", "extended"}
- )
- func (v ListSelectMode) String() string {
- if v >= 0 && int(v) < len(listSelectName) {
- return listSelectName[v]
- }
- return ""
- }
- func parserListSelectModeResult(r string, err error) ListSelectMode {
- if err != nil {
- return 0
- }
- for n, s := range listSelectName {
- if s == r {
- return ListSelectMode(n)
- }
- }
- return 0
- }
- type DisplyCursor int
- const (
- DisplyCursorNone DisplyCursor = iota
- DisplyCursorHollow
- DisplyCursorSolid
- )
- var (
- displyCursorName = []string{"none", "hollow", "solid"}
- )
- func (v DisplyCursor) String() string {
- if v >= 0 && int(v) < len(displyCursorName) {
- return displyCursorName[v]
- }
- return ""
- }
- func parserDisplyCursorResult(r string, err error) DisplyCursor {
- if err != nil {
- return 0
- }
- for n, s := range displyCursorName {
- if s == r {
- return DisplyCursor(n)
- }
- }
- return 0
- }
- type LineWrapMode int
- const (
- LineWrapNone LineWrapMode = iota
- LineWrapChar
- LineWrapWord
- )
- var (
- lineWrapName = []string{"none", "char", "word"}
- )
- func (v LineWrapMode) String() string {
- if v >= 0 && int(v) < len(lineWrapName) {
- return lineWrapName[v]
- }
- return ""
- }
- func parserLineWrapModeResult(r string, err error) LineWrapMode {
- if err != nil {
- return 0
- }
- for n, s := range lineWrapName {
- if s == r {
- return LineWrapMode(n)
- }
- }
- return 0
- }
- type TreeSelectMode int
- const (
- TreeSelectExtended TreeSelectMode = iota
- TreeSelectBrowse
- TreeSelectNode
- )
- var (
- treeSelectName = []string{"extended", "browse", "none"}
- )
- func (v TreeSelectMode) String() string {
- if v >= 0 && int(v) < len(treeSelectName) {
- return treeSelectName[v]
- }
- return ""
- }
- func parserTreeSelectModeResult(r string, err error) TreeSelectMode {
- if err != nil {
- return 0
- }
- for n, s := range treeSelectName {
- if s == r {
- return TreeSelectMode(n)
- }
- }
- return 0
- }
- func parserPaddingResult(r string, err error) (int, int) {
- if err != nil {
- return 0, 0
- }
- return parserTwoInt(r)
- }
|