Subversion Repositories Kolibri OS

Rev

Rev 6456 | Rev 6470 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 6456 Rev 6457
Line 1... Line 1...
1
#ifndef KOLIBRI_EDITBOX_H
1
#ifndef KOLIBRI_EDITBOX_H
2
#define KOLIBRI_EDITBOX_H
2
#define KOLIBRI_EDITBOX_H
Line 3... Line 3...
3
 
3
 
Line 4... Line 4...
4
#include "kolibri_colors.h"
4
#include "kolibri_colors.h"
5
 
5
 
6
struct edit_box {
6
typedef struct {
7
  unsigned int width; 
7
  unsigned int width; 
8
    unsigned int left;
8
    unsigned int left;
9
    unsigned int top; 
9
    unsigned int top; 
Line 23... Line 23...
23
    unsigned int offset;
23
    unsigned int offset;
24
    unsigned int cl_curs_x;
24
    unsigned int cl_curs_x;
25
    unsigned int cl_curs_y;
25
    unsigned int cl_curs_y;
26
    unsigned int shift;
26
    unsigned int shift;
27
    unsigned int shift_old;
27
    unsigned int shift_old;
28
};
28
}edit_box;
Line 29... Line 29...
29
 
29
 
30
/* Initializes an Editbox with sane settings, sufficient for most use. 
30
/* Initializes an Editbox with sane settings, sufficient for most use. 
31
   This will let you create a box and position it somewhere on the screen. 
31
   This will let you create a box and position it somewhere on the screen. 
32
   The text_buffer is a pointer to a character array and needs to be as long as 
32
   The text_buffer is a pointer to a character array and needs to be as long as 
Line 40... Line 40...
40
 
40
 
41
   tlx,tly = Coordinates of the beginning of the edit box. 
41
   tlx,tly = Coordinates of the beginning of the edit box. 
42
   max_chars = Limit of number of characters user can enter into edit box.
42
   max_chars = Limit of number of characters user can enter into edit box.
Line 43... Line 43...
43
*/
43
*/
44
 
44
 
45
struct edit_box* kolibri_new_edit_box(unsigned int tlx, unsigned int tly, unsigned int max_chars)
45
edit_box* kolibri_new_edit_box(unsigned int tlx, unsigned int tly, unsigned int max_chars)
46
{
46
{
47
    unsigned int PIXELS_PER_CHAR = 7;
47
    unsigned int PIXELS_PER_CHAR = 7;
Line 48... Line 48...
48
    struct edit_box *new_textbox = (struct edit_box *)malloc(sizeof(struct edit_box));
48
    edit_box *new_textbox = (edit_box *)malloc(sizeof(edit_box));
49
    char *text_buffer = (char *)calloc(max_chars + 1, sizeof(char));
49
    char *text_buffer = (char *)calloc(max_chars + 1, sizeof(char));
Line 75... Line 75...
75
    new_textbox -> shift_old = 0;
75
    new_textbox -> shift_old = 0;
Line 76... Line 76...
76
 
76
 
77
    return new_textbox;
77
    return new_textbox;
Line 78... Line 78...
78
}
78
}
Line 79... Line 79...
79
 
79
 
80
extern void (*edit_box_draw)(struct edit_box *) __attribute__((__stdcall__));
80
extern void (*edit_box_draw)(edit_box *) __attribute__((__stdcall__));
81
 
81
 
82
/* editbox_key is a wrapper written in assembly to handle key press events for editboxes */
82
/* editbox_key is a wrapper written in assembly to handle key press events for editboxes */
Line 83... Line 83...
83
/* because inline assembly in GCC is a PITA and interferes with the EAX (AH) register */
83
/* because inline assembly in GCC is a PITA and interferes with the EAX (AH) register */
84
/* which edit_box_key requires */
84
/* which edit_box_key requires */
85
extern void editbox_key(struct edit_box *) __attribute__((__stdcall__));
85
extern void editbox_key(edit_box *) __attribute__((__stdcall__));