License.cpp 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  1. /*
  2. ==============================================================================
  3. This is an automatically generated GUI class created by the Introjucer!
  4. Be careful when adding custom code to these files, as only the code within
  5. the "//[xyz]" and "//[/xyz]" sections will be retained when the file is loaded
  6. and re-saved.
  7. Created with Introjucer version: 3.1.1
  8. ------------------------------------------------------------------------------
  9. The Introjucer is part of the JUCE library - "Jules' Utility Class Extensions"
  10. Copyright 2004-13 by Raw Material Software Ltd.
  11. ==============================================================================
  12. */
  13. //[Headers] You can add your own extra header files here...
  14. #include "LinJam.h"
  15. //[/Headers]
  16. #include "License.h"
  17. //[MiscUserDefs] You can add your own user definitions and misc code here...
  18. //[/MiscUserDefs]
  19. //==============================================================================
  20. License::License (Value is_agreed, Value always_agree)
  21. : isAgreed(is_agreed), alwaysAgree(always_agree)
  22. {
  23. //[Constructor_pre] You can add your own custom stuff here..
  24. //[/Constructor_pre]
  25. setName ("License");
  26. addAndMakeVisible (licenseTextEditor = new TextEditor ("licenseTextEditor"));
  27. licenseTextEditor->setMultiLine (true);
  28. licenseTextEditor->setReturnKeyStartsNewLine (false);
  29. licenseTextEditor->setReadOnly (true);
  30. licenseTextEditor->setScrollbarsShown (true);
  31. licenseTextEditor->setCaretVisible (false);
  32. licenseTextEditor->setPopupMenuEnabled (false);
  33. licenseTextEditor->setColour (TextEditor::textColourId, Colours::grey);
  34. licenseTextEditor->setColour (TextEditor::backgroundColourId, Colour (0x00000000));
  35. licenseTextEditor->setText (String());
  36. addAndMakeVisible (cancelButton = new TextButton ("cancelButton"));
  37. cancelButton->setTooltip (TRANS("Check this if you do not agree to these above terms. You will not be able to jam here."));
  38. cancelButton->setExplicitFocusOrder (2);
  39. cancelButton->setButtonText (TRANS("Cancel"));
  40. cancelButton->addListener (this);
  41. addAndMakeVisible (agreeButton = new TextButton ("agreeButton"));
  42. agreeButton->setTooltip (TRANS("Check this to agree to the above terms for this session only."));
  43. agreeButton->setExplicitFocusOrder (1);
  44. agreeButton->setButtonText (TRANS("Agree"));
  45. agreeButton->addListener (this);
  46. addAndMakeVisible (alwaysButton = new ToggleButton ("alwaysButton"));
  47. alwaysButton->setTooltip (TRANS("Check this to automatically agree to these terms on this server. You will not see this screen again unless the terms should change."));
  48. alwaysButton->setButtonText (TRANS("Always Agree"));
  49. alwaysButton->addListener (this);
  50. alwaysButton->setColour (ToggleButton::textColourId, Colours::grey);
  51. //[UserPreSize]
  52. //[/UserPreSize]
  53. setSize (622, 442);
  54. //[Constructor] You can add your own custom stuff here..
  55. this->alwaysAgree.addListener(this) ;
  56. //[/Constructor]
  57. }
  58. License::~License()
  59. {
  60. //[Destructor_pre]. You can add your own custom destruction code here..
  61. //[/Destructor_pre]
  62. licenseTextEditor = nullptr;
  63. cancelButton = nullptr;
  64. agreeButton = nullptr;
  65. alwaysButton = nullptr;
  66. //[Destructor]. You can add your own custom destruction code here..
  67. //[/Destructor]
  68. }
  69. //==============================================================================
  70. void License::paint (Graphics& g)
  71. {
  72. //[UserPrePaint] Add your own custom painting code here..
  73. //[/UserPrePaint]
  74. g.setColour (Colour (0xff101010));
  75. g.fillRoundedRectangle (0.0f, 0.0f, static_cast<float> (getWidth() - 0), static_cast<float> (getHeight() - 0), 10.000f);
  76. g.setColour (Colours::white);
  77. g.drawRoundedRectangle (0.0f, 0.0f, static_cast<float> (getWidth() - 0), static_cast<float> (getHeight() - 0), 10.000f, 1.000f);
  78. g.setColour (Colours::black);
  79. g.fillRoundedRectangle (4.0f, 4.0f, static_cast<float> (getWidth() - 8), static_cast<float> (getHeight() - 36), 10.000f);
  80. g.setColour (Colours::grey);
  81. g.drawRoundedRectangle (4.0f, 4.0f, static_cast<float> (getWidth() - 8), static_cast<float> (getHeight() - 36), 10.000f, 1.000f);
  82. //[UserPaint] Add your own custom painting code here..
  83. //[/UserPaint]
  84. }
  85. void License::resized()
  86. {
  87. //[UserPreResize] Add your own custom resize code here..
  88. //[/UserPreResize]
  89. licenseTextEditor->setBounds (4, 4, getWidth() - 8, getHeight() - 36);
  90. cancelButton->setBounds (getWidth() - 68, getHeight() - 28, 64, 24);
  91. agreeButton->setBounds (getWidth() - 136, getHeight() - 28, 64, 24);
  92. alwaysButton->setBounds (getWidth() - 204, getHeight() - 28, 64, 24);
  93. //[UserResized] Add your own custom resize handling here..
  94. //[/UserResized]
  95. }
  96. void License::buttonClicked (Button* buttonThatWasClicked)
  97. {
  98. //[UserbuttonClicked_Pre]
  99. //[/UserbuttonClicked_Pre]
  100. if (buttonThatWasClicked == cancelButton)
  101. {
  102. //[UserButtonCode_cancelButton] -- add your button handler code here..
  103. this->isAgreed = false ;
  104. //[/UserButtonCode_cancelButton]
  105. }
  106. else if (buttonThatWasClicked == agreeButton)
  107. {
  108. //[UserButtonCode_agreeButton] -- add your button handler code here..
  109. this->isAgreed = true ;
  110. //[/UserButtonCode_agreeButton]
  111. }
  112. else if (buttonThatWasClicked == alwaysButton)
  113. {
  114. //[UserButtonCode_alwaysButton] -- add your button handler code here..
  115. this->isAgreed = this->alwaysButton->getToggleState() ;
  116. this->alwaysAgree = this->alwaysButton->getToggleState() ;
  117. //[/UserButtonCode_alwaysButton]
  118. }
  119. //[UserbuttonClicked_Post]
  120. LinJam::Disconnect() ; if (this->isAgreed == true) LinJam::Connect() ;
  121. //[/UserbuttonClicked_Post]
  122. }
  123. //[MiscUserCode] You can add your own definitions of your custom methods or any other code here...
  124. void License::valueChanged(Value& a_value)
  125. {
  126. if (!a_value.refersToSameSourceAs(this->alwaysAgree)) return ;
  127. bool alwaysAgree = bool(this->alwaysAgree.getValue()) ;
  128. this->alwaysButton->setToggleState(alwaysAgree , juce::dontSendNotification) ;
  129. }
  130. void License::setLicenseText(String license_text)
  131. {
  132. this->licenseTextEditor->setText(TRANS(license_text)) ;
  133. }
  134. //[/MiscUserCode]
  135. //==============================================================================
  136. #if 0
  137. /* -- Introjucer information section --
  138. This is where the Introjucer stores the metadata that describe this GUI layout, so
  139. make changes in here at your peril!
  140. BEGIN_JUCER_METADATA
  141. <JUCER_COMPONENT documentType="Component" className="License" componentName="License"
  142. parentClasses="public Component, public ValueListener" constructorParams="Value is_agreed, Value always_agree"
  143. variableInitialisers="isAgreed(is_agreed), alwaysAgree(always_agree)"
  144. snapPixels="8" snapActive="1" snapShown="1" overlayOpacity="0.330"
  145. fixedSize="0" initialWidth="622" initialHeight="442">
  146. <BACKGROUND backgroundColour="0">
  147. <ROUNDRECT pos="0 0 0M 0M" cornerSize="10" fill="solid: ff101010" hasStroke="1"
  148. stroke="1, mitered, butt" strokeColour="solid: ffffffff"/>
  149. <ROUNDRECT pos="4 4 8M 36M" cornerSize="10" fill="solid: ff000000" hasStroke="1"
  150. stroke="1, mitered, butt" strokeColour="solid: ff808080"/>
  151. </BACKGROUND>
  152. <TEXTEDITOR name="licenseTextEditor" id="ba11ad8bfe4752c1" memberName="licenseTextEditor"
  153. virtualName="" explicitFocusOrder="0" pos="4 4 8M 36M" textcol="ff808080"
  154. bkgcol="0" initialText="" multiline="1" retKeyStartsLine="0"
  155. readonly="1" scrollbars="1" caret="0" popupmenu="0"/>
  156. <TEXTBUTTON name="cancelButton" id="e40ccd6a36998aa2" memberName="cancelButton"
  157. virtualName="" explicitFocusOrder="2" pos="68R 28R 64 24" tooltip="Check this if you do not agree to these above terms. You will not be able to jam here."
  158. buttonText="Cancel" connectedEdges="0" needsCallback="1" radioGroupId="0"/>
  159. <TEXTBUTTON name="agreeButton" id="1c12b4600196bad4" memberName="agreeButton"
  160. virtualName="" explicitFocusOrder="1" pos="136R 28R 64 24" tooltip="Check this to agree to the above terms for this session only."
  161. buttonText="Agree" connectedEdges="0" needsCallback="1" radioGroupId="0"/>
  162. <TOGGLEBUTTON name="alwaysButton" id="7f039929e852c525" memberName="alwaysButton"
  163. virtualName="" explicitFocusOrder="0" pos="204R 28R 64 24" tooltip="Check this to automatically agree to these terms on this server. You will not see this screen again unless the terms should change."
  164. txtcol="ff808080" buttonText="Always Agree" connectedEdges="0"
  165. needsCallback="1" radioGroupId="0" state="0"/>
  166. </JUCER_COMPONENT>
  167. END_JUCER_METADATA
  168. */
  169. #endif
  170. //[EndFile] You can add extra defines here...
  171. //[/EndFile]