I just created the longest variable name I have ever used
window_client_tabber_network_controls_toolbar_refresh_itemid:Int = 0
Enjoy!
window_client_tabber_network_controls_toolbar_refresh_itemid:Int = 0
Enjoy!
'### gui ### Const _imageroot:String = "images/" Const _imageformat:String = ".png" Global window:tgadget = CreateWindow("Master admin",10,10,500,500,Null,WINDOW_TITLEBAR) Global window_status:tgadget = CreatePanel(0,ClientHeight(window)-20,ClientWidth(window),20,window)',PANEL_BORDER) Global window_client:tgadget = CreatePanel(0,0,ClientWidth(window),ClientHeight(window)-GadgetHeight(window_status),window) Global window_client_tabber:tgadget = CreateTabber(0,0,ClientWidth(window_client),ClientHeight(window_client),window_client) 'network tab Const window_client_tabber_network_itemid:Int = 0 AddGadgetItem(window_client_tabber,"Network",GADGETITEM_NORMAL,-1,"Browse the network") Global window_client_tabber_network:tgadget = CreatePanel(0,0,ClientWidth(window_client_tabber),ClientHeight(window_client_tabber),window_client_tabber) HideGadget(window_client_tabber_network) 'network controls Global window_client_tabber_network_controls:tgadget = CreatePanel(0,-2,ClientWidth(window_client_tabber_network),24,window_client_tabber_network) Global window_client_tabber_network_controls_toolbar:tgadget = CreateToolBar(_imageroot+"network_controls"+_imageformat,0,0,ClientWidth(window_client_tabber_network_controls),ClientHeight(window_client_tabber_network_controls),window_client_tabber_network_controls) SetToolBarTips(window_client_tabber_network_controls_toolbar,["Refresh the network structure"]) 'network control toolbar buttons Const window_client_tabber_network_controls_toolbar_refresh_itemid:Int = 0 'networks treeview Global window_client_tabber_network_treeview:tgadget = CreateTreeView(0,GadgetHeight(window_client_tabber_network_controls),ClientWidth(window_client_tabber_network),ClientHeight(window_client_tabber_network)-GadgetHeight(window_client_tabber_network_controls),window_client_tabber_network) Global window_client_tabber_network_treeview_icons:ticonstrip = LoadIconStrip(_imageroot+"network_treeview"+_imageformat) SetGadgetIconStrip(window_client_tabber_network_treeview,window_client_tabber_network_treeview_icons) Global window_client_tabber_network_treeview_root:tgadget = TreeViewRoot(window_client_tabber_network_treeview) Global window_client_tabber_network_treeview_root_master:tgadget = AddTreeViewNode("master",window_client_tabber_network_treeview_root,0) 'logs tab Const window_client_tabber_logs_itemid:Int = 1 AddGadgetItem(window_client_tabber,"Logs",GADGETITEM_NORMAL,-1,"View logs") Global window_client_tabber_logs:tgadget = CreatePanel(0,0,ClientWidth(window_client_tabber),ClientHeight(window_client_tabber),window_client_tabber) HideGadget(window_client_tabber_logs)
Global window_client_tabber_network_treeview:tgadget =.. CreateTreeView(.. 0,.. GadgetHeight(window_client_tabber_network_controls),.. ClientWidth(window_client_tabber_network),.. ClientHeight(window_client_tabber_network)-GadgetHeight(window_client_tabber_network_controls),.. window_client_tabber_network)
SuperStrict Type network Field blah:Int End Type Type tabber Field net:network = New network End Type Type window_client Field tab:tabber = New tabber End Type Local win:window_client = New window_client win.tab.net.blah = 50
Function DefineKey() Rem After a lot of fidgetting (and a regrettable dropping of a great bit of automagic code), the plan here is currently as follows: Any code can define these Keys, which are used to identify chunks of data for Extensions. For example, the model loader base could define a Key for MODELLOADER_FileType. Any Extension could then apply a value to that key in their ExtensionData. At the moment, an extension function depending on a container which does not exist will simply not work. I am hoping that it will eventually be possible to actually disable such extensions automatically with the help of a precompiler... This definition of keys could be entirely done in a precompiler, and I am hoping to get it that way some day. Syntax to call this function is very primitive: Global MyKey=TExtensionData.DefineKey() Note that if other bits of programs are to have access to your key (which they should), then you need to define it as a Global. It works, and no it is not remotely cool :( The idea here is abstraction at its simplest, I guess. Some day, if these things get more advanced, it won't be a problem to toss some more stuff into this little Keys "system". End Rem KeysCount=KeysCount+1 'Heh, kind of anticlimactic? Return KeysCount End Function
Global gmain:_gmain = _gmain.create() Type _gmain Field window:gwindow Field tabber:gtabber Const networktoolbar:Int = 0 Function hookupdate_networktab:Int() 'this function is hooked by the update function Select EventSource() Case gmain.i.tabber Select EventID() Case EVENT_ACTION gmain.tabber.changetab(EventData()) End Select Case gmain.tabber.tabs[0].gadgets[0] 'toolbar event Select EventID() Case EVENT_ACTION 'user has requested network information 'disable refresh button gmain.tabber.tabs[0].gadgets[0].disablebutton(0) 'clear the tree nodes tnetworktree.instance.clear() 'request list of servers from the master tcpc_master.sendcommand(_command_adminrequestservers) End Select Case gmain.i.tabber.tabs[0].gadgets[1] 'tree view event Select EventID() Case EVENT_ACTION 'check if server / peer info window Local temp_peer:tnetworktree_peer = tnetworktree.instance.findpeerfromgadget(tgadget(EventExtra())) If temp_peer CreatePeerWindow(nip,nport) End If End Select End Select End Function Function create:_gmain() Local window:_gmain = New _gmain window.window = gwindow.create("Master admin",[10,10,500,500]) window.tabber = gtabber.create(window.insiderect(),window) 'network tab window.tabber.addtab("Network","Browse the network") window.tabber.tabs[0].addgadget(gtoolbar.create([0,0,window.tabber.tabs[0].insidewidth(),24],window.tabber.tabs[0],imagepath_networktoolbar,"Refresh the network")) window.tabber.tabs[0].addgadget(gtreeview.create([0,window.tabber.tabs[0].gadgets[0].outerheight(),window.tabber.tabs[0].innerwidth,window.tabber.tabs[0].innerheight()-window.tabber.tabs[0].gadgets[0].outerheight()],window.tabber.tabs[0],iconstrip_networktreeview)) window.tabber.tabs[0].gadget[1].addnode("master",0) 'window.tabber.tabs[0].setupdatehook( 'log tab window.tabber.addtab("Logs","View traffic logs") window.tabber.tabs[1].addgadget(gtextarea.create(window.tabber.tabs[0].innerrect(),window.tabber.tabs[1],True)) Return window End Function End Type
Import BRL.Win32MaxGUI Import BRL.EventQueue Type ggadget Abstract Global list:TList = CreateList() Field gadgets:ggadget[] Field gadget:tgadget Field _hookupdate:Int() Method update:Int() 'this function should return true if it wants to halt gui updates If _hookupdate <> Null Return _hookupdate() 'scan through all gadgets until a return was matched If gadgets.length > 0 Local temp_i:Int For temp_i = 0 Until gadgets.length If gadgets[temp_i].update() Return True Next End If End Method Method setupdatehook:Int(nhook:Int()) _hookupdate = nhook End Method Method show:Int() ShowGadget(Gadget) End Method Method hide:Int() HideGadget(gadget) End Method Method enable:Int() EnableGadget(gadget) End Method Method disable:Int() DisableGadget(gadget) End Method Method insidex:Int() Return 0 End Method Method insidey:Int() Return 0 End Method Method insidewidth:Int() Return ClientWidth(gadget) End Method Method insideheight:Int() Return ClientHeight(gadget) End Method Method outsidex:Int() Return GadgetX(gadget) End Method Method outsidey:Int() Return GadgetY(gadget) End Method Method outsidewidth:Int() Return GadgetWidth(gadget) End Method Method outsideheight:Int() Return GadgetHeight(gadget) End Method Method insiderect:Int[](noffsetx:Int=0,noffsety:Int=0,noffsetw:Int=0,noffseth:Int=0) Return [0+noffsetx,0+noffsety,ClientWidth(gadget)+noffsetw,ClientHeight(gadget)+noffseth] End Method Method outsiderect:Int[](noffsetx:Int=0,noffsety:Int=0,noffsetw:Int=0,noffseth:Int=0) Return [GadgetX(gadget)+noffsetx,GadgetY(gadget)+noffsety,ClientWidth(gadget)+noffsetw,ClientHeight(gadget)+noffseth] End Method Method addgadget:Int(ngadget:ggadget) Local temp_slot:Int = gadgets.length gadgets = gadgets[..temp_slot+1] gadgets[temp_slot] = ngadget Return temp_slot End Method End Type Type gwindow Extends ggadget Field window:tgadget Function create:gwindow(ntitle:String,nrect:Int[],nparent:ggadget=Null,nstyle:Int=WINDOW_TITLEBAR) Local window:gwindow = New gwindow Local temp_parent:tgadget = Null If nparent <> Null temp_parent = nparent.gadget window.window = CreateWindow(ntitle,nrect[0],nrect[1],nrect[2],nrect[3],temp_gadget,nstyle) window.gadget = CreatePanel(nrect[0],nrect[1],nrect[2],nrect[3],window.window) SetGadgetLayout(window.gadget,EDGE_ALIGNED,EDGE_ALIGNED,EDGE_ALIGNED,EDGE_ALIGNED) Return window End Function End Type Type gtoolwindow Extends ggadget Field window:tgadget Function create:gtoolwindow(ntitle:String,nrect:Int[],nparent:ggadget=Null,nstyle:Int=WINDOW_TITLEBAR) Local window:gtoolwindow = New gtoolwindow Local temp_parent:tgadget = Null If nparent <> Null temp_parent = nparent.gadget window.window = CreateWindow(ntitle,nrect[0],nrect[1],nrect[2],nrect[3],temp_gadget,nstyle | WINDOW_TOOL) window.gadget = CreatePanel(nrect[0],nrect[1],nrect[2],nrect[3],window.window) SetGadgetLayout(window.gadget,EDGE_ALIGNED,EDGE_ALIGNED,EDGE_ALIGNED,EDGE_ALIGNED) Return window End Function End Type Type gtabber Extends ggadget Field selected:Int = -1 Field icons:ticonstrip Field tabs:gtab[] Method addtab:gtab(ntitle:String,ntip:String="",nicon:Int=-1) 'create a new tab ggadget Local tab:gtab = New gtab 'setup the tab tab.slot = tabs.length tab.gadget = CreatePanel(0,0,ClientWidth(gadget),ClientHeight(gadget),gadget) SetGadgetLayout(tab.gadget,EDGE_ALIGNED,EDGE_ALIGNED,EDGE_ALIGNED,EDGE_ALIGNED) 'resize tabs array for this new tab tabs = tabs[..tab.slot+1] tabs[tab.slot] = tab 'add tab to tabber AddGadgetItem(gadget,ntitle,0,nicon,ntip) 'hide the tab unless it is only current active tab in tabber If tabs.length > 1 tab.hide() Else selected = 0 End If Return tab End Method Method changetab:Int(ntab:Int) If ntab > tabs.length Or ntab = selected Return False Local temp_i:Int tabs[selected].hide() tabs[ntab].show() End Method Function create:gtabber(nrect[],nparent:ggadget=Null,nicons:Object=Null) Local tabber:gtabber = New gtabber Local temp_parent:tgadget = Null If nparent <> Null temp_parent = nparent.gadget tabber.gadget = CreateTabber(nrect[0],nrect[1],nrect[2],nrect[3],temp_parent,nstyle) Local iconstrip:ticonstrip = ticonstrip(nicons) If iconstrip = Null tabber.icons = LoadIconStrip(String(nicons)) Else tabber.icons = ticonstrip(nicons) End If If tabber.icons SetGadgetIconStrip(tabber.gadget,tabber.icons) SetGadgetLayout(tabber.gadget,EDGE_ALIGNED,EDGE_ALIGNED,EDGE_ALIGNED,EDGE_ALIGNED) Return tabber End Function End Type Type gtab Extends ggadget Field slot:Int End Type Type glistbox Extends ggadget Field icons:ticonstrip Function create:glistbox(nrect[],nparent:ggadget=Null,nicons:Object=Null) Local listbox:glistbox = New glistbox Local temp_parent:tgadget = Null If nparent <> Null temp_parent = nparent.gadget Local iconstrip:ticonstrip = ticonstrip(nicons) If iconstrip = Null listbox.icons = LoadIconStrip(String(nicons)) Else listbox.icons = ticonstrip(nicons) End If listbox.gadget = CreateListBox(nrect[0],nrect[1],nrect[2],nrect[3],temp_parent) If listbox.icons SetGadgetIconStrip(listbox.gadget,listbox.icons) Return listbox End Function End Type Type gtoolbar Extends ggadget Field toolbar:tgadget Function enablebutton:Int(nbutton:Int) EnableGadgetItem(toolbar,nbutton) End Function Function disablebutton:Int(nbutton:Int) DisableGadgetItem(toolbar,nbutton) End Function Function create:gtoolbar(nrect[],nparent:ggadget=Null,nicons:String="",ntips:String[]=Null) Local toolbar:gtoolbar = New gtoolbar Local temp_parent:tgadget = Null If nparent <> Null temp_parent = nparent.gadget toolbar.gadget = CreatePanel(nrect[0],nrect[1],nrect[2],nrect[3],nparent.gadget) SetGadgetLayout(toolbar.toolbar,EDGE_ALIGNED,EDGE_ALIGNED,EDGE_ALIGNED,EDGE_ALIGNED) If ntips SetToolBarTips(toolbar.toolbar,ntips) Return toolbar End Function End Type Type gtreeview Extends ggadget Field icons:ticonstrip Field nodes:gtreeviewnode[] Method addnode:Int(ntitle:String,nicon:Int=-1) Local node:gtreeviewnode = New gtreeviewnode node.parent = TreeViewRoot(gadget) node.gadget = AddTreeViewNode(ntitle,node.parent,nicon) Local temp_slot:Int = nodes.length nodes = nodes[..temp_slot+1] nodes[temp_slot] = node Return temp_slot End Method Function create:gtreeview(nrect[],nparent:ggadget=Null,nicons:Object=Null) Local treeview:gtreeview = New gtreeview Local temp_parent:tgadget = Null If nparent <> Null temp_parent = nparent.gadget treeview.gadget = CreateTreeView(nrect[0],nrect[1],nrect[2],nrect[3],temp_parent) Local iconstrip:ticonstrip = ticonstrip(nicons) If iconstrip = Null treeview.icons = LoadIconStrip(String(nicons)) Else treeview.icons = ticonstrip(nicons) End If If treeview.icons SetGadgetIconStrip(treeview.gadget,treeview.icons) Return treeview End Function End Type Type gtreeviewnode Field parent:tgadget Field gadget:tgadget Field nodes:gtreeviewnode[] Method addnode:Int(ntitle:String,nicon:Int=-1) Local node:gtreeviewnode = New gtreeviewnode node.parent = gadget node.gadget = AddTreeViewNode(ntitle,node.parent,nicon) Local temp_slot:Int = nodes.length nodes = nodes[..temp_slot+1] nodes[temp_slot] = node Return temp_slot End Method End Type Type gtextarea Extends ggadget Function create:gtextarea(nrect[],nparent:ggadget=Null,nreadonly:Int=False) Local textarea:gtextarea = New gtextarea Local temp_parent:tgadget = Null If nparent <> Null temp_parent = nparent.gadget If nreadonly = False textarea.gadget = CreateTextArea(nrect[0],nrect[1],nrect[2],nrect[3],temp_parent) Else textarea.gadget = CreateTextArea(nrect[0],nrect[1],nrect[2],nrect[3],temp_parent,TEXTAREA_READONLY) End If Return textarea End Function End Type