License.cpp 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  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.0
  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. #include "./Trace/TraceLicense.h"
  16. //[/Headers]
  17. #include "License.h"
  18. //[MiscUserDefs] You can add your own user definitions and misc code here...
  19. //[/MiscUserDefs]
  20. //==============================================================================
  21. License::License ()
  22. {
  23. setName ("License");
  24. addAndMakeVisible (licenseTextEditor = new TextEditor ("licenseTextEditor"));
  25. licenseTextEditor->setMultiLine (true);
  26. licenseTextEditor->setReturnKeyStartsNewLine (false);
  27. licenseTextEditor->setReadOnly (true);
  28. licenseTextEditor->setScrollbarsShown (true);
  29. licenseTextEditor->setCaretVisible (false);
  30. licenseTextEditor->setPopupMenuEnabled (false);
  31. licenseTextEditor->setColour (TextEditor::textColourId, Colours::grey);
  32. licenseTextEditor->setColour (TextEditor::backgroundColourId, Colour (0x00000000));
  33. licenseTextEditor->setText (String::empty);
  34. addAndMakeVisible (cancelButton = new TextButton ("cancelButton"));
  35. cancelButton->setTooltip (TRANS("Check this if you do not agree to these above terms. You will not be able to jam here."));
  36. cancelButton->setExplicitFocusOrder (2);
  37. cancelButton->setButtonText (TRANS("Cancel"));
  38. cancelButton->addListener (this);
  39. addAndMakeVisible (agreeButton = new TextButton ("agreeButton"));
  40. agreeButton->setTooltip (TRANS("Check this to agree to the above terms for this session only."));
  41. agreeButton->setExplicitFocusOrder (1);
  42. agreeButton->setButtonText (TRANS("Agree"));
  43. agreeButton->addListener (this);
  44. addAndMakeVisible (alwaysButton = new ToggleButton ("alwaysButton"));
  45. 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."));
  46. alwaysButton->setButtonText (TRANS("Always Agree"));
  47. alwaysButton->addListener (this);
  48. alwaysButton->setColour (ToggleButton::textColourId, Colours::grey);
  49. //[UserPreSize]
  50. //[/UserPreSize]
  51. setSize (622, 442);
  52. //[Constructor] You can add your own custom stuff here..
  53. //[/Constructor]
  54. }
  55. License::~License()
  56. {
  57. //[Destructor_pre]. You can add your own custom destruction code here..
  58. //[/Destructor_pre]
  59. licenseTextEditor = nullptr;
  60. cancelButton = nullptr;
  61. agreeButton = nullptr;
  62. alwaysButton = nullptr;
  63. //[Destructor]. You can add your own custom destruction code here..
  64. //[/Destructor]
  65. }
  66. //==============================================================================
  67. void License::paint (Graphics& g)
  68. {
  69. //[UserPrePaint] Add your own custom painting code here..
  70. //[/UserPrePaint]
  71. g.setColour (Colour (0xff101010));
  72. g.fillRoundedRectangle (0.0f, 0.0f, static_cast<float> (getWidth() - 0), static_cast<float> (getHeight() - 0), 10.000f);
  73. g.setColour (Colours::white);
  74. g.drawRoundedRectangle (0.0f, 0.0f, static_cast<float> (getWidth() - 0), static_cast<float> (getHeight() - 0), 10.000f, 1.000f);
  75. g.setColour (Colours::black);
  76. g.fillRoundedRectangle (4.0f, 4.0f, static_cast<float> (getWidth() - 8), static_cast<float> (getHeight() - 36), 10.000f);
  77. g.setColour (Colours::grey);
  78. g.drawRoundedRectangle (4.0f, 4.0f, static_cast<float> (getWidth() - 8), static_cast<float> (getHeight() - 36), 10.000f, 1.000f);
  79. //[UserPaint] Add your own custom painting code here..
  80. //[/UserPaint]
  81. }
  82. void License::resized()
  83. {
  84. licenseTextEditor->setBounds (4, 4, getWidth() - 8, getHeight() - 36);
  85. cancelButton->setBounds (getWidth() - 68, getHeight() - 28, 64, 24);
  86. agreeButton->setBounds (getWidth() - 136, getHeight() - 28, 64, 24);
  87. alwaysButton->setBounds (getWidth() - 204, getHeight() - 28, 64, 24);
  88. //[UserResized] Add your own custom resize handling here..
  89. //[/UserResized]
  90. }
  91. void License::buttonClicked (Button* buttonThatWasClicked)
  92. {
  93. //[UserbuttonClicked_Pre]
  94. DEBUG_TRACE_LICENSE_CLICKED
  95. bool is_agreed ;
  96. //[/UserbuttonClicked_Pre]
  97. if (buttonThatWasClicked == cancelButton)
  98. {
  99. //[UserButtonCode_cancelButton] -- add your button handler code here..
  100. is_agreed = false ;
  101. //[/UserButtonCode_cancelButton]
  102. }
  103. else if (buttonThatWasClicked == agreeButton)
  104. {
  105. //[UserButtonCode_agreeButton] -- add your button handler code here..
  106. is_agreed = true ;
  107. //[/UserButtonCode_agreeButton]
  108. }
  109. else if (buttonThatWasClicked == alwaysButton)
  110. {
  111. //[UserButtonCode_alwaysButton] -- add your button handler code here..
  112. bool should_always_agree = is_agreed = this->alwaysButton->getToggleState() ;
  113. LinJam::Config->setServerShouldAgree(should_always_agree) ;
  114. //[/UserButtonCode_alwaysButton]
  115. }
  116. //[UserbuttonClicked_Post]
  117. LinJam::Config->client.setProperty(CONFIG::IS_AGREED_ID , is_agreed , nullptr) ;
  118. LinJam::Disconnect() ; if (is_agreed) LinJam::Connect() ;
  119. //[/UserbuttonClicked_Post]
  120. }
  121. //[MiscUserCode] You can add your own definitions of your custom methods or any other code here...
  122. void License::setLicenseText(String license_text)
  123. { this->licenseTextEditor->setText(TRANS(license_text)) ; }
  124. //[/MiscUserCode]
  125. //==============================================================================
  126. #if 0
  127. /* -- Introjucer information section --
  128. This is where the Introjucer stores the metadata that describe this GUI layout, so
  129. make changes in here at your peril!
  130. BEGIN_JUCER_METADATA
  131. <JUCER_COMPONENT documentType="Component" className="License" componentName="License"
  132. parentClasses="public Component" constructorParams="" variableInitialisers=""
  133. snapPixels="8" snapActive="1" snapShown="1" overlayOpacity="0.330"
  134. fixedSize="0" initialWidth="622" initialHeight="442">
  135. <BACKGROUND backgroundColour="0">
  136. <ROUNDRECT pos="0 0 0M 0M" cornerSize="10" fill="solid: ff101010" hasStroke="1"
  137. stroke="1, mitered, butt" strokeColour="solid: ffffffff"/>
  138. <ROUNDRECT pos="4 4 8M 36M" cornerSize="10" fill="solid: ff000000" hasStroke="1"
  139. stroke="1, mitered, butt" strokeColour="solid: ff808080"/>
  140. </BACKGROUND>
  141. <TEXTEDITOR name="licenseTextEditor" id="ba11ad8bfe4752c1" memberName="licenseTextEditor"
  142. virtualName="" explicitFocusOrder="0" pos="4 4 8M 36M" textcol="ff808080"
  143. bkgcol="0" initialText="" multiline="1" retKeyStartsLine="0"
  144. readonly="1" scrollbars="1" caret="0" popupmenu="0"/>
  145. <TEXTBUTTON name="cancelButton" id="e40ccd6a36998aa2" memberName="cancelButton"
  146. 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."
  147. buttonText="Cancel" connectedEdges="0" needsCallback="1" radioGroupId="0"/>
  148. <TEXTBUTTON name="agreeButton" id="1c12b4600196bad4" memberName="agreeButton"
  149. virtualName="" explicitFocusOrder="1" pos="136R 28R 64 24" tooltip="Check this to agree to the above terms for this session only."
  150. buttonText="Agree" connectedEdges="0" needsCallback="1" radioGroupId="0"/>
  151. <TOGGLEBUTTON name="alwaysButton" id="7f039929e852c525" memberName="alwaysButton"
  152. 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."
  153. txtcol="ff808080" buttonText="Always Agree" connectedEdges="0"
  154. needsCallback="1" radioGroupId="0" state="0"/>
  155. </JUCER_COMPONENT>
  156. END_JUCER_METADATA
  157. */
  158. #endif
  159. //[EndFile] You can add extra defines here...
  160. //[/EndFile]