Main.cpp 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. /*
  2. ==============================================================================
  3. This file was auto-generated by the Introjucer!
  4. It contains the basic startup code for a Juce application.
  5. ==============================================================================
  6. */
  7. // NOTE: in order to avoid "multiple definitions of WinMain()" compiler error
  8. // arrange that "windows.h" be included before "JuceHeader.h" in all contexts
  9. // also arrange to include "JuceHeader.h" before any "*Component.h"
  10. #include "LinJam.h" // includes "windows.h" and "JuceHeader.h"
  11. #include "Login.h"
  12. class LinJamApplication : public JUCEApplication , NJClient , MultiTimer
  13. {
  14. public:
  15. LinJamApplication() {}
  16. void initialise(const String& command_line) override
  17. {
  18. this->mainWindow = new MainWindow() ;
  19. if (!LinJam::Initialize(this , this->mainWindow->mainContent , this , command_line))
  20. {
  21. LinJam::Shutdown() ; quit() ;
  22. }
  23. }
  24. void anotherInstanceStarted(const String& command_line) override
  25. {
  26. // When another instance of the app is launched while this one is running,
  27. // this method is invoked, and the commandLine parameter tells you what
  28. // the other instance's command-line arguments were.
  29. String host = command_line ; this->mainWindow->mainContent->login->quickLogin(host) ;
  30. }
  31. void shutdown() override { LinJam::Shutdown() ; this->mainWindow = nullptr ; }
  32. void systemRequestedQuit() override { this->quit() ; }
  33. const String getApplicationName() override { return ProjectInfo::projectName ; }
  34. const String getApplicationVersion() override { return ProjectInfo::versionString ; }
  35. bool moreThanOneInstanceAllowed() override { return false ; }
  36. /*
  37. This class implements the desktop window that contains an instance of
  38. our MainContentComponent class.
  39. */
  40. class MainWindow : public DocumentWindow
  41. {
  42. friend class LinJamApplication ;
  43. public:
  44. MainWindow() : DocumentWindow(GUI::APP_NAME ,
  45. Colour(0xff202020) ,
  46. DocumentWindow::allButtons)
  47. {
  48. // config button (managed and handled by MainContent)
  49. this->configButton = new TextButton("configButton") ;
  50. Component::addAndMakeVisible(this->configButton) ;
  51. // main content (title managed by MainContent)
  52. this->mainContent = new MainContent(this , this->configButton) ;
  53. this->mainContent->setComponentID(GUI::CONTENT_GUI_ID) ;
  54. setContentOwned(this->mainContent , true) ;
  55. // this main desktop window
  56. #ifdef _MAC
  57. setTitleBarButtonsRequired(DocumentWindow::allButtons , true) ;
  58. #endif // _MAC
  59. setTitleBarHeight(GUI::TITLEBAR_H) ;
  60. // setIcon(const Image &imageToUse) ;
  61. centreWithSize(getWidth() , getHeight()) ;
  62. setVisible(true) ;
  63. }
  64. ~MainWindow()
  65. {
  66. this->mainContent = nullptr ;
  67. this->configButton = nullptr ;
  68. }
  69. void closeButtonPressed() { JUCEApplication::getInstance()->systemRequestedQuit() ; }
  70. private:
  71. ScopedPointer<MainContent> mainContent ;
  72. ScopedPointer<TextButton> configButton ;
  73. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(MainWindow)
  74. } ;
  75. private:
  76. ScopedPointer<MainWindow> mainWindow ;
  77. void timerCallback(int timer_id) override { LinJam::HandleTimer(timer_id) ; }
  78. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(LinJamApplication)
  79. } ;
  80. START_JUCE_APPLICATION(LinJamApplication)