cocoa

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2024 License: MIT, MIT Imports: 5 Imported by: 0

Documentation

Overview

Package cocoa - Go bindings for the Cocoa framework. It is currently in early stage development and not very usable yet.

Index

Constants

View Source
const (
	DatePickerStyleClockAndCalendar    DatePickerStyle = 1
	DatePickerStyleTextField           DatePickerStyle = 2
	DatePickerStyleTextFieldAndStepper DatePickerStyle = 0
	DatePickerModeRange                DatePickerMode  = 1
	DatePickerModeSingle               DatePickerMode  = 0
)

Variables

This section is empty.

Functions

func InitApplication

func InitApplication()

InitApplication initializes the global application instance. Call this before using the rest of the cocoa package.

func OnApplicationDidFinishLaunching

func OnApplicationDidFinishLaunching(fn func())

OnApplicationDidFinishLaunching - will be triggered after Application Launch is finished

func RunApplication

func RunApplication()

RunApplication launches the main Cocoa runloop.

func RunOnMainLoop

func RunOnMainLoop(fn func())

func TerminateApplication

func TerminateApplication()

TerminateApplication - will be triggered, when the Application terminates

Types

type Button

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

Button represents a button control that can trigger actions.

func NewButton

func NewButton(x int, y int, width int, height int) *Button

NewButton constructs a new button at position (x, y) and with size (width x height). Gotcha! It is currently hard-coded to quit the app when the button is being pressed, until callbacks have been implemented. This func is not thread safe.

func (*Button) OnClick

func (btn *Button) OnClick(fn func())

OnClick - function, that will be triggered, if the button is clicked.

func (*Button) Remove

func (btn *Button) Remove()

Remove - removes a button from the parent view

func (*Button) SetBackgroundColor

func (btn *Button) SetBackgroundColor(hexRGBA string)

func (*Button) SetBezelStyle

func (btn *Button) SetBezelStyle(bezelStyle ButtonBezelStyle)

func (*Button) SetBorderColor

func (btn *Button) SetBorderColor(hexRGBA string)

func (*Button) SetBorderWidth

func (btn *Button) SetBorderWidth(borderWidth int)

func (*Button) SetButtonType

func (btn *Button) SetButtonType(buttonType ButtonType)

func (*Button) SetColor

func (btn *Button) SetColor(hexRGBA string)

func (*Button) SetFontFamily

func (btn *Button) SetFontFamily(fontFamily string)

func (*Button) SetFontSize

func (btn *Button) SetFontSize(fontSize int)

func (*Button) SetImage

func (btn *Button) SetImage(img *image.RGBA)

func (*Button) SetState

func (btn *Button) SetState(state ButtonState)

func (*Button) SetTitle

func (btn *Button) SetTitle(title string)

SetTitle sets the title of the button, which is the text displayed on the button.

func (*Button) State

func (btn *Button) State() ButtonState

func (*Button) Title

func (btn *Button) Title() string

type ButtonBezelStyle

type ButtonBezelStyle int32
const (
	ButtonBezelStyleRounded           ButtonBezelStyle = 1
	ButtonBezelStyleRegularSquare     ButtonBezelStyle = 2
	ButtonBezelStyleShadowlessSquare  ButtonBezelStyle = 6
	ButtonBezelStyleSmallSquare       ButtonBezelStyle = 10
	ButtonBezelStyleRoundRect         ButtonBezelStyle = 12
	ButtonBezelStyleInline            ButtonBezelStyle = 15
	ButtonBezelStyleRecessed          ButtonBezelStyle = 13
	ButtonBezelStyleDisclosure        ButtonBezelStyle = 5
	ButtonBezelStyleRoundedDisclosure ButtonBezelStyle = 14
	ButtonBezelStyleCircular          ButtonBezelStyle = 7
	ButtonBezelStyleHelpButton        ButtonBezelStyle = 9
	ButtonBezelStyleTexturedRounded   ButtonBezelStyle = 11
	ButtonBezelStyleTexturedSquare    ButtonBezelStyle = 8
)

type ButtonState

type ButtonState int32
const (
	ButtonStateValueOff   ButtonState = 0
	ButtonStateValueOn    ButtonState = 1
	ButtonStateValueMixed ButtonState = 2
)

type ButtonType

