newfolder.cpp 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. #include "newfolder.h"
  2. #include "mainwindow.h"
  3. #include "globalParams.h"
  4. #define WINDOW_POSX 400
  5. #define WINDOW_POSY 10
  6. #define WINDOW_WIDTH 440
  7. #define WINDOW_HEIGHT 100
  8. extern TMainWindow* MainWindow;
  9. TNewFolder::TNewFolder () : GUIWindow (NULL, WINDOW_POSX, WINDOW_POSY, WINDOW_WIDTH, WINDOW_HEIGHT)
  10. {
  11. bAlwaysOnTop = true;
  12. bSystemButton = false;
  13. Caption = "Create folder";
  14. pDesc = NEW GUILabel (this, 20, 3, 20, 18);
  15. pDesc->Layout = GUILABELLAYOUT_Left;
  16. pDesc->Caption = "Folder name";
  17. pDesc->FontColor = 0xFF000000;
  18. pDesc->pFont->SetSize (16);
  19. pDirName = NEW GUIEdit (this, 23, 27, 300, 22);
  20. pDirName->Text = "NewFolder";
  21. pDirName->FontColor = 0xFF000000;
  22. pDirName->pFont->SetSize (16);
  23. pDirName->OnAccept = (CONTROL_EVENT)&TNewFolder::onOKPressed;
  24. pDirName->Flat = true;
  25. //onOKPressed;
  26. btnOK = NEW GUIButton (this, 340,9, 78, 24);
  27. btnOK->Glyph->Load ("ok");
  28. btnOK->Caption = "Accept";
  29. btnOK->pFont->SetSize (12);
  30. btnOK->OnMousePressed = (CONTROL_EVENT)&TNewFolder::onOKPressed;
  31. btnOK->FlatButton = true;
  32. btnCancel = NEW GUIButton (this, 340,39, 78, 24);
  33. btnCancel->Glyph->Load ("cancel");
  34. btnCancel->Caption = "Cancel";
  35. btnCancel->pFont->SetSize (12);
  36. btnCancel->OnMousePressed = (CONTROL_EVENT)&TNewFolder::onCancelPressed;
  37. btnCancel->FlatButton = true;
  38. SetScreenCenter ();
  39. }
  40. void TNewFolder::OnCreate ()
  41. {
  42. pDirName->SetFocus ();
  43. pDirName->SelectText (0, pDirName->Text.Len ());
  44. }
  45. TNewFolder::~TNewFolder ()
  46. {
  47. delete pDirName;
  48. delete pDesc;
  49. }
  50. void _cdecl TNewFolder::onOKPressed (GUIControl* sender)
  51. {
  52. gp->folder_to_create = pDirName->Text;
  53. Close (this);
  54. }
  55. void _cdecl TNewFolder::onCancelPressed (GUIControl* sender)
  56. {
  57. gp->folder_to_create = "";
  58. Close (this);
  59. }
  60. void TNewFolder::KeyPressed(int Key, bool bSysKey)
  61. {
  62. if (!bSysKey) return;
  63. if (Key == 13) onOKPressed (NULL);
  64. if (Key == VK_ESCAPE) onCancelPressed (NULL);
  65. }