2
0

PolycodeTextEditor.cpp 726 B

12345678910111213141516171819202122232425262728293031323334353637
  1. #include "PolycodeTextEditor.h"
  2. PolycodeTextEditor::PolycodeTextEditor() : PolycodeEditor(true){
  3. }
  4. PolycodeTextEditor::~PolycodeTextEditor() {
  5. }
  6. bool PolycodeTextEditor::openFile(String filePath) {
  7. textInput = new UITextInput(true, 100, 100);
  8. addChild(textInput);
  9. Data *data = new Data();
  10. data->loadFromFile(filePath);
  11. textInput->insertText(data->getAsString(String::ENCODING_UTF8));
  12. delete data;
  13. PolycodeEditor::openFile(filePath);
  14. return true;
  15. }
  16. void PolycodeTextEditor::saveFile() {
  17. Data *data = new Data();
  18. data->setFromString(textInput->getText(), String::ENCODING_UTF8);
  19. data->saveToFile(filePath);
  20. delete data;
  21. }
  22. void PolycodeTextEditor::Resize(int x, int y) {
  23. textInput->Resize(x,y);
  24. }