Product Information > JADE Encyclopaedia of Classes – Volume 3 > Chapter 2 - Window Classes > drawDeskTopRectangle

drawDeskTopRectangle

drawDeskTopRectangle(pattern: Integer;
                     x1:      Integer;
                     y1:      Integer;
                     x2:      Integer;
                     y2:      Integer;
                     color:   Integer;
                     width:   Integer);

The drawDeskTopRectangle method of the Window class displays a dragging rectangle on the screen over any window that is displayed.

The image consists of a rectangle with a pattern drawn just inside the rectangle. As this method draws over the top of anything on the screen using an Xor draw mode, call the method twice using the same parameters to display the original screen image again.

The parameters for the drawDeskTopRectangle method are listed in the following table.

Parameter Description
pattern 0 (hatch style 45 degrees left to right)
  1 (cross-hatch)
  2 (45 degree cross-hatch)
  3 (hatch style 45 degrees right to left)
  4 (horizontal)
  5 (vertical)
  Any other value means that the bounding rectangle only is drawn
x1, y1 Left and top corner positions of rectangle, respectively, in pixels relative to the client area of the window
x2, y2 Right and bottom corner positions of rectangle, respectively, in pixels relative to the client area of the window
color Color with which to draw the rectangle
width Width of the inner area of the rectangle drawn with the pattern specified in the pattern parameter

If the width of the border area is greater than or equal to the width or height of the rectangle being drawn, the entire rectangle is filled with the specified pattern.

The methods in the following examples (in which inDragOver: Boolean, lastMouseX: Integer, and lastMouseY: Integer are form properties) show the use of this method to draw a dragging rectangle when the user drags the mouse over the ListBox control.

listBox1_dragOver(listBox: ListBox;
                  win:     Window;
                  x, y:    Real;
                  state:   Integer) updating;
vars
    w : Integer;
    h : Integer;
begin
    w := (listBox.clientWidth/2).Integer;
    h := (listBox.clientHeight/2).Integer;
    if inDragOver then
        // remove previous drawn rectangle
        listBox.drawDeskTopRectangle(0, lastMouseX - w, lastMouseY - h,
                                    lastMouseX + w, lastMouseY + h, Red, 4);
        if state = 2 then           // drag dropped
            inDragOver := false;
            return;
        endif;
    endif;
    // draw in new position
    inDragOver := true;
    lastMouseX := x.Integer;
    lastMouseY := y.Integer;
    listBox.drawDeskTopRectangle(0, lastMouseX - w, lastMouseY - h,
                                 lastMouseX + w, lastMouseY + h, Red, 4);
end;

listBox1_dragDrop(listBox: ListBox; win: Window; x, y: Real) updating;
begin
    if inDragOver then
        listBox1_dragOver(listBox, win, x, y, 2);
    endif;
end;