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.

114 lines
3.7KB

  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. #pragma once
  19. /* Just like an Fl_Input, except that when not being edited it
  20. * displays just like a label. */
  21. #include <FL/fl_draw.H>
  22. #include <FL/Fl.H>
  23. #include <FL/Fl_Window.H>
  24. #include <FL/Fl_Input.H>
  25. class Fl_Sometimes_Input : public Fl_Input
  26. {
  27. Fl_Boxtype _up_box;
  28. public:
  29. Fl_Sometimes_Input ( int X, int Y, int W, int H, const char *L=0 )
  30. : Fl_Input( X, Y, W, H, L )
  31. {
  32. clear_visible_focus();
  33. up_box( FL_NO_BOX );
  34. when(FL_WHEN_ENTER_KEY);
  35. }
  36. void up_box ( Fl_Boxtype b ) { _up_box = b; }
  37. Fl_Boxtype up_box ( void ) const { return _up_box; }
  38. virtual void
  39. draw ( void )
  40. {
  41. if ( this == Fl::focus() )
  42. Fl_Input::draw();
  43. else
  44. {
  45. fl_draw_box( up_box(), x(), y(), w(), h(), color() );
  46. Fl_Color c = fl_contrast( textcolor(), color() );
  47. fl_color( active_r() ? c : fl_inactive( c ) );
  48. fl_font( textfont(), textsize() );
  49. fl_draw( value(), x(), y(), w(), h(), (Fl_Align)(FL_ALIGN_CENTER | FL_ALIGN_CLIP) );
  50. }
  51. }
  52. virtual void
  53. take_focus ( void )
  54. {
  55. set_visible_focus();
  56. Fl_Widget::take_focus();
  57. clear_visible_focus();
  58. }
  59. virtual int
  60. handle ( int m )
  61. {
  62. int r = 0;
  63. switch ( m )
  64. {
  65. case FL_KEYDOWN:
  66. {
  67. if ( ( Fl::event_key() == FL_Enter ||
  68. Fl::event_key() == FL_Tab ) )
  69. {
  70. Fl::focus( NULL );
  71. r = 1;
  72. }
  73. break;
  74. }
  75. case FL_FOCUS:
  76. redraw();
  77. r = 1;
  78. break;
  79. case FL_UNFOCUS:
  80. do_callback();
  81. r = 1;
  82. break;
  83. case FL_PUSH:
  84. take_focus();
  85. redraw();
  86. r = 1;
  87. break;
  88. case FL_DND_ENTER:
  89. return 0;
  90. case FL_PASTE:
  91. return 0;
  92. default:
  93. break;
  94. }
  95. return Fl_Input::handle( m ) | r;
  96. }
  97. };