From 6dc71a2dcdec6dce9c575c3f33092738e3d1f222 Mon Sep 17 00:00:00 2001 From: Ian C Date: Tue, 10 Jan 2006 00:41:39 +0000 Subject: Development checkin --- mwidget/.cvsignore | 2 + mwidget/icons.png | Bin 0 -> 448 bytes mwidget/test.bmx | 455 +++++++++++++++++++++++++++++++++++++++++++++++++++++ vectorgfx/obj2.2d | Bin 60 -> 148 bytes vectorgfx/test.bmx | 66 +++++--- 5 files changed, 502 insertions(+), 21 deletions(-) create mode 100644 mwidget/.cvsignore create mode 100644 mwidget/icons.png create mode 100644 mwidget/test.bmx diff --git a/mwidget/.cvsignore b/mwidget/.cvsignore new file mode 100644 index 0000000..8f686ea --- /dev/null +++ b/mwidget/.cvsignore @@ -0,0 +1,2 @@ +test.debug.exe +.bmx \ No newline at end of file diff --git a/mwidget/icons.png b/mwidget/icons.png new file mode 100644 index 0000000..66ab29f Binary files /dev/null and b/mwidget/icons.png differ diff --git a/mwidget/test.bmx b/mwidget/test.bmx new file mode 100644 index 0000000..38812f7 --- /dev/null +++ b/mwidget/test.bmx @@ -0,0 +1,455 @@ +' $Id$ +Strict +Import noddybox.mwidget + +Incbin "icons.png" + +Const SUBCLASS:Int=False +Const TESTTIMER:Int=False + +Global top:TMWindow +Global tabs:TMTabber +Global ok:TMButton +Global cancel:TMButton + +Global check:TMCheckbox + +Global radio1:TMRadioButton +Global radio2:TMRadioButton +Global radio3:TMRadioButton + +Global radios:TMRadioButtonSet + +Global txtfield:TMTextField +Global txtarea:TMTextArea + +Global list:TMListBox + +Global icons:TIconStrip=LoadIconStrip("incbin::icons.png") + +Global html:TMHTMLView +Global html_url:TMTextField +Global html_go:TMButton +Global html_back:TMButton +Global html_forward:TMButton + +Local slider1:TMSlider +Local slider2:TMSlider + +Global tree:TMTreeView + +Global tree_node:TMTextField +Global tree_add:TMButton +Global tree_remove:TMButton + +' +' CALLBACK FUNCTION VERSION +' +Function OnTimer(w:TMWidget) + w.Text("(Callback) Test Managed Widgets -- " + CurrentTime() + " " + CurrentDate()) +End Function + +Function OnClose(o:TMWidget) + Local w:TMWindow=TMWindow(o) + w.closed=Confirm("(Callback) Really quit?") +End Function + +Function OnMove(o:TMWidget, x:Int, y:Int) + Local w:TMWindow=TMWindow(o) + w.StatusText("(Callback) "+x+","+y) +End Function + +Function OnResize(o:TMWidget, x:Int, y:Int) + Local w:TMWindow=TMWindow(o) + w.StatusText("(Callback) ["+x+","+y+"]") +End Function + +Function OnPress_OK(o:TMWidget) + top.Close() +End Function + +Function OnPress_Cancel(o:TMWidget) + Notify("Cancel pressed -- text='" + txtfield.GetText() + "'") +End Function + +Function OnPress_Check(o:TMWidget, checked:Int) + Notify("Ticked - " + checked) +End Function + +Function OnSelected_Radio(o:TMWidget, index:Int) + Notify("Radio changed - " + index) +End Function + +Function OnTextChanged_Field(o:TMWidget, txt:String) + top.StatusText(MilliSecs() + " -- " + txt) +End Function + +Function ShowAreaStatus(o:TMWidget) + Local t:TMTextArea=TMTextArea(o) + Local s:String="" + s:+"Pos: " + t.GetCursorColumn() + "," + t.GetCursorRow() + " " + s:+"Len: " + t.GetLength() + " " + s:+"[Sel: " + t.GetSelectionLength() + "," + t.GetSelectionRows() +"]" + top.StatusText(MilliSecs() + " -- " + s) +End Function + +Function OnMenu_Area(o:TMWidget) + Notify("No menu!") +End Function + +Function ShowChangedInt(o:TMWidget, val:Int) + top.StatusText(MilliSecs() + " -- " + val) +End Function + +Function OnForward(o:TMWidget) + html.Forward() +End Function + +Function OnBack(o:TMWidget) + html.Back() +End Function + +Function OnGO(o:TMWidget) + html.Go(html_url.GetText()) +End Function + +Function OnPageLoaded(o:TMWidget, url:String) + top.StatusText(MilliSecs() + " -- Loaded " + url) +End Function + +Function OnSelectURL(o:TMWidget, url:String) + html_url.Text(url) +End Function + +Function OnSelected_Tree(o:TMWidget, path:String, tag:Object) + top.StatusText(MilliSecs() + " -- Selected " + path + " (" + tag.ToString() + ")") +End Function + +Function OnClicked_Tree(o:TMWidget, path:String, tag:Object) + top.StatusText(MilliSecs() + " -- Clicked " + path + " (" + tag.ToString() + ")") +End Function + +Function OnExpanded_Tree(o:TMWidget, path:String, tag:Object) + top.StatusText(MilliSecs() + " -- Expanded " + path + " (" + tag.ToString() + ")") +End Function + +Function OnCollapsed_Tree(o:TMWidget, path:String, tag:Object) + top.StatusText(MilliSecs() + " -- Collapsed " + path + " (" + tag.ToString() + ")") +End Function + +Function OnMenu_Tree(o:TMWidget, path:String, tag:Object) + top.StatusText(MilliSecs() + " -- Menu " + path + " (" + tag.ToString() + ")") +End Function + +' +' SUBCLASS VERSION +' +Type MyApp Extends TMWindow + Method OnTimer() + Text("Test Managed Widgets -- " + CurrentTime() + " " + CurrentDate()) + End Method + + Method OnClose() + closed=Confirm("Really quit?") + End Method + + Method OnMove(x:Int, y:Int) + StatusText(x+","+y) + End Method + + Method OnResize(x:Int, y:Int) + StatusText("["+x+","+y+"]") + End Method +End Type + +Type MyOK Extends TMButton + Method OnPress() + top.Close() + End Method +End Type + +Type MyCancel Extends TMButton + Method OnPress() + Notify("Cancel pressed -- text='" + txtfield.GetText() + "'") + End Method +End Type + +Type MyCheck Extends TMCheckbox + Method OnPress(checked:Int) + Notify("Ticked - " + checked) + End Method +End Type + +Type MyRadio Extends TMRadioButtonSet + Method OnSelected(index:Int) + Notify("Radio changed - " + index) + End Method +End Type + +Type MyTextField Extends TMTextField + Method OnTextChanged(txt:String) + top.StatusText(MilliSecs() + " -- " + txt) + End Method +End Type + +Type MyTextArea Extends TMTextArea + Method SetStatus() + Local s:String="" + s:+"Pos: " + GetCursorColumn() + "," + GetCursorRow() + " " + s:+"Len: " + GetLength() + " " + s:+"[Sel: " + GetSelectionLength() + "," + GetSelectionRows() +"]" + top.StatusText(MilliSecs() + " -- " + s) + End Method + Method OnTextChanged() + SetStatus() + End Method + + Method OnSelection() + SetStatus() + End Method + + Method OnMenu() + Notify("No menu!") + End Method +End Type + +Type MySlider Extends TMSlider + Method OnValueChanged(val:Int) + top.StatusText(MilliSecs() + " -- " + val) + End Method +End Type + +Type MyList Extends TMListBox + Method OnIndexChanged(index:Int) + top.StatusText(MilliSecs() + " -- " + index) + End Method +End Type + +Type MyForward Extends TMButton + Method OnPress() + html.Forward() + End Method +End Type + +Type MyBack Extends TMButton + Method OnPress() + html.Back() + End Method +End Type + +Type MyGo Extends TMButton + Method OnPress() + html.Go(html_url.GetText()) + End Method +End Type + +Type MyHTML Extends TMHTMLView + Method OnPageLoaded(url:String) + top.StatusText(MilliSecs() + " -- Loaded " + url) + End Method + + Method OnSelectURL(url:String) + html_url.Text(url) + End Method +End Type + +Type MyTree Extends TMTreeView + Method OnSelected(path:String, tag:Object) + top.StatusText(MilliSecs() + " -- Selected " + path + " (" + tag.ToString() + ")") + End Method + + Method OnClicked(path:String, tag:Object) + top.StatusText(MilliSecs() + " -- Clicked " + path + " (" + tag.ToString() + ")") + End Method + + Method OnExpanded(path:String, tag:Object) + top.StatusText(MilliSecs() + " -- Expanded " + path + " (" + tag.ToString() + ")") + End Method + + Method OnCollapsed(path:String, tag:Object) + top.StatusText(MilliSecs() + " -- Collapsed " + path + " (" + tag.ToString() + ")") + End Method + + Method OnMenu(path:String, tag:Object) + top.StatusText(MilliSecs() + " -- Menu " + path + " (" + tag.ToString() + ")") + End Method +End Type + +' +' GENERIC SUBCLASSES +' +Type AddToTree Extends TMButton + Method OnPress() + tree.Set(tree_node.GetText(),StripDir(tree_node.GetText())) + End Method +End Type + +Type RemoveFromTree Extends TMButton + Method OnPress() + tree.Remove(tree_node.GetText()) + End Method +End Type + +' +' TEST +' + +If SUBCLASS + top=New MyApp.Create("Test Managed Widgets",100,100,640,400,Null,WINDOW_TITLEBAR|WINDOW_CLIENTCOORDS|WINDOW_STATUS|WINDOW_RESIZABLE|WINDOW_MENU) +Else + top=New TMWindow.Create("Test Managed Widgets",100,100,640,400,Null,WINDOW_TITLEBAR|WINDOW_CLIENTCOORDS|WINDOW_STATUS|WINDOW_RESIZABLE|WINDOW_MENU) + top.OnCloseEvent.Add(OnClose) + top.OnTimerEvent.Add(OnTimer) + top.OnMoveEvent.Add(OnMove) + top.OnResizeEvent.Add(OnResize) +EndIf + +top.MinSize(top.Width(),top.Height()) + +tabs=New TMTabber.Create(0,10,640,390,top) +tabs.SetIconStrip(icons) +tabs.AddItem(CreateListEntry("Buttons",0,0,"Test different button types")) +tabs.AddItem(CreateListEntry("Text",0,1,"Test text entry fields")) +tabs.AddItem(CreateListEntry("Sliders",0,2,"Test sliders")) +tabs.AddItem(CreateListEntry("Lists",0,3,"Test list")) +tabs.AddItem(CreateListEntry("HTML",0,-1,"Test HTML view")) +tabs.AddItem(CreateListEntry("Tree View",0,-1,"Test tree view")) +tabs.AddItem(CreateListEntry("Canvas",0,-1,"Test canvas")) + +If SUBCLASS + ok=New MyOK.CreateOK("OK",10,300,80,30,tabs) + cancel=New MyCancel.CreateCancel("Cancel",100,300,80,30,tabs) + + check=New MyCheck.Create("Checkbox",10,10,100,20,tabs) + + radio1=New TMRadioButton.Create("Radio 1",10,30,100,20,tabs) + radio2=New TMRadioButton.Create("Radio 2",10,50,100,20,tabs) + radio3=New TMRadioButton.Create("Radio 3",10,70,100,20,tabs) + + radio1.Checked(True) + + radios=New MyRadio.Create([radio1,radio2,radio3]) + + txtfield=New MyTextField.Create(90,10,80,20,tabs) + txtarea=New MyTextArea.Create(10,40,620,300,tabs) + + slider1=New MySlider.Create(10,10,15,300,tabs,SLIDER_VERTICAL|SLIDER_SCROLLBAR) + slider2=New MySlider.Create(30,10,300,15,tabs,SLIDER_HORIZONTAL|SLIDER_TRACKBAR) + + list=New MyList.Create(10,10,300,300,tabs) + + html=New MyHTML.Create(10,10,620,300,tabs,HTMLVIEW_NOCONTEXTMENU|HTMLVIEW_NONAVIGATE) + html_url=New TMTextField.Create(10,320,620,20,tabs) + html_go=New MyGo.Create("GO",10,345,90,20,tabs) + html_back=New MyBack.Create("Back",110,345,90,20,tabs) + html_forward=New MyForward.Create("Forward",210,345,90,20,tabs) + + tree=New MyTree.Create(10,10,620,250,tabs) +Else + ok=New TMButton.CreateOK("OK",10,300,80,30,tabs) + cancel=New TMButton.CreateCancel("Cancel",100,300,80,30,tabs) + + check=New TMCheckbox.Create("Checkbox",10,10,100,20,tabs) + + radio1=New TMRadioButton.Create("Radio 1",10,30,100,20,tabs) + radio2=New TMRadioButton.Create("Radio 2",10,50,100,20,tabs) + radio3=New TMRadioButton.Create("Radio 3",10,70,100,20,tabs) + + radio1.Checked(True) + + radios=New TMRadioButtonSet.Create([radio1,radio2,radio3]) + + txtfield=New TMTextField.Create(90,10,80,20,tabs) + txtarea=New TMTextArea.Create(10,40,620,300,tabs) + + slider1=New MySlider.Create(10,10,15,300,tabs,SLIDER_VERTICAL|SLIDER_SCROLLBAR) + slider2=New MySlider.Create(30,10,300,15,tabs,SLIDER_HORIZONTAL|SLIDER_TRACKBAR) + + list=New TMListBox.Create(10,10,300,300,tabs) + + html=New TMHTMLView.Create(10,10,620,300,tabs,HTMLVIEW_NOCONTEXTMENU|HTMLVIEW_NONAVIGATE) + html_url=New TMTextField.Create(10,320,620,20,tabs) + html_go=New TMButton.Create("GO",10,345,90,20,tabs) + html_back=New TMButton.Create("Back",110,345,90,20,tabs) + html_forward=New TMButton.Create("Forward",210,345,90,20,tabs) + + tree=New TMTreeView.Create(10,10,620,250,tabs) + + ok.OnPressEvent.Add(OnPress_OK) + cancel.OnPressEvent.Add(OnPress_Cancel) + check.OnPressEvent.Add(OnPress_Check) + + radios.OnSelectedEvent.Add(OnSelected_Radio) + + txtfield.OnTextChangedEvent.Add(OnTextChanged_Field) + txtarea.OnTextChangedEvent.Add(ShowAreaStatus) + txtarea.OnSelectionEvent.Add(ShowAreaStatus) + txtarea.OnMenuEvent.Add(OnMenu_Area) + + slider1.OnValueChangedEvent.Add(ShowChangedInt) + slider2.OnValueChangedEvent.Add(ShowChangedInt) + list.OnIndexChangedEvent.Add(ShowChangedInt) + + html.OnPageLoadedEvent.Add(OnPageLoaded) + html.OnSelectURLEvent.Add(OnSelectURL) + html_go.OnPressEvent.Add(OnGO) + html_forward.OnPressEvent.Add(OnForward) + html_back.OnPressEvent.Add(OnBack) + + tree.OnSelectedEvent.Add(OnSelected_Tree) + tree.OnClickedEvent.Add(OnClicked_Tree) + tree.OnExpandedEvent.Add(OnExpanded_Tree) + tree.OnCollapsedEvent.Add(OnCollapsed_Tree) + tree.OnMenuEvent.Add(OnMenu_Tree) + +EndIf + +Local label:TMLabel=New TMLabel.Create("Label:",10,10,80,20,tabs) + +list.SetIconStrip(icons) +list.AddItem(CreateListEntry("Item 1",0,0)) +list.AddItem(CreateListEntry("Item 2",0,1)) +list.AddItem(CreateListEntry("Item 3",0,2)) +list.AddItem(CreateListEntry("Item 4",0,3)) + +list.ItemEnabled(2,False) + +tabs.ItemEnabled(4,True) +tabs.ItemEnabled(5,False) +tabs.ItemEnabled(6,False) + +list.SetSelectedIndex(0) + +tree.SetIconStrip(icons) +tree.BeginUpdate() +tree.Set("/dir1","Dir1",0) +tree.Set("/dir2","Dir2",1) +tree.Set("/dir1/ent1","Ent1",2) +tree.Set("/dir1/ent2","Ent2",3) +tree.Set("/dir1/ent3","Ent3",3) +tree.Set("/dir1/ent3","Ent3 (Edit)",3) +tree.EndUpdate() + +html.Go("http://www.noddybox.demon.co.uk") + +tree_node=New TMTextField.Create(10,280,300,20,tabs) +tree_add=New AddToTree.Create("Add",320,280,100,20,tabs) +tree_remove=New RemoveFromTree.Create("Remove",430,280,100,20,tabs) + +tabs.SetPages([ [TMWidget(ok),TMWidget(cancel),TMWidget(check),TMWidget(radio1),TMWidget(radio2),TMWidget(radio3)], .. + [TMWidget(label),TMWidget(txtfield),TMWidget(txtarea)], .. + [TMWidget(slider1),TMWidget(slider2)], .. + [TMWidget(list)], .. + [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)]]) + + +tabs.SetSelectedIndex(0) + +If TESTTIMER + top.SetTimer(1) +EndIf + +MWidgetMainLoop(top) + +End diff --git a/vectorgfx/obj2.2d b/vectorgfx/obj2.2d index 5b31b57..b1936cf 100644 Binary files a/vectorgfx/obj2.2d and b/vectorgfx/obj2.2d differ diff --git a/vectorgfx/test.bmx b/vectorgfx/test.bmx index 0b12e11..191a81b 100644 --- a/vectorgfx/test.bmx +++ b/vectorgfx/test.bmx @@ -8,7 +8,7 @@ Const SCRH=600'1024 SetGraphicsDriver GLMax2DDriver() Graphics SCRW,SCRH,32,60' Or HARDSYNC -'HideMouse() +HideMouse() SetBlend(ALPHABLEND) @@ -45,22 +45,31 @@ o1.y=300 o1.Save("obj1.2d") l.Clear() -l.AddLast(TVectorGfxPoint.Create(-SIZE,0)) -l.AddLast(TVectorGfxPoint.Create(SIZE,0)) +l.AddLast(TVectorGfxPoint.Create(-SIZE/2,-SIZE/2)) +l.AddLast(TVectorGfxPoint.Create(SIZE/2,-SIZE/2)) +l.AddLast(TVectorGfxPoint.Create(SIZE/2,SIZE/2)) +l.AddLast(TVectorGfxPoint.Create(-SIZE/2,SIZE/2)) o2.SetPoints(l.ToArray()) l.Clear() l.AddLast(TVectorGfxLine.Create(0,1,255,255,255,0)) +l.AddLast(TVectorGfxLine.Create(1,2,255,255,255,0)) +l.AddLast(TVectorGfxLine.Create(2,3,255,255,255,0)) +l.AddLast(TVectorGfxLine.Create(3,0,255,255,255,0)) o2.SetLines(l.ToArray()) o2.Save("obj2.2d") 'EndRem -Local o3:TVectorGfxObject=o1.Clone() -o3.x:/2 +Local o3:TList=CreateList() + +For Local f:Int=2 To 40 + Local o:TVectorGfxObject=o1.Clone() + o.x=o1.x/f + o3.AddLast(o) +Next Type FadeLine Extends TVectorGfxLineStyle - Method Draw:Int(x1:Int, y1:Int, x2:Int, y2:Int, r:Int, g:Int, b:Int, id:Int, obj:TVectorGfxObject, line:Int, colmap:TVectorGfxCollisionMap, actor:Int, list:TList) - 'Method Draw:Int(x1:Int, y1:Int, x2:Int, y2:Int, r:Int, g:Int, b:Int, id:Int, colmap:TVectorGfxCollisionMap) + Method LineToCollisionMap:Int(x1:Int, y1:Int, x2:Int, y2:Int, r:Int, g:Int, b:Int, id:Int, obj:TVectorGfxObject, line:Int, colmap:TVectorGfxCollisionMap, actor:Int, list:TList) Local mask:Int=0 Local lp:TList=DoLine(x1,y1,x2,y2) @@ -90,6 +99,21 @@ Type FadeLine Extends TVectorGfxLineStyle b=Max(0,b-10) Next + Return mask + End Method + Method LineToPointList:Int(x1:Int, y1:Int, x2:Int, y2:Int, r:Int, g:Int, b:Int, list:TList) + Local mask:Int=0 + Local lp:TList=DoLine(x1,y1,x2,y2) + + For Local p:TAlgoPoint=EachIn lp + SetColor(r,g,b) + Plot(p.x,p.y) + list.AddLast(TVectorGfxPoint.Create(p.x,p.y)) + r=Max(0,r-10) + g=Max(0,g-10) + b=Max(0,b-10) + Next + Return mask End Method End Type @@ -161,14 +185,6 @@ While Not KeyHit(KEY_ESCAPE) EndIf If KeyHit(KEY_F2) - VectorGfxSetAlpha(0.5,0.5) - EndIf - - If KeyHit(KEY_F3) - VectorGfxSetThickAlpha(0.2) - EndIf - - If KeyHit(KEY_F4) VectorGfxSetCustom(New FadeLine) EndIf @@ -180,16 +196,19 @@ While Not KeyHit(KEY_ESCAPE) o1.scale:-0.1 EndIf - o1.Draw(cm) - o1.ang=(o1.ang+2) Mod 3600 - - o3.Draw(cm) + o1.DrawToCollisionMap(cm) + o1.ang=(o1.ang+10) Mod 3600 + 'o2.ang=(o2.ang+5) Mod 3600 + + For Local o:TVectorGfxObject=EachIn o3 + o.DrawToCollisionMap(cm) + Next o2.x=MouseX() o2.y=MouseY() list.Clear() - o2.Draw(cm,True,list) + o2.DrawToCollisionMap(cm,True,list) SetColor(255,0,255) For Local c:TVectorGfxCollision=EachIn list @@ -205,9 +224,14 @@ While Not KeyHit(KEY_ESCAPE) DrawLine(o1.x+p[0].x,o1.y+p[0].y,o1.x+p[0].x+v.x*20,o1.y+p[0].y+v.y*20) Next - DrawText (MilliSecs()-t) + ":Col=" + o2.Draw(cm),0,0 + SetColor(255,255,255) + DrawText (MilliSecs()-t) + ":Col=" + o2.DrawToCollisionMap(cm),0,0 DrawText MemAlloced(),0,10 + If o1.IsInside(MouseX(),MouseY()) + DrawText "INSIDE!",0,20 + EndIf + Flip FlushMem Wend -- cgit v1.2.3