2016-02-12 22:54:29 +03:00
|
|
|
#ifndef INCLUDE_GUI_H
|
2015-07-22 21:32:54 +03:00
|
|
|
#define INCLUDE_GUI_H
|
|
|
|
|
|
|
|
#ifndef INCLUDE_KOLIBRI_H
|
|
|
|
#include "../lib/kolibri.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef INCLUDE_STRING_H
|
|
|
|
#include "../lib/strings.h"
|
|
|
|
#endif
|
2012-12-15 04:16:06 +04:00
|
|
|
|
2016-02-09 04:43:58 +03:00
|
|
|
#ifndef INCLUDE_RGB_H
|
|
|
|
#include "../lib/patterns/rgb.h"
|
|
|
|
#endif
|
|
|
|
|
2017-10-11 01:26:56 +03:00
|
|
|
#ifndef INCLUDE_MATH_H
|
|
|
|
#include "../lib/math.h"
|
|
|
|
#endif
|
|
|
|
|
2018-04-11 20:46:08 +03:00
|
|
|
#include "../lib/gui/tabs.h"
|
|
|
|
#include "../lib/gui/more_less_box.h"
|
|
|
|
|
2013-10-11 02:45:19 +04:00
|
|
|
:void DrawRectangle(dword x,y,w,h,color1)
|
2012-11-26 19:26:15 +04:00
|
|
|
{
|
2013-02-04 17:15:13 +04:00
|
|
|
if (w<=0) || (h<=0) return;
|
|
|
|
DrawBar(x,y,w,1,color1);
|
|
|
|
DrawBar(x,y+h,w,1,color1);
|
|
|
|
DrawBar(x,y,1,h,color1);
|
|
|
|
DrawBar(x+w,y,1,h+1,color1);
|
2012-11-26 19:26:15 +04:00
|
|
|
}
|
|
|
|
|
2015-08-18 00:24:56 +03:00
|
|
|
:void DrawWideRectangle(dword x,y,w,h,boder,color1)
|
|
|
|
{
|
|
|
|
if (w<=0) || (h<=0) return;
|
|
|
|
DrawBar(x, y, w, boder, color1);
|
|
|
|
DrawBar(x, y+h-boder, w, boder, color1);
|
|
|
|
DrawBar(x, y+boder, boder, h-boder-boder, color1);
|
|
|
|
DrawBar(x+w-boder, y+boder, boder, h-boder-boder, color1);
|
|
|
|
}
|
|
|
|
|
2013-10-11 02:45:19 +04:00
|
|
|
:void DrawRectangle3D(dword x,y,w,h,color1,color2)
|
2012-11-26 19:26:15 +04:00
|
|
|
{
|
2013-02-04 17:15:13 +04:00
|
|
|
if (w<=0) || (h<=0) return;
|
|
|
|
DrawBar(x,y,w+1,1,color1);
|
|
|
|
DrawBar(x,y+1,1,h-1,color1);
|
|
|
|
DrawBar(x+w,y+1,1,h,color2);
|
|
|
|
DrawBar(x,y+h,w,1,color2);
|
2012-11-26 19:26:15 +04:00
|
|
|
}
|
|
|
|
|
2013-10-11 02:45:19 +04:00
|
|
|
:void DrawCaptButton(dword x,y,w,h,id,color_b, color_t,text)
|
2012-11-26 19:26:15 +04:00
|
|
|
{
|
2016-02-13 01:07:55 +03:00
|
|
|
dword tx = -strlen(text)*8+w/2+x;
|
|
|
|
dword ty = h/2-7+y;
|
|
|
|
|
2014-04-17 22:07:07 +04:00
|
|
|
if (id>0) DefineButton(x,y,w,h,id,color_b);
|
2016-02-12 22:54:29 +03:00
|
|
|
WriteText(tx+1,ty+1,0x90,MixColors(color_b,0,230),text);
|
|
|
|
WriteText(tx,ty,0x90,color_t,text);
|
2012-11-26 19:26:15 +04:00
|
|
|
}
|
|
|
|
|
2017-09-28 12:59:41 +03:00
|
|
|
:int active_button_id = 0;
|
2016-10-28 19:06:18 +03:00
|
|
|
:int DrawStandartCaptButton(dword x, y, id, text)
|
2016-10-05 16:12:39 +03:00
|
|
|
{
|
2018-04-03 16:57:56 +03:00
|
|
|
#define padding_v 5
|
|
|
|
#define padding_h 15
|
|
|
|
#define right_margin 12
|
|
|
|
#define h padding_v + padding_v + 16 //16 font height
|
2016-10-05 16:12:39 +03:00
|
|
|
int tx = x + padding_h;
|
2016-11-05 13:13:29 +03:00
|
|
|
int ty = y + padding_v+1;
|
2017-09-28 12:59:41 +03:00
|
|
|
int tw = strlen(text)*8;
|
|
|
|
int w = tw + padding_h + padding_h;
|
|
|
|
|
2016-10-05 16:12:39 +03:00
|
|
|
|
2016-10-28 19:06:18 +03:00
|
|
|
if (id>0) DefineButton(x,y,w,h,id,system.color.work_button);
|
2017-09-28 12:59:41 +03:00
|
|
|
|
2016-10-28 19:06:18 +03:00
|
|
|
WriteText(tx+1,ty+1,0x90,MixColors(system.color.work_button,0,230),text);
|
|
|
|
WriteText(tx,ty,0x90,system.color.work_button_text,text);
|
2017-09-28 12:59:41 +03:00
|
|
|
|
|
|
|
if (active_button_id==id) {
|
|
|
|
DrawBar(tx,ty+15,tw,1, MixColors(system.color.work_button,0,230));
|
|
|
|
DrawBar(tx,ty+14,tw,1, system.color.work_button_text);
|
|
|
|
}
|
|
|
|
|
2016-10-05 16:12:39 +03:00
|
|
|
return w + right_margin;
|
|
|
|
}
|
|
|
|
|
2017-09-28 12:59:41 +03:00
|
|
|
:void ActiveButtonSwitch(int min, max)
|
|
|
|
{
|
|
|
|
active_button_id++;
|
|
|
|
if (active_button_id>max) || (active_button_id<max) active_button_id=min;
|
|
|
|
}
|
|
|
|
|
2014-04-17 22:07:07 +04:00
|
|
|
:void WriteTextCenter(dword x,y,w,color_t,text)
|
|
|
|
{
|
|
|
|
WriteText(-strlen(text)*6+w/2+x+1,y,0x80,color_t,text);
|
|
|
|
}
|
|
|
|
|
2015-03-16 17:20:32 +03:00
|
|
|
:void DrawCircle(int x, y, r, color)
|
2012-11-26 19:26:15 +04:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
float px=0, py=r, ii = r * 3.1415926 * 2;
|
|
|
|
FOR (i = 0; i < ii; i++)
|
|
|
|
{
|
2015-03-16 17:20:32 +03:00
|
|
|
PutPixel(px + x, y - py, color);
|
2012-11-26 19:26:15 +04:00
|
|
|
px = py / r + px;
|
|
|
|
py = -px / r + py;
|
|
|
|
}
|
2012-12-05 19:25:01 +04:00
|
|
|
}
|
2012-12-15 03:55:44 +04:00
|
|
|
|
2016-02-21 01:09:50 +03:00
|
|
|
:unsigned char checkbox_flag[507] = {
|
2016-02-11 16:46:53 +03:00
|
|
|
0xFC, 0xD4, 0x04, 0xFC,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 0x04
|
|
|
|
};
|
|
|
|
|
2016-02-09 04:43:58 +03:00
|
|
|
:void CheckBox(dword x,y,bt_id, text, is_checked)
|
2012-12-15 03:55:44 +04:00
|
|
|
{
|
2016-02-09 04:43:58 +03:00
|
|
|
byte w=14, h=14;
|
2016-02-11 16:46:53 +03:00
|
|
|
DefineButton(x-1, y-1, strlen(text)*8 + w + 17, h+2, bt_id+BT_HIDE+BT_NOFRAME, 0);
|
2016-02-22 00:57:22 +03:00
|
|
|
EDI = system.color.work;
|
|
|
|
WriteText(x+w+8, h / 2 + y -7, 0xD0, system.color.work_text, text);
|
2016-02-09 04:43:58 +03:00
|
|
|
DrawRectangle(x, y, w, h, system.color.work_graph);
|
2015-02-26 19:48:22 +03:00
|
|
|
if (is_checked == 0)
|
|
|
|
{
|
|
|
|
DrawRectangle3D(x+1, y+1, w-2, h-2, 0xDDDddd, 0xffffff);
|
|
|
|
DrawBar(x+2, y+2, w-3, h-3, 0xffffff);
|
|
|
|
}
|
|
|
|
else if (is_checked == 1)
|
2012-12-15 03:55:44 +04:00
|
|
|
{
|
2016-02-09 04:43:58 +03:00
|
|
|
DrawWideRectangle(x+1, y+1, w-1, h-1, 2, 0xffffff);
|
2016-02-11 16:46:53 +03:00
|
|
|
_PutImage(x+1, y+1, 13, 13, #checkbox_flag);
|
2012-12-15 03:55:44 +04:00
|
|
|
}
|
2015-02-26 19:48:22 +03:00
|
|
|
else if (is_checked == 2) //not active
|
2012-12-15 03:55:44 +04:00
|
|
|
{
|
2016-02-09 04:43:58 +03:00
|
|
|
DrawWideRectangle(x+1, y+1, w-1, h-1, 2, 0xffffff);
|
2015-03-18 14:59:32 +03:00
|
|
|
DrawBar(x+3, y+3, w-5, h-5, 0x888888);
|
2015-02-26 19:48:22 +03:00
|
|
|
}
|
2016-02-11 04:07:04 +03:00
|
|
|
DrawRectangle3D(x-1,y-1,w+2,h+2,system.color.work_dark,system.color.work_light);
|
2015-02-26 19:48:22 +03:00
|
|
|
}
|
|
|
|
|
2016-02-22 00:57:22 +03:00
|
|
|
:void DrawEditBox(dword edit_box_pointer)
|
2016-02-11 05:22:34 +03:00
|
|
|
{
|
2016-02-22 00:57:22 +03:00
|
|
|
dword x,y,w,h,bg;
|
2016-02-11 05:22:34 +03:00
|
|
|
ESI = edit_box_pointer;
|
|
|
|
x = ESI.edit_box.left;
|
|
|
|
y = ESI.edit_box.top;
|
|
|
|
w = ESI.edit_box.width+1;
|
2016-02-22 00:57:22 +03:00
|
|
|
if (ESI.edit_box.flags & 100000000000b) bg = 0xCACACA; else bg = 0xFFFfff;
|
2016-11-05 13:13:29 +03:00
|
|
|
edit_box_draw stdcall (edit_box_pointer);
|
2016-11-14 03:42:32 +03:00
|
|
|
h = 22;
|
2018-04-03 15:45:08 +03:00
|
|
|
DrawRectangle3D(x-1, y-1, w+1, h+1, 0xE7E7E7, bg);
|
|
|
|
DrawRectangle(x-2, y-2, w+3, h+3, system.color.work_graph);
|
|
|
|
DrawRectangle3D(x-3, y-3, w+5, h+5, system.color.work_dark, system.color.work_light);
|
2016-02-11 05:22:34 +03:00
|
|
|
}
|
|
|
|
|
2014-03-23 21:12:21 +04:00
|
|
|
:void DrawProgressBar(dword st_x, st_y, st_w, st_h, col_fon, col_border, col_fill, col_text, progress_percent)
|
2012-12-15 19:56:24 +04:00
|
|
|
{
|
2013-02-04 17:15:13 +04:00
|
|
|
int progress_w;
|
2012-12-15 19:56:24 +04:00
|
|
|
static int fill_old;
|
|
|
|
|
2013-03-11 22:16:24 +04:00
|
|
|
//if (progress_percent<=0) {DrawBar(st_x,st_y, st_x + st_w + fill_old + 15,st_h+1, col_fon); fill_old=0; return;}
|
|
|
|
if (progress_percent<=0) || (progress_percent>=100) return;
|
2012-12-15 19:56:24 +04:00
|
|
|
|
|
|
|
DrawRectangle(st_x, st_y, st_w,st_h, col_border);
|
|
|
|
DrawRectangle3D(st_x+1, st_y+1, st_w-2,st_h-2, 0xFFFfff, 0xFFFfff);
|
2013-02-04 17:15:13 +04:00
|
|
|
|
|
|
|
if (progress_percent>0) && (progress_percent<=100)
|
|
|
|
{
|
|
|
|
progress_w = st_w - 3 * progress_percent / 100;
|
|
|
|
DrawBar(st_x+2, st_y+2, progress_w, st_h-3, col_fill);
|
|
|
|
DrawBar(st_x+2+progress_w, st_y+2, st_w-progress_w-3, st_h-3, 0xFFFfff);
|
|
|
|
}
|
2013-03-11 22:16:24 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
:void DrawLink(dword x,y,font_type,btn_id, inscription)
|
|
|
|
{
|
|
|
|
int w;
|
|
|
|
WriteText(x,y,font_type,0x4E00E7,inscription);
|
2017-09-28 12:59:41 +03:00
|
|
|
if (font_type==0x80) w = strlen(inscription)*6; else w = strlen(inscription)*8;
|
2013-03-11 22:16:24 +04:00
|
|
|
DefineButton(x-1,y-1,w,10,btn_id+BT_HIDE,0);
|
|
|
|
DrawBar(x,y+8,w,1,0x4E00E7);
|
|
|
|
}
|
|
|
|
|
2013-10-09 22:10:23 +04:00
|
|
|
:void PutShadow(dword x,y,w,h,skinned,strength)
|
2013-03-11 22:16:24 +04:00
|
|
|
{
|
|
|
|
proc_info wForm;
|
|
|
|
dword shadow_buf, skin_height;
|
|
|
|
shadow_buf = mem_Alloc(w*h*3);
|
|
|
|
GetProcessInfo(#wForm, SelfInfo);
|
2013-10-09 22:10:23 +04:00
|
|
|
CopyScreen(shadow_buf, 5*skinned+x+wForm.left, GetSkinHeight()*skinned+y+wForm.top, w, h);
|
2013-03-11 22:16:24 +04:00
|
|
|
ShadowImage(shadow_buf, w, h, strength);
|
|
|
|
_PutImage(x,y,w,h,shadow_buf);
|
|
|
|
mem_Free(shadow_buf);
|
|
|
|
}
|
|
|
|
|
2013-10-09 22:10:23 +04:00
|
|
|
:void DrawPopup(dword x,y,w,h,skinned, col_work,col_border)
|
|
|
|
{
|
|
|
|
DrawRectangle(x,y,w,h,col_border);
|
2013-10-09 23:12:03 +04:00
|
|
|
DrawBar(x+1,y+1,w-1,1,0xFFFfff);
|
2013-10-15 14:30:46 +04:00
|
|
|
DrawBar(x+1,y+2,1,h-2,0xFFFfff);
|
2013-10-09 23:12:03 +04:00
|
|
|
if (col_work!=-1) DrawBar(x+2,y+2,w-2,h-2,col_work);
|
2013-10-09 22:10:23 +04:00
|
|
|
DrawPopupShadow(x,y,w,h-1,skinned);
|
|
|
|
}
|
|
|
|
|
2015-03-05 23:55:28 +03:00
|
|
|
:void DrawPopupShadow(dword x,y,w,h,skinned)
|
|
|
|
{
|
|
|
|
PutShadow(w+x+1,y,1,h+2,skinned,2);
|
|
|
|
PutShadow(w+x+2,y+1,1,h+2,skinned,1);
|
|
|
|
PutShadow(x,y+h+2,w+2,1,skinned,2);
|
|
|
|
PutShadow(x+1,y+h+3,w+1,1,skinned,1);
|
|
|
|
}
|
|
|
|
|
2013-03-11 22:16:24 +04:00
|
|
|
:void GrayScaleImage(dword color_image, w, h)
|
|
|
|
{
|
2015-08-22 16:27:12 +03:00
|
|
|
dword i,gray,to,rr,gg,bb;
|
|
|
|
to = w*h*3 + color_image;
|
|
|
|
for (i = color_image; i < to; i+=3)
|
2013-03-11 22:16:24 +04:00
|
|
|
{
|
2015-08-22 16:27:12 +03:00
|
|
|
rr = DSBYTE[i];
|
|
|
|
gg = DSBYTE[i+1];
|
|
|
|
bb = DSBYTE[i+2];
|
2013-03-11 22:16:24 +04:00
|
|
|
gray = rr*rr;
|
|
|
|
gray += gg*gg;
|
|
|
|
gray += bb*bb;
|
|
|
|
gray = sqrt(gray) / 3;
|
2015-08-22 16:27:12 +03:00
|
|
|
DSBYTE[i] = DSBYTE[i+1] = DSBYTE[i+2] = gray;
|
2013-03-11 22:16:24 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
:void ShadowImage(dword color_image, w, h, strength)
|
|
|
|
{
|
|
|
|
dword col, to;
|
|
|
|
strength = 10 - strength;
|
|
|
|
to = w*h*3 + color_image;
|
|
|
|
for ( ; color_image < to; color_image++)
|
|
|
|
{
|
|
|
|
col = strength * DSBYTE[color_image] / 10;
|
|
|
|
DSBYTE[color_image] = col;
|
|
|
|
}
|
2015-07-22 21:32:54 +03:00
|
|
|
}
|
|
|
|
|
2015-12-14 17:50:28 +03:00
|
|
|
:void WriteTextLines(dword x,y,byte fontType, dword color, text_pointer, line_h)
|
|
|
|
{
|
|
|
|
dword next_word_pointer = strchr(text_pointer, '\n');
|
|
|
|
if (next_word_pointer) WriteTextLines(dword x, y+line_h, byte fontType, dword color, next_word_pointer+2, line_h);
|
|
|
|
ESBYTE[next_word_pointer] = NULL;
|
|
|
|
WriteText(dword x, y, byte fontType, dword color, text_pointer);
|
|
|
|
ESBYTE[next_word_pointer] = '\n';
|
|
|
|
}
|
|
|
|
|
2016-10-28 19:06:18 +03:00
|
|
|
/*
|
|
|
|
We have a long text and need to show it in block.
|
|
|
|
Normal line break '\n' must be applied.
|
|
|
|
Long lines should be breaked by word.
|
|
|
|
TODO: scroll
|
|
|
|
*/
|
2016-11-02 15:19:15 +03:00
|
|
|
:int DrawTextViewArea(int x,y,w,h, dword buf_start, bg_col, text_col)
|
2016-10-28 19:06:18 +03:00
|
|
|
{
|
|
|
|
dword write_start;
|
|
|
|
dword buf_end;
|
2016-11-02 15:19:15 +03:00
|
|
|
int line_h = 15;
|
2016-10-28 19:06:18 +03:00
|
|
|
int label_length_max;
|
|
|
|
int write_length;
|
|
|
|
bool end_found;
|
|
|
|
|
|
|
|
write_start = buf_start;
|
|
|
|
buf_end = strlen(buf_start) + buf_start;
|
|
|
|
label_length_max = w / 8; // 8 big font char width
|
|
|
|
|
|
|
|
loop()
|
|
|
|
{
|
|
|
|
if (bg_col!=-1) DrawBar(x, y, w+1, line_h, bg_col);
|
|
|
|
end_found = false;
|
|
|
|
write_length = strchr(write_start, '\n') - write_start; //search normal line break
|
|
|
|
if (write_length > label_length_max) || (write_length<=0) //check its position: exceeds maximum line length or not found
|
|
|
|
{
|
|
|
|
if (buf_end - write_start < label_length_max) //check does current line the last
|
|
|
|
{
|
|
|
|
write_length = buf_end - write_start;
|
|
|
|
end_found = true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
for (write_length=label_length_max; write_length>0; write_length--) { //search for white space to make the line break
|
|
|
|
if (ESBYTE[write_start+write_length] == ' ') {
|
|
|
|
end_found = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (end_found != true) write_length = label_length_max; //no white space, so we write label_length_max
|
|
|
|
}
|
|
|
|
ESI = write_length; //set text length attribute for WriteText()
|
2016-11-03 15:41:15 +03:00
|
|
|
WriteText(x, y, 0x10, text_col, write_start);
|
2016-10-28 19:06:18 +03:00
|
|
|
// if (editpos >= write_start-buf_start) && (editpos <= write_start-buf_start + write_length) {
|
|
|
|
// WriteTextB(-write_start+buf_start+editpos * 8 + x - 5 +1, y, 0x90, 0xFF0000, "|");
|
|
|
|
// }
|
|
|
|
write_start += write_length + 1;
|
|
|
|
y += line_h;
|
|
|
|
if (write_start >= buf_end) break;
|
|
|
|
}
|
|
|
|
if (bg_col!=-1) DrawBar(x,y,w+1,h-y+line_h-4,bg_col);
|
|
|
|
return y+line_h;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-02-11 16:46:53 +03:00
|
|
|
//this function increase falue and return it
|
|
|
|
//useful for list of controls which goes one after one
|
2018-02-16 18:53:51 +03:00
|
|
|
:struct incn
|
2016-02-11 16:46:53 +03:00
|
|
|
{
|
|
|
|
dword n;
|
|
|
|
dword inc(dword _addition);
|
|
|
|
};
|
|
|
|
|
2018-02-16 18:53:51 +03:00
|
|
|
:dword incn::inc(dword _addition)
|
2016-02-11 16:46:53 +03:00
|
|
|
{
|
|
|
|
n+=_addition;
|
|
|
|
return n;
|
|
|
|
}
|
|
|
|
|
2018-04-16 01:44:36 +03:00
|
|
|
//block with hover
|
|
|
|
struct block {
|
|
|
|
int x,y,w,h;
|
|
|
|
bool hovered();
|
|
|
|
void set_size();
|
|
|
|
};
|
|
|
|
|
|
|
|
:bool block::hovered() {
|
|
|
|
if ((mouse.x>x) && (mouse.y>y)
|
|
|
|
&& (mouse.y<y+h) && (mouse.x<x+w))
|
|
|
|
return true;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
:void block::set_size(dword _x, _y, _w, _h)
|
|
|
|
{
|
|
|
|
x=_x;
|
|
|
|
y=_y;
|
|
|
|
w=_w;
|
|
|
|
h=_h;
|
|
|
|
}
|
|
|
|
|
2016-02-20 16:06:19 +03:00
|
|
|
|
2017-10-11 01:26:56 +03:00
|
|
|
|
2016-02-20 16:06:19 +03:00
|
|
|
|
|
|
|
|
2015-07-22 21:32:54 +03:00
|
|
|
#endif
|