NewString.cpp 1.9 KB

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