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.

132 lines
3.6KB

  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 "SpiralPluginGUI.h"
  19. #include "SpiralPlugin.h"
  20. #include "../SpiralInfo.h"
  21. #include <FL/fl_draw.h>
  22. #include <FL/fl_draw.H>
  23. #include <FL/Fl_Multiline_Output.h>
  24. #include <FL/Fl_Text_Display.h>
  25. #include <FL/Fl_Text_Buffer.h>
  26. using namespace std;
  27. Fl_Double_Window* SpiralPluginGUI::m_HelpWin=NULL;
  28. Fl_Text_Display* SpiralPluginGUI::m_HelpWin_text=NULL;
  29. SpiralPluginGUI* SpiralPluginGUI::Help_owner=NULL;
  30. SpiralPluginGUI::SpiralPluginGUI(int w, int h, SpiralPlugin* o, ChannelHandler *ch) :
  31. SpiralGUIType(0,0,w,h,"")
  32. {
  33. Fl::visible_focus(false);
  34. m_GUICH = ch;
  35. box(FL_NO_BOX);
  36. m_Hide = new Fl_Button(2,2,10,10,"X");
  37. m_Hide->labeltype(FL_ENGRAVED_LABEL);
  38. m_Hide->labelsize(10);
  39. m_Hide->box(FL_NO_BOX);
  40. m_Hide->callback((Fl_Callback*)cb_Hide);
  41. add(m_Hide);
  42. m_Help = new Fl_Button(w-11,2,10,10,"?");
  43. m_Help->labeltype(FL_ENGRAVED_LABEL);
  44. m_Help->labelsize(10);
  45. m_Help->box(FL_NO_BOX);
  46. m_Help->down_box(FL_NO_BOX);
  47. m_Help->callback((Fl_Callback*)cb_Help);
  48. add(m_Help);
  49. resizable(NULL);
  50. }
  51. SpiralPluginGUI::~SpiralPluginGUI()
  52. {
  53. // Needed to properly remove the window.
  54. Fl::check();
  55. }
  56. void SpiralPluginGUI::Resize (int neww, int newh) {
  57. resize (x(), y(), neww, newh);
  58. m_Help->position (x()+neww-11, y()+2);
  59. DoResizeCallback ();
  60. }
  61. void SpiralPluginGUI::Update()
  62. {
  63. }
  64. const string SpiralPluginGUI::GetHelpText(const string &loc)
  65. {
  66. return "Help! I need some helptext!!!";
  67. }
  68. //// Callbacks ////
  69. inline void SpiralPluginGUI::cb_Hide_i(Fl_Button* o, void* v)
  70. { hide(); }
  71. void SpiralPluginGUI::cb_Hide(Fl_Button* o, void* v)
  72. { ((SpiralPluginGUI*)(o->parent()))->cb_Hide_i(o,v); }
  73. // Boo - changed to use one 'global' help win. for all plugins, coz Fl_Text_Display
  74. // seems to be too buggy to create and destroy it multiple times.
  75. // (symptom was - ssm crashes after opening/closing plugin help window 4-7 times)
  76. // (i use FLTK 1.1.0 rc7)
  77. inline void SpiralPluginGUI::cb_Help_i(Fl_Button* o, void* v)
  78. {
  79. //Boo - create 'global' help window
  80. if (m_HelpWin==NULL)
  81. {
  82. int h_w=450,h_h=200;
  83. m_HelpWin = new Fl_Double_Window(h_w,h_h,"Help");
  84. m_HelpWin_text = new Fl_Text_Display(0,0,h_w,h_h);
  85. m_HelpWin_text->buffer(new Fl_Text_Buffer);
  86. m_HelpWin_text->textsize(12);
  87. m_HelpWin->add(m_HelpWin_text);
  88. m_HelpWin->resizable(m_HelpWin_text);
  89. m_HelpWin->callback((Fl_Callback*)cb_Help_close);
  90. }
  91. if(Help_owner!=this)
  92. {
  93. m_HelpWin_text->buffer()->text(GetHelpText(SpiralInfo::LOCALE).c_str());
  94. m_HelpWin->show();
  95. Help_owner=this;
  96. }
  97. else cb_Help_close_i(m_HelpWin, NULL);
  98. }
  99. void SpiralPluginGUI::cb_Help(Fl_Button* o, void* v)
  100. { ((SpiralPluginGUI*)(o->parent()))->cb_Help_i(o,v); }
  101. inline void SpiralPluginGUI::cb_Help_close_i(Fl_Double_Window* w, void* v)
  102. {
  103. w->hide();
  104. Help_owner=NULL;
  105. }
  106. void SpiralPluginGUI::cb_Help_close(Fl_Double_Window* w, void* v)
  107. { ((SpiralPluginGUI*)(w->parent()))->cb_Help_close_i(w,v); }