[49] | 1 | #include "tools.hpp" |
---|
| 2 | |
---|
| 3 | |
---|
| 4 | |
---|
| 5 | tool_picker::~tool_picker() |
---|
| 6 | { delete old_pal; |
---|
| 7 | delete map; |
---|
| 8 | for (int i=0;i<total_icons;i++) |
---|
| 9 | delete icons[i]; // delete visual object, which should be a "shell" |
---|
| 10 | } |
---|
| 11 | |
---|
| 12 | void tool_picker::remap(palette *pal, window_manager *wm, image *screen) |
---|
| 13 | { |
---|
| 14 | delete map; |
---|
| 15 | map=new filter(old_pal,pal); |
---|
| 16 | draw_first(screen,wm); |
---|
| 17 | } |
---|
| 18 | |
---|
| 19 | tool_picker::tool_picker(int X, int Y, int ID, |
---|
| 20 | int show_h, visual_object **Icons, int *Ids, int total_ic, |
---|
| 21 | palette *icon_palette, palette *pal, window_manager *wm, ifield *Next) : |
---|
| 22 | spicker(X,Y,ID,show_h,1,1,0,Next) |
---|
| 23 | { |
---|
| 24 | iw=ih=0; |
---|
| 25 | icons=Icons; |
---|
| 26 | ids=Ids; |
---|
| 27 | total_icons=total_ic; |
---|
| 28 | for (int i=0;i<total_ic;i++) |
---|
| 29 | { |
---|
| 30 | if (icons[i]->width(wm)>iw) iw=icons[i]->width(wm); |
---|
| 31 | if (icons[i]->height(wm)>ih) ih=icons[i]->height(wm); |
---|
| 32 | } |
---|
| 33 | map=new filter(icon_palette,pal); |
---|
| 34 | old_pal=icon_palette->copy(); |
---|
| 35 | reconfigure(); |
---|
| 36 | } |
---|
| 37 | |
---|
| 38 | void tool_picker::draw_item(window_manager *wm, image *screen, int x, int y, int num, int active) |
---|
| 39 | { |
---|
| 40 | if (!active) |
---|
| 41 | screen->bar(x,y,x+iw-1,y+ih-1,wm->black()); |
---|
| 42 | else |
---|
| 43 | screen->bar(x,y,x+iw-1,y+ih-1,wm->bright_color()); |
---|
| 44 | icons[num]->draw(screen,x,y,wm,map); |
---|
| 45 | } |
---|
| 46 | |
---|