4 UI_InputBox *InputBox_Initialise(UI_Sheet_Control *sheetctrl, IO_MemoryControl *memctrl, uint x, uint y, uint xsize, uint ysize, uint txtbufsize, uint forecol, uint backcol, uint height)
\r
8 box = MemoryBlock_Allocate_System(sizeof(UI_InputBox));
\r
9 MemoryBlock_Write_Description(box, "UI_InputBox");
\r
12 ysize = ysize & ~15;
\r
13 box->sheet = Sheet_Get(sheetctrl, xsize, ysize, 0, 0);
\r
14 box->input_buf_size = txtbufsize;
\r
15 box->input_buf = (uchar *)MemoryBlock_Allocate_User(box->input_buf_size, memctrl);
\r
16 MemoryBlock_Write_Description(box->input_buf, "INPBOX_TXTBUF");
\r
17 box->input_count = 0;
\r
22 box->forecol = forecol;
\r
23 box->backcol = backcol;
\r
24 box->cursor_state = false;
\r
26 Draw_Fill_Rectangle(box->sheet->vram, box->sheet->size.x, box->backcol, 0, 0, box->sheet->size.x - 1, box->sheet->size.y - 1);
\r
27 Sheet_Show(box->sheet, x, y, height);
\r
31 int InputBox_Put_String(UI_InputBox *box, const uchar *s)
\r
37 InputBox_Put_String_Main(box, s);
\r
43 for(i = 0; s[i] != 0x00; i++){
\r
53 if(count > (box->input_buf_size - box->input_count)){
\r
57 InputBox_Put_String_Main(box, s);
\r
62 for(i = 0; count < old; i++){
\r
64 if(count != 0) count--;
\r
66 box->input_buf[box->input_count + count] = s[i];
\r
70 box->input_buf[box->input_count + count] = 0x00;
\r
71 box->input_count += count;
\r
76 int InputBox_Put_Character(UI_InputBox *box, uchar c)
\r
82 return InputBox_Put_String(box, str);
\r
85 void InputBox_Put_String_Main(UI_InputBox *box, const uchar *str)
\r
90 InputBox_Check_NewLine(box);
\r
95 } else if(str[i] == '\r'){
\r
97 } else if(str[i] == '\n'){
\r
98 InputBox_NewLine_No_Prompt(box);
\r
99 } else if(str[i] == '\t'){
\r
101 Sheet_Draw_Fill_Rectangle(box->sheet, box->backcol, box->cursor.x, box->cursor.y, box->cursor.x + 8 - 1, box->cursor.y + 16 - 1);
\r
102 box->cursor.x += 8;
\r
103 InputBox_Check_NewLine(box);
\r
104 if((box->cursor.x & 0x1f) == 0 && box->cursor.x != 0) break;
\r
106 } else if(str[i] == '\b'){
\r
107 Sheet_Draw_Fill_Rectangle(box->sheet, box->backcol, box->cursor.x, box->cursor.y, box->cursor.x + 8 - 1, box->cursor.y + 16 - 1);
\r
108 box->cursor.x -= 8;
\r
109 InputBox_Check_NewLine(box);
\r
110 Sheet_Draw_Fill_Rectangle(box->sheet, box->backcol, box->cursor.x, box->cursor.y, box->cursor.x + 8 - 1, box->cursor.y + 16 - 1);
\r
111 if(box->input_count != 0 && box->record){
\r
112 box->input_count--;
\r
113 box->input_buf[box->input_count] = 0x00;
\r
118 Sheet_Draw_Fill_Rectangle(box->sheet, box->backcol, box->cursor.x, box->cursor.y, box->cursor.x + 8 - 1, box->cursor.y + 16 - 1);
\r
119 Sheet_Draw_Put_String(box->sheet, box->cursor.x, box->cursor.y, box->forecol, s);
\r
120 box->cursor.x += 8;
\r
121 InputBox_Check_NewLine(box);
\r
127 void InputBox_Check_NewLine(UI_InputBox *box)
\r
129 if(box->cursor.x <= box->prompt.x || box->cursor.x < 0){ /*
\83v
\83\8d\83\93\83v
\83g
\82Ü
\82½
\82Í
\89æ
\96Ê
\82æ
\82è
\8d¶
\82É
\88Ú
\93®
\82µ
\82æ
\82¤
\82Æ
\82µ
\82½*/
\r
130 if(box->cursor.y != box->prompt.y){ /*
\83v
\83\8d\83\93\83v
\83g
\82Æ
\93¯
\82¶
\8ds
\82Å
\82Í
\82È
\82¢*/
\r
131 box->cursor.y -= 16;
\r
132 box->cursor.x = box->sheet->size.x - 8;
\r
133 } else{/*
\83v
\83\8d\83\93\83v
\83g
\82Æ
\93¯
\82¶
\8ds*/
\r
134 box->cursor.y = box->prompt.y;
\r
135 box->cursor.x = box->prompt.x + 8;
\r
137 } else if(box->cursor.x >= box->sheet->size.x){
\r
138 if(box->cursor.y <= box->sheet->size.y - 17){
\r
139 box->cursor.x = box->prompt.x + 8;
\r
140 box->cursor.y += 16;
\r
142 InputBox_Slide_Line(box);
\r
143 box->cursor.x = box->prompt.x + 8;
\r
144 if(box->prompt.y > 0){
\r
145 box->prompt.y -= 16;
\r
151 if(box->cursor.y < box->prompt.y){
\r
152 box->cursor.y = box->prompt.y;
\r
157 void InputBox_NewLine_No_Prompt(UI_InputBox *box)
\r
159 if(box->cursor.y <= box->sheet->size.y - 17){
\r
160 Sheet_Draw_Fill_Rectangle(box->sheet, box->backcol, box->cursor.x, box->cursor.y, box->cursor.x + 8 - 1, box->cursor.y + 16 - 1);
\r
161 box->cursor.x = box->prompt.x + 8;
\r
162 box->cursor.y = box->cursor.y + 16;
\r
164 Sheet_Draw_Fill_Rectangle(box->sheet, box->backcol, box->cursor.x, box->cursor.y, box->cursor.x + 8 - 1, box->cursor.y + 16 - 1);
\r
165 InputBox_Slide_Line(box);
\r
166 box->cursor.x = box->prompt.x + 8;
\r
168 InputBox_Check_NewLine(box);
\r
172 void InputBox_NewLine(UI_InputBox *box)
\r
174 if(box->cursor.y <= box->sheet->size.y - 17){
\r
175 box->prompt.y = box->cursor.y + 16;
\r
176 InputBox_Put_Prompt(box);
\r
178 Sheet_Draw_Fill_Rectangle(box->sheet, box->backcol, box->cursor.x, box->cursor.y, box->cursor.x + 16 - 1, box->cursor.y + 16 - 1);
\r
179 InputBox_Slide_Line(box);
\r
180 box->prompt.y = box->sheet->size.y - 16;
\r
181 InputBox_Put_Prompt(box);
\r
186 void InputBox_Slide_Line(UI_InputBox *box)
\r
188 // Sheet_Draw_Fill_Rectangle(box->sheet, box->backcol, box->cursor.x, box->cursor.y, box->cursor.x + 8 - 1, box->cursor.y + 16 - 1);
\r
189 Draw_Slide_Line(box->sheet->vram, box->sheet->size.x, box->sheet->size.y, box->sheet->size.x, 0, 0);
\r
190 Sheet_Draw_Fill_Rectangle(box->sheet, box->backcol, 0, box->sheet->size.y - 16, box->sheet->size.x - 1, box->sheet->size.y - 1);
\r
191 box->sheet->Refresh(box->sheet, 0, 0, box->sheet->size.x - 1, box->sheet->size.y - 1);
\r
195 void InputBox_Put_Prompt(UI_InputBox *box)
\r
197 Sheet_Draw_Fill_Rectangle(box->sheet, box->backcol, box->cursor.x, box->cursor.y, box->cursor.x + 16 - 1, box->cursor.y + 16 - 1);
\r
199 Sheet_Draw_Put_String(box->sheet, box->prompt.x, box->prompt.y, box->forecol, ">");
\r
200 box->cursor.x = box->prompt.x + 8;
\r
201 box->cursor.y = box->prompt.y;
\r
205 void InputBox_Reset_Input_Buffer(UI_InputBox *box)
\r
207 box->input_buf[0] = 0x00;
\r
208 box->input_count = 0;
\r
212 void InputBox_Change_Cursor_State(UI_InputBox *box)
\r
214 if(box->cursor_state){
\r
215 Sheet_Draw_Fill_Rectangle(box->sheet, box->backcol, box->cursor.x, box->cursor.y, box->cursor.x + 8 - 1, box->cursor.y + 16 - 1);
\r
216 box->cursor_state = false;
\r
218 Sheet_Draw_Fill_Rectangle(box->sheet, box->forecol, box->cursor.x, box->cursor.y, box->cursor.x + 8 - 1, box->cursor.y + 16 - 1);
\r
219 box->cursor_state = true;
\r
224 void InputBox_Clear(UI_InputBox *box)
\r
226 InputBox_Reset_Input_Buffer(box);
\r
229 box->prompt.x = -8;
\r
231 Sheet_Draw_Fill_Rectangle(box->sheet, box->backcol, 0, 0, box->sheet->size.x - 1, box->sheet->size.y - 1);
\r
235 void InputBox_Set_Record(UI_InputBox *box, bool record)
\r
237 box->record = record;
\r