[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: How do I Draw a rectangle, not a square!
From: |
Marcus G. Daniels |
Subject: |
Re: How do I Draw a rectangle, not a square! |
Date: |
21 Sep 1999 12:10:43 -0700 |
User-agent: |
Gnus/5.070084 (Pterodactyl Gnus v0.84) Emacs/20.4 |
>>>>> "WS" == William S Shu <address@hidden> writes:
WS> I may be missing something, but the following code (swarm 1.4.1)
WS> to draw a rectangle seems to ignore my y1 coordinate, and computes
WS> another so I obtain a square with size (x1-x0), with top-left
WS> positioned at (x0,y0). (x1,y1) is supposed to be bottom-right.
This works for me with 2.0.1 on Windows and X11. (That problem was fixed
shortly after the 1.4.1 release.)
#import <simtools.h>
#import <objectbase/SwarmObject.h>
#import <gui.h>
#import <defobj/defalloc.h> // getZone
#define XSIZE 200
#define YSIZE 200
BOOL quitFlag = NO;
@interface MyClass: SwarmObject
{
id <Colormap> colormap;
id <ZoomRaster> raster;
id <ButtonPanel> panel;
}
- drawRectangle;
@end
@implementation MyClass
- exit
{
quitFlag = YES;
return self;
}
- drawRectangle
{
[raster erase];
[raster rectangleX0: 50 Y0: 50 X1: 150 Y1: 100 Width: 1 Color: 1];
[raster drawSelf];
return self;
}
- zoomIn
{
[raster increaseZoom];
[self drawRectangle];
return self;
}
- zoomOut
{
[raster decreaseZoom];
[self drawRectangle];
return self;
}
- createEnd
{
colormap = [Colormap create: getZone (self)];
[colormap setColor: 0 ToName: "red"];
[colormap setColor: 1 ToName: "green"];
raster = [ZoomRaster create: getZone (self)];
[raster setColormap: colormap];
[raster setWidth: XSIZE Height: YSIZE];
[raster setWindowTitle: "Raster"];
[raster setZoomFactor: 1];
[raster pack];
panel = [ButtonPanel createBegin: getZone (self)];
[panel setButtonTarget: self];
panel = [panel createEnd];
[panel setWindowTitle: "ControlPanel"];
[panel addButtonName: "ZoomIn" method: @selector (zoomIn)];
[panel addButtonName: "ZoomOut" method: @selector (zoomOut)];
[panel addButtonName: "Exit" method: @selector (exit)];
return self;
}
@end
int
main (int argc, const char **argv)
{
id mainObj;
initSwarm (argc, argv);
mainObj = [MyClass create: globalZone];
[mainObj drawRectangle];
while (!quitFlag) { while (GUI_EVENT_ASYNC ()) {} }
}
/*
Local Variables:
compile-command: "$SWARMHOME/bin/libtool-swarm --mode=link gcc -DDLL -o
rectangle -g -Wno-import -I$SWARMHOME/include -L$SWARMHOME/lib rectangle.m
-lswarmdll -lobjcdll"
End:
*/
==================================
Swarm-Support is for discussion of the technical details of the day
to day usage of Swarm. For list administration needs (esp.
[un]subscribing), please send a message to <address@hidden>
with "help" in the body of the message.