Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » Internal workings of GUI? or something easier...

This thread is locked; no one can reply to it. rss feed Print
Internal workings of GUI? or something easier...
jaime barrachina
Member #6,780
January 2006
avatar

Hello guys, I need your advice again, I've got my marvelous GUI made using allegro but my icon array still needs a little tweaking which i have no idea how to do, attached theres a screenshot of the program I'm making. If you check it out you'll see theres map on the left and array of icons on the right, but if you look closely, you'll see theres 3 icons pressed, obviously, this wont do for any decent editor. My code for the dialog in question is:

1 
2int my_icon_proc (int msg, DIALOG *d, int c)
3{
4 int ret = d_icon_proc (msg, d, c);
5 if (msg == MSG_CLICK)
6 return ((int (*)(void))d->dp3)();
7 return ret;
8}
9 
10 
11 void iconos(void)
12{
13 short int xl = 742, yl = 30, u,ax,ay = 0;
14 the_dialog = new DIALOG[265];
15
16 the_dialog[0].proc = my_bitmap_proc;
17 the_dialog[0].x = 0;
18 the_dialog[0].y = 15;
19 the_dialog[0].w = 756;
20 the_dialog[0].h = 711;
21 the_dialog[0].fg = 0;
22 the_dialog[0].bg = 0;
23 the_dialog[0].key = 0;
24 the_dialog[0].flags = 0;
25 the_dialog[0].d1 = 0;
26 the_dialog[0].d2 = 0;
27 the_dialog[0].dp = NULL;
28 the_dialog[0].dp2 = NULL;
29 the_dialog[0].dp3 = (void *) cambiar_raton;
30
31 for(u = 0; u < 256; u++)
32 {
33 xl += 32;
34 if (xl >= 1024) { xl=774; yl += 22; }
35
36 que_le_den<u>= create_bitmap(32,32);
37 clear_to_color(que_le_den<u>,makecol(255,0,255));
38
39 ax=32*(u/32);
40 ay=32*(u%32);
41 blit((BITMAP*)data[TILES].dat,que_le_den<u>,ax,ay,0,0,TILESIZE,TILESIZE);
42
43 the_dialog [u+1].proc = my_icon_proc;
44 the_dialog [u+1].x = xl;
45 the_dialog [u+1].y = yl;
46 the_dialog [u+1].w = 32;
47 the_dialog [u+1].h = 22;
48 the_dialog [u+1].fg =0;
49 the_dialog [u+1].bg = 0;
50 the_dialog [u+1].key = 0;
51 the_dialog [u+1].flags = 0;
52 the_dialog [u+1].d1 = 2;
53 the_dialog [u+1].d2 = 1;
54 the_dialog [u+1].dp = que_le_den<u>;
55 the_dialog [u+1].dp2 = NULL;
56 the_dialog [u+1].dp3 = (void *) iconitos;
57 }
58 // Here some more procs of the dialog which arent realy relevant for the matter.
59 }

The final idea is for the user to click a icon, then whenever he preses on the map, the tiles he presses on change to the one selected, and when he presses on another icon, the one he pressed earlier somehow "unpresses", and the tile that the mouse now draws changes to the one selected.

The thing is that I have absolutely no idea how to "unpress" a my_icon_proc. As far as I've seen none of the dp fields are used for it, iconitos() right now is an empty function which doesn't do anything and I'm also having difficulty on seeing how I'm going to tell the program which icon its selected if i cant use parameters in the function (which i haven't been able to do yet)

If anyone of you guys can tell me how the icon_proc thing works, give me advice on the iconitos function or just any odd thought he might have about what I'm asking, please go ahead.

[EDIT] Problem solved, everithing works fine now.

"Under the sword lifted high There is hell making you tremble: But go ahead, And you have the land of bliss. - Miyamoto Musahshi"
"When all else fails, read the manual - Dad"

Go to: