PDA

View Full Version : Help on an extension



Bidmaron
April 20th, 2009, 00:31
I have been trying to get a simple shell of an extension going for several hours, and got very close. Using columnstringfield, etc controls, I couldn't get the offsets from the window background graphic right, so I defined a subwindow and moved all my controls into a windowclass referenced by the subwindow control. Anyway, when I did that, everything vanished. I can no longer see any of my contents. I'm sure I'm doing something very stupid, but I just can't see it. My code is below:


<icon name="gears" file="Programming.png" />
<framedef name="butn">
<bitmap file="button.png" />
<topleft rect="0,0,6,4" />
<top rect="7,0,32,4" />
<topright rect="39,0,6,4" />
<left rect="0,5,6,17" />
<middle rect="7,5,32,17" />
<right rect="39,5,6,17" />
<bottomleft rect="0,22,6,4" />
<bottom rect="7,22,32,4" />
<bottomright rect="39,22,6,4" />
</framedef>
<framedef name="butn_down">
<bitmap file="button_down.png" />
<topleft rect="0,0,6,4" />
<top rect="7,0,32,4" />
<topright rect="39,0,6,4" />
<left rect="0,5,6,17" />
<middle rect="7,5,32,17" />
<right rect="39,5,6,17" />
<bottomleft rect="0,22,6,4" />
<bottom rect="7,22,32,4" />
<bottomright rect="39,22,6,4" />
</framedef>

<template name="framebutton">
<stringcontrol>
<empty>Okay</empty>
<nodrag />
<nodrop />
<nodragselect />
<center />
<font>sheetlabelsmall</font>
<bounds>-46,-27,46,27</bounds>
<frame>
<name>butn</name>
<offset>7,5,7,5</offset>
</frame>
<script>
function onClickDown(button,x,y)
if button == 1 then
setFrame(butn_down,7,5,7,5);
return true;
end
end
function onClickRelease(button,x,y)
if button == 1 then
if self.onClicked then
self.onClicked();
end
setFrame(butn,7,5,7,5);
return true;
end
end
</script>
</stringcontrol>
</template>

<windowclass name="debug_stuff">
<sheetdata>
<columnstringfield name="charout">
<empty>?</empty>
</columnstringfield>
<columnfieldlabel>
<anchor>charout</anchor>
<static>Character</static>
</columnfieldlabel>
<columnstringfield name="font">
<anchor>charout</anchor>
</columnstringfield>
<columnfieldlabel>
<anchor>font</anchor>
<static>Font</static>
</columnfieldlabel>

<columnnumberfield name="ascii">
<anchor>charout</anchor>
<empty>128</empty>
<script>
</script>
</columnnumberfield>
<columnfieldlabel>
<anchor>ascii</anchor>
<static>Ascii</static>
</columnfieldlabel>
<framebutton name="render">
<static>Render</static>
<script>
function onClicked()
window.getDatabaseNode().getChild("char").setValue(string.char(window.getDatabaseNode().ge tChild("ascii").getValue()));
end

</script>
</framebutton>
</sheetdata>
</windowclass>

<windowclass name="programlist">
<frame>storybox</frame>
<dynamic />
<datasource>debug</datasource>
<placement>
<size>
<width>275</width>
<height>350</height>
</size>
</placement>
<sizelimits>
<dynamic />
<minimum>
<width>200</width>
<height>220</height>
</minimum>
</sizelimits>
<nodelete />
<sheetdata>
<subwindow name="stuff">
<bounds>22,22,-22,-22</bounds>
<class>debug_stuff</class>
</subwindow>
</sheetdata>
</windowclass>

<script name="programminginit">
function onInit()
if not User.isLocal() and User.isHost() then
if DB.findNode("Debug") then
DesktopManager.registerDockShortcut("gears", "gears", "Programming", "programlist", " ");
end
end
end
</script>

I appreciate the help.

If you're curious, what the code is attempting to do is to put the character from a given font into the charout field. The user would input the ascii value he wanted in the ascii area. If I can get this working, I intend to make a <Next> button that would automatically increment the ascii value and update the charout field accordingly. Then I intend to get fancy and output a table of ascii values and characters from the given font. I'm putting all this in a debugging extension, and the onInit check above is to look for a global node 'Debug' and only display the extension if the node exists.

Ultimately, I'd like to make this much more useful and offer a place where you could insert debuging calls in your code to display in fields of the debugger (I envision something like Debug(output,segment), where you could, through the debugger, turn on and off different segments throughout your code. The Debug would place the variable or constant contents into a scrolling output window. I could even get fancy (I think) by using onUpdate to define the equivalent of watch nodes like a fancier debugger.

Foen
April 20th, 2009, 06:20
I think you need an <activate/> tag in the subwindow to make it visible.

The debug project sounds very interesting, and it is something that is sorely needed in FG (using print() calls isn't that great).

Cheers

Foen

Bidmaron
April 20th, 2009, 10:59
Boy, do I feel stupid. Figured it would be something like that.