rename.cpp 2.0 KB

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