The JUCE cross-platform C++ framework, with DISTRHO/KXStudio specific changes
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.

189 lines
6.3KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library - "Jules' Utility Class Extensions"
  4. Copyright 2004-10 by Raw Material Software Ltd.
  5. ------------------------------------------------------------------------------
  6. JUCE can be redistributed and/or modified under the terms of the GNU General
  7. Public License (Version 2), as published by the Free Software Foundation.
  8. A copy of the license is included in the JUCE distribution, or can be found
  9. online at www.gnu.org/licenses.
  10. JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
  11. WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  12. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  13. ------------------------------------------------------------------------------
  14. To release a closed-source product which uses JUCE, commercial licenses are
  15. available: visit www.rawmaterialsoftware.com/juce for more information.
  16. ==============================================================================
  17. */
  18. #include "../jucer_Headers.h"
  19. #include "jucer_PrefsPanel.h"
  20. //==============================================================================
  21. class MiscPage : public Component
  22. {
  23. FilenameComponent* templateDir;
  24. public:
  25. MiscPage()
  26. {
  27. addAndMakeVisible (templateDir
  28. = new FilenameComponent (T("C++ template folder:"),
  29. StoredSettings::getInstance()->getTemplatesDir(),
  30. true,
  31. true,
  32. false,
  33. T("*.*"),
  34. String::empty,
  35. T("(select the directory containing template .cpp and .h files)")));
  36. (new Label (String::empty, templateDir->getName()))->attachToComponent (templateDir, true);
  37. }
  38. ~MiscPage()
  39. {
  40. StoredSettings::getInstance()->setTemplatesDir (templateDir->getCurrentFile());
  41. deleteAllChildren();
  42. }
  43. void resized()
  44. {
  45. templateDir->setBounds (150, 16, getWidth() - 160, 22);
  46. }
  47. };
  48. //==============================================================================
  49. class AboutPage : public Component
  50. {
  51. HyperlinkButton* link;
  52. Image logo;
  53. TextLayout text1, text2;
  54. public:
  55. AboutPage()
  56. {
  57. logo = ImageCache::getFromMemory (BinaryData::jules_jpg, BinaryData::jules_jpgSize);
  58. text1.appendText ("Programmer Julian Storer, seen here demonstrating a beard designed to "
  59. "gain approval from the Linux programming community. Each hair of the beard "
  60. "represents one line of source code from the ", Font (13.0f));
  61. text1.appendText ("Jucer", Font (13.0f, Font::bold));
  62. text1.appendText (" component design tool.", Font (13.0f));
  63. text2.appendText (T("Jucer v") + JUCEApplication::getInstance()->getApplicationVersion()
  64. + T(", ") + SystemStats::getJUCEVersion(), Font (14.0f, Font::bold));
  65. addAndMakeVisible (link = new HyperlinkButton (T("www.rawmaterialsoftware.com/juce"),
  66. URL (T("http://www.rawmaterialsoftware.com/juce"))));
  67. link->setFont (Font (10.0f, Font::bold | Font::underlined), true);
  68. }
  69. ~AboutPage()
  70. {
  71. deleteAllChildren();
  72. }
  73. void paint (Graphics& g)
  74. {
  75. g.fillAll (Colour (0xffebebeb));
  76. g.drawImageWithin (logo, 0, 4, getWidth(), getHeight() - 134,
  77. RectanglePlacement::centred | RectanglePlacement::onlyReduceInSize,
  78. false);
  79. text1.drawWithin (g, 0, getHeight() - 120, getWidth(), 100, Justification::centredTop);
  80. text2.drawWithin (g, 0, getHeight() - 50, getWidth(), 100, Justification::centredTop);
  81. }
  82. void resized()
  83. {
  84. text1.layout (getWidth() - 24, Justification::topLeft, false);
  85. text2.layout (getWidth() - 24, Justification::centred, false);
  86. link->setSize (100, 22);
  87. link->changeWidthToFitText();
  88. link->setTopLeftPosition ((getWidth() - link->getWidth()) / 2, getHeight() - link->getHeight() - 10);
  89. }
  90. };
  91. //==============================================================================
  92. static const tchar* miscPage = T("Misc");
  93. static const tchar* keysPage = T("Keys");
  94. static const tchar* aboutPage = T("About");
  95. class PrefsTabComp : public PreferencesPanel
  96. {
  97. public:
  98. PrefsTabComp()
  99. {
  100. addSettingsPage (miscPage, BinaryData::prefs_misc_png, BinaryData::prefs_misc_pngSize);
  101. addSettingsPage (keysPage, BinaryData::prefs_keys_png, BinaryData::prefs_keys_pngSize);
  102. addSettingsPage (aboutPage, BinaryData::prefs_about_png, BinaryData::prefs_about_pngSize);
  103. }
  104. ~PrefsTabComp()
  105. {
  106. StoredSettings::getInstance()->flush();
  107. }
  108. Component* createComponentForPage (const String& pageName)
  109. {
  110. if (pageName == miscPage)
  111. {
  112. return new MiscPage();
  113. }
  114. else if (pageName == keysPage)
  115. {
  116. return new KeyMappingEditorComponent (commandManager->getKeyMappings(), true);
  117. }
  118. else if (pageName == aboutPage)
  119. {
  120. return new AboutPage();
  121. }
  122. return new Component();
  123. }
  124. };
  125. //==============================================================================
  126. static String prefsWindowPos;
  127. PrefsPanel::PrefsPanel()
  128. : DialogWindow (T("Jucer Preferences"), Colour::greyLevel (0.92f), true)
  129. {
  130. PrefsTabComp* const p = new PrefsTabComp();
  131. p->setSize (456, 510);
  132. setContentComponent (p, true, true);
  133. if (! restoreWindowStateFromString (prefsWindowPos))
  134. centreAroundComponent (0, getWidth(), getHeight());
  135. setResizable (true, true);
  136. setResizeLimits (400, 400, 1000, 800);
  137. }
  138. PrefsPanel::~PrefsPanel()
  139. {
  140. prefsWindowPos = getWindowStateAsString();
  141. }
  142. void PrefsPanel::closeButtonPressed()
  143. {
  144. setVisible (false);
  145. }
  146. void PrefsPanel::show()
  147. {
  148. PrefsPanel pp;
  149. pp.runModalLoop();
  150. }