type ButtonType int32
const (
	ButtonTypeMomentaryPushIn       ButtonType = 7
	ButtonTypeMomentaryLight        ButtonType = 0
	ButtonTypeMomentaryChange       ButtonType = 5
	ButtonTypePushOnPushOff         ButtonType = 1
	ButtonTypeOnOff                 ButtonType = 6
	ButtonTypeToggle                ButtonType = 2
	ButtonTypeSwitch                ButtonType = 3
	ButtonTypeRadio                 ButtonType = 4
	ButtonTypeAccelerator           ButtonType = 8
	ButtonTypeMultiLevelAccelerator ButtonType = 9
)

type ComboBox

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

func NewComboBox

func NewComboBox(x int, y int, width int, height int) *ComboBox

func (*ComboBox) AddItem

func (comboBox *ComboBox) AddItem(item string)

func (*ComboBox) OnSelectionDidChange

func (comboBox *ComboBox) OnSelectionDidChange(fn func())

func (*ComboBox) Remove

func (comboBox *ComboBox) Remove()

Remove removes a ComboBox from the parent view again.

func (*ComboBox) SelectedIndex

func (comboBox *ComboBox) SelectedIndex() int

func (*ComboBox) SelectedText

func (comboBox *ComboBox) SelectedText() string

func (*ComboBox) SetEditable

func (comboBox *ComboBox) SetEditable(editable bool)

func (*ComboBox) SetSelectedIndex

func (comboBox *ComboBox) SetSelectedIndex(selectedIndex int)

func (*ComboBox) SetSelectedText

func (comboBox *ComboBox) SetSelectedText(selectedText string)

func (*ComboBox) SetStringValue

func (comboBox *ComboBox) SetStringValue(stringValue string)

func (*ComboBox) StringValue

func (comboBox *ComboBox) StringValue() string

type DatePicker

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

DatePicker represents a date picker control that can trigger actions.

func NewDatePicker

func NewDatePicker(x int, y int, width int, height int) *DatePicker

func (*DatePicker) Date

func (datePicker *DatePicker) Date() string

func (*DatePicker) Remove

func (datePicker *DatePicker) Remove()

Remove removes a DatePicker from the parent view again.

func (*DatePicker) SetDate

func (datePicker *DatePicker) SetDate(date string)

func (*DatePicker) SetDateFormat

func (datePicker *DatePicker) SetDateFormat(dateFormat string)

func (*DatePicker) SetMaximumDate

func (datePicker *DatePicker) SetMaximumDate(date string)

func (*DatePicker) SetMinimumDate

func (datePicker *DatePicker) SetMinimumDate(date string)

func (*DatePicker) SetMode

func (datePicker *DatePicker) SetMode(mode DatePickerMode)

func (*DatePicker) SetStyle

func (datePicker *DatePicker) SetStyle(style DatePickerStyle)

type DatePickerMode

type DatePickerMode int32

type DatePickerStyle

type DatePickerStyle int32

type EventHandler

type EventHandler func(wnd *Window)

EventHandler - handler functions that accepts the updated window as parameter

type FrameStyle

type FrameStyle int32
const (
	FrameStyleNone      FrameStyle = 0
	FrameStylePhoto     FrameStyle = 1
	FrameStyleGrayBezel FrameStyle = 2
	FrameStyleGroove    FrameStyle = 3
	FrameStyleButton    FrameStyle = 4
)

type ImageAlignment

type ImageAlignment int32
const (
	ImageAlignCenter      ImageAlignment = 0
	ImageAlignTop         ImageAlignment = 1
	ImageAlignTopLeft     ImageAlignment = 2
	ImageAlignTopRight    ImageAlignment = 3
	ImageAlignLeft        ImageAlignment = 4
	ImageAlignBottom      ImageAlignment = 5
	ImageAlignBottomLeft  ImageAlignment = 6
	ImageAlignBottomRight ImageAlignment = 7
	ImageAlignRight       ImageAlignment = 8
)

type ImageScaling

type ImageScaling int32
const (
	ImageScalingScaleProportionallyDown     ImageScaling = 0
	ImageScalingScaleAxesIndependently      ImageScaling = 1
	ImageScalingScaleNone                   ImageScaling = 2
	ImageScalingScaleProportionallyUpOrDown ImageScaling = 3
)

type ImageView

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

Represents an ImageView control that can display images.

func NewImageView

func NewImageView(x int, y int, width int, height int) *ImageView

func NewImageViewWithContentsOfURL

func NewImageViewWithContentsOfURL(x int, y int, width int, height int, url string) *ImageView

func NewImageViewWithImage

func NewImageViewWithImage(x int, y int, width int, height int, image *image.RGBA) *ImageView

func (*ImageView) Remove

func (imageView *ImageView) Remove()

Remove removes an ImageView from the parent view again.

func (*ImageView) SetAnimates

