Rights.cpp 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711
  1. //---------------------------------------------------------------------------
  2. #include <vcl.h>
  3. #pragma hdrstop
  4. #include <Common.h>
  5. #include "Rights.h"
  6. #include <VCLCommon.h>
  7. #include <Tools.h>
  8. #include <GUITools.h>
  9. //---------------------------------------------------------------------------
  10. #pragma package(smart_init)
  11. #pragma link "GrayedCheckBox"
  12. #pragma link "PngImageList"
  13. #ifndef NO_RESOURCES
  14. #pragma resource "*.dfm"
  15. #endif
  16. //---------------------------------------------------------------------------
  17. __fastcall TRightsFrame::TRightsFrame(TComponent* Owner)
  18. : TFrame(Owner)
  19. {
  20. FAddXToDirectoriesSuffix = L"+x";
  21. FOnChange = NULL;
  22. FAllowAddXToDirectories = true;
  23. FPopup = false;
  24. FPopupParent = NULL;
  25. FDefaultButton = NULL;
  26. FCancelButton = NULL;
  27. // to avoid duplication of reference in forms that uses the frame
  28. PopupMenu = RightsPopup;
  29. FPopingContextMenu = false;
  30. FInitialized = false;
  31. #define COPY_HINT(R) \
  32. Checks[TRights::rrGroup ## R]->Hint = Checks[TRights::rrUser ## R]->Hint; \
  33. Checks[TRights::rrOther ## R]->Hint = Checks[TRights::rrUser ## R]->Hint;
  34. COPY_HINT(Read);
  35. COPY_HINT(Write);
  36. COPY_HINT(Exec);
  37. #undef COPY_HINT
  38. UpgradeSpeedButton(OwnerButton);
  39. UpgradeSpeedButton(GroupButton);
  40. UpgradeSpeedButton(OthersButton);
  41. }
  42. //---------------------------------------------------------------------------
  43. __fastcall TRightsFrame::~TRightsFrame()
  44. {
  45. }
  46. //---------------------------------------------------------------------------
  47. void __fastcall TRightsFrame::SetStates(TRights::TRight Right, TRights::TState value)
  48. {
  49. DebugAssert(((value == TRights::rsNo) || (value == TRights::rsYes) || (value == TRights::rsUndef)));
  50. TCheckBox * CheckBox = Checks[Right];
  51. if (CheckBox != NULL)
  52. {
  53. switch (value) {
  54. case TRights::rsNo: CheckBox->State = cbUnchecked; break;
  55. case TRights::rsYes: CheckBox->State = cbChecked; break;
  56. case TRights::rsUndef: CheckBox->State = cbGrayed; break;
  57. }
  58. }
  59. }
  60. //---------------------------------------------------------------------------
  61. TRights::TState __fastcall TRightsFrame::GetStates(TRights::TRight Right)
  62. {
  63. TCheckBox * CheckBox = Checks[Right];
  64. if (CheckBox != NULL)
  65. {
  66. switch (CheckBox->State) {
  67. case cbUnchecked: return TRights::rsNo;
  68. case cbChecked: return TRights::rsYes;
  69. case cbGrayed:
  70. default: return TRights::rsUndef;
  71. }
  72. }
  73. else
  74. {
  75. return TRights::rsNo;
  76. }
  77. }
  78. //---------------------------------------------------------------------------
  79. void __fastcall TRightsFrame::SetRights(const TRights & value)
  80. {
  81. bool Changed = (AllowUndef != value.AllowUndef);
  82. AllowUndef = true; // temporarily
  83. for (int Right = TRights::rrFirst; Right <= TRights::rrLast; Right++)
  84. {
  85. TRights::TRight R = static_cast<TRights::TRight>(Right);
  86. if (States[R] != value.RightUndef[R])
  87. {
  88. States[R] = value.RightUndef[R];
  89. Changed = true;
  90. }
  91. }
  92. AllowUndef = value.AllowUndef;
  93. if (Changed || !FInitialized)
  94. {
  95. UpdateControls();
  96. }
  97. }
  98. //---------------------------------------------------------------------------
  99. TRights __fastcall TRightsFrame::GetRights()
  100. {
  101. TRights Result;
  102. Result.AllowUndef = AllowUndef;
  103. for (int Right = TRights::rrFirst; Right <= TRights::rrLast; Right++)
  104. {
  105. Result.RightUndef[static_cast<TRights::TRight>(Right)] =
  106. States[static_cast<TRights::TRight>(Right)];
  107. }
  108. return Result;
  109. }
  110. //---------------------------------------------------------------------------
  111. void __fastcall TRightsFrame::SetAllowUndef(bool value)
  112. {
  113. for (int Right = TRights::rrFirst; Right <= TRights::rrLast; Right++)
  114. {
  115. TCheckBox * CheckBox = Checks[static_cast<TRights::TRight>(Right)];
  116. if (CheckBox != NULL)
  117. {
  118. CheckBox->AllowGrayed = value;
  119. }
  120. }
  121. }
  122. //---------------------------------------------------------------------------
  123. bool __fastcall TRightsFrame::GetAllowUndef()
  124. {
  125. bool Result = false, First = true;
  126. for (int Right = TRights::rrFirst; Right <= TRights::rrLast; Right++)
  127. {
  128. TCheckBox * Check = Checks[static_cast<TRights::TRight>(Right)];
  129. if (Check != NULL)
  130. {
  131. if (First)
  132. {
  133. Result = Check->AllowGrayed;
  134. First = false;
  135. }
  136. else if (Result != Check->AllowGrayed)
  137. {
  138. DebugFail();
  139. }
  140. }
  141. }
  142. return Result;
  143. }
  144. //---------------------------------------------------------------------------
  145. TCheckBox * __fastcall TRightsFrame::GetChecks(TRights::TRight Right)
  146. {
  147. for (int Index = 0; Index < ControlCount; Index++)
  148. {
  149. if (Controls[Index]->InheritsFrom(__classid(TCheckBox)) &&
  150. (Controls[Index]->Tag == TRights::RightToFlag(Right)))
  151. {
  152. return ((TCheckBox *)Controls[Index]);
  153. }
  154. }
  155. return NULL;
  156. }
  157. //---------------------------------------------------------------------------
  158. void __fastcall TRightsFrame::SetAddXToDirectories(bool value)
  159. {
  160. DirectoriesXCheck->Checked = value;
  161. }
  162. //---------------------------------------------------------------------------
  163. bool __fastcall TRightsFrame::GetAddXToDirectories()
  164. {
  165. return DirectoriesXCheck->Checked;
  166. }
  167. //---------------------------------------------------------------------------
  168. void __fastcall TRightsFrame::ControlChange(TObject * /*Sender*/)
  169. {
  170. UpdateControls();
  171. }
  172. //---------------------------------------------------------------------------
  173. bool __fastcall TRightsFrame::DirectoriesXEffective()
  174. {
  175. return !((Rights.NumberSet & TRights::rfExec) == TRights::rfExec);
  176. }
  177. //---------------------------------------------------------------------------
  178. void __fastcall TRightsFrame::UpdateControls()
  179. {
  180. if (!OctalEdit->Focused())
  181. {
  182. UpdateOctalEdit();
  183. }
  184. Color = (FPopup ? clWindow : clBtnFace);
  185. DirectoriesXCheck->Visible = AllowAddXToDirectories;
  186. EnableControl(DirectoriesXCheck,
  187. Enabled && DirectoriesXEffective());
  188. FInitialized = true;
  189. DoChange();
  190. }
  191. //---------------------------------------------------------------------------
  192. void __fastcall TRightsFrame::CycleRights(int Group)
  193. {
  194. TRights::TState State;
  195. bool Same = true;
  196. for (int Right = 0; Right < 3; Right++)
  197. {
  198. TRights::TState CState = States[static_cast<TRights::TRight>(
  199. TRights::rrUserRead + Right + ((Group - 1) * 3))];
  200. if (Right == 0) State = CState;
  201. else
  202. if (State != CState) Same = False;
  203. }
  204. if (!Same)
  205. {
  206. State = TRights::rsYes;
  207. }
  208. else
  209. {
  210. switch (State) {
  211. case TRights::rsYes:
  212. State = TRights::rsNo;
  213. break;
  214. case TRights::rsNo:
  215. State = AllowUndef ? TRights::rsUndef : TRights::rsYes;
  216. break;
  217. case TRights::rsUndef:
  218. State = TRights::rsYes;
  219. break;
  220. }
  221. }
  222. for (int Right = 0; Right < 3; Right++)
  223. {
  224. States[static_cast<TRights::TRight>(
  225. TRights::rrUserRead + Right + ((Group - 1) * 3))] = State;
  226. }
  227. UpdateControls();
  228. }
  229. //---------------------------------------------------------------------------
  230. void __fastcall TRightsFrame::RightsButtonsClick(TObject *Sender)
  231. {
  232. CycleRights(((TComponent*)Sender)->Tag);
  233. }
  234. //---------------------------------------------------------------------------
  235. void __fastcall TRightsFrame::SetAllowAddXToDirectories(bool value)
  236. {
  237. if ((FAllowAddXToDirectories != value) || !FInitialized)
  238. {
  239. FAllowAddXToDirectories = value;
  240. UpdateControls();
  241. }
  242. }
  243. //---------------------------------------------------------------------------
  244. void __fastcall TRightsFrame::DoChange()
  245. {
  246. if (FOnChange)
  247. {
  248. FOnChange(this);
  249. }
  250. }
  251. //---------------------------------------------------------------------------
  252. void __fastcall TRightsFrame::SetEnabled(bool Value)
  253. {
  254. TFrame::SetEnabled(Value);
  255. UpdateControls();
  256. }
  257. //---------------------------------------------------------------------------
  258. void __fastcall TRightsFrame::ForceUpdate()
  259. {
  260. UpdateOctalEdit();
  261. }
  262. //---------------------------------------------------------------------------
  263. bool __fastcall TRightsFrame::HasFocus()
  264. {
  265. return
  266. (Focused() ||
  267. ((Screen->ActiveControl != NULL) && (Screen->ActiveControl->Parent == this))) ||
  268. ((PopupParent != NULL) && PopupParent->Focused());
  269. }
  270. //---------------------------------------------------------------------------
  271. void __fastcall TRightsFrame::RightsActionsExecute(TBasicAction * Action,
  272. bool & Handled)
  273. {
  274. // prevent shortcuts to be evaluated when frame does not have a focus
  275. if (HasFocus())
  276. {
  277. bool Changed = true;
  278. TRights R = Rights;
  279. R.Number = TRights::rfNo;
  280. Handled = true;
  281. if (Action == NoRightsAction)
  282. {
  283. R = TRights::rfNo;
  284. }
  285. else if (Action == DefaultRightsAction)
  286. {
  287. R = TRights::rfDefault;
  288. }
  289. else if (Action == AllRightsAction)
  290. {
  291. R = TRights::rfAll;
  292. }
  293. else if (Action == LeaveRightsAsIsAction)
  294. {
  295. R.AllUndef();
  296. }
  297. else if (Action == CopyTextAction)
  298. {
  299. TInstantOperationVisualizer Visualizer;
  300. CopyToClipboard(Text);
  301. Changed = false;
  302. }
  303. else if (Action == CopyOctalAction)
  304. {
  305. TRights R = Rights;
  306. DebugAssert(!R.IsUndef);
  307. if (!R.IsUndef)
  308. {
  309. TInstantOperationVisualizer Visualizer;
  310. CopyToClipboard(R.Octal);
  311. }
  312. Changed = false;
  313. }
  314. else if (Action == PasteAction)
  315. {
  316. UnicodeString S;
  317. if (TextFromClipboard(S, true))
  318. {
  319. Text = S;
  320. }
  321. // trigger on change event, even if no change actually occurred to
  322. // allow parent form to visualize feedback of an action
  323. DoChange();
  324. // Update octal edit in Rights frame even if it has focus
  325. ForceUpdate();
  326. Changed = false;
  327. }
  328. else
  329. {
  330. Handled = false;
  331. }
  332. if (Changed)
  333. {
  334. Rights = R;
  335. ForceUpdate();
  336. DoChange();
  337. }
  338. }
  339. }
  340. //---------------------------------------------------------------------------
  341. void __fastcall TRightsFrame::RightsActionsUpdate(TBasicAction *Action,
  342. bool &Handled)
  343. {
  344. TRights R = Rights;
  345. Handled = true;
  346. if (Action == NoRightsAction)
  347. {
  348. // explicitly enable as action gets disabled, if its shortcut is pressed,
  349. // while the form does not have a focus and OnExecute handler denies the execution
  350. NoRightsAction->Enabled = true;
  351. NoRightsAction->Checked = !R.IsUndef && (R.NumberSet == TRights::rfNo);
  352. }
  353. else if (Action == DefaultRightsAction)
  354. {
  355. DefaultRightsAction->Enabled = true;
  356. DefaultRightsAction->Checked = !R.IsUndef && (R.NumberSet == TRights::rfDefault);
  357. }
  358. else if (Action == AllRightsAction)
  359. {
  360. AllRightsAction->Enabled = true;
  361. AllRightsAction->Checked = !R.IsUndef && (R.NumberSet == TRights::rfAll);
  362. }
  363. else if (Action == LeaveRightsAsIsAction)
  364. {
  365. LeaveRightsAsIsAction->Enabled = true;
  366. LeaveRightsAsIsAction->Visible = R.AllowUndef;
  367. LeaveRightsAsIsAction->Checked = (R.NumberSet == TRights::rfNo) &&
  368. (R.NumberUnset == TRights::rfNo);
  369. }
  370. else if (Action == CopyTextAction)
  371. {
  372. CopyTextAction->Enabled = !R.IsUndef;
  373. }
  374. else if (Action == CopyOctalAction)
  375. {
  376. CopyOctalAction->Enabled = !R.IsUndef;
  377. }
  378. else if (Action == PasteAction)
  379. {
  380. PasteAction->Enabled = IsFormatInClipboard(CF_TEXT);
  381. }
  382. else
  383. {
  384. Handled = false;
  385. }
  386. }
  387. //---------------------------------------------------------------------------
  388. void __fastcall TRightsFrame::CreateParams(TCreateParams & Params)
  389. {
  390. TFrame::CreateParams(Params);
  391. if (FPopup)
  392. {
  393. Params.Style |= WS_BORDER;
  394. }
  395. }
  396. //---------------------------------------------------------------------------
  397. void __fastcall TRightsFrame::CreateWnd()
  398. {
  399. if (FPopup)
  400. {
  401. Width += 2 * GetSystemMetricsForControl(Parent, SM_CXBORDER);
  402. Height += 2 * GetSystemMetricsForControl(Parent, SM_CYBORDER);
  403. }
  404. TFrame::CreateWnd();
  405. }
  406. //---------------------------------------------------------------------------
  407. void __fastcall TRightsFrame::SetPopup(bool value)
  408. {
  409. if (Popup != value)
  410. {
  411. FPopup = value;
  412. Visible = !FPopup;
  413. CloseButton->Visible = value;
  414. CloseButton->Cancel = value;
  415. CloseButton->Default = value;
  416. }
  417. }
  418. //---------------------------------------------------------------------------
  419. void __fastcall TRightsFrame::DoCloseUp()
  420. {
  421. Hide();
  422. if (FDefaultButton != NULL)
  423. {
  424. FDefaultButton->Default = true;
  425. FDefaultButton = NULL;
  426. }
  427. if (FCancelButton != NULL)
  428. {
  429. FCancelButton->Cancel = true;
  430. FCancelButton = NULL;
  431. }
  432. }
  433. //---------------------------------------------------------------------------
  434. void __fastcall TRightsFrame::DoExit()
  435. {
  436. // this is bit hack to make frame hide when ComboEdit button is pressed while
  437. // from is poped-up already.
  438. if (FPopup && !IsAncestor(Screen->ActiveControl, FPopupParent))
  439. {
  440. DoCloseUp();
  441. }
  442. TFrame::DoExit();
  443. }
  444. //---------------------------------------------------------------------------
  445. bool __fastcall TRightsFrame::IsAncestor(TControl * Control, TControl * Ancestor)
  446. {
  447. while ((Control != NULL) &&
  448. (Control->Parent != Ancestor))
  449. {
  450. Control = Control->Parent;
  451. }
  452. return (Control != NULL);
  453. }
  454. //---------------------------------------------------------------------------
  455. void __fastcall TRightsFrame::WMContextMenu(TWMContextMenu & Message)
  456. {
  457. FPopingContextMenu = true;
  458. try
  459. {
  460. TFrame::Dispatch(&Message);
  461. }
  462. __finally
  463. {
  464. FPopingContextMenu = false;
  465. }
  466. }
  467. //---------------------------------------------------------------------------
  468. void __fastcall TRightsFrame::CMDialogKey(TCMDialogKey & Message)
  469. {
  470. if (FPopup && Visible &&
  471. ((Message.CharCode == VK_RETURN) ||
  472. (Message.CharCode == VK_ESCAPE)) &&
  473. KeyDataToShiftState(Message.KeyData).Empty())
  474. {
  475. CloseUp();
  476. Message.Result = 1;
  477. }
  478. else
  479. {
  480. TFrame::Dispatch(&Message);
  481. }
  482. }
  483. //---------------------------------------------------------------------------
  484. void __fastcall TRightsFrame::CMCancelMode(TCMCancelMode & Message)
  485. {
  486. if (FPopup && Visible && !FPopingContextMenu &&
  487. ((Message.Sender == NULL) ||
  488. (!IsAncestor(Message.Sender, this) &&
  489. !IsAncestor(Message.Sender, FPopupParent) &&
  490. (Message.Sender != this))))
  491. {
  492. CloseUp();
  493. }
  494. TFrame::Dispatch(&Message);
  495. }
  496. //---------------------------------------------------------------------------
  497. void __fastcall TRightsFrame::Dispatch(void * Message)
  498. {
  499. TMessage & AMessage = *static_cast<TMessage *>(Message);
  500. switch (AMessage.Msg)
  501. {
  502. case CM_CANCELMODE:
  503. CMCancelMode(*(TCMCancelMode *)Message);
  504. break;
  505. case CM_DIALOGKEY:
  506. CMDialogKey(*(TCMDialogKey *)Message);
  507. break;
  508. case WM_CONTEXTMENU:
  509. WMContextMenu(*(TWMContextMenu *)Message);
  510. break;
  511. default:
  512. TFrame::Dispatch(Message);
  513. break;
  514. }
  515. }
  516. //---------------------------------------------------------------------------
  517. void __fastcall TRightsFrame::DropDown()
  518. {
  519. TCustomForm * Form = GetParentForm(this);
  520. // Due to lack of better idea, we clear "default" and "cancel" flags of respective
  521. // form buttons to prevent them to handle ESC/ENTER keys.
  522. // Could use FindStandardButton.
  523. for (int Index = 0; Index < Form->ControlCount; Index++)
  524. {
  525. TButton * Button = dynamic_cast<TButton *>(Form->Controls[Index]);
  526. if (Button != NULL)
  527. {
  528. if (Button->Default)
  529. {
  530. DebugAssert(FDefaultButton == NULL);
  531. FDefaultButton = Button;
  532. Button->Default = false;
  533. }
  534. if (Button->Cancel)
  535. {
  536. DebugAssert(FCancelButton == NULL);
  537. FCancelButton = Button;
  538. Button->Cancel = false;
  539. }
  540. }
  541. }
  542. TPoint Origin(PopupParent->Left, PopupParent->Top + PopupParent->Height);
  543. Origin = Parent->ScreenToClient(PopupParent->Parent->ClientToScreen(Origin));
  544. if (Origin.x + Width > Parent->ClientWidth)
  545. {
  546. Origin.x += PopupParent->Width - Width;
  547. }
  548. Left = Origin.x;
  549. Top = Origin.y;
  550. Show();
  551. SetFocus();
  552. }
  553. //---------------------------------------------------------------------------
  554. void __fastcall TRightsFrame::CloseUp()
  555. {
  556. DebugAssert(FPopup);
  557. DebugAssert(Visible);
  558. if (!Focused())
  559. {
  560. // this can happen only if called from on-click handler of drop down button
  561. DoCloseUp();
  562. }
  563. FPopupParent->SetFocus();
  564. }
  565. //---------------------------------------------------------------------------
  566. UnicodeString __fastcall TRightsFrame::GetText()
  567. {
  568. UnicodeString Result = Rights.Text;
  569. if (AllowAddXToDirectories && DirectoriesXEffective() && AddXToDirectories)
  570. {
  571. Result = FORMAT(L"%s (%s)", (Result, FAddXToDirectoriesSuffix));
  572. }
  573. return Result;
  574. }
  575. //---------------------------------------------------------------------------
  576. void __fastcall TRightsFrame::SetText(UnicodeString value)
  577. {
  578. if (Text != value)
  579. {
  580. UnicodeString RightsStr = value;
  581. int P = RightsStr.LowerCase().Pos(FAddXToDirectoriesSuffix);
  582. bool AAddXToDirectories = (P > 0);
  583. if (AAddXToDirectories)
  584. {
  585. RightsStr.Delete(P, FAddXToDirectoriesSuffix.Length());
  586. }
  587. RightsStr = DeleteChar(DeleteChar(RightsStr, L'('), L')').Trim();
  588. TRights R = Rights;
  589. if (((RightsStr.Length() == 3) || (RightsStr.Length() == 4)) &&
  590. IsNumber(RightsStr))
  591. {
  592. R.Octal = RightsStr;
  593. }
  594. else
  595. {
  596. R.Text = RightsStr;
  597. }
  598. Rights = R;
  599. AddXToDirectories = AAddXToDirectories;
  600. }
  601. }
  602. //---------------------------------------------------------------------------
  603. void __fastcall TRightsFrame::RightsPopupPopup(TObject * /*Sender*/)
  604. {
  605. if (!HasFocus())
  606. {
  607. SetFocus();
  608. }
  609. }
  610. //---------------------------------------------------------------------------
  611. void __fastcall TRightsFrame::FrameContextPopup(TObject * Sender,
  612. TPoint & MousePos, bool & Handled)
  613. {
  614. SelectScaledImageList(RightsImages);
  615. MenuPopup(Sender, MousePos, Handled);
  616. }
  617. //---------------------------------------------------------------------------
  618. void __fastcall TRightsFrame::UpdateByOctal()
  619. {
  620. if (!OctalEdit->Text.IsEmpty())
  621. {
  622. TRights R = Rights;
  623. R.Octal = OctalEdit->Text;
  624. Rights = R;
  625. }
  626. UpdateControls();
  627. OctalEdit->Modified = false;
  628. }
  629. //---------------------------------------------------------------------------
  630. void __fastcall TRightsFrame::UpdateOctalEdit()
  631. {
  632. TRights R = Rights;
  633. OctalEdit->Text = R.IsUndef ? UnicodeString() : R.Octal;
  634. OctalEdit->Modified = false;
  635. OctalEdit->SelectAll();
  636. }
  637. //---------------------------------------------------------------------------
  638. void __fastcall TRightsFrame::OctalEditChange(TObject *)
  639. {
  640. if (OctalEdit->Modified && OctalEdit->Text.Length() >= 3)
  641. {
  642. try
  643. {
  644. UpdateByOctal();
  645. }
  646. catch(...)
  647. {
  648. OctalEdit->Modified = true;
  649. }
  650. }
  651. }
  652. //---------------------------------------------------------------------------
  653. void __fastcall TRightsFrame::OctalEditExit(TObject *)
  654. {
  655. if ((!Visible && DebugAlwaysTrue(Popup)) || // Popup assert: should happen only if popup is closed by esc key
  656. IsCancelButtonBeingClicked(this) || // CloseButton
  657. ((FCancelButton != NULL) && IsButtonBeingClicked(FCancelButton)))
  658. {
  659. // cancel changes
  660. ForceUpdate();
  661. }
  662. else if (OctalEdit->Modified)
  663. {
  664. // Now the text in OctalEdit is almost necessarily invalid, otherwise
  665. // OctalEditChange would have already cleared Modified flag
  666. try
  667. {
  668. UpdateByOctal();
  669. }
  670. catch(...)
  671. {
  672. OctalEdit->SelectAll();
  673. OctalEdit->SetFocus();
  674. throw;
  675. }
  676. }
  677. else
  678. {
  679. UpdateControls();
  680. }
  681. }
  682. //---------------------------------------------------------------------------
  683. void __fastcall TRightsFrame::CloseButtonClick(TObject *)
  684. {
  685. CloseUp();
  686. }
  687. //---------------------------------------------------------------------------