Subversion Repositories Kolibri OS

Rev

Rev 9719 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
3107 leency 1
//BOX_LIB - Asper
5598 pavelyakov 2
#ifndef INCLUDE_BOX_LIB_H
3
#define INCLUDE_BOX_LIB_H
4
 
5
#ifndef INCLUDE_KOLIBRI_H
6
#include "../lib/kolibri.h"
7
#endif
8
 
9699 Coldy 9
#ifdef __COFF__
10
extern dword edit_box_draw;
9719 Coldy 11
extern dword edit_box_key_safe;
9699 Coldy 12
extern dword edit_box_mouse;
13
extern dword edit_box_set_text;
14
 
15
extern dword scrollbar_v_draw;
16
extern dword scrollbar_v_mouse;
17
extern dword scrollbar_h_draw;
18
extern dword scrollbar_h_mouse;
19
 
20
extern dword PathShow_prepare;
21
extern dword PathShow_draw;
22
 
23
extern dword progressbar_draw;
24
extern dword progressbar_progress;
25
 
26
extern dword frame_draw;
9719 Coldy 27
 
28
/*
29
    Legacy support
9727 Coldy 30
    For new programs need to use edit_box_key_safe (or edit_box_key_c
31
    with a define below)
32
    TODO: change in all cmm programs edit_box_key to edit_box_key_safe (edit_box_key_c)
33
          See examples in eolite and imgedit
34
 
35
    This define changed all edit_box_key_c to edit_box_key_safe identifier's
9719 Coldy 36
*/
9727 Coldy 37
#define edit_box_key_c  edit_box_key_safe
9719 Coldy 38
 
9699 Coldy 39
#else
5598 pavelyakov 40
#ifndef INCLUDE_DLL_H
41
#include "../lib/dll.h"
42
#endif
43
 
3107 leency 44
dword boxlib = #aEdit_box_lib;
5503 leency 45
char aEdit_box_lib[]="/sys/lib/box_lib.obj";
3107 leency 46
 
47
dword box_lib_init   = #aboxlib_init;
48
 
7086 leency 49
dword edit_box_draw     = #aEdit_box_draw;
50
dword edit_box_key      = #aEdit_box_key;
9644 leency 51
dword edit_box_key_c    = #aEdit_box_key_c;
7086 leency 52
dword edit_box_mouse    = #aEdit_box_mouse;
53
dword edit_box_set_text = #aEdit_box_set_text;
3107 leency 54
 
55
dword scrollbar_v_draw  = #aScrollbar_v_draw;
56
dword scrollbar_v_mouse = #aScrollbar_v_mouse;
57
dword scrollbar_h_draw  = #aScrollbar_h_draw;
58
dword scrollbar_h_mouse = #aScrollbar_h_mouse;
59
 
7086 leency 60
dword PathShow_prepare  = #aPathShow_prepare;
61
dword PathShow_draw     = #aPathShow_draw;
4674 leency 62
 
63
dword progressbar_draw = #aProgressbar_draw;
64
dword progressbar_progress = #aProgressbar_progress;
65
 
5444 leency 66
dword frame_draw = #aFrame_draw;
67
 
3839 Asper 68
$DD 2 dup 0
3363 leency 69
 
5520 leency 70
char aEdit_box_draw []    = "edit_box";
5444 leency 71
char aEdit_box_key  []    = "edit_box_key";
9644 leency 72
char aEdit_box_key_c[]    = "edit_box_key_safe";
5444 leency 73
char aEdit_box_mouse[]    = "edit_box_mouse";
7086 leency 74
char aEdit_box_set_text[] = "edit_box_set_text";
3107 leency 75
 
8281 leency 76
char aboxlib_init[]       = "lib_init";
5444 leency 77
char aScrollbar_v_draw [] = "scrollbar_v_draw";
78
char aScrollbar_v_mouse[] = "scrollbar_v_mouse";
79
char aScrollbar_h_draw [] = "scrollbar_h_draw";
80
char aScrollbar_h_mouse[] = "scrollbar_h_mouse";
3107 leency 81
 
5444 leency 82
char aPathShow_prepare [] = "PathShow_prepare";
83
char aPathShow_draw    [] = "PathShow_draw";
3107 leency 84
 
8281 leency 85
char aProgressbar_draw    [] = "progressbar_draw";
5444 leency 86
char aProgressbar_progress[] = "progressbar_progress";
3363 leency 87
 
5444 leency 88
char aFrame_draw[] = "frame_draw";
9699 Coldy 89
#endif
4674 leency 90
 
3363 leency 91
struct PathShow_data
92
{
5444 leency 93
dword type;
8895 leency 94
word  start_y;
95
word  start_x;
96
word  font_w;       // 6 - for font 0, 8 - for font 1
97
word  area_size_x;
98
dword font_number;  // 0 - monospace, 1 - variable
99
dword background_flag;
100
dword font_color;
101
dword background_color;
102
dword text_pointer;
103
dword work_area_pointer;
104
dword temp_text_length;
3363 leency 105
};
106
/*
107
char temp[128];
108
PathShow_data PathShow = {0, 100,20, 6, 200, 0, 1, 0x0, 0xFFFfff, #email_text, #temp, 0};
109
PathShow_prepare stdcall(#PathShow);
110
PathShow_draw stdcall(#PathShow);
111
*/
112
 