func (imageView *ImageView) SetAnimates(animates bool)

func (*ImageView) SetContentTintColor

func (imageView *ImageView) SetContentTintColor(hexRGBA string)

func (*ImageView) SetEditable

func (imageView *ImageView) SetEditable(editable bool)

func (*ImageView) SetImage

func (imageView *ImageView) SetImage(img *image.RGBA)

func (*ImageView) SetImageAlignment

func (imageView *ImageView) SetImageAlignment(imageAlignment ImageAlignment)

func (*ImageView) SetImageFrameStyle

func (imageView *ImageView) SetImageFrameStyle(frameStyle FrameStyle)

func (*ImageView) SetImageScaling

func (imageView *ImageView) SetImageScaling(imageScaling ImageScaling)

type InteractiveView

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

func NewInteractiveView

func NewInteractiveView(x int, y int, width int, height int) *InteractiveView

func (*InteractiveView) OnClick

func (c *InteractiveView) OnClick(fn func(x, y int, secondary bool))

func (*InteractiveView) Remove

func (c *InteractiveView) Remove()

func (*InteractiveView) SetImage

func (c *InteractiveView) SetImage(img *image.RGBA)

type ProgressIndicator

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

ProgressIndicator represents a indicator control that can trigger actions.

func NewProgressIndicator

func NewProgressIndicator(x int, y int, w int, h int) *ProgressIndicator

NewProgressIndicator constructs a new ProgressIndicator

func (*ProgressIndicator) GetIsIndeterminate

func (indicator *ProgressIndicator) GetIsIndeterminate() bool

GetIsIndeterminate - return if the progressbar is indeterminate

func (*ProgressIndicator) GetValue

func (indicator *ProgressIndicator) GetValue() float64

GetValue - returns the current value of the indicator

func (*ProgressIndicator) Hide

func (indicator *ProgressIndicator) Hide()

Hide - hides the Progressbar

func (*ProgressIndicator) IncrementBy

func (indicator *ProgressIndicator) IncrementBy(inc float64)

IncrementBy - increments by `inc`

func (*ProgressIndicator) Remove

func (indicator *ProgressIndicator) Remove()

Remove - removes the indicator from the superview

func (*ProgressIndicator) SetAutohide

func (indicator *ProgressIndicator) SetAutohide(value bool)

SetAutohide - if set to true, the indicator will disapear after 100%, default false

func (*ProgressIndicator) SetDisplayedWhenStopped

func (indicator *ProgressIndicator) SetDisplayedWhenStopped(value bool)

SetDisplayedWhenStopped - A Boolean that indicates whether the progress indicator hides itself when it isn’t animating.

func (*ProgressIndicator) SetIsIndeterminate

func (indicator *ProgressIndicator) SetIsIndeterminate(value bool)

SetIsIndeterminate - sets if the progressbar is indeterminate

func (*ProgressIndicator) SetLimits

func (indicator *ProgressIndicator) SetLimits(minValue float64, maxValue float64)

SetLimits - sets min and max values

func (*ProgressIndicator) SetValue

func (indicator *ProgressIndicator) SetValue(value float64)

SetValue - sets the value to `value`

func (*ProgressIndicator) Show

func (indicator *ProgressIndicator) Show()

Show - shows the Progressbar

func (*ProgressIndicator) StartAnimation

func (indicator *ProgressIndicator) StartAnimation()

StartAnimation - Starts the animation of an indeterminate progress indicator.

func (*ProgressIndicator) StopAnimation

func (indicator *ProgressIndicator) StopAnimation()

StopAnimation - Stops the animation of an indeterminate progress indicator.

type Screen

type Screen struct {
	X int
	Y int
}

Screen the screen of the window.

type Slider

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

func NewSlider

func NewSlider(x int, y int, width int, height int) *Slider

func (*Slider) OnSliderValueChanged

func (slider *Slider) OnSliderValueChanged(fn func())

func (*Slider) Remove

func (slider *Slider) Remove()

Remove removes a Slider from the parent view again.

func (*Slider) SetMaximumValue

func (slider *Slider) SetMaximumValue(val float64)

func (*Slider) SetMinimumValue

func (slider *Slider) SetMinimumValue(val float64)

func (*Slider) SetSliderType

func (slider *Slider) SetSliderType(sliderType SliderType)

func (*Slider) SetValue

func (slider *Slider) SetValue(val float64)

func (*Slider) Value

func (slider *Slider) Value() float64

type SliderType

type SliderType int32
const (
	SliderTypeCircular SliderType = 1
	SliderTypeLinear   SliderType = 0
)

