fix kolibri_editbox.h, improves boardmsg

git-svn-id: svn://kolibrios.org@6393 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Serhii Sakhno 2016-04-11 16:50:10 +00:00
parent 9ead5001b6
commit 7ea16e0e19
3 changed files with 36 additions and 20 deletions

View File

@ -8,19 +8,21 @@ int main()
elements can be used after a successful call to this function
*/
kolibri_gui_init();
/* Set gui_event to REDRAW so that window is drawn in first iteration */
unsigned int gui_event = KOLIBRI_EVENT_REDRAW;
oskey_t key;
struct kolibri_window *main_window = kolibri_new_window(50, 50, 400, 100, "BoardMsg: Send msg to debug board");
struct kolibri_window *main_window = kolibri_new_window(50, 50, 400, 100, "BoardMsg: OpenDialog 0.12");
struct check_box *checkbox = kolibri_new_check_box(20, 40, 12, 12, "Append BOARDMSG to entered message.");
struct edit_box *textbox = kolibri_new_edit_box(20, 55, 40);
struct kolibri_button *button = kolibri_new_button(310, 55, 14, 14, 0x00123456, kolibri_color_table.color_work_button);
struct kolibri_button *button = kolibri_new_button(310, 55, 24, 14, 0x21, kolibri_color_table.color_work_button);
kolibri_window_add_element(main_window, KOLIBRI_EDIT_BOX, textbox);
kolibri_window_add_element(main_window, KOLIBRI_CHECK_BOX, checkbox);
kolibri_window_add_element(main_window, KOLIBRI_BUTTON, button);
volatile unsigned press_key2;
do /* Start of main activity loop */
{
if(gui_event == KOLIBRI_EVENT_REDRAW)
@ -29,21 +31,35 @@ int main()
}
else if(gui_event == KOLIBRI_EVENT_KEY)
{
key = get_key();
switch (key.code)
{
case 13:
if(checkbox -> flags & CHECKBOX_IS_SET) /* Append BoardMsg checkbox is set */
debug_board_write_str("BOARDMSG: ");
debug_board_write_str(textbox->text);
debug_board_write_str("\n");
break;
}
press_key = key.val;
kolibri_handle_event_key(main_window);
}
else if(gui_event == KOLIBRI_EVENT_BUTTON)
{
unsigned int pressed_button = kolibri_button_get_identifier();
if(pressed_button = 0x00123456) /* Our button was pressed */
{
if(checkbox -> flags & CHECKBOX_IS_SET) /* Append BoardMsg checkbox is set */
debug_board_write_str("BOARDMSG: ");
debug_board_write_str(textbox->text);
debug_board_write_str("\n");
}
}
switch (pressed_button)
{
case 0x21:
if(checkbox -> flags & CHECKBOX_IS_SET) /* Append BoardMsg checkbox is set */
debug_board_write_str("BOARDMSG: ");
debug_board_write_str(textbox->text);
debug_board_write_str("\n");
break;
case 0x00000001:
kolibri_exit();
}
}
else if(gui_event == KOLIBRI_EVENT_MOUSE)
{
kolibri_handle_event_mouse(main_window);

View File

@ -62,8 +62,7 @@ struct edit_box* kolibri_new_edit_box(unsigned int tlx, unsigned int tly, unsign
new_textbox -> max = max_chars;
new_textbox -> text = text_buffer;
new_textbox -> mouse_variable = 1; /* let the mouse take control? */
new_textbox -> flags = 0x00004002; /*ed_focus + ed_always_focus */
new_textbox -> flags = 0x00000000;
/* If these lines are uncommented, the executable will crash for no reason at start */
/* Even though these lines are not ever read it ALWAYS causes a crash, even crashes MTDBG. What gives? */
@ -86,5 +85,5 @@ extern void (*edit_box_draw)(struct edit_box *) __attribute__((__stdcall__));
extern void editbox_key(struct edit_box *) __attribute__((__stdcall__));
extern void (*edit_box_mouse)(struct edit_box *) __attribute__((__stdcall__));
extern volatile unsigned press_key;
#endif /* KOLIBRI_EDITBOX_H */

View File

@ -13,7 +13,7 @@ include 'dll.inc'
public init_boxlib as '_init_boxlib_asm'
public editbox_key as '_editbox_key@4'
public press_key as '_press_key'
;;; Returns 0 on success. -1 on failure.
proc init_boxlib
@ -37,13 +37,14 @@ endp
editbox_key:
mov [oldebp], ebp ;Save ebp because GCC is crazy for it otherwise.
pop ebp ;Save return address in ebp. Stack top is param now.
mcall 2
mov eax, dword [press_key]
call [edit_box_key] ; The pointer we passed should be on the stack already.
push ebp ;push the return address back to stack
mov ebp, [oldebp]
ret
oldebp dd ?
press_key dd ?
@IMPORT:
library lib_boxlib, 'box_lib.obj'