2002-08-17 05:27:34 +00:00
|
|
|
#include "InputLine.h"
|
2002-08-15 21:00:51 +00:00
|
|
|
|
2002-08-20 21:19:53 +00:00
|
|
|
#include "Rect.h"
|
|
|
|
|
2002-08-15 21:00:51 +00:00
|
|
|
inputline_t (integer lines, integer size, integer prompt) InputLine_Create = #0;
|
2002-08-20 02:09:34 +00:00
|
|
|
void (inputline_t il, void [] data) InputLine_SetUserData = #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
|
|
|
{
|
2002-08-17 05:27:34 +00:00
|
|
|
id (self) = [super init];
|
2002-08-20 21:19:53 +00:00
|
|
|
control.x = aRect.origin.x;
|
|
|
|
control.y = aRect.origin.y;
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2002-08-17 05:27:34 +00:00
|
|
|
- (void) free
|
2002-08-15 21:00:51 +00:00
|
|
|
{
|
2002-08-17 05:27:34 +00:00
|
|
|
InputLine_Destroy (il);
|
|
|
|
[super free];
|
2002-08-15 21:00:51 +00:00
|
|
|
}
|
|
|
|
|
2002-08-17 05:27:34 +00:00
|
|
|
- (void) setWidth: (integer)visibleWidth
|
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);
|
|
|
|
}
|
|
|
|
|
2002-08-17 05:27:34 +00:00
|
|
|
- (void) draw: (BOOL)cursor
|
2002-08-15 21:00:51 +00:00
|
|
|
{
|
2002-08-20 21:19:53 +00:00
|
|
|
control.cursor = cursor;
|
|
|
|
InputLine_Draw (il);
|
2002-08-15 21:00:51 +00:00
|
|
|
}
|
|
|
|
|
2002-08-17 05:27:34 +00:00
|
|
|
- (void) setText: (string)text
|
2002-08-15 21:00:51 +00:00
|
|
|
{
|
|
|
|
InputLine_SetText (il, text);
|
|
|
|
}
|
|
|
|
|
2002-08-17 05:27:34 +00:00
|
|
|
- (string) text
|
2002-08-15 21:00:51 +00:00
|
|
|
{
|
|
|
|
return InputLine_GetText (il);
|
|
|
|
}
|
|
|
|
|
|
|
|
@end
|