Assists music production by grouping standalone programs into sessions. Community version of "Non Session Manager".
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

112 lines
4.1KB

  1. /*******************************************************************************/
  2. /* Copyright (C) 2008 Jonathan Moore Liles */
  3. /* */
  4. /* This program is free software; you can redistribute it and/or modify it */
  5. /* under the terms of the GNU General Public License as published by the */
  6. /* Free Software Foundation; either version 2 of the License, or (at your */
  7. /* option) any later version. */
  8. /* */
  9. /* This program is distributed in the hope that it will be useful, but WITHOUT */
  10. /* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */
  11. /* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for */
  12. /* more details. */
  13. /* */
  14. /* You should have received a copy of the GNU General Public License along */
  15. /* with This program; see the file COPYING. If not,write to the Free Software */
  16. /* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
  17. /*******************************************************************************/
  18. /* Just like an Fl_Input, except that when not being edited it
  19. * displays just like a label. */
  20. class Fl_Sometimes_Input : public Fl_Input
  21. {
  22. bool _editing;
  23. public:
  24. Fl_Sometimes_Input ( int X, int Y, int W, int H, const char *L=0 )
  25. : Fl_Input( X, Y, W, H, L )
  26. {
  27. _editing = false;
  28. }
  29. virtual void
  30. draw ( void )
  31. {
  32. if ( _editing )
  33. Fl_Input::draw();
  34. else
  35. {
  36. fl_color( FL_WHITE /* textcolor() */ );
  37. fl_font( textfont(), textsize() );
  38. fl_draw( value(), x(), y(), w(), h(), FL_ALIGN_CENTER );
  39. }
  40. }
  41. virtual int
  42. handle ( int m )
  43. {
  44. int r = Fl_Input::handle( m );
  45. switch ( m )
  46. {
  47. case FL_FOCUS:
  48. _editing = true;
  49. redraw();
  50. return 1;
  51. case FL_PUSH:
  52. _editing = true;
  53. redraw();
  54. return r;
  55. case FL_UNFOCUS:
  56. _editing = false;
  57. {
  58. /* lame, but we have to find the next parent
  59. * with a box in order to clear the background
  60. * properly */
  61. Fl_Group *g = parent();
  62. for ( ; g; g = g->parent() )
  63. {
  64. switch ( g->box() )
  65. {
  66. case FL_NO_BOX:
  67. case FL_UP_FRAME:
  68. case FL_DOWN_FRAME:
  69. case FL_THIN_UP_FRAME:
  70. case FL_THIN_DOWN_FRAME:
  71. case FL_ENGRAVED_FRAME:
  72. case FL_EMBOSSED_FRAME:
  73. // case FL_SHADOW_FRAME:
  74. // case FL_PLASTIC_UP_FRAME:
  75. // case FL_PLASTIC_DOWN_FRAME:
  76. // case FL_ROUNDED_FRAME:
  77. // case FL_OVAL_FRAME:
  78. continue;
  79. default:
  80. break;
  81. }
  82. break;
  83. }
  84. if ( g )
  85. {
  86. printf( "damaging parent\n" );
  87. g->damage( FL_DAMAGE_EXPOSE, x(), y(), w(), h() );
  88. }
  89. }
  90. redraw();
  91. return r;
  92. default:
  93. return r;
  94. }
  95. }
  96. };