Several Requester functions have been added to support user-drawing features
in the panel. The drawing functions can be called only from within the
script’s redraw callback.
drawpixel
The drawpixel() function draws a pixel on the panel at the specified point
using the specified color.
prototype:
void
drawpixel(<color>,xPos,yPos)
<color> vector;
color of the pixel to be drawn.
xPos integer;
X coordinate of the pixel.
yPos integer;
Y coordinate of the pixel.
example:
drawpixel(<200,200,200>,
10, 10);
drawline
The drawline() function draws a line on the panel between the specified
points using the specified color.
prototype:
void
drawline(<color>, x1, y1, x2, y2)
<color>
vector;
the color of the line to be drawn.
x1
integer;
x coordinate of the starting point.
y1
integer;
y coordinate of the starting point.
x2
integer;
x coordinate of the ending position.
y2
integer;
y coordinate of the ending position.
example:
drawline(<200,200,200>,
10, 10, 50, 50);
drawbox
The drawbox() function draws a box filled with the specified color and
the specified width and height. The box is positioned at the specified
point.
prototype:
void
drawbox(<color>, xPos, yPos, width, height)
xPos
integer;
X coordinate of the box’s starting corner.
yPos
integer;
Y coordinate of the box’s starting coordinate.
width
integer;
width of the box.
height
integer,
height of the box.
example:
drawbox(<200,200,200>,
10, 10, 50, 50);
drawborder
The drawborder() function draws an unfilled, 3D box outline at the specified
point using the specified width and height. If height is 0, then a horizontal
divider line is drawn. The drawborder() Requester redraw function accepts
a fifth optional Boolean argument that indicates the indentation of the
border to be drawn. If omitted (or false), then the border is draw with
a "raised" look. If true, then the border has a "sunken"
look.
prototype:
void
drawborder(xPos, yPos, width, height, bool)
xPos
integer;
X coordinate of the starting point.
yPos
integer;
Y coordinate of the starting point.
width
integer;
width of the border.
height
integer;
height of the border.
bool
Boolean;
controls the 3D look of the box.
example:
drawborder(5,
5, 100, 100, true);
drawtext
The drawtext() function draws the provided text using the specified color
at the specified point.
prototype:
void
drawtext(text, <color>, xPos, yPos)
text
string;
The text to be drawn.
<color>
vector;
The color of the text to be drawn.
xPos
integer;
x coordinate to place text.
yPos
integer;
y coordinate to place text.
example:
drawtext("I’m
drawing text", <200,200,200>, 10, 10);
drawtextwidth
drawtextheight
drawtextwidth() and drawtextheight(), have been
added to determine the display width and height, in pixels, of a text
string. They each take a single character string, and return an
integer value representing this pixel width or height.
drawerase
The drawerase() function takes the X and Y position, and the width and
height, of the area to be erased on the Requester panel.
prototype:
void
drawerase(xPos, yPos, width, height)
xPos:
integer,
x Position of the starting corner.
yPos:
integer,
y Position of the starting corner.
width:
integer,
width of the area to be erased.
height: integer,
height of the area to be erased.
example:
drawerase(10,10,50,25);
drawcircle(<color>,xcentre,ycentre,radius)
drawfillcircle(<bordercolour>,<fill color>,xcentre,ycentre,radius)
drawellipse(<colour>,xcentre,ycentre,xradius,yradius)
drawfillellipse(<bordercolour>,<fill color>,xcentre,ycentre,xradius,yradius)
Mouse Object Agent
The
Mouse functions now take a single Object Agent argument that wraps all
available parameters into a single package. This Object Agent
exports the following data members:
ctl the Control Object
Agent involved in the event ('nil' if none)
x X position of the event
y Y position of the event
button which mouse button triggered the
event; 1=LMB, 2=MMB, 3=RMB
count the click count;
1=single-click, 2=double-click
keys[3] indicates key active modifiers;
[1]=CTRL, [2]=SHIFT, [3]=ALT
The Object Agent currently exports no public methods.
...
reqmousemove: md
{
if(md.ctl)
{
vp_x = md.x - md.ctl.x + md.ctl.xoffset;
...
reqmousemove when the mouse moves around.
reqmousedown when a button is pressed.
reqmouseup when a button is released.
reqmousetrack when the mouse moves with holding a button.
all of them generate the same object agent, with all these features.
But the MOVE function will not be activated, when someone clicks with a
still mouse. Makes it kind of icky to use, since most people stop
before clicking somewhere... Thats why its important to put clicking
actions in the DOWN functions.
Vice versa, you can get a pretty good value out of md.button when it
appears in the MOVE function, because that means someone is dragging
while holding a button.
TRACK is kind of weird, since it is essentially the same as MOVE. One
difference I found, though, is that MOVE is called while someone drags
a minislider, but TRACK isn't. Weird.
I could use it to my advantage to find out if someone has just released
a minislider, to switch back from a preview mode to applying the actual
effect of that minislider.
Dunno if it helps, but here are some code snippets from my dragn drop:
Code:
reqmousetrack: md // catch if the minislider is just released { if(c13.value != editGam) { quick = false; setvalue(c13,editGam); } }
reqmousemove: md //_______ TRACK in window { if(md.y >= 90 && md.y <= 390 && md.x >= 20 && md.x <= 620 && xxx != 0) { if(md.button == 1) // LMB { getPickerInfo(md); } else if(md.button == 3 && rmbClick_x != nil) // RMB { t = Langle[xxx] + (md.x - rmbClick_x)/100; Langle[xxx] = max(min(t,1.5),0.001); rmbClick_x = md.x;
normalizeLights(); helpmessage = "Coverage Radius = " + Langle[xxx] + " , Light Intensity = " + round(Lint[xxx]*normalFactor,4) + "%";
requpdate(c1,c2); setvalue(c2,lb_name(xxx)); } } else if(md.button == 1 && md.y >= 391 && md.y <= 421 && md.x >= 20 && md.x <= 620 && xxx != 0) // rollover toolbar { curs = false; Lx[xxx] = md.x - 20; Ly[xxx] = md.y - 90; if(md.y >= 394 && md.y <= 415 && md.x >= 550 && md.x <= 566) // trashcan { clearLight(); } requpdate(c1); } } }
reqmousedown: md //_______ CLICK { if(about) { about = false; requpdate(); } else { if(md.y <= 45) // click in title { about = !about; requpdate(c1); } if(md.y >= 90 && md.y <= 390 && md.x >= 20 && md.x <= 620 && imgPICK) { if(LightNum > 0) // ______ select a Light { dx1 = md.x - 24; dx2 = md.x - 16; dy1 = md.y - 94; dy2 = md.y - 86;
for(i = 1; i <= LightNum; i++) { // found = false; if(Lx[i] >= dx1 && Lx[i] <= dx2 && Ly[i] >= dy1 && Ly[i] <= dy2) { xxx = i; setvalue(c2,lb_name(xxx)); requpdate(c2); f = true; } } } if(!f) // nothing selected, make new one { LightNum = LightNum + 1; xxx = LightNum; Lx[xxx] = md.x - 20; Ly[xxx] = md.y - 90; Lphi[xxx] = 1; Ltheta[xxx] = 1; Langle[xxx] = 0.2; Lint[xxx] = 1; Lcol[xxx] = <0,0,0>; Llumi[xxx] = 0.2; f = false; } if(md.button == 3) // RMB Click { rmbClick_x = md.x; rmbClick_y = md.y; } getPickerInfo(md); } if(md.button == 1 && md.y >= 391 && md.y <= 421 && md.x >= 550 && md.x <= 566 && md.count == 2) { // double click on trashcan clearAllLights(true); } } }
|