2004-02-03 08:31:26 +00:00
|
|
|
#include "draw.h"
|
|
|
|
|
|
|
|
#include "gui/Slider.h"
|
|
|
|
#include "gui/Rect.h"
|
|
|
|
|
|
|
|
@implementation Slider
|
|
|
|
|
2011-03-25 07:46:32 +00:00
|
|
|
- (id) initWithBounds: (Rect)aRect size: (int) aSize
|
2004-02-03 08:31:26 +00:00
|
|
|
{
|
2004-02-13 02:51:38 +00:00
|
|
|
self = [self initWithBounds:aRect];
|
2004-02-03 08:31:26 +00:00
|
|
|
dir = ylen > xlen;
|
|
|
|
size = aSize;
|
|
|
|
index = 0;
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
2011-03-25 07:46:32 +00:00
|
|
|
- (void) setIndex: (int) ind
|
2004-02-03 08:31:26 +00:00
|
|
|
{
|
|
|
|
index = ind;
|
|
|
|
if (index < 0)
|
|
|
|
index = 0;
|
|
|
|
if (index > size)
|
|
|
|
index = size;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) draw
|
|
|
|
{
|
2011-03-25 07:46:32 +00:00
|
|
|
local int pos, x, y;
|
2004-02-03 08:31:26 +00:00
|
|
|
|
2004-02-03 13:33:16 +00:00
|
|
|
pos = (index * ((dir ? ylen : xlen) - 24) / size) + 8;
|
2004-02-03 08:31:26 +00:00
|
|
|
if (dir) {
|
|
|
|
Draw_Character (xabs, yabs, 1);
|
|
|
|
for (y = 8; y < ylen - 8; y += 8)
|
|
|
|
Draw_Character (xabs, yabs + y, 2);
|
|
|
|
Draw_Character (xabs, yabs + y, 3);
|
|
|
|
Draw_Character (xabs, yabs + pos, 131);
|
|
|
|
} else {
|
|
|
|
Draw_Character (xabs, yabs, 128);
|
|
|
|
for (x = 8; x < xlen - 8; x += 8)
|
|
|
|
Draw_Character (xabs + x, yabs, 129);
|
|
|
|
Draw_Character (xabs + x, yabs, 130);
|
|
|
|
Draw_Character (xabs + pos, yabs, 131);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@end
|