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.

155 lines
4.2KB

  1. /* SpiralPlugin
  2. * Copyleft (C) 2000 David Griffiths <dave@pawfal.org>
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; either version 2 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write to the Free Software
  16. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  17. */
  18. #include "OutputPluginGUI.h"
  19. #include <FL/fl_draw.h>
  20. #include <FL/fl_file_chooser.H>
  21. static const int GUI_COLOUR = 179;
  22. static const int GUIBG_COLOUR = 144;
  23. static const int GUIBG2_COLOUR = 145;
  24. OutputPluginGUI::OutputPluginGUI(int w, int h, SpiralPlugin *o, ChannelHandler *ch,const HostInfo *Info) :
  25. SpiralPluginGUI(w,h,o,ch)
  26. {
  27. Volume = new Fl_Knob(30, 22, 40, 40, "Volume");
  28. Volume->color(GUI_COLOUR);
  29. Volume->type(Fl_Knob::DOTLIN);
  30. Volume->labelsize(10);
  31. Volume->maximum(1);
  32. Volume->step(0.001);
  33. Volume->value(0.5);
  34. Volume->callback((Fl_Callback*)cb_Volume);
  35. Record = new Fl_Button(30, 80, 40, 25, "Record");
  36. Record->type(1);
  37. Record->down_box(FL_DOWN_BOX);
  38. Record->labelsize(10);
  39. Record->callback((Fl_Callback*)cb_Record);
  40. OpenRead = new Fl_Button(2, 110, 30, 15, "Read");
  41. OpenRead->type(1);
  42. OpenRead->down_box(FL_DOWN_BOX);
  43. OpenRead->labelsize(10);
  44. OpenRead->callback((Fl_Callback*)cb_OpenRead);
  45. OpenDuplex = new Fl_Button(34, 110, 31, 15, "Dplx");
  46. OpenDuplex->type(1);
  47. OpenDuplex->down_box(FL_DOWN_BOX);
  48. OpenDuplex->labelsize(10);
  49. OpenDuplex->callback((Fl_Callback*)cb_OpenDuplex);
  50. OpenWrite = new Fl_Button(68, 110, 30, 15, "Write");
  51. OpenWrite->type(1);
  52. OpenWrite->down_box(FL_DOWN_BOX);
  53. OpenWrite->labelsize(10);
  54. OpenWrite->callback((Fl_Callback*)cb_OpenWrite);
  55. end();
  56. }
  57. void OutputPluginGUI::UpdateValues(SpiralPlugin *o)
  58. {
  59. Volume->value(OSSOutput::Get()->GetVolume());
  60. }
  61. //// Callbacks ////
  62. inline void OutputPluginGUI::cb_Volume_i(Fl_Knob* o, void* v)
  63. { OSSOutput::Get()->SetVolume(o->value()); }
  64. void OutputPluginGUI::cb_Volume(Fl_Knob* o, void* v)
  65. { ((OutputPluginGUI*)(o->parent()))->cb_Volume_i(o,v); }
  66. inline void OutputPluginGUI::cb_Record_i(Fl_Button* o, void* v)
  67. {
  68. if (o->value())
  69. {
  70. char *fn=fl_file_chooser("Pick a Wav file to save to", "*.wav", NULL);
  71. if (fn && fn!="")
  72. {
  73. OSSOutput::Get()->WavOpen(fn);
  74. }
  75. else
  76. {
  77. OSSOutput::Get()->WavClose();
  78. o->value(false);
  79. }
  80. }
  81. else
  82. {
  83. OSSOutput::Get()->WavClose();
  84. }
  85. }
  86. void OutputPluginGUI::cb_Record(Fl_Button* o, void* v)
  87. { ((OutputPluginGUI*)(o->parent()))->cb_Record_i(o,v); }
  88. inline void OutputPluginGUI::cb_OpenRead_i(Fl_Button* o, void* v)
  89. {
  90. if (o->value())
  91. {
  92. OpenWrite->value(0);
  93. OSSOutput::Get()->Close();
  94. OSSOutput::Get()->OpenRead();
  95. m_GUICH->Set("Mode",(char)OutputPlugin::INPUT);
  96. }
  97. else
  98. {
  99. OpenWrite->value(0);
  100. OSSOutput::Get()->Close();
  101. }
  102. }
  103. void OutputPluginGUI::cb_OpenRead(Fl_Button* o, void* v)
  104. { ((OutputPluginGUI*)(o->parent()))->cb_OpenRead_i(o,v); }
  105. inline void OutputPluginGUI::cb_OpenDuplex_i(Fl_Button* o, void* v)
  106. {
  107. if (o->value())
  108. {
  109. OpenRead->value(0);
  110. OSSOutput::Get()->Close();
  111. OSSOutput::Get()->OpenReadWrite();
  112. m_GUICH->Set("Mode",(char)OutputPlugin::DUPLEX);
  113. }
  114. else
  115. {
  116. OpenRead->value(0);
  117. OSSOutput::Get()->Close();
  118. }
  119. }
  120. void OutputPluginGUI::cb_OpenDuplex(Fl_Button* o, void* v)
  121. { ((OutputPluginGUI*)(o->parent()))->cb_OpenDuplex_i(o,v); }
  122. inline void OutputPluginGUI::cb_OpenWrite_i(Fl_Button* o, void* v)
  123. {
  124. if (o->value())
  125. {
  126. OpenRead->value(0);
  127. OSSOutput::Get()->Close();
  128. OSSOutput::Get()->OpenWrite();
  129. m_GUICH->Set("Mode",(char)OutputPlugin::OUTPUT);
  130. }
  131. else
  132. {
  133. OpenRead->value(0);
  134. OSSOutput::Get()->Close();
  135. }
  136. }
  137. void OutputPluginGUI::cb_OpenWrite(Fl_Button* o, void* v)
  138. { ((OutputPluginGUI*)(o->parent()))->cb_OpenWrite_i(o,v); }