ExportProjectWindow.cpp 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. /*
  2. Copyright (C) 2012 by Ivan Safrin
  3. Permission is hereby granted, free of charge, to any person obtaining a copy
  4. of this software and associated documentation files (the "Software"), to deal
  5. in the Software without restriction, including without limitation the rights
  6. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  7. copies of the Software, and to permit persons to whom the Software is
  8. furnished to do so, subject to the following conditions:
  9. The above copyright notice and this permission notice shall be included in
  10. all copies or substantial portions of the Software.
  11. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  12. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  13. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  14. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  15. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  16. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  17. THE SOFTWARE.
  18. */
  19. #include "ExportProjectWindow.h"
  20. #include "PolycodeFrame.h"
  21. extern PolycodeFrame *globalFrame;
  22. ExportProjectWindow::ExportProjectWindow() : UIWindow(L"Publish Project", 400, 360) {
  23. closeOnEscape = true;
  24. UILabel *label = new UILabel("LOCATION", 22, "section", Label::ANTIALIAS_FULL);
  25. addChild(label);
  26. label->color.a = 1.0;
  27. label->setPosition(padding, 50);
  28. projectLocationInput = new UITextInput(false, 420-(padding*2.0), 12);
  29. addChild(projectLocationInput);
  30. projectLocationInput->setPosition(padding, 80);
  31. locationSelectButton = new UIButton(L"Choose...", 100);
  32. locationSelectButton->addEventListener(this, UIEvent::CLICK_EVENT);
  33. addChild(locationSelectButton);
  34. locationSelectButton->setPosition(padding, projectLocationInput->getPosition().y+projectLocationInput->getHeight()+5);
  35. label = new UILabel("PLATFORMS", 22, "section", Label::ANTIALIAS_FULL);
  36. addChild(label);
  37. label->color.a = 1.0;
  38. label->setPosition(padding, 150);
  39. macCheckBox = new UICheckBox("MacOS X (Intel 64-bit)", false);
  40. addChild(macCheckBox);
  41. macCheckBox->setPosition(padding, 185);
  42. winCheckBox = new UICheckBox("Microsoft Windows (32-bit)", false);
  43. addChild(winCheckBox);
  44. winCheckBox->setPosition(padding, 205);
  45. linCheckBox = new UICheckBox("Linux (Intel 32-bit)", false);
  46. addChild(linCheckBox);
  47. linCheckBox->setPosition(padding, 225);
  48. label = new UILabel("OPTIONS", 22, "section", Label::ANTIALIAS_FULL);
  49. addChild(label);
  50. label->color.a = 1.0;
  51. label->setPosition(padding, 260);
  52. compileCheckBox = new UICheckBox("Compile Scripts (experimental)", false);
  53. addChild(compileCheckBox);
  54. compileCheckBox->setPosition(padding, 295);
  55. cancelButton = new UIButton(L"Cancel", 100);
  56. cancelButton->addEventListener(this, UIEvent::CLICK_EVENT);
  57. addChild(cancelButton);
  58. cancelButton->setPosition(400-75-padding-100-10, 360-15);
  59. okButton = new UIButton(L"Publish", 100);
  60. okButton->addEventListener(this, UIEvent::CLICK_EVENT);
  61. addChild(okButton);
  62. okButton->setPosition(400-75-padding, 360-15);
  63. projectLocationInput->setText(CoreServices::getInstance()->getCore()->getUserHomeDirectory()+"/Documents/Polycode");
  64. }
  65. ExportProjectWindow::~ExportProjectWindow() {
  66. }
  67. void ExportProjectWindow::resetForm() {
  68. /*
  69. projectLocationInput->setText(CoreServices::getInstance()->getCore()->getUserHomeDirectory()+"/Documents/Polycode");
  70. macCheckBox->setChecked(false);
  71. winCheckBox->setChecked(false);
  72. linCheckBox->setChecked(false);
  73. */
  74. }
  75. void ExportProjectWindow::handleEvent(Event *event) {
  76. if(event->getEventType() == "UIEvent") {
  77. if(event->getEventCode() == UIEvent::OK_EVENT && event->getDispatcher() == globalFrame->fileDialog) {
  78. String pathName = globalFrame->fileDialog->getSelection();
  79. if(pathName != "")
  80. projectLocationInput->setText(pathName);
  81. }
  82. if(enabled) {
  83. if(event->getEventCode() == UIEvent::CLICK_EVENT) {
  84. if(event->getDispatcher() == okButton) {
  85. dispatchEvent(new UIEvent(), UIEvent::OK_EVENT);
  86. }
  87. if(event->getDispatcher() == cancelButton) {
  88. dispatchEvent(new UIEvent(), UIEvent::CLOSE_EVENT);
  89. }
  90. if(event->getDispatcher() == locationSelectButton) {
  91. #ifdef USE_POLYCODEUI_FILE_DIALOGS
  92. std::vector<String> exts;
  93. globalFrame->showFileBrowser(CoreServices::getInstance()->getCore()->getUserHomeDirectory(), true, exts, false);
  94. globalFrame->fileDialog->addEventListener(this, UIEvent::OK_EVENT);
  95. #else
  96. String pathName = CoreServices::getInstance()->getCore()->openFolderPicker();
  97. if(pathName != "")
  98. projectLocationInput->setText(pathName);
  99. #endif
  100. }
  101. }
  102. }
  103. }
  104. UIWindow::handleEvent(event);
  105. }