Postby ConvertFromOldNGs » Fri Aug 07, 2009 11:14 am
by Craig Shearer >> Wed, 14 Apr 1999 20:06:09 GMT
Hi Dave
Creating a splitter bar in JADE is pretty simple, once you know how to create custom controls, and draw on a parent control!
You'd simply have a frame control that knew how to respond to mouseDown, mouseMove, and mouseUp events and reposition itself accordingly.
I wrote a couple of splitter bar controls a while ago now, including advanced features like the ability to register dependant controls - ie. set up your splitter bar with the controls you want to resize, and have it automatically resize/move them according to where the splitter bar is dragged.
Anyway, here's some stuff you might find useful...
You should draw a rectangle in the mouseMove event to show the user where the splitter bar is being dragged to. Here's how:
drawRect(pos: Real) protected;
vars
begin
parent.drawMode := DrawMode_Xor;
parent.drawWidth := 1;
parent.drawFillStyle := DrawFillStyle_Solid;
parent.drawFillColor := White;
parent.drawFilledRectangle
(
left,top + pos - offset ,
left + width,top + pos - offset + height,
White
);
end;
On the mouseDown event, record the position of the mouse, set some state to say you're in drag mode, and draw the rectangle on the parent control. Then, on each mouse move, redraw the rectangle in the old position (the Xor will cause it to restore the previous pixels) then draw the rectangle in the new position. Finally, on the mouseUp event, move the control to the new position.
Of course, you'd want to have a mouse cursor for the splitter bar control. You can set the mousePointer to a special setting that allows a custom cursor (using a .cur file) as follows:
mousePointer := MousePointer_Icon;
then you'll need to set the mouseCursor property. You'll need to find a way of storing the image somewhere. In our systems, we have a collection of images on the global object, but you could just as easily store in on a form, or even load it from a file...
mouseCursor := app.loadPicture("hSplitter.cur");
Finally, I've included a couple of cursors that you'd probably want to use.
Hope this helps,
Craig.
-
Attachments
-
[The extension cur has been deactivated and can no longer be displayed.]
-
[The extension cur has been deactivated and can no longer be displayed.]
Last edited by
ConvertFromOldNGs on Fri Aug 07, 2009 3:44 pm, edited 1 time in total.