delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/07/09/10:50:47

From: "Pavlos" <trash24379 AT usa DOT net>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Allegro GUI
Date: Fri, 9 Jul 1999 06:23:44 +0300
Organization: An OTEnet S.A. customer
Lines: 112
Message-ID: <7m3pv0$kdp$1@newssrv.otenet.gr>
References: <X75h3.5879$jl DOT 14653415 AT newscontent-01 DOT sprint DOT ca>
NNTP-Posting-Host: dram-a06.otenet.gr
X-Trace: newssrv.otenet.gr 931490592 20921 195.167.113.229 (9 Jul 1999 03:23:12 GMT)
X-Complaints-To: abuse AT otenet DOT gr
NNTP-Posting-Date: 9 Jul 1999 03:23:12 GMT
X-Newsreader: Microsoft Outlook Express 4.72.3110.1
X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3110.3
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Well, I looked at your code and now it works (for me).
First of all, you forgot to put a NULL DIALOG object at the end of your main
dialog.
And (not really a bug), since you do vsync() in change_color(), you don't
need to do it in add_xxx() functions which call change_color().

Pavlos

<code>

#include <allegro.h>

int change_color(int r, int g, int b);

int add_red()
{
RGB col;
change_color(col.r+15, col.g, col.b);
return D_O_K;
}

int add_green()
{
RGB col;
change_color(col.r, col.g + 15, col.b);
return D_O_K;
}

int add_blue()
{
RGB col;
change_color(col.r, col.g, col.b + 15);
return D_O_K;
}

int prog_quit()
{
return D_CLOSE;
}

int change_color(int r, int g, int b)
{
RGB col;

col.r = r;
col.g = g;
col.b = b;

vsync();

set_color(254, &col);
}

MENU file_menu[] =
{
{"&Gray", NULL, NULL, D_DISABLED, NULL},
{"",      NULL, NULL, 0, NULL},
{"E&xit\tCtrl-X", prog_quit, NULL, 0, NULL},
{NULL, NULL, NULL, 0, NULL}
};

MENU child_menu[] =
{
{"Red", add_red, NULL, 0, NULL},
{"Green", add_green, NULL, 0, NULL},
{"Blue", add_blue, NULL, 0, NULL},
{NULL, NULL, NULL, 0, NULL}
};

MENU RGB_menu[] =
{
{"Add RGB", NULL, child_menu, 0,  NULL},
{NULL, NULL, NULL, 0, NULL}
};

MENU main_menu[] =
{
{"&File", NULL, file_menu, 0, NULL},
{"&RGB", NULL, RGB_menu, 0, NULL},
{NULL, NULL, NULL, 0, NULL}
};



#define ctrl(x)      (x - 'a' + 1)

DIALOG main_dialog[] =
{
{d_clear_proc, 0, 0, 640, 480, 0, 0, 0, 0, 0, 0, NULL},
{d_menu_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, main_menu},
{d_keyboard_proc, 0, 0, 0, 0, 0, 0, ctrl('x'), 0, 0, 0, prog_quit},
{d_ctext_proc, 320, 240, 300, 20, 254, 0, 0, 0, 0, 0, "RGB values..."},
{NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL}
};

int main()
{
allegro_init();
install_keyboard();
install_mouse();
install_timer();
set_gfx_mode(GFX_AUTODETECT, 640, 480, 0, 0);
set_palette(desktop_palette);

change_color(0, 0, 0);
do_dialog(main_dialog, -1);

return 0;
}



- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019