1
0

Rights.cpp 20 KB

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