7422 leency 113
//editbox flags
114
#define ed_pass                        1b
115
#define ed_focus                      10b   //focused
116
#define ed_shift                     100b   //flag is set when Shift is pressed
117
#define ed_shift_on                 1000b
7506 leency 118
#define ed_shift_bac               10000b   //bit for Shift reset, if set the smth is selected
7422 leency 119
#define ed_left_fl                100000b
120
#define ed_offset_fl             1000000b
121
#define ed_insert               10000000b
122
#define ed_mouse_on            100000000b
7506 leency 123
#define ed_mouse_adn_b         100011000b
124
#define ed_disabled         100000000000b
7422 leency 125
#define ed_always_focus  100000000000000b
7447 leency 126
#define ed_figure_only  1000000000000000b   //numbers only
7422 leency 127
#define ed_shift_cl     1111111111100011b
128
#define ed_shift_mcl    1111111111111011b
129
#define ed_shift_off    1111111111111011b
130
#define ed_shift_on_off 1111111111110111b
131
#define ed_shift_bac_cl 1111111111101111b
132
#define ed_right_fl     1111111111011111b
133
#define ed_offset_cl    1111111110111111b
134
#define ed_insert_cl    1111111101111111b
135
#define ed_mouse_on_off 1111111011111111b
136
 
3107 leency 137
struct edit_box{
9644 leency 138
dword width, left, top,
139
	bg_color, selec_color, focus_border_color, border_color, text_color,
5685 leency 140
	max,
141
	text,
142
	mouse_variable,
143
	flags,
9644 leency 144
	size, pos, offset,
145
	cl_curs_x, cl_curs_y,
146
	shift, shift_old,
147
	height, char_width;
3107 leency 148
};
149
 
7506 leency 150
:void EditBox_UpdateText(dword ed, _flags)
151
{
152
	dword ed_text;
153
	ESI = ed;
7904 leency 154
	//ESI.edit_box.offset = ESI.edit_box.shift = ESI.edit_box.shift_old = 0; //no need because of 7904
7506 leency 155
	ESI.edit_box.flags = _flags;
156
	ed_text = ESI.edit_box.text;
7904 leency 157
	//ESI.edit_box.pos =  //no need because of 7904
158
	ESI.edit_box.size = strlen(ed_text);
7506 leency 159
}
160
 
9643 leency 161
:dword EditBox_Create(dword eb, left, top, width, maxlen, text, flags)
9362 leency 162
{
163
	ESDWORD[eb] = width;
164
	ESDWORD[eb + 4] = left;
165
	ESDWORD[eb + 8] = top;
166
	ESDWORD[eb + 12] = 0xffffff;
167
	ESDWORD[eb + 16] = 0x94AECE;
168
	ESDWORD[eb + 20] = 0xffffff;
169
	ESDWORD[eb + 24] = 0xffffff;
170
	ESDWORD[eb + 28] = 0x10000000;
171
	ESDWORD[eb + 32] = maxlen;
172
	ESDWORD[eb + 36] = text;
173
	ESDWORD[eb + 40] = 0;
174
	ESDWORD[eb + 44] = flags;
175
	ESDWORD[eb + 48] = 0;
176
	ESDWORD[eb + 52] = 0;
177
}
178
 
3107 leency 179
struct scroll_bar
180
{
9396 leency 181
	word size_x, start_x, size_y, start_y;
182
	dword btn_height, type, max_area, cur_area, position,
183
	bckg_col, frnt_col, line_col, redraw;
184
	word delta, delta2, r_size_x, r_start_x, r_size_y, r_start_y;
185
	dword m_pos, m_pos_2, m_keys, run_size, position2, work_size, all_redraw, ar_offset;
4674 leency 186
};
187
 
5444 leency 188
struct progress_bar
4674 leency 189
{
9644 leency 190
  dword value,
191
	left, top,
192
	width, height,
5444 leency 193
	style,
9644 leency 194
	min, max,
195
	back_color, progress_color, frame_color;
5444 leency 196
};
197
 
198
struct frame
199
{
200
	dword type;
9396 leency 201
	word size_x; //start_x, size_x => Mario, WTF? Is this so complex to use x/y/w/h ?
202
	word start_x;
203
	word size_y;
204
	word start_y;
205
	dword ext_col;
206
	dword int_col;
7254 leency 207
	dword flags;  // see FR_FLAGS
9396 leency 208
	dword text_pointer;
5444 leency 209
	dword text_position;   //  0-up,1-bottom
210
	dword font_number;     //  0-monospace,1-variable
9396 leency 211
	dword font_size_y;
212
	dword font_color;
5444 leency 213
	dword font_backgr_color;
7227 leency 214
};
5598 pavelyakov 215
 
7254 leency 216
// FR_FLAGS = [x][yyy][z]
217
// z        -  Caption
218
// yyy      -  BorderStyle
219
// x        -  BackStyle
220
#define FR_CAPTION 00001b // [z]
221
#define FR_DOUBLE  00000b // [yyy]
222
#define FR_RAISED  00010b // [yyy]
223
#define FR_SUNKEN  00100b // [yyy]
224
#define FR_ETCHED  00110b // [yyy]
225
#define FR_RIDGED  01000b // [yyy]
226
#define FR_FILLED  10000b // [x]
227
 
7227 leency 228
:frame frame123 = { 0, 260, 10, 60, 16, NULL, 0xFFFfff, 1, NULL, 0, 1, 12, 0x000111, 0xCCCccc };
229
:void DrawFrame(dword x,y,w,h,text)
230
{
7806 leency 231
	frame123.font_color = sc.work_text;
9602 leency 232
	frame123.ext_col = sc.line;
233
	frame123.int_col = sc.light;
7806 leency 234
	frame123.font_backgr_color = sc.work;
7227 leency 235
 
236
	frame123.start_x = x;
237
	frame123.start_y = y;
238
	frame123.size_x = w;
239
	frame123.size_y = h;
240
	frame123.text_pointer = text;
7254 leency 241
	if (!text) frame123.flags=0; else frame123.flags=FR_CAPTION;
7227 leency 242
	frame_draw stdcall (#frame123);
243
}
244
 
245
 
5598 pavelyakov 246
#endif