mirror of
https://github.com/aseprite/aseprite.git
synced 2025-02-05 09:40:02 +00:00
Fixed the tests
This commit is contained in:
parent
7a0913c2cf
commit
c50df75059
@ -55,7 +55,7 @@ int main (int argc, char *argv[])
|
||||
ji_set_standard_theme();
|
||||
|
||||
jmanager_refresh_screen();
|
||||
ji_mouse_set_cursor(JI_CURSOR_NORMAL);
|
||||
jmouse_set_cursor(JI_CURSOR_NORMAL);
|
||||
|
||||
jalert("Normal==First Alert||&Ok");
|
||||
jalert ("Error"
|
||||
|
@ -32,7 +32,7 @@
|
||||
#include <allegro.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "jinete/jinete/jinete.h"
|
||||
#include "jinete/jinete.h"
|
||||
|
||||
static JWidget check, radio[12];
|
||||
|
||||
|
@ -35,11 +35,11 @@
|
||||
|
||||
FONT *my_font = NULL;
|
||||
|
||||
void set_my_font (void);
|
||||
void set_my_palette (void);
|
||||
JTheme my_theme_new (void);
|
||||
void set_my_font(void);
|
||||
void set_my_palette(void);
|
||||
JTheme my_theme_new(void);
|
||||
|
||||
int main (int argc, char *argv[])
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
JWidget manager, window, box1, box2, box3, box4, box5, button1, button2;
|
||||
JWidget label_username, label_password;
|
||||
@ -47,145 +47,145 @@ int main (int argc, char *argv[])
|
||||
JTheme my_theme;
|
||||
|
||||
/* Allegro stuff */
|
||||
allegro_init ();
|
||||
set_color_depth (16);
|
||||
allegro_init();
|
||||
set_color_depth(16);
|
||||
if (set_gfx_mode(GFX_AUTODETECT_WINDOWED, 320, 200, 0, 0) < 0) {
|
||||
if (set_gfx_mode(GFX_AUTODETECT, 320, 200, 0, 0) < 0) {
|
||||
set_color_depth (8);
|
||||
if (set_gfx_mode (GFX_AUTODETECT_WINDOWED, 320, 200, 0, 0) < 0) {
|
||||
if (set_gfx_mode (GFX_AUTODETECT, 320, 200, 0, 0) < 0) {
|
||||
allegro_message ("%s\n", allegro_error);
|
||||
set_color_depth(8);
|
||||
if (set_gfx_mode(GFX_AUTODETECT_WINDOWED, 320, 200, 0, 0) < 0) {
|
||||
if (set_gfx_mode(GFX_AUTODETECT, 320, 200, 0, 0) < 0) {
|
||||
allegro_message("%s\n", allegro_error);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
install_timer ();
|
||||
install_keyboard ();
|
||||
install_mouse ();
|
||||
install_timer();
|
||||
install_keyboard();
|
||||
install_mouse();
|
||||
|
||||
/* Jinete initialization */
|
||||
manager = jmanager_new ();
|
||||
manager = jmanager_new();
|
||||
|
||||
set_my_font ();
|
||||
set_my_palette ();
|
||||
set_my_font();
|
||||
set_my_palette();
|
||||
|
||||
/* change to custom theme */
|
||||
my_theme = my_theme_new ();
|
||||
ji_set_theme (my_theme);
|
||||
my_theme = my_theme_new();
|
||||
ji_set_theme(my_theme);
|
||||
|
||||
window = jwindow_new ("Login");
|
||||
box1 = jbox_new (JI_VERTICAL);
|
||||
box2 = jbox_new (JI_HORIZONTAL);
|
||||
box3 = jbox_new (JI_VERTICAL | JI_HOMOGENEOUS);
|
||||
box4 = jbox_new (JI_VERTICAL | JI_HOMOGENEOUS);
|
||||
box5 = jbox_new (JI_HORIZONTAL | JI_HOMOGENEOUS);
|
||||
label_username = jlabel_new ("Username");
|
||||
label_password = jlabel_new ("Password");
|
||||
entry_username = jentry_new (32, "");
|
||||
entry_password = jentry_new (32, "");
|
||||
button1 = jbutton_new ("&OK");
|
||||
button2 = jbutton_new ("&Cancel");
|
||||
window = jwindow_new("Login");
|
||||
box1 = jbox_new(JI_VERTICAL);
|
||||
box2 = jbox_new(JI_HORIZONTAL);
|
||||
box3 = jbox_new(JI_VERTICAL | JI_HOMOGENEOUS);
|
||||
box4 = jbox_new(JI_VERTICAL | JI_HOMOGENEOUS);
|
||||
box5 = jbox_new(JI_HORIZONTAL | JI_HOMOGENEOUS);
|
||||
label_username = jlabel_new("Username");
|
||||
label_password = jlabel_new("Password");
|
||||
entry_username = jentry_new(32, "");
|
||||
entry_password = jentry_new(32, "");
|
||||
button1 = jbutton_new("&OK");
|
||||
button2 = jbutton_new("&Cancel");
|
||||
|
||||
jentry_password (entry_password, TRUE);
|
||||
jwidget_magnetic (entry_username, TRUE);
|
||||
jwidget_magnetic (button1, TRUE);
|
||||
jentry_password(entry_password, TRUE);
|
||||
jwidget_magnetic(entry_username, TRUE);
|
||||
jwidget_magnetic(button1, TRUE);
|
||||
|
||||
jwidget_add_child (window, box1);
|
||||
jwidget_add_child (box1, box2);
|
||||
jwidget_add_child (box1, box5);
|
||||
jwidget_add_child (box2, box3);
|
||||
jwidget_add_child (box2, box4);
|
||||
jwidget_add_child (box3, label_username);
|
||||
jwidget_add_child (box3, label_password);
|
||||
jwidget_add_child (box4, entry_username);
|
||||
jwidget_add_child (box4, entry_password);
|
||||
jwidget_add_child (box5, button1);
|
||||
jwidget_add_child (box5, button2);
|
||||
jwidget_add_child(window, box1);
|
||||
jwidget_add_child(box1, box2);
|
||||
jwidget_add_child(box1, box5);
|
||||
jwidget_add_child(box2, box3);
|
||||
jwidget_add_child(box2, box4);
|
||||
jwidget_add_child(box3, label_username);
|
||||
jwidget_add_child(box3, label_password);
|
||||
jwidget_add_child(box4, entry_username);
|
||||
jwidget_add_child(box4, entry_password);
|
||||
jwidget_add_child(box5, button1);
|
||||
jwidget_add_child(box5, button2);
|
||||
|
||||
jwindow_sizeable (window, FALSE);
|
||||
jwindow_sizeable(window, FALSE);
|
||||
|
||||
again:;
|
||||
jwindow_open_fg (window);
|
||||
jwindow_open_fg(window);
|
||||
|
||||
if (jwindow_get_killer (window) == button1) {
|
||||
if (*jwidget_get_text (entry_username) &&
|
||||
*jwidget_get_text (entry_password))
|
||||
jalert ("Login Successful"
|
||||
"==Welcome \"%s\""
|
||||
"||&Done",
|
||||
jwidget_get_text (entry_username));
|
||||
if (jwindow_get_killer(window) == button1) {
|
||||
if (*jwidget_get_text(entry_username) &&
|
||||
*jwidget_get_text(entry_password))
|
||||
jalert("Login Successful"
|
||||
"==Welcome \"%s\""
|
||||
"||&Done",
|
||||
jwidget_get_text(entry_username));
|
||||
else {
|
||||
jalert ("Login Failed"
|
||||
"==Try to use some username==and password"
|
||||
"||&OK");
|
||||
jalert("Login Failed"
|
||||
"==Try to use some username==and password"
|
||||
"||&OK");
|
||||
goto again;
|
||||
}
|
||||
}
|
||||
|
||||
jwidget_free (window);
|
||||
jwidget_free(window);
|
||||
|
||||
jtheme_free (my_theme);
|
||||
jmanager_free (manager);
|
||||
jtheme_free(my_theme);
|
||||
jmanager_free(manager);
|
||||
|
||||
if (my_font)
|
||||
destroy_font (my_font);
|
||||
destroy_font(my_font);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
END_OF_MAIN ();
|
||||
END_OF_MAIN();
|
||||
|
||||
void set_my_font (void)
|
||||
void set_my_font(void)
|
||||
{
|
||||
char buf[512], argv0[512];
|
||||
get_executable_name (argv0, sizeof (argv0));
|
||||
replace_filename (buf, argv0, "zerohour.ttf", sizeof (buf));
|
||||
my_font = ji_font_load_ttf (buf);
|
||||
get_executable_name(argv0, sizeof(argv0));
|
||||
replace_filename(buf, argv0, "zerohour.ttf", sizeof(buf));
|
||||
my_font = ji_font_load_ttf(buf);
|
||||
if (my_font) {
|
||||
font = my_font;
|
||||
ji_font_set_size (font, 8);
|
||||
ji_font_set_size(font, 8);
|
||||
}
|
||||
}
|
||||
|
||||
void set_my_palette (void)
|
||||
void set_my_palette(void)
|
||||
{
|
||||
char buf[512], argv0[512];
|
||||
BITMAP *bmp;
|
||||
PALETTE pal;
|
||||
get_executable_name (argv0, sizeof (argv0));
|
||||
replace_filename (buf, argv0, "pal17.pcx", sizeof (buf));
|
||||
bmp = load_bitmap (buf, pal);
|
||||
get_executable_name(argv0, sizeof(argv0));
|
||||
replace_filename(buf, argv0, "pal17.pcx", sizeof(buf));
|
||||
bmp = load_bitmap(buf, pal);
|
||||
if (bmp) {
|
||||
set_palette (pal);
|
||||
rgb_map = malloc (sizeof (RGB_MAP));
|
||||
create_rgb_table (rgb_map, pal, NULL);
|
||||
set_palette(pal);
|
||||
rgb_map = malloc(sizeof(RGB_MAP));
|
||||
create_rgb_table(rgb_map, pal, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
/**********************************************************************/
|
||||
/* Theme */
|
||||
|
||||
static void theme_regen (void);
|
||||
static void theme_set_cursor (int type);
|
||||
static void theme_init_widget (JWidget widget);
|
||||
static JRegion theme_get_window_mask (JWidget widget);
|
||||
static void theme_regen(void);
|
||||
static BITMAP *theme_set_cursor(int type, int *focus_x, int *focus_y);
|
||||
static void theme_init_widget(JWidget widget);
|
||||
static JRegion theme_get_window_mask(JWidget widget);
|
||||
|
||||
static void theme_draw_box (JWidget widget);
|
||||
static void theme_draw_button (JWidget widget);
|
||||
static void theme_draw_entry (JWidget widget);
|
||||
static void theme_draw_label (JWidget widget);
|
||||
static void theme_draw_window (JWidget widget);
|
||||
static void theme_draw_box(JWidget widget);
|
||||
static void theme_draw_button(JWidget widget);
|
||||
static void theme_draw_entry(JWidget widget);
|
||||
static void theme_draw_label(JWidget widget);
|
||||
static void theme_draw_window(JWidget widget);
|
||||
|
||||
static void draw_rect (JRect rect, int color, bool invert);
|
||||
static void draw_edge (JRect rect, int color, bool invert);
|
||||
static void draw_entry_cursor (JWidget widget, int x, int y);
|
||||
static void draw_rect(JRect rect, int color, bool invert);
|
||||
static void draw_edge(JRect rect, int color, bool invert);
|
||||
static void draw_entry_cursor(JWidget widget, int x, int y);
|
||||
|
||||
JTheme my_theme_new (void)
|
||||
JTheme my_theme_new(void)
|
||||
{
|
||||
JTheme theme;
|
||||
|
||||
theme = jtheme_new ();
|
||||
theme = jtheme_new();
|
||||
if (!theme)
|
||||
return NULL;
|
||||
|
||||
@ -198,26 +198,26 @@ JTheme my_theme_new (void)
|
||||
theme->init_widget = theme_init_widget;
|
||||
theme->get_window_mask = theme_get_window_mask;
|
||||
|
||||
jtheme_set_method (theme, JI_BOX, theme_draw_box);
|
||||
jtheme_set_method (theme, JI_BUTTON, theme_draw_button);
|
||||
jtheme_set_method (theme, JI_ENTRY, theme_draw_entry);
|
||||
jtheme_set_method (theme, JI_LABEL, theme_draw_label);
|
||||
jtheme_set_method (theme, JI_WINDOW, theme_draw_window);
|
||||
jtheme_set_method(theme, JI_BOX, theme_draw_box);
|
||||
jtheme_set_method(theme, JI_BUTTON, theme_draw_button);
|
||||
jtheme_set_method(theme, JI_ENTRY, theme_draw_entry);
|
||||
jtheme_set_method(theme, JI_LABEL, theme_draw_label);
|
||||
jtheme_set_method(theme, JI_WINDOW, theme_draw_window);
|
||||
|
||||
return theme;
|
||||
}
|
||||
|
||||
static void theme_regen (void)
|
||||
static void theme_regen(void)
|
||||
{
|
||||
ji_get_theme ()->desktop_color = makecol (0, 128, 196);
|
||||
ji_get_theme()->desktop_color = makecol(0, 128, 196);
|
||||
}
|
||||
|
||||
static void theme_set_cursor (int type)
|
||||
static BITMAP *theme_set_cursor(int type, int *focus_x, int *focus_y)
|
||||
{
|
||||
set_mouse_sprite (NULL); /* use default Allegro cursor */
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void theme_init_widget (JWidget widget)
|
||||
static void theme_init_widget(JWidget widget)
|
||||
{
|
||||
#define BORDER(n) \
|
||||
widget->border_width.l = n; \
|
||||
@ -234,259 +234,259 @@ static void theme_init_widget (JWidget widget)
|
||||
switch (widget->draw_type) {
|
||||
|
||||
case JI_BOX:
|
||||
BORDER (4);
|
||||
BORDER(4);
|
||||
widget->child_spacing = 2;
|
||||
break;
|
||||
|
||||
case JI_BUTTON:
|
||||
BORDER (5);
|
||||
BORDER(5);
|
||||
widget->child_spacing = 0;
|
||||
break;
|
||||
|
||||
case JI_ENTRY:
|
||||
BORDER (6);
|
||||
BORDER(6);
|
||||
widget->child_spacing = 0;
|
||||
break;
|
||||
|
||||
case JI_WINDOW:
|
||||
BORDER4 (7, 7+jwidget_get_text_height (widget)+7, 7, 7);
|
||||
BORDER4(7, 7+jwidget_get_text_height(widget)+7, 7, 7);
|
||||
widget->child_spacing = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static JRegion theme_get_window_mask (JWidget widget)
|
||||
static JRegion theme_get_window_mask(JWidget widget)
|
||||
{
|
||||
JRegion reg1 = jregion_new (NULL, 0);
|
||||
JRegion reg2 = jregion_new (NULL, 0);
|
||||
JRegion reg1 = jregion_new(NULL, 0);
|
||||
JRegion reg2 = jregion_new(NULL, 0);
|
||||
int table[2] = { 2, 1 };
|
||||
JRect rect = jrect_new (0, 0, 0, 0);
|
||||
JRect pos = jwidget_get_rect (widget);
|
||||
JRect rect = jrect_new(0, 0, 0, 0);
|
||||
JRect pos = jwidget_get_rect(widget);
|
||||
int c;
|
||||
bool overlap;
|
||||
|
||||
for (c=0; c<2; c++) {
|
||||
jrect_replace (rect,
|
||||
pos->x1+table[c], pos->y1+c,
|
||||
pos->x2-table[c], pos->y1+c+1);
|
||||
jregion_reset (reg2, rect);
|
||||
jregion_append (reg1, reg2);
|
||||
jrect_replace(rect,
|
||||
pos->x1+table[c], pos->y1+c,
|
||||
pos->x2-table[c], pos->y1+c+1);
|
||||
jregion_reset(reg2, rect);
|
||||
jregion_append(reg1, reg2);
|
||||
|
||||
jrect_replace (rect,
|
||||
pos->x1+table[c], pos->y2-c-1,
|
||||
pos->x2-table[c], pos->y2-c);
|
||||
jregion_reset (reg2, rect);
|
||||
jregion_append (reg1, reg2);
|
||||
jrect_replace(rect,
|
||||
pos->x1+table[c], pos->y2-c-1,
|
||||
pos->x2-table[c], pos->y2-c);
|
||||
jregion_reset(reg2, rect);
|
||||
jregion_append(reg1, reg2);
|
||||
}
|
||||
|
||||
jrect_replace (rect, pos->x1, pos->y1+c, pos->x2, pos->y2-c);
|
||||
jregion_reset (reg2, rect);
|
||||
jregion_append (reg1, reg2);
|
||||
jrect_replace(rect, pos->x1, pos->y1+c, pos->x2, pos->y2-c);
|
||||
jregion_reset(reg2, rect);
|
||||
jregion_append(reg1, reg2);
|
||||
|
||||
jrect_free (pos);
|
||||
jrect_free (rect);
|
||||
jregion_free (reg2);
|
||||
jrect_free(pos);
|
||||
jrect_free(rect);
|
||||
jregion_free(reg2);
|
||||
|
||||
jregion_validate (reg1, &overlap);
|
||||
jregion_validate(reg1, &overlap);
|
||||
return reg1;
|
||||
}
|
||||
|
||||
static void theme_draw_box (JWidget widget)
|
||||
static void theme_draw_box(JWidget widget)
|
||||
{
|
||||
JWidget window = jwidget_get_window (widget);
|
||||
JWidget window = jwidget_get_window(widget);
|
||||
if (window) {
|
||||
JRect pos = jwidget_get_child_rect (window);
|
||||
draw_edge (pos, makecol (255, 196, 64), FALSE);
|
||||
jrect_shrink (pos, 1);
|
||||
draw_rect (pos, makecol (255, 196, 64), FALSE);
|
||||
jrect_free (pos);
|
||||
JRect pos = jwidget_get_child_rect(window);
|
||||
draw_edge(pos, makecol(255, 196, 64), FALSE);
|
||||
jrect_shrink(pos, 1);
|
||||
draw_rect(pos, makecol(255, 196, 64), FALSE);
|
||||
jrect_free(pos);
|
||||
}
|
||||
}
|
||||
|
||||
static void theme_draw_button (JWidget widget)
|
||||
static void theme_draw_button(JWidget widget)
|
||||
{
|
||||
JRect pos = jwidget_get_rect (widget);
|
||||
JRect pos = jwidget_get_rect(widget);
|
||||
int fg, bg;
|
||||
|
||||
if (jwidget_is_disabled (widget)) {
|
||||
fg = makecol (196, 196, 196);
|
||||
bg = makecol (128, 128, 128);
|
||||
if (jwidget_is_disabled(widget)) {
|
||||
fg = makecol(196, 196, 196);
|
||||
bg = makecol(128, 128, 128);
|
||||
}
|
||||
else {
|
||||
fg = makecol (0, 0, 0);
|
||||
bg = jwidget_has_mouse (widget) ? makecol (64, 224, 255):
|
||||
makecol (0, 196, 255);
|
||||
fg = makecol(0, 0, 0);
|
||||
bg = jwidget_has_mouse(widget) ? makecol(64, 224, 255):
|
||||
makecol(0, 196, 255);
|
||||
}
|
||||
|
||||
draw_edge (pos, makecol (255, 196, 64), TRUE);
|
||||
draw_edge(pos, makecol(255, 196, 64), TRUE);
|
||||
|
||||
if (jwidget_has_focus (widget)) {
|
||||
jrect_shrink (pos, 1);
|
||||
draw_edge (pos, makecol (0, 0, 0), FALSE);
|
||||
jrect_shrink(pos, 1);
|
||||
draw_edge(pos, makecol(0, 0, 0), FALSE);
|
||||
}
|
||||
|
||||
jrect_shrink (pos, 1);
|
||||
draw_edge (pos, bg, jwidget_is_selected (widget));
|
||||
jrect_shrink(pos, 1);
|
||||
draw_edge(pos, bg, jwidget_is_selected(widget));
|
||||
|
||||
jrect_shrink (pos, 1);
|
||||
draw_edge (pos, makecol (128, 128, 128), !jwidget_is_selected (widget));
|
||||
jrect_shrink(pos, 1);
|
||||
draw_edge(pos, makecol(128, 128, 128), !jwidget_is_selected(widget));
|
||||
|
||||
jrect_shrink (pos, 1);
|
||||
draw_rect (pos, bg, jwidget_is_selected (widget));
|
||||
jrect_shrink(pos, 1);
|
||||
draw_rect(pos, bg, jwidget_is_selected(widget));
|
||||
|
||||
if (widget->text) {
|
||||
struct jrect text;
|
||||
|
||||
jwidget_get_texticon_info (widget, NULL, &text, NULL, 0, 0, 0);
|
||||
jwidget_get_texticon_info(widget, NULL, &text, NULL, 0, 0, 0);
|
||||
|
||||
if (jwidget_is_selected (widget))
|
||||
jrect_displace (&text, 1, 1);
|
||||
if (jwidget_is_selected(widget))
|
||||
jrect_displace(&text, 1, 1);
|
||||
|
||||
jdraw_text (widget->text_font, widget->text, text.x1+1, text.y1+1,
|
||||
makecol (255, 255, 255), bg, FALSE);
|
||||
jdraw_text (widget->text_font, widget->text,
|
||||
text.x1, text.y1, fg, bg, FALSE);
|
||||
jdraw_text(widget->text_font, widget->text, text.x1+1, text.y1+1,
|
||||
makecol(255, 255, 255), bg, FALSE);
|
||||
jdraw_text(widget->text_font, widget->text,
|
||||
text.x1, text.y1, fg, bg, FALSE);
|
||||
}
|
||||
|
||||
jrect_free (pos);
|
||||
jrect_free(pos);
|
||||
}
|
||||
|
||||
static void theme_draw_entry (JWidget widget)
|
||||
static void theme_draw_entry(JWidget widget)
|
||||
{
|
||||
int scroll, cursor, state, selbeg, selend;
|
||||
bool password = jentry_is_password (widget);
|
||||
bool password = jentry_is_password(widget);
|
||||
const char *text = widget->text;
|
||||
int c, ch, x, y, w, fg, bg;
|
||||
int cursor_x;
|
||||
JRect pos = jwidget_get_rect (widget);
|
||||
JRect pos = jwidget_get_rect(widget);
|
||||
|
||||
jtheme_entry_info (widget, &scroll, &cursor, &state, &selbeg, &selend);
|
||||
jtheme_entry_info(widget, &scroll, &cursor, &state, &selbeg, &selend);
|
||||
|
||||
bg = makecol (255, 255, 255);
|
||||
bg = makecol(255, 255, 255);
|
||||
|
||||
/* 1st border */
|
||||
draw_edge (pos, makecol (255, 196, 64), TRUE);
|
||||
draw_edge(pos, makecol (255, 196, 64), TRUE);
|
||||
|
||||
/* 2nd border */
|
||||
jrect_shrink (pos, 1);
|
||||
if (jwidget_has_focus (widget)) {
|
||||
jdraw_rect (pos, makecol (0, 0, 0));
|
||||
jrect_shrink (pos, 1);
|
||||
jrect_shrink(pos, 1);
|
||||
if (jwidget_has_focus(widget)) {
|
||||
jdraw_rect(pos, makecol(0, 0, 0));
|
||||
jrect_shrink(pos, 1);
|
||||
}
|
||||
draw_edge (pos, makecol (192, 192, 192), FALSE);
|
||||
draw_edge(pos, makecol(192, 192, 192), FALSE);
|
||||
|
||||
/* background */
|
||||
jrect_shrink (pos, 1);
|
||||
jdraw_rectshade (pos, JI_COLOR_SHADE (bg, -64, -64, -64), bg,
|
||||
JI_VERTICAL);
|
||||
jrect_shrink(pos, 1);
|
||||
jdraw_rectshade(pos, JI_COLOR_SHADE(bg, -64, -64, -64), bg,
|
||||
JI_VERTICAL);
|
||||
|
||||
/* draw the text */
|
||||
x = widget->rc->x1 + widget->border_width.l;
|
||||
y = (widget->rc->y1+widget->rc->y2)/2 - jwidget_get_text_height (widget)/2;
|
||||
y = (widget->rc->y1+widget->rc->y2)/2 - jwidget_get_text_height(widget)/2;
|
||||
|
||||
for (c=scroll; ugetat (text, c); c++) {
|
||||
ch = password ? '*': ugetat (text, c);
|
||||
|
||||
/* normal text */
|
||||
bg = -1;
|
||||
fg = makecol (0, 0, 0);
|
||||
fg = makecol(0, 0, 0);
|
||||
|
||||
/* selected */
|
||||
if ((c >= selbeg) && (c <= selend)) {
|
||||
if (jwidget_has_focus (widget))
|
||||
bg = makecol (44, 76, 145);
|
||||
if (jwidget_has_focus(widget))
|
||||
bg = makecol(44, 76, 145);
|
||||
else
|
||||
bg = makecol (128, 128, 128);
|
||||
fg = makecol (255, 255, 255);
|
||||
bg = makecol(128, 128, 128);
|
||||
fg = makecol(255, 255, 255);
|
||||
}
|
||||
|
||||
/* disabled */
|
||||
if (jwidget_is_disabled (widget)) {
|
||||
if (jwidget_is_disabled(widget)) {
|
||||
bg = -1;
|
||||
fg = makecol (128, 128, 128);
|
||||
fg = makecol(128, 128, 128);
|
||||
}
|
||||
|
||||
w = ji_font_char_len (widget->text_font, ch);
|
||||
w = ji_font_char_len(widget->text_font, ch);
|
||||
if (x+w > widget->rc->x2-3)
|
||||
return;
|
||||
|
||||
cursor_x = x;
|
||||
jdraw_char (widget->text_font, ch, x, y, fg,
|
||||
bg >= 0 ? bg: makecol (192, 192, 192), bg >= 0);
|
||||
jdraw_char(widget->text_font, ch, x, y, fg,
|
||||
bg >= 0 ? bg: makecol (192, 192, 192), bg >= 0);
|
||||
x += w;
|
||||
|
||||
/* cursor */
|
||||
if ((c == cursor) && (state) && (jwidget_has_focus (widget)))
|
||||
draw_entry_cursor (widget, cursor_x, y);
|
||||
if ((c == cursor) && (state) && (jwidget_has_focus(widget)))
|
||||
draw_entry_cursor(widget, cursor_x, y);
|
||||
}
|
||||
|
||||
/* draw the cursor if it is next of the last character */
|
||||
if ((c == cursor) && (state) &&
|
||||
(jwidget_has_focus (widget)) &&
|
||||
(jwidget_is_enabled (widget)))
|
||||
draw_entry_cursor (widget, x, y);
|
||||
(jwidget_has_focus(widget)) &&
|
||||
(jwidget_is_enabled(widget)))
|
||||
draw_entry_cursor(widget, x, y);
|
||||
|
||||
jrect_free (pos);
|
||||
jrect_free(pos);
|
||||
}
|
||||
|
||||
static void theme_draw_label (JWidget widget)
|
||||
static void theme_draw_label(JWidget widget)
|
||||
{
|
||||
/* draw background as Box */
|
||||
theme_draw_box (widget);
|
||||
theme_draw_box(widget);
|
||||
|
||||
if (widget->text) {
|
||||
struct jrect text;
|
||||
|
||||
jwidget_get_texticon_info (widget, NULL, &text, NULL, 0, 0, 0);
|
||||
jwidget_get_texticon_info(widget, NULL, &text, NULL, 0, 0, 0);
|
||||
|
||||
jdraw_text (widget->text_font, widget->text, text.x1+1, text.y1+1,
|
||||
makecol (0, 0, 0), makecol (196, 128, 0), FALSE);
|
||||
jdraw_text (widget->text_font, widget->text, text.x1, text.y1,
|
||||
makecol (255, 255, 255), makecol (196, 128, 0), FALSE);
|
||||
jdraw_text(widget->text_font, widget->text, text.x1+1, text.y1+1,
|
||||
makecol(0, 0, 0), makecol(196, 128, 0), FALSE);
|
||||
jdraw_text(widget->text_font, widget->text, text.x1, text.y1,
|
||||
makecol(255, 255, 255), makecol(196, 128, 0), FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
static void theme_draw_window (JWidget widget)
|
||||
static void theme_draw_window(JWidget widget)
|
||||
{
|
||||
JRect pos;
|
||||
int c;
|
||||
|
||||
pos = jwidget_get_rect (widget);
|
||||
pos = jwidget_get_rect(widget);
|
||||
|
||||
/* borders */
|
||||
for (c=0; c<3; c++) {
|
||||
jdraw_rectedge (pos,
|
||||
JI_COLOR_SHADE (makecol (0, 127, 255), +90, +90, +90),
|
||||
JI_COLOR_SHADE (makecol (0, 127, 255), -90, -90, -90));
|
||||
jrect_shrink (pos, 1);
|
||||
jdraw_rectedge(pos,
|
||||
JI_COLOR_SHADE(makecol(0, 127, 255), +90, +90, +90),
|
||||
JI_COLOR_SHADE(makecol(0, 127, 255), -90, -90, -90));
|
||||
jrect_shrink(pos, 1);
|
||||
}
|
||||
|
||||
/* background */
|
||||
draw_rect (pos, makecol (0, 127, 255), FALSE);
|
||||
draw_rect(pos, makecol(0, 127, 255), FALSE);
|
||||
|
||||
/* title bar */
|
||||
pos->x1 += 8;
|
||||
pos->y1 += 6;
|
||||
jdraw_text (widget->text_font, widget->text, pos->x1+1, pos->y1+1,
|
||||
makecol (0, 0, 0), makecol (0, 127, 255), FALSE);
|
||||
jdraw_text (widget->text_font, widget->text, pos->x1, pos->y1,
|
||||
makecol (255, 255, 255), makecol (0, 127, 255), FALSE);
|
||||
jdraw_text(widget->text_font, widget->text, pos->x1+1, pos->y1+1,
|
||||
makecol(0, 0, 0), makecol(0, 127, 255), FALSE);
|
||||
jdraw_text(widget->text_font, widget->text, pos->x1, pos->y1,
|
||||
makecol(255, 255, 255), makecol(0, 127, 255), FALSE);
|
||||
|
||||
/* border to client area */
|
||||
jrect_free (pos);
|
||||
pos = jwidget_get_child_rect (widget);
|
||||
jrect_stretch (pos, 1);
|
||||
jdraw_rectedge (pos,
|
||||
JI_COLOR_SHADE (makecol (0, 127, 255), -32, -32, -32),
|
||||
JI_COLOR_SHADE (makecol (0, 127, 255), +32, +32, +32));
|
||||
jrect_free (pos);
|
||||
jrect_free(pos);
|
||||
pos = jwidget_get_child_rect(widget);
|
||||
jrect_stretch(pos, 1);
|
||||
jdraw_rectedge(pos,
|
||||
JI_COLOR_SHADE(makecol(0, 127, 255), -32, -32, -32),
|
||||
JI_COLOR_SHADE(makecol(0, 127, 255), +32, +32, +32));
|
||||
jrect_free(pos);
|
||||
}
|
||||
|
||||
static void draw_rect (JRect rect, int color, bool invert)
|
||||
static void draw_rect(JRect rect, int color, bool invert)
|
||||
{
|
||||
JRect p = jrect_new (0, 0, 0, 0);
|
||||
int c1 = JI_COLOR_SHADE (color, +32, +32, +32);
|
||||
int c2 = JI_COLOR_SHADE (color, -32, -32, -32);
|
||||
JRect p = jrect_new(0, 0, 0, 0);
|
||||
int c1 = JI_COLOR_SHADE(color, +32, +32, +32);
|
||||
int c2 = JI_COLOR_SHADE(color, -32, -32, -32);
|
||||
int c, h = 3;
|
||||
|
||||
if (invert) {
|
||||
@ -495,23 +495,23 @@ static void draw_rect (JRect rect, int color, bool invert)
|
||||
c2 = c;
|
||||
}
|
||||
|
||||
jrect_replace (p, rect->x1, rect->y1, rect->x2, rect->y1+h);
|
||||
jdraw_rectshade (p, c1, color, JI_VERTICAL);
|
||||
jrect_replace(p, rect->x1, rect->y1, rect->x2, rect->y1+h);
|
||||
jdraw_rectshade(p, c1, color, JI_VERTICAL);
|
||||
|
||||
jrect_replace (p, rect->x1, rect->y1+h, rect->x2, rect->y2-h);
|
||||
jdraw_rectfill (p, color);
|
||||
jrect_replace(p, rect->x1, rect->y1+h, rect->x2, rect->y2-h);
|
||||
jdraw_rectfill(p, color);
|
||||
|
||||
jrect_replace (p, rect->x1, rect->y2-h, rect->x2, rect->y2);
|
||||
jdraw_rectshade (p, color, c2, JI_VERTICAL);
|
||||
jrect_replace(p, rect->x1, rect->y2-h, rect->x2, rect->y2);
|
||||
jdraw_rectshade(p, color, c2, JI_VERTICAL);
|
||||
|
||||
jrect_free (p);
|
||||
jrect_free(p);
|
||||
}
|
||||
|
||||
static void draw_edge (JRect rect, int color, bool invert)
|
||||
static void draw_edge(JRect rect, int color, bool invert)
|
||||
{
|
||||
JRect p = jrect_new (0, 0, 0, 0);
|
||||
int c1 = JI_COLOR_SHADE (color, +90, +90, +90);
|
||||
int c2 = JI_COLOR_SHADE (color, -90, -90, -90);
|
||||
JRect p = jrect_new(0, 0, 0, 0);
|
||||
int c1 = JI_COLOR_SHADE(color, +90, +90, +90);
|
||||
int c2 = JI_COLOR_SHADE(color, -90, -90, -90);
|
||||
int c;
|
||||
|
||||
if (invert) {
|
||||
@ -520,25 +520,25 @@ static void draw_edge (JRect rect, int color, bool invert)
|
||||
c2 = c;
|
||||
}
|
||||
|
||||
jrect_replace (p, rect->x1, rect->y1, rect->x2, rect->y1+1);
|
||||
jdraw_rectshade (p, c1, color, JI_HORIZONTAL);
|
||||
jrect_replace(p, rect->x1, rect->y1, rect->x2, rect->y1+1);
|
||||
jdraw_rectshade(p, c1, color, JI_HORIZONTAL);
|
||||
|
||||
jrect_moveto (p, p->x1, rect->y2-1);
|
||||
jdraw_rectshade (p, color, c2, JI_HORIZONTAL);
|
||||
jrect_moveto(p, p->x1, rect->y2-1);
|
||||
jdraw_rectshade(p, color, c2, JI_HORIZONTAL);
|
||||
|
||||
jrect_replace (p, rect->x1, rect->y1, rect->x1+1, rect->y2);
|
||||
jdraw_rectshade (p, c1, color, JI_VERTICAL);
|
||||
jrect_replace(p, rect->x1, rect->y1, rect->x1+1, rect->y2);
|
||||
jdraw_rectshade(p, c1, color, JI_VERTICAL);
|
||||
|
||||
jrect_moveto (p, rect->x2-1, p->y1);
|
||||
jdraw_rectshade (p, color, c2, JI_VERTICAL);
|
||||
jrect_moveto(p, rect->x2-1, p->y1);
|
||||
jdraw_rectshade(p, color, c2, JI_VERTICAL);
|
||||
|
||||
jrect_free (p);
|
||||
jrect_free(p);
|
||||
}
|
||||
|
||||
static void draw_entry_cursor (JWidget widget, int x, int y)
|
||||
static void draw_entry_cursor(JWidget widget, int x, int y)
|
||||
{
|
||||
int h = jwidget_get_text_height (widget);
|
||||
int h = jwidget_get_text_height(widget);
|
||||
|
||||
vline (ji_screen, x, y-1, y+h, makecol (0, 0, 0));
|
||||
vline (ji_screen, x+1, y-1, y+h, makecol (0, 0, 0));
|
||||
vline(ji_screen, x, y-1, y+h, makecol(0, 0, 0));
|
||||
vline(ji_screen, x+1, y-1, y+h, makecol(0, 0, 0));
|
||||
}
|
||||
|
@ -40,40 +40,40 @@ int main (int argc, char *argv[])
|
||||
{
|
||||
JWidget manager, window, box, check1, check2, button1, button2;
|
||||
|
||||
allegro_init ();
|
||||
allegro_init();
|
||||
if (set_gfx_mode(GFX_AUTODETECT_WINDOWED, 320, 200, 0, 0) < 0) {
|
||||
if (set_gfx_mode(GFX_AUTODETECT, 320, 200, 0, 0) < 0) {
|
||||
allegro_message("%s\n", allegro_error);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
install_timer ();
|
||||
install_keyboard ();
|
||||
install_mouse ();
|
||||
install_timer();
|
||||
install_keyboard();
|
||||
install_mouse();
|
||||
|
||||
manager = jmanager_new ();
|
||||
ji_set_standard_theme ();
|
||||
manager = jmanager_new();
|
||||
ji_set_standard_theme();
|
||||
|
||||
window = jwindow_new ("Example 18");
|
||||
box = jbox_new (JI_VERTICAL | JI_HOMOGENEOUS);
|
||||
check1 = jcheck_new ("Check &1");
|
||||
check2 = jcheck_new ("Check &2");
|
||||
button1 = jbutton_new ("&OK");
|
||||
button2 = jbutton_new ("&Cancel");
|
||||
window = jwindow_new("Example 18");
|
||||
box = jbox_new(JI_VERTICAL | JI_HOMOGENEOUS);
|
||||
check1 = jcheck_new("Check &1");
|
||||
check2 = jcheck_new("Check &2");
|
||||
button1 = jbutton_new("&OK");
|
||||
button2 = jbutton_new("&Cancel");
|
||||
|
||||
jwidget_add_tip (button1, "This is a tip for \"OK\" button");
|
||||
jwidget_add_tip (button2, "This is a tip for the \"Cancel\" button");
|
||||
jwidget_add_tip(button1, "This is a tip for \"OK\" button");
|
||||
jwidget_add_tip(button2, "This is a tip for the \"Cancel\" button");
|
||||
|
||||
jwidget_add_child (window, box);
|
||||
jwidget_add_child (box, check1);
|
||||
jwidget_add_child (box, check2);
|
||||
jwidget_add_child (box, button1);
|
||||
jwidget_add_child (box, button2);
|
||||
jwidget_add_child(window, box);
|
||||
jwidget_add_child(box, check1);
|
||||
jwidget_add_child(box, check2);
|
||||
jwidget_add_child(box, button1);
|
||||
jwidget_add_child(box, button2);
|
||||
|
||||
jwindow_open_bg (window);
|
||||
jwindow_open_bg(window);
|
||||
|
||||
jmanager_run (manager);
|
||||
jmanager_free (manager);
|
||||
jmanager_run(manager);
|
||||
jmanager_free(manager);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -82,11 +82,11 @@ END_OF_MAIN();
|
||||
/**********************************************************************/
|
||||
/* tip */
|
||||
|
||||
static int tip_type (void);
|
||||
static bool tip_hook (JWidget widget, JMessage msg);
|
||||
static int tip_type(void);
|
||||
static bool tip_hook(JWidget widget, JMessage msg);
|
||||
|
||||
static JWidget tip_window_new (const char *text);
|
||||
static bool tip_window_hook (JWidget widget, JMessage msg);
|
||||
static JWidget tip_window_new(const char *text);
|
||||
static bool tip_window_hook(JWidget widget, JMessage msg);
|
||||
|
||||
typedef struct TipData {
|
||||
int time;
|
||||
@ -135,11 +135,11 @@ static bool tip_hook(JWidget widget, JMessage msg)
|
||||
JWidget window = tip_window_new (tip->text);
|
||||
int w = jrect_w(window->rc);
|
||||
int h = jrect_h(window->rc);
|
||||
jwindow_remap (window);
|
||||
jwindow_position (window,
|
||||
MID (0, ji_mouse_x (0)-w/2, JI_SCREEN_W-w),
|
||||
MID (0, ji_mouse_y (0)-h/2, JI_SCREEN_H-h));
|
||||
jwindow_open (window);
|
||||
jwindow_remap(window);
|
||||
jwindow_position(window,
|
||||
MID(0, jmouse_x(0)-w/2, JI_SCREEN_W-w),
|
||||
MID(0, jmouse_y(0)-h/2, JI_SCREEN_H-h));
|
||||
jwindow_open(window);
|
||||
|
||||
tip->time = -1;
|
||||
}
|
||||
@ -159,8 +159,9 @@ static JWidget tip_window_new(const char *text)
|
||||
jwidget_set_align(window, JI_CENTER | JI_MIDDLE);
|
||||
|
||||
/* remove decorative widgets */
|
||||
JI_LIST_EACH_SAFE(window->children, link, next)
|
||||
JI_LIST_FOR_EACH_SAFE(window->children, link, next) {
|
||||
jwidget_free(link->data);
|
||||
}
|
||||
|
||||
jwidget_add_hook(window, JI_WIDGET, tip_window_hook, NULL);
|
||||
jwidget_init_theme(window);
|
||||
|
@ -133,7 +133,7 @@ void draw_gui()
|
||||
{
|
||||
jwidget_dirty(manager);
|
||||
jwidget_flush_redraw(manager);
|
||||
jmanager_dispatch_draw_messages();
|
||||
//jmanager_dispatch_draw_messages();
|
||||
}
|
||||
|
||||
float get_speed(void)
|
||||
|
@ -19,7 +19,7 @@
|
||||
#include <allegro.h>
|
||||
#include <math.h>
|
||||
|
||||
#include "jinete/jbase.h"
|
||||
#include "jinete/jinete.h"
|
||||
|
||||
#include "raster/algo.h"
|
||||
#include "raster/image.h"
|
||||
@ -131,18 +131,19 @@ void draw_bezier_path(BITMAP *bmp, BEZIER_PATH *path, int flags, int color)
|
||||
|
||||
typedef struct Point { int x, y; } Point;
|
||||
|
||||
static void add_shape_seg(int x1, int y1, int x2, int y2, JList *shape)
|
||||
static void add_shape_seg(int x1, int y1, int x2, int y2, JList shape)
|
||||
{
|
||||
Point *point = jnew (Point, 1);
|
||||
Point *point = jnew(Point, 1);
|
||||
point->x = x2;
|
||||
point->y = y2;
|
||||
*shape = jlist_append (*shape, point);
|
||||
jlist_append(shape, point);
|
||||
}
|
||||
|
||||
void draw_filled_bezier_path(BITMAP *bmp, BEZIER_PATH *path, int color)
|
||||
{
|
||||
BEZIER_NODE *node;
|
||||
JList it, shape = NULL;
|
||||
JList shape = jlist_new();
|
||||
JLink link;
|
||||
int c, vertices;
|
||||
int *points;
|
||||
|
||||
@ -157,7 +158,7 @@ void draw_filled_bezier_path(BITMAP *bmp, BEZIER_PATH *path, int color)
|
||||
node->next->prev_y,
|
||||
node->next->x,
|
||||
node->next->y,
|
||||
(void *)&shape, (AlgoLine)add_shape_seg);
|
||||
(void *)shape, (AlgoLine)add_shape_seg);
|
||||
}
|
||||
|
||||
if (node == path->last)
|
||||
@ -166,20 +167,24 @@ void draw_filled_bezier_path(BITMAP *bmp, BEZIER_PATH *path, int color)
|
||||
|
||||
vertices = jlist_length(shape);
|
||||
if (vertices > 0) {
|
||||
points = jmalloc(sizeof (int) * vertices * 2);
|
||||
for (c=0, it=shape; it; it=it->next) {
|
||||
points[c++] = ((Point *)it->data)->x;
|
||||
points[c++] = ((Point *)it->data)->y;
|
||||
points = jmalloc(sizeof(int) * vertices * 2);
|
||||
|
||||
c = 0;
|
||||
JI_LIST_FOR_EACH(shape, link) {
|
||||
points[c++] = ((Point *)link->data)->x;
|
||||
points[c++] = ((Point *)link->data)->y;
|
||||
}
|
||||
polygon(bmp, vertices, points, color);
|
||||
ji_free(points);
|
||||
jfree(points);
|
||||
}
|
||||
|
||||
for (it=shape; it; it=it->next)
|
||||
jfree(it->data);
|
||||
JI_LIST_FOR_EACH(shape, link);
|
||||
jfree(link->data);
|
||||
|
||||
jlist_free(shape);
|
||||
}
|
||||
|
||||
void draw_art_filled_bezier_path (BITMAP *bmp, BEZIER_PATH *path)
|
||||
void draw_art_filled_bezier_path(BITMAP *bmp, BEZIER_PATH *path)
|
||||
{
|
||||
Image *image = image_new (IMAGE_RGB, SCREEN_W, SCREEN_H);
|
||||
Path *art_path = path_new (NULL);
|
||||
|
@ -54,15 +54,16 @@ void test ()
|
||||
|
||||
/* build the layers */
|
||||
{
|
||||
Layer *layer = layer_new (sprite->imgtype);
|
||||
Layer *layer = layer_new(sprite);
|
||||
|
||||
/* add this layer to the sprite */
|
||||
layer_add_layer (sprite->set, layer);
|
||||
layer_add_layer(sprite->set, layer);
|
||||
|
||||
/* build the "stock" and the properties */
|
||||
{
|
||||
int i, c, image_index;
|
||||
Image *image;
|
||||
Cel *cel;
|
||||
|
||||
for (i=0; i<32; i++) {
|
||||
/* make the image */
|
||||
@ -79,30 +80,31 @@ void test ()
|
||||
}
|
||||
|
||||
/* add the new image in the stock */
|
||||
image_index = stock_add_image (layer->stock, image);
|
||||
image_index = stock_add_image(sprite->stock, image);
|
||||
|
||||
/* image property */
|
||||
layer_add_frame (layer,
|
||||
frame_new (i, /* frpos */
|
||||
image_index, /* image */
|
||||
cos(AL_PI*i/16)*64, /* x */
|
||||
sin(AL_PI*i/16)*64, /* y */
|
||||
128+sin(AL_PI*i/32)*127)); /* opacity */
|
||||
/* cel properties */
|
||||
cel = cel_new(i, image_index);
|
||||
cel_set_position(cel,
|
||||
cos(AL_PI*i/16)*64,
|
||||
sin(AL_PI*i/16)*64);
|
||||
cel_set_opacity(cel, 128+sin(AL_PI*i/32)*127);
|
||||
|
||||
layer_add_cel(layer, cel);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
do {
|
||||
image_copy (image_screen, image_bg, 0, 0);
|
||||
sprite_render (sprite, image_screen,
|
||||
mouse_x-sprite->w/2, mouse_y-sprite->h/2);
|
||||
image_to_allegro (image_screen, bmp, 0, 0);
|
||||
image_copy(image_screen, image_bg, 0, 0);
|
||||
sprite_render(sprite, image_screen,
|
||||
mouse_x-sprite->w/2, mouse_y-sprite->h/2);
|
||||
image_to_allegro(image_screen, bmp, 0, 0);
|
||||
|
||||
if (key[KEY_LEFT]) sprite->frpos--;
|
||||
if (key[KEY_RIGHT]) sprite->frpos++;
|
||||
if (key[KEY_LEFT]) sprite->frame--;
|
||||
if (key[KEY_RIGHT]) sprite->frame++;
|
||||
|
||||
text_mode(makecol (0, 0, 0));
|
||||
textprintf(bmp, font, 0, 0, makecol (255, 255, 255), "%d", sprite->frpos);
|
||||
textprintf(bmp, font, 0, 0, makecol(255, 255, 255), "%d", sprite->frame);
|
||||
blit(bmp, screen, 0, 0, 0, 0, SCREEN_W, SCREEN_H);
|
||||
} while (!key[KEY_ESC]);
|
||||
|
||||
@ -114,16 +116,16 @@ void test ()
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
allegro_init ();
|
||||
set_color_depth (16);
|
||||
set_gfx_mode (GFX_AUTODETECT, 320, 200, 0, 0);
|
||||
install_timer ();
|
||||
install_keyboard ();
|
||||
install_mouse ();
|
||||
allegro_init();
|
||||
set_color_depth(16);
|
||||
set_gfx_mode(GFX_AUTODETECT_WINDOWED, 320, 200, 0, 0);
|
||||
install_timer();
|
||||
install_keyboard();
|
||||
install_mouse();
|
||||
|
||||
set_palette (default_palette);
|
||||
set_palette(default_palette);
|
||||
|
||||
test ();
|
||||
test();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user