2004-02-13 05:36:35 +00:00
|
|
|
#include "draw.h"
|
2004-02-03 08:31:26 +00:00
|
|
|
#include "gui/InputLine.h"
|
|
|
|
#include "gui/Rect.h"
|
2002-08-20 21:19:53 +00:00
|
|
|
|
2002-08-15 21:00:51 +00:00
|
|
|
inputline_t (integer lines, integer size, integer prompt) InputLine_Create = #0;
|
2011-02-14 13:13:55 +00:00
|
|
|
void InputLine_SetUserData (inputline_t il, void *data) = #0;
|
2002-08-15 21:00:51 +00:00
|
|
|
void (inputline_t il, integer width) InputLine_SetWidth = #0;
|
|
|
|
void (inputline_t il) InputLine_Destroy = #0;
|
2002-08-28 16:02:43 +00:00
|
|
|
void (inputline_t il, integer size) InputLine_Clear = #0;
|
2002-08-15 21:00:51 +00:00
|
|
|
void (inputline_t il, integer ch) InputLine_Process = #0;
|
2002-08-20 21:19:53 +00:00
|
|
|
void (inputline_t il) InputLine_Draw = #0;
|
2002-08-15 21:00:51 +00:00
|
|
|
void (inputline_t il, string str) InputLine_SetText = #0;
|
|
|
|
string (inputline_t il) InputLine_GetText = #0;
|
|
|
|
|
|
|
|
@implementation InputLine
|
|
|
|
|
2002-08-17 05:27:34 +00:00
|
|
|
- (id) initWithBounds: (Rect)aRect promptCharacter: (integer)char
|
2002-08-15 21:00:51 +00:00
|
|
|
{
|
2004-02-13 05:36:35 +00:00
|
|
|
self = [super initWithComponents:aRect.origin.x :aRect.origin.y :aRect.size.width * 8 :8];
|
|
|
|
control.x = xpos;
|
|
|
|
control.y = ypos;
|
2003-05-06 02:19:13 +00:00
|
|
|
control.xbase = control.ybase = 0;
|
2002-08-20 21:19:53 +00:00
|
|
|
control.cursor = NO;
|
2002-08-17 05:27:34 +00:00
|
|
|
|
2002-08-20 21:19:53 +00:00
|
|
|
il = InputLine_Create (aRect.size.height, aRect.size.width, char);
|
|
|
|
InputLine_SetUserData (il, &control);
|
2002-08-17 05:27:34 +00:00
|
|
|
|
|
|
|
return self;
|
2002-08-15 21:00:51 +00:00
|
|
|
}
|
|
|
|
|
2004-02-13 05:36:35 +00:00
|
|
|
- (void) dealloc
|
2002-08-15 21:00:51 +00:00
|
|
|
{
|
2002-08-17 05:27:34 +00:00
|
|
|
InputLine_Destroy (il);
|
2004-02-13 05:36:35 +00:00
|
|
|
[super dealloc];
|
2002-08-15 21:00:51 +00:00
|
|
|
}
|
|
|
|
|
2004-02-04 02:35:57 +00:00
|
|
|
- (void) setBasePos: (Point)pos
|
2003-05-06 02:19:13 +00:00
|
|
|
{
|
2004-02-04 02:35:57 +00:00
|
|
|
[super setBasePos:pos];
|
|
|
|
control.xbase = pos.x;
|
|
|
|
control.ybase = pos.y;
|
2003-05-06 02:19:13 +00:00
|
|
|
}
|
|
|
|
|
2004-11-10 04:09:00 +00:00
|
|
|
- (void) setWidth: (integer)width
|
2002-08-15 21:00:51 +00:00
|
|
|
{
|
2002-08-17 05:27:34 +00:00
|
|
|
InputLine_SetWidth (il, width);
|
2002-08-15 21:00:51 +00:00
|
|
|
}
|
|
|
|
|
2002-08-17 05:27:34 +00:00
|
|
|
- (void) processInput: (integer)key
|
2002-08-15 21:00:51 +00:00
|
|
|
{
|
|
|
|
InputLine_Process (il, key);
|
|
|
|
}
|
|
|
|
|
2004-02-13 05:36:35 +00:00
|
|
|
- (void) cursor: (BOOL)cursor
|
2002-08-15 21:00:51 +00:00
|
|
|
{
|
2002-08-20 21:19:53 +00:00
|
|
|
control.cursor = cursor;
|
2004-02-13 05:36:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void) draw
|
|
|
|
{
|
2002-08-20 21:19:53 +00:00
|
|
|
InputLine_Draw (il);
|
2002-08-15 21:00:51 +00:00
|
|
|
}
|
|
|
|
|
2003-04-22 15:48:39 +00:00
|
|
|
- (id) setText: (string)text
|
2002-08-15 21:00:51 +00:00
|
|
|
{
|
|
|
|
InputLine_SetText (il, text);
|
2003-04-22 15:48:39 +00:00
|
|
|
return self;
|
2002-08-15 21:00:51 +00:00
|
|
|
}
|
|
|
|
|
2002-08-17 05:27:34 +00:00
|
|
|
- (string) text
|
2002-08-15 21:00:51 +00:00
|
|
|
{
|
|
|
|
return InputLine_GetText (il);
|
|
|
|
}
|
|
|
|
|
|
|
|
@end
|
2004-02-13 05:36:35 +00:00
|
|
|
|
|
|
|
@implementation InputLineBox
|
|
|
|
- (id) initWithBounds: (Rect)aRect promptCharacter: (integer)char
|
|
|
|
{
|
|
|
|
local integer xp, yp, xl, yl;
|
|
|
|
local Rect r;
|
|
|
|
|
|
|
|
xp = aRect.origin.x;
|
|
|
|
yp = aRect.origin.y;
|
|
|
|
xl = (aRect.size.width - 2) * 8;
|
|
|
|
yl = 24;
|
|
|
|
self = [self initWithComponents:xp :yp :xl :yl];
|
|
|
|
|
|
|
|
xp = 0;
|
|
|
|
yp = 8;
|
|
|
|
xl = aRect.size.width;
|
|
|
|
yl = aRect.size.height;
|
2010-11-17 06:50:07 +00:00
|
|
|
r = makeRect (xp, yp, xl, yl);
|
2004-02-13 05:36:35 +00:00
|
|
|
input_line = [[InputLine alloc] initWithBounds:r promptCharacter:char];
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) setWidth: (integer)width
|
|
|
|
{
|
|
|
|
[input_line setWidth:width];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) cursor: (BOOL)cursor
|
|
|
|
{
|
|
|
|
[input_line cursor:cursor];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) processInput: (integer)key
|
|
|
|
{
|
|
|
|
[input_line processInput:key];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (id) setText: (string)text
|
|
|
|
{
|
|
|
|
return [input_line setText:text];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (string) text
|
|
|
|
{
|
|
|
|
return [input_line text];
|
|
|
|
}
|
|
|
|
|
2004-02-13 05:49:43 +00:00
|
|
|
- (void) setBasePos:(Point)pos
|
2004-02-13 05:36:35 +00:00
|
|
|
{
|
2004-02-13 05:49:43 +00:00
|
|
|
[super setBasePos:pos];
|
2004-02-13 05:36:35 +00:00
|
|
|
[input_line setBasePos:xabs y:yabs];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) draw
|
|
|
|
{
|
|
|
|
[super draw];
|
|
|
|
text_box (xabs, yabs, xlen / 8, ylen / 24);
|
|
|
|
[input_line draw];
|
|
|
|
}
|
|
|
|
@end
|