Created
June 5, 2020 23:17
-
-
Save uvtc/c1300a6dfaf4b4eaf1aa931f72b4fb5b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package; | |
import hx.widgets.Panel; | |
import hx.widgets.GraphicsContext; | |
import hx.widgets.PaintDC; | |
import hx.widgets.Pen; | |
import hx.widgets.Brush; | |
import hx.widgets.StockBrushes; | |
import hx.widgets.AntialiasMode; | |
import hx.widgets.EventType; | |
import haxe.ui.HaxeUIApp; | |
import haxe.ui.core.Component; | |
import haxe.ui.macros.ComponentMacros; | |
import haxe.ui.components.Button; | |
import haxe.ui.components.Slider; | |
import haxe.ui.components.Label; | |
import haxe.ui.containers.Box; | |
class Main { | |
static var mainView:Component; | |
static var button1:Button; | |
static var slider1:Slider; | |
static var panel1:Panel; | |
public static function main() { | |
var app = new HaxeUIApp(); | |
app.ready(function() { | |
mainView = ComponentMacros.buildComponent("assets/main.xml"); | |
app.addComponent(mainView); | |
button1 = mainView.findComponent("button1", Button); | |
slider1 = mainView.findComponent("slider1", Slider); | |
var box1 = mainView.findComponent("box1", Box); | |
panel1 = cast(box1.window, Panel); | |
panel1.bind(EventType.PAINT, function(e) { | |
var dc = new PaintDC(panel1); | |
dc.background = StockBrushes.BRUSH_BLACK; | |
dc.clear(); | |
var gc = new GraphicsContext(panel1); | |
gc.setFont(panel1.font, 0xffffff); | |
gc.drawText("Hello, GraphicsContext!", 10, 10); | |
gc.antialiasMode = AntialiasMode.DEFAULT; | |
gc.pen = new Pen(0xff0000, 3); | |
gc.brush = new Brush(0x880000); | |
gc.drawRoundedRectangle(10, 30, 100, 50, 10); | |
gc.pen = new Pen(0xffffff, 3); | |
gc.strokeLine(10, 120, 50, 160); | |
}); | |
button1.onClick = handleButton1; | |
app.start(); | |
}); | |
} | |
public static function handleButton1(e) { | |
trace("button clicked!"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment