2015-07-22 20:32:54 +02:00
|
|
|
#ifndef INCLUDE_GUI_H
|
|
|
|
#define INCLUDE_GUI_H
|
2015-08-04 17:48:36 +02:00
|
|
|
#print "[include <gui.h>]\n"
|
2015-07-22 20:32:54 +02:00
|
|
|
|
|
|
|
#ifndef INCLUDE_KOLIBRI_H
|
|
|
|
#include "../lib/kolibri.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef INCLUDE_STRING_H
|
|
|
|
#include "../lib/strings.h"
|
|
|
|
#endif
|
2012-12-15 01:16:06 +01:00
|
|
|
|
2016-02-09 02:43:58 +01:00
|
|
|
#ifndef INCLUDE_RGB_H
|
|
|
|
#include "../lib/patterns/rgb.h"
|
|
|
|
#endif
|
|
|
|
|
2013-10-11 00:45:19 +02:00
|
|
|
:void DrawRectangle(dword x,y,w,h,color1)
|
2012-11-26 16:26:15 +01:00
|
|
|
{
|
2013-02-04 14:15:13 +01: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 16:26:15 +01:00
|
|
|
}
|
|
|
|
|
2015-08-17 23:24:56 +02: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 00:45:19 +02:00
|
|
|
:void DrawRectangle3D(dword x,y,w,h,color1,color2)
|
2012-11-26 16:26:15 +01:00
|
|
|
{
|
2013-02-04 14:15:13 +01: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 16:26:15 +01:00
|
|
|
}
|
|
|
|
|
2013-10-11 00:45:19 +02:00
|
|
|
:void DrawCaptButton(dword x,y,w,h,id,color_b, color_t,text)
|
2012-11-26 16:26:15 +01:00
|
|
|
{
|
2016-02-09 02:43:58 +01:00
|
|
|
word tx = -strlen(text)*6+w/2+x+1;
|
|
|
|
word ty = h/2-3+y;
|
2014-04-17 20:07:07 +02:00
|
|
|
if (id>0) DefineButton(x,y,w,h,id,color_b);
|
2016-02-09 02:43:58 +01:00
|
|
|
WriteText(tx+1,ty+1,0x80,MixColors(color_b,0,200),text);
|
|
|
|
WriteText(tx,ty,0x80,color_t,text);
|
2012-11-26 16:26:15 +01:00
|
|
|
}
|
|
|
|
|
2014-04-17 20:07:07 +02: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 15:20:32 +01:00
|
|
|
:void DrawCircle(int x, y, r, color)
|
2012-11-26 16:26:15 +01:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
float px=0, py=r, ii = r * 3.1415926 * 2;
|
|
|
|
FOR (i = 0; i < ii; i++)
|
|
|
|
{
|
2015-03-16 15:20:32 +01:00
|
|
|
PutPixel(px + x, y - py, color);
|
2012-11-26 16:26:15 +01:00
|
|
|
px = py / r + px;
|
|
|
|
py = -px / r + py;
|
|
|
|
}
|
2012-12-05 16:25:01 +01:00
|
|
|
}
|
2012-12-15 00:55:44 +01:00
|
|
|
|
2016-02-09 02:43:58 +01:00
|
|
|
:void CheckBox(dword x,y,bt_id, text, is_checked)
|
2012-12-15 00:55:44 +01:00
|
|
|
{
|
2016-02-09 02:43:58 +01:00
|
|
|
byte w=14, h=14;
|
|
|
|
DefineButton(x-1, y-1, strlen(text)*6 + w + 17, h+2, bt_id+BT_HIDE+BT_NOFRAME, 0);
|
|
|
|
WriteText(x+w+8, h / 2 + y -3, 0x80, system.color.work_text, text);
|
|
|
|
DrawRectangle(x, y, w, h, system.color.work_graph);
|
2015-02-26 17:48:22 +01: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 00:55:44 +01:00
|
|
|
{
|
2016-02-09 02:43:58 +01:00
|
|
|
DrawWideRectangle(x+1, y+1, w-1, h-1, 2, 0xffffff);
|
2016-02-11 02:07:04 +01:00
|
|
|
DrawBar(x+3, y+3, w-5, h-5, 0x00C000); //0x13A113
|
2012-12-15 00:55:44 +01:00
|
|
|
}
|
2015-02-26 17:48:22 +01:00
|
|
|
else if (is_checked == 2) //not active
|
2012-12-15 00:55:44 +01:00
|
|
|
{
|
2016-02-09 02:43:58 +01:00
|
|
|
DrawWideRectangle(x+1, y+1, w-1, h-1, 2, 0xffffff);
|
2015-03-18 12:59:32 +01:00
|
|
|
DrawBar(x+3, y+3, w-5, h-5, 0x888888);
|
2015-02-26 17:48:22 +01:00
|
|
|
}
|
2016-02-11 02:07:04 +01:00
|
|
|
DrawRectangle3D(x-1,y-1,w+2,h+2,system.color.work_dark,system.color.work_light);
|
2015-02-26 17:48:22 +01:00
|
|
|
}
|
|
|
|
|
2016-02-09 02:43:58 +01:00
|
|
|
:void MoreLessBox(dword x,y, bt_id_more, bt_id_less, value, text)
|
2015-02-26 17:48:22 +01:00
|
|
|
{
|
2016-02-09 02:43:58 +01:00
|
|
|
#define VALUE_FIELD_W 26
|
|
|
|
#define SIZE 18
|
2015-03-21 00:40:49 +01:00
|
|
|
|
2016-02-09 02:43:58 +01:00
|
|
|
DrawRectangle(x, y, VALUE_FIELD_W, SIZE, system.color.work_graph);
|
|
|
|
DrawRectangle3D(x+1, y+1, VALUE_FIELD_W-2, SIZE-2, 0xDDDddd, 0xffffff);
|
|
|
|
DrawBar(x+2, y+2, VALUE_FIELD_W-3, SIZE-3, 0xffffff);
|
|
|
|
WriteText(x+6, SIZE / 2 + y -3, 0x80, 0x000000, itoa(value));
|
2015-02-26 17:48:22 +01:00
|
|
|
|
2016-02-11 02:07:04 +01:00
|
|
|
DrawCaptButton(VALUE_FIELD_W + x, y, SIZE, SIZE, bt_id_more, system.color.work_button, system.color.work_button_text, "+");
|
|
|
|
DrawCaptButton(VALUE_FIELD_W + x + SIZE, y, SIZE, SIZE, bt_id_less, system.color.work_button, system.color.work_button_text, "-");
|
2016-02-09 02:43:58 +01:00
|
|
|
WriteText(x+VALUE_FIELD_W+SIZE+SIZE+10, SIZE / 2 + y -3, 0x80, system.color.work_text, text);
|
2016-02-11 02:07:04 +01:00
|
|
|
DrawRectangle3D(x-1,y-1,VALUE_FIELD_W+SIZE+SIZE+2,SIZE+2,system.color.work_dark,system.color.work_light);
|
2012-12-15 16:56:24 +01:00
|
|
|
}
|
|
|
|
|
2016-02-11 03:22:34 +01:00
|
|
|
:void EditBox(dword edit_box_pointer)
|
|
|
|
{
|
|
|
|
dword x,y,w,h;
|
|
|
|
ESI = edit_box_pointer;
|
|
|
|
x = ESI.edit_box.left;
|
|
|
|
y = ESI.edit_box.top;
|
|
|
|
w = ESI.edit_box.width+1;
|
|
|
|
h = 15;
|
|
|
|
DrawRectangle(x-1, y-1, w+2, h+2, 0xFFFfff);
|
|
|
|
DrawRectangle3D(x-2, y-2, w+2, h+2, 0xDDDddd, 0xffffff);
|
|
|
|
DrawRectangle(x-3, y-3, w+6, h+6, system.color.work_graph);
|
|
|
|
DrawRectangle3D(x-4, y-4, w+8, h+8, system.color.work_dark, system.color.work_light);
|
|
|
|
}
|
|
|
|
|
2014-03-23 18:12:21 +01: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 16:56:24 +01:00
|
|
|
{
|
2013-02-04 14:15:13 +01:00
|
|
|
int progress_w;
|
2012-12-15 16:56:24 +01:00
|
|
|
static int fill_old;
|
|
|
|
|
2013-03-11 19:16:24 +01: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 16:56:24 +01: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 14:15:13 +01: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 19:16:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
:void DrawLink(dword x,y,font_type,btn_id, inscription)
|
|
|
|
{
|
|
|
|
int w;
|
|
|
|
WriteText(x,y,font_type,0x4E00E7,inscription);
|
|
|
|
if (font_type==0x80) w = strlen(inscription)*6; else w = strlen(inscription)*7;
|
|
|
|
DefineButton(x-1,y-1,w,10,btn_id+BT_HIDE,0);
|
|
|
|
DrawBar(x,y+8,w,1,0x4E00E7);
|
|
|
|
}
|
|
|
|
|
2013-10-09 20:10:23 +02:00
|
|
|
:void PutShadow(dword x,y,w,h,skinned,strength)
|
2013-03-11 19:16:24 +01:00
|
|
|
{
|
|
|
|
proc_info wForm;
|
|
|
|
dword shadow_buf, skin_height;
|
|
|
|
shadow_buf = mem_Alloc(w*h*3);
|
|
|
|
GetProcessInfo(#wForm, SelfInfo);
|
2013-10-09 20:10:23 +02:00
|
|
|
CopyScreen(shadow_buf, 5*skinned+x+wForm.left, GetSkinHeight()*skinned+y+wForm.top, w, h);
|
2013-03-11 19:16:24 +01:00
|
|
|
ShadowImage(shadow_buf, w, h, strength);
|
|
|
|
_PutImage(x,y,w,h,shadow_buf);
|
|
|
|
mem_Free(shadow_buf);
|
|
|
|
}
|
|
|
|
|
2013-10-09 20:10:23 +02:00
|
|
|
:void DrawPopup(dword x,y,w,h,skinned, col_work,col_border)
|
|
|
|
{
|
|
|
|
DrawRectangle(x,y,w,h,col_border);
|
2013-10-09 21:12:03 +02:00
|
|
|
DrawBar(x+1,y+1,w-1,1,0xFFFfff);
|
2013-10-15 12:30:46 +02:00
|
|
|
DrawBar(x+1,y+2,1,h-2,0xFFFfff);
|
2013-10-09 21:12:03 +02:00
|
|
|
if (col_work!=-1) DrawBar(x+2,y+2,w-2,h-2,col_work);
|
2013-10-09 20:10:23 +02:00
|
|
|
DrawPopupShadow(x,y,w,h-1,skinned);
|
|
|
|
}
|
|
|
|
|
2015-03-05 21:55:28 +01: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 19:16:24 +01:00
|
|
|
:void GrayScaleImage(dword color_image, w, h)
|
|
|
|
{
|
2015-08-22 15:27:12 +02: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 19:16:24 +01:00
|
|
|
{
|
2015-08-22 15:27:12 +02:00
|
|
|
rr = DSBYTE[i];
|
|
|
|
gg = DSBYTE[i+1];
|
|
|
|
bb = DSBYTE[i+2];
|
2013-03-11 19:16:24 +01:00
|
|
|
gray = rr*rr;
|
|
|
|
gray += gg*gg;
|
|
|
|
gray += bb*bb;
|
|
|
|
gray = sqrt(gray) / 3;
|
2015-08-22 15:27:12 +02:00
|
|
|
DSBYTE[i] = DSBYTE[i+1] = DSBYTE[i+2] = gray;
|
2013-03-11 19:16:24 +01: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 20:32:54 +02:00
|
|
|
}
|
|
|
|
|
2015-12-14 15:50:28 +01: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';
|
|
|
|
}
|
|
|
|
|
2015-07-22 20:32:54 +02:00
|
|
|
#endif
|