summaryrefslogtreecommitdiff
path: root/mwidget/test.bmx
diff options
context:
space:
mode:
Diffstat (limited to 'mwidget/test.bmx')
-rw-r--r--mwidget/test.bmx122
1 files changed, 120 insertions, 2 deletions
diff --git a/mwidget/test.bmx b/mwidget/test.bmx
index 8c80dd2..c0f7cc3 100644
--- a/mwidget/test.bmx
+++ b/mwidget/test.bmx
@@ -5,7 +5,7 @@ Import noddybox.mwidget
Incbin "icons.png"
Incbin "toolbar.png"
-Const SUBCLASS:Int=False
+Const SUBCLASS:Int=True
Const TESTTIMER:Int=False
Global top:TMWindow
@@ -65,6 +65,14 @@ Global canvas_my:Int
Global toolbar:TMToolbar
+Global panel:TMPanel
+Global panel_kd:TMLabel
+Global panel_ku:TMLabel
+Global panel_k:TMLabel
+Global panel_prog:TMProgressBar
+Global panel_button:TMButton
+
+
'
' CALLBACK FUNCTION VERSION
'
@@ -190,6 +198,11 @@ Function OnButtonDown_Canvas(w:TMWidget, b:Int)
End Function
Function OnButtonUp_Canvas(w:TMWidget, b:Int)
+ Local c:TMCanvas=TMCanvas(w)
+ c.SetupGraphics()
+ SetColor(0,0,0)
+ DrawLine(w.Width(),w.Height(),canvas_mx,canvas_my)
+ Flip()
top.StatusText(MilliSecs() + " -- Button Up " + b)
End Function
@@ -238,6 +251,36 @@ Function OnSelected_Toolbar(w:TMWidget, i:Int)
top.StatusText(MilliSecs() + " -- Toolbar " + i)
toolbar.ItemEnabled(1,Not i=0)
End Function
+
+Function OnButtonDown_Panel(w:TMWidget, b:Int)
+ top.StatusText(MilliSecs() + " -- Panel Button Down " + b)
+End Function
+
+Function OnButtonUp_Panel(w:TMWidget, b:Int)
+ top.StatusText(MilliSecs() + " -- Panel Button Up " + b)
+End Function
+
+Function OnMouseMove_Panel(w:TMWidget, x:Int, y:Int)
+ panel_prog.SetValue(Double(x)/Double(w.Width()))
+ top.StatusText(MilliSecs() + " -- Panel Mouse move " + x + "," + y)
+End Function
+
+Function OnMouseWheel_Panel(w:TMWidget, b:Int)
+ top.StatusText(MilliSecs() + " -- Panel Mouse wheel " + b)
+End Function
+
+Function OnKeyDown_Panel(w:TMWidget, b:Int)
+ panel_kd.Text(MilliSecs() + " -- Panel Key down " + b)
+End Function
+
+Function OnKeyUp_Panel(w:TMWidget, b:Int)
+ panel_ku.Text(MilliSecs() + " -- Panel Key up " + b)
+End Function
+
+Function OnKey_Panel(w:TMWidget, b:Int)
+ panel_k.Text(MilliSecs() + " -- Panel Key " + b + "(" + Chr(b) + ")")
+End Function
+
'
' SUBCLASS VERSION
'
@@ -400,6 +443,10 @@ Type MyCanvas Extends TMCanvas
End Method
Method OnButtonUp(b:Int)
+ SetupGraphics()
+ SetColor(0,0,0)
+ DrawLine(0,0,mx,my)
+ Flip()
top.StatusText(MilliSecs() + " -- Button Up " + b)
End Method
@@ -448,6 +495,46 @@ Type MyToolbar Extends TMToolbar
End Method
End Type
+Type MyPanel Extends TMPanel
+
+ Method OnMouseEnter()
+ SetPointer(POINTER_CROSS)
+ End Method
+
+ Method OnMouseLeave()
+ SetPointer(POINTER_DEFAULT)
+ End Method
+
+ Method OnButtonDown(b:Int)
+ top.StatusText(MilliSecs() + " -- Panel Button Down " + b)
+ End Method
+
+ Method OnButtonUp(b:Int)
+ top.StatusText(MilliSecs() + " -- Panel Button Up " + b)
+ End Method
+
+ Method OnMouseMove(x:Int, y:Int)
+ panel_prog.SetValue(Double(x)/Double(Width()))
+ top.StatusText(MilliSecs() + " -- Panel Mouse move " + x + "," + y)
+ End Method
+
+ Method OnMouseWheel(b:Int)
+ top.StatusText(MilliSecs() + " -- Panel Mouse wheel " + b)
+ End Method
+
+ Method OnKeyDown(b:Int)
+ panel_kd.Text(MilliSecs() + " -- Panel Key down " + b)
+ End Method
+
+ Method OnKeyUp(b:Int)
+ panel_ku.Text(MilliSecs() + " -- Panel Key up " + b)
+ End Method
+
+ Method OnKey(b:Int)
+ panel_k.Text(MilliSecs() + " -- Panel Key " + b + "(" + Chr(b) + ")")
+ End Method
+End Type
+
'
' ALWAYS SUBCLASSES
'
@@ -518,6 +605,12 @@ Type MyMenu Extends TMMenu
End Method
End Type
+Type MyPanelButton Extends TMButton
+ Method OnPress()
+ Notify("Pressed")
+ End Method
+End Type
+
'
' ALWAYS CALLBACKS
'
@@ -555,6 +648,7 @@ tabs.AddItem(CreateListEntry("HTML",0,-1,"Test HTML view"))
tabs.AddItem(CreateListEntry("Tree View",0,-1,"Test tree view"))
tabs.AddItem(CreateListEntry("Menu",0,-1,"Test menus"))
tabs.AddItem(CreateListEntry("Canvas",0,-1,"Test canvas"))
+tabs.AddItem(CreateListEntry("Panel",0,-1,"Test panel"))
If SUBCLASS
ok=New MyOK.CreateOK("OK",10,300,80,30,tabs)
@@ -589,6 +683,9 @@ If SUBCLASS
canvas=New MyCanvas.Create(10,10,620,320,tabs)
toolbar=New MyToolbar.Create("incbin::toolbar.png",top)
+
+ panel=New MyPanel.Create(10,10,620,320,tabs,PANEL_ACTIVE,"Panel")
+
Else
ok=New TMButton.CreateOK("OK",10,300,80,30,tabs)
cancel=New TMButton.CreateCancel("Cancel",100,300,80,30,tabs)
@@ -622,6 +719,8 @@ Else
canvas=New TMCanvas.Create(10,10,620,320,tabs)
toolbar=New TMToolbar.Create("incbin::toolbar.png",top)
+
+ panel=New TMPanel.Create(10,10,620,320,tabs,PANEL_ACTIVE,"Panel")
ok.OnPressEvent.Add(OnPress_OK)
cancel.OnPressEvent.Add(OnPress_Cancel)
@@ -662,8 +761,26 @@ Else
canvas.OnKeyEvent.Add(OnKey_Canvas)
toolbar.OnSelectedEvent.Add(OnSelected_Toolbar)
+
+ panel.OnMouseEnterEvent.Add(OnMouseEnter_Canvas)
+ panel.OnMouseLeaveEvent.Add(OnMouseLeave_Canvas)
+ panel.OnButtonDownEvent.Add(OnButtonDown_Panel)
+ panel.OnButtonUpEvent.Add(OnButtonUp_Panel)
+ panel.OnMouseWheelEvent.Add(OnMouseWheel_Panel)
+ panel.OnMouseMoveEvent.Add(OnMouseMove_Panel)
+ panel.OnKeyDownEvent.Add(OnKeyDown_Panel)
+ panel.OnKeyUpEvent.Add(OnKeyUp_Panel)
+ panel.OnKeyEvent.Add(OnKey_Panel)
+
EndIf
+panel_kd=New TMLabel.Create("Key down",10,10,320,20,panel)
+panel_ku=New TMLabel.Create("Key up",10,40,320,20,panel)
+panel_k=New TMLabel.Create("Key",10,70,320,20,panel)
+
+panel_prog=New TMProgressBar.Create(10,100,320,10,panel)
+panel_button=New MyPanelButton.Create("Button",10,120,100,20,panel)
+
Local label:TMLabel=New TMLabel.Create("Label:",10,10,80,20,tabs)
list.SetIconStrip(icons)
@@ -735,7 +852,8 @@ tabs.SetPages([ ..
[TMWidget(html), TMWidget(html_url), TMWidget(html_go), TMWidget(html_back), TMWidget(html_forward)], ..
[TMWidget(tree), TMWidget(tree_node), TMWidget(tree_add), TMWidget(tree_remove), TMWidget(tree_count)], ..
[TMWidget(menu_status), TMWidget(menu_path), TMWidget(menu_name), TMWidget(menu_add), TMWidget(menu_remove), TMWidget(menu_check), TMWidget(menu_uncheck), TMWidget(menu_enable), TMWidget(menu_disable), TMWidget(menu_popup)], ..
- [TMWidget(canvas)] ..
+ [TMWidget(canvas)], ..
+ [TMWidget(panel)] ..
])