/[enigma]/enigma/src/gui.cc
ViewVC logotype

Diff of /enigma/src/gui.cc

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.8 by ant_39, Sat Jun 7 15:21:07 2003 UTC revision 1.9 by dheck, Thu Jun 19 14:27:59 2003 UTC
# Line 185  Container::boundingbox() Line 185  Container::boundingbox()
185  void  void
186  Button::draw(px::GC &gc, const px::Rect &r)  Button::draw(px::GC &gc, const px::Rect &r)
187  {  {
188      char bordername[50];      const int borderw = 4;
189      sprintf(bordername, "b%dx%d%s", get_w(), get_h(),      
190              highlighted ? "h" : "");      px::Surface *s = enigma::GetImage (highlighted ? "buttonhl" : "button");
191      if (px::Surface *s = enigma::GetImage(bordername))  
192          blit(gc, get_x(), get_y(), s);      if (s) {                    // Ugly, but hey, it works
193            set_color (gc, 0,0,0);
194            Rect srcrect (0,0,borderw, borderw);
195            Rect area = get_area();
196    
197            // background
198            box (gc, smaller(area, borderw));
199    
200            // corners
201            blit (gc, area.x, area.y, s, srcrect);
202            srcrect.x += s->width()-borderw;
203            blit (gc, area.x+area.w-borderw, area.y, s, srcrect);
204            srcrect.x = 0;
205            srcrect.y += s->height()-borderw;
206            blit (gc, area.x, area.y+area.h-borderw, s, srcrect);
207            srcrect.x += s->width()-borderw;
208            blit (gc, area.x+area.w-borderw, area.y+area.h-borderw, s, srcrect);
209    
210            // horizontal borders
211            {
212                int tilew = s->width() - 2*borderw;
213                int ntiles = (area.w - 2*borderw) / tilew;
214                int x = area.x + borderw;
215                for (int i=0; i<ntiles; ++i) {
216                    blit (gc, x, area.y, s, Rect (borderw, 0, tilew, borderw));
217                    blit (gc, x, area.y+area.h-borderw, s,
218                          Rect (borderw, s->height()-borderw, tilew, borderw));
219                    x += tilew;
220                }
221                int restw = (area.w - 2*borderw) - tilew*ntiles;
222                blit (gc, x, area.y, s, Rect (borderw, 0, restw, borderw));
223                blit (gc, x, area.y+area.h-borderw, s,
224                      Rect (borderw, s->height()-borderw, restw, borderw));
225            }
226            // vertical borders
227            {
228                int tileh = s->height() - 2*borderw;
229                int ntiles = (area.h - 2*borderw) / tileh;
230                int y = area.y + borderw;
231                for (int i=0; i<ntiles; ++i) {
232                    blit (gc, area.x, y, s, Rect (0, borderw, borderw, tileh));
233                    blit (gc, area.x+area.w-borderw, y, s,
234                          Rect (s->width()-borderw, borderw, borderw, tileh));
235                    y += tileh;
236                }
237                int resth = (area.h - 2*borderw) - tileh*ntiles;
238                blit (gc, area.x, y, s, Rect (0, borderw, borderw, resth));
239                blit (gc, area.x+area.w-borderw, y, s,
240                      Rect (s->width()-borderw, borderw, borderw, resth));
241            }
242        }
243      else {      else {
244          set_color (gc, 0,0,0);          set_color (gc, 0,0,0);
245          box (gc, r);          box (gc, r);
# Line 270  TextButton::TextButton(const string &t, Line 320  TextButton::TextButton(const string &t,
320  void  void
321  TextButton::set_text(const std::string &t)  TextButton::set_text(const std::string &t)
322  {  {
323      text = t;      if (t != text) {
324      redraw();          text = t;
325            redraw();
326        }
327  }  }
328    
329  void  void

Legend:
Removed from v.1.8  
changed lines
  Added in v.1.9

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26