type Stepper

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

func NewStepper

func NewStepper(x int, y int, width int, height int) *Stepper

func (*Stepper) OnStepperValueChanged

func (stepper *Stepper) OnStepperValueChanged(fn func(value float64))

func (*Stepper) Remove

func (stepper *Stepper) Remove()

Remove removes a Slider from the parent view again.

func (*Stepper) SetIncrement

func (stepper *Stepper) SetIncrement(val float64)

func (*Stepper) SetMaxValue

func (stepper *Stepper) SetMaxValue(val float64)

func (*Stepper) SetMinValue

func (stepper *Stepper) SetMinValue(val float64)

func (*Stepper) SetValue

func (stepper *Stepper) SetValue(val float64)

func (*Stepper) SetValueWraps

func (stepper *Stepper) SetValueWraps(val bool)

func (*Stepper) Value

func (stepper *Stepper) Value() float64

type TableView

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

TableView -Button represents a button control that can trigger actions.

func NewTableView

func NewTableView(x int, y int, width int, height int) *TableView

NewTableView - This func is not thread safe.

func (*TableView) Add

func (tableView *TableView) Add(row string)

func (*TableView) AllowsMultipleSelection

func (tableView *TableView) AllowsMultipleSelection() bool

func (*TableView) Clear

func (tableView *TableView) Clear()

func (*TableView) DeselectAll

func (tableView *TableView) DeselectAll()

func (*TableView) IsEnabled

func (tableView *TableView) IsEnabled() bool

func (*TableView) IsRowSelected

func (tableView *TableView) IsRowSelected(index int) bool

func (*TableView) NumberOfRows

func (tableView *TableView) NumberOfRows() int

func (*TableView) OnSelectionDidChange

func (tableView *TableView) OnSelectionDidChange(fn func(indexes []int))

func (*TableView) Remove

func (tableView *TableView) Remove()

Remove - removes a Text Field from the parent view

func (*TableView) ScrollRowToVisible

func (tableView *TableView) ScrollRowToVisible(index int)

func (*TableView) SelectRowIndex

func (tableView *TableView) SelectRowIndex(index int)

func (*TableView) SetAllowsMultipleSelection

func (tableView *TableView) SetAllowsMultipleSelection(enabled bool)

func (*TableView) SetEnabled

func (tableView *TableView) SetEnabled(enabled bool)

type TextField

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

TextField -Button represents a button control that can trigger actions.

func NewLabel

func NewLabel(x int, y int, width int, height int) *TextField

NewLabel - This func is not thread safe. Label is only for convenience. Under the hood it's still a textfield with some preconfiguration in place

func NewTextField

func NewTextField(x int, y int, width int, height int) *TextField

NewTextField - This func is not thread safe.

func (*TextField) Editable

func (textField *TextField) Editable() bool

func (*TextField) Enabled

func (textField *TextField) Enabled() bool

func (*TextField) OnChange

func (textField *TextField) OnChange(fn func(value string))

func (*TextField) Remove

func (textField *TextField) Remove()

Remove - removes a Text Field from the parent view

func (*TextField) SetAlignmentCenter

func (textField *TextField) SetAlignmentCenter()

func (*TextField) SetAlignmentLeft

func (textField *TextField) SetAlignmentLeft()

func (*TextField) SetAlignmentRight

func (textField *TextField) SetAlignmentRight()

func (*TextField) SetBackgroundColor

func (textField *TextField) SetBackgroundColor(hexRGBA string)

func (*TextField) SetBezeled

func (textField *TextField) SetBezeled(bezeled bool)

func (*TextField) SetBorderColor

func (textField *TextField) SetBorderColor(hexRGBA string)

func (*TextField) SetBorderWidth

func (textField *TextField) SetBorderWidth(borderWidth int)

func (*TextField) SetColor

func (textField *TextField) SetColor(hexRGBA string)

func (*TextField) SetDrawsBackground

func (textField *TextField) SetDrawsBackground(drawsBackground bool)

func (*TextField) SetEditable

func (textField *TextField) SetEditable(editable bool)

func (*TextField) SetEnabled

func (textField *TextField) SetEnabled(enabled bool)

SetEnabled sets the enabled value of the text field. CANNOT BE CHANGED AT RUNTIME

func (*TextField) SetFontFamily

func (textField *TextField) SetFontFamily(fontFamily string)

func (*TextField) SetFontSize

func (textField *TextField) SetFontSize(fontSize int)

func (*TextField) SetSelectable

func (textField *TextField) SetSelectable(selectable bool)

