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.

110 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( fl_contrast( textcolor(), color() ) );
  47. fl_font( textfont(), textsize() );
  48. fl_draw( value(), x(), y(), w(), h(), (Fl_Align)(FL_ALIGN_CENTER | FL_ALIGN_CLIP) );
  49. }
  50. }
  51. virtual void
  52. take_focus ( void )
  53. {
  54. set_visible_focus();
  55. Fl_Widget::take_focus();
  56. clear_visible_focus();
  57. }
  58. virtual int
  59. handle ( int m )
  60. {
  61. int r = 0;
  62. switch ( m )
  63. {
  64. case FL_KEYDOWN:
  65. {
  66. if ( ( Fl::event_key() == FL_Enter ||
  67. Fl::event_key() == FL_Tab ) )
  68. {
  69. Fl::focus( NULL );
  70. r = 1;
  71. }
  72. break;
  73. }
  74. case FL_FOCUS:
  75. redraw();
  76. r = 1;
  77. break;
  78. case FL_UNFOCUS:
  79. do_callback();
  80. r = 1;
  81. break;
  82. case FL_PUSH:
  83. take_focus();
  84. redraw();
  85. r = 1;
  86. break;
  87. case FL_DND_ENTER:
  88. return 0;
  89. case FL_PASTE:
  90. return 0;
  91. default:
  92. break;
  93. }
  94. return Fl_Input::handle( m ) | r;
  95. }
  96. };