Flu_Simple_Group.cpp 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. // $Id: Flu_Simple_Group.cpp,v 1.5 2004/06/17 14:16:42 jbryan Exp $
  2. /***************************************************************
  3. * FLU - FLTK Utility Widgets
  4. * Copyright (C) 2002 Ohio Supercomputer Center, Ohio State University
  5. *
  6. * This file and its content is protected by a software license.
  7. * You should have received a copy of this license with this file.
  8. * If not, please contact the Ohio Supercomputer Center immediately:
  9. * Attn: Jason Bryan Re: FLU 1224 Kinnear Rd, Columbus, Ohio 43212
  10. *
  11. ***************************************************************/
  12. #include "FLU/Flu_Simple_Group.H"
  13. #include <string.h>
  14. #include <stdio.h>
  15. Flu_Simple_Group :: Flu_Simple_Group( int x, int y, int w, int h, const char *l )
  16. : Fl_Group( x, y, w, h, l )
  17. {
  18. box( FL_EMBOSSED_FRAME );
  19. align( FL_ALIGN_LEFT | FL_ALIGN_INSIDE );
  20. }
  21. void Flu_Simple_Group :: draw()
  22. {
  23. int lblW = 0, lblH, X;
  24. if( label() == 0 )
  25. lblW = lblH = 0;
  26. else if( strlen( label() ) == 0 )
  27. lblW = lblH = 0;
  28. else
  29. {
  30. measure_label( lblW, lblH );
  31. lblW += 4;
  32. lblH += 2;
  33. }
  34. // align the label
  35. if( align() & FL_ALIGN_LEFT )
  36. X = 4;
  37. else if( align() & FL_ALIGN_RIGHT )
  38. X = w() - lblW - 8;
  39. else
  40. X = w()/2 - lblW/2 - 2;
  41. // draw the main group box
  42. if( damage() & ~FL_DAMAGE_CHILD )
  43. fl_draw_box( box(), x(), y()+lblH/2, w(), h()-lblH/2, color() );
  44. // clip and draw the children
  45. fl_clip( x()+2, y()+lblH+1, w()-4, h()-lblH-3 );
  46. draw_children();
  47. fl_pop_clip();
  48. // clear behind the label and draw it
  49. fl_color( color() );
  50. fl_rectf( x()+X, y(), lblW+4, lblH );
  51. fl_color( labelcolor() );
  52. draw_label( x()+X+2, y(), lblW, lblH, FL_ALIGN_CENTER );
  53. }