func (*TextField) SetStringValue

func (textField *TextField) SetStringValue(text string)

SetStringValue sets the string value of the text field

func (*TextField) StringValue

func (textField *TextField) StringValue() string

StringValue - returns the string value of the text field

type TextView

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

TextView - represents a textView control that can trigger actions.

func NewTextView

func NewTextView(x int, y int, width int, height int) *TextView

NewTextView - This func is not thread safe.

func (*TextView) GetText added in v0.3.1

func (textview *TextView) GetText() string

GetText gets the text of the text view

func (*TextView) OnChange added in v0.3.1

func (c *TextView) OnChange(fn func(value string))

func (*TextView) Remove

func (textview *TextView) Remove()

Remove - removes a Text View from the parent view

func (*TextView) SetEditable

func (c *TextView) SetEditable(editable bool)

func (*TextView) SetFontSize

func (textview *TextView) SetFontSize(size int)

SetText sets the text of the text view

func (*TextView) SetText

func (textview *TextView) SetText(text string)

SetText sets the text of the text view

type Window

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

Window is just that.

func NewCenteredWindow

func NewCenteredWindow(title string, w int, h int) *Window

NewCenteredWindow constructs and returns a new window.

func NewWindow

func NewWindow(title string, x int, y int, w int, h int) *Window

NewWindow constructs and returns a new window.

func (*Window) AddButton

func (wnd *Window) AddButton(btn *Button)

AddButton adds a Button to the window.

func (*Window) AddComboBox

func (wnd *Window) AddComboBox(comboBox *ComboBox)

func (*Window) AddDatePicker

func (wnd *Window) AddDatePicker(datePicker *DatePicker)

AddDatePicker adds a DatePicker to the window.

func (*Window) AddDefaultQuitMenu

func (wnd *Window) AddDefaultQuitMenu()

func (*Window) AddImageView

func (wnd *Window) AddImageView(imageView *ImageView)

AddImageView adds an ImageView to the window.

func (*Window) AddInteractiveView

func (w *Window) AddInteractiveView(c *InteractiveView)

func (*Window) AddLabel

func (wnd *Window) AddLabel(tv *TextField)

AddTextField - adds a Button to the window.

func (*Window) AddProgressIndicator

func (wnd *Window) AddProgressIndicator(indicator *ProgressIndicator)

AddProgressIndicator adds a ProgressIndicator to the window.

func (*Window) AddSlider

func (wnd *Window) AddSlider(slider *Slider)

func (*Window) AddStepper

func (wnd *Window) AddStepper(stepper *Stepper)

func (*Window) AddTableView

func (wnd *Window) AddTableView(tableView *TableView)

func (*Window) AddTextField

func (wnd *Window) AddTextField(tf *TextField)

AddTextField - adds a Text Field to the window.

func (*Window) AddTextView

func (wnd *Window) AddTextView(tv *TextView)

AddTextView - adds a Text View to the window.

func (*Window) GetScreen

func (wnd *Window) GetScreen() *Screen

GetScreen - returns the screen dimensions

func (*Window) MakeKeyAndOrderFront

func (wnd *Window) MakeKeyAndOrderFront()

MakeKeyAndOrderFront moves the window to the front of the screen list, within its level and it shows the window.

func (*Window) OnDidDeminiaturize

func (wnd *Window) OnDidDeminiaturize(fn EventHandler)

func (*Window) OnDidMiniaturize

func (wnd *Window) OnDidMiniaturize(fn EventHandler)

func (*Window) OnDidMove

func (wnd *Window) OnDidMove(fn EventHandler)

func (*Window) OnDidResize

func (wnd *Window) OnDidResize(fn EventHandler)

func (*Window) OnShouldClose added in v0.3.2

func (wnd *Window) OnShouldClose(fn EventHandler)

func (*Window) SetAllowsResizing

func (wnd *Window) SetAllowsResizing(allowsResizing bool)

func (*Window) SetCloseButtonEnabled

func (wnd *Window) SetCloseButtonEnabled(enabled bool)

func (*Window) SetMiniaturizeButtonEnabled

func (wnd *Window) SetMiniaturizeButtonEnabled(enabled bool)

func (*Window) SetTitle

func (wnd *Window) SetTitle(title string)

func (*Window) SetZoomButtonEnabled

func (wnd *Window) SetZoomButtonEnabled(enabled bool)

func (*Window) Update

func (wnd *Window) Update()

Update - forces the whole window to repaint

type WindowEvent

type WindowEvent int

WindowEvent - different window delegate Events

Jump to

Keyboard shortcuts

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