Browse Source

Merging Rights and RightsExt frames as there's no use for separate Rights frame since 3.8 (2005)

Source commit: 9724971d3503155ddc46424a750d1542e0731603
Martin Prikryl 7 years ago
parent
commit
7ad202c63d

+ 0 - 8
source/ScpForms.cbproj

@@ -277,14 +277,6 @@
 			<BuildOrder>101</BuildOrder>
 		</CppCompile>
 		<FormResources Include="forms\Rights.dfm"/>
-		<CppCompile Include="forms\RightsExt.cpp">
-			<BuildOrder>17</BuildOrder>
-			<Form>RightsExtFrame</Form>
-			<DesignClass>TFrame</DesignClass>
-			<DependentOn>forms\RightsExt.h</DependentOn>
-			<BuildOrder>104</BuildOrder>
-		</CppCompile>
-		<FormResources Include="forms\RightsExt.dfm"/>
 		<CppCompile Include="forms\SelectMask.cpp">
 			<BuildOrder>14</BuildOrder>
 			<Form>SelectMaskDialog</Form>

+ 1 - 1
source/forms/CopyParams.cpp

@@ -23,7 +23,7 @@
 __fastcall TCopyParamsFrame::TCopyParamsFrame(TComponent* Owner)
         : TFrame(Owner)
 {
-  FRightsFrame = new TRightsExtFrame(this);
+  FRightsFrame = new TRightsFrame(this);
   FRightsFrame->TabStop = false;
   FRightsFrame->Parent = this;
   FRightsFrame->TabOrder = 1000;

+ 1 - 1
source/forms/CopyParams.h

@@ -65,7 +65,7 @@ private:
   UnicodeString FOrigMasks;
   TCopyParamType * FParams;
   int FCopyParamAttrs;
-  TRightsExtFrame * FRightsFrame;
+  TRightsFrame * FRightsFrame;
   bool FRemoveCtrlZ;
   void __fastcall SetParams(TCopyParamType value);
   TCopyParamType __fastcall GetParams();

+ 1 - 1
source/forms/CreateDirectory.dfm

@@ -57,7 +57,7 @@ object CreateDirectoryDialog: TCreateDirectoryDialog
       Anchors = [akLeft, akTop, akRight, akBottom]
       Caption = 'Attributes'
       TabOrder = 0
-      inline RightsFrame: TRightsExtFrame
+      inline RightsFrame: TRightsFrame
         Left = 7
         Top = 36
         Width = 239

+ 1 - 1
source/forms/CreateDirectory.h

@@ -25,7 +25,7 @@ __published:
   TButton *HelpButton;
   TPanel *MorePanel;
   TGroupBox *AttributesGroup;
-  TRightsExtFrame *RightsFrame;
+  TRightsFrame *RightsFrame;
   TCheckBox *SetRightsCheck;
   TCheckBox *SaveSettingsCheck;
   void __fastcall ControlChange(TObject *Sender);

+ 1 - 1
source/forms/Properties.dfm

@@ -185,7 +185,7 @@ object PropertiesDialog: TPropertiesDialog
         Anchors = [akLeft, akTop, akRight]
         Shape = bsTopLine
       end
-      inline RightsFrame: TRightsExtFrame
+      inline RightsFrame: TRightsFrame
         Left = 84
         Top = 200
         Width = 244

+ 1 - 1
source/forms/Properties.h

@@ -45,7 +45,7 @@ __published:
   TBevel *RecursiveBevel;
   TCheckBox *RecursiveCheck;
   TButton *CalculateSizeButton;
-  TRightsExtFrame *RightsFrame;
+  TRightsFrame *RightsFrame;
   TButton *HelpButton;
   TTabSheet *ChecksumSheet;
   TListView *ChecksumView;

+ 80 - 0
source/forms/Rights.cpp

@@ -182,6 +182,10 @@ bool __fastcall TRightsFrame::DirectoriesXEffective()
 //---------------------------------------------------------------------------
 void __fastcall TRightsFrame::UpdateControls()
 {
+  if (!OctalEdit->Focused())
+  {
+    UpdateOctalEdit();
+  }
   Color = (FPopup ? clWindow : clBtnFace);
   DirectoriesXCheck->Visible = AllowAddXToDirectories;
   EnableControl(DirectoriesXCheck,
@@ -263,6 +267,7 @@ void __fastcall TRightsFrame::SetEnabled(bool Value)
 //---------------------------------------------------------------------------
 void __fastcall TRightsFrame::ForceUpdate()
 {
+  UpdateOctalEdit();
 }
 //---------------------------------------------------------------------------
 bool __fastcall TRightsFrame::HasFocus()
@@ -418,6 +423,10 @@ void __fastcall TRightsFrame::SetPopup(bool value)
   {
     FPopup = value;
     Visible = !FPopup;
+
+    CloseButton->Visible = value;
+    CloseButton->Cancel = value;
+    CloseButton->Default = value;
   }
 }
 //---------------------------------------------------------------------------
@@ -629,3 +638,74 @@ void __fastcall TRightsFrame::FrameContextPopup(TObject * Sender,
   MenuPopup(Sender, MousePos, Handled);
 }
 //---------------------------------------------------------------------------
+void __fastcall TRightsFrame::UpdateByOctal()
+{
+  if (!OctalEdit->Text.IsEmpty())
+  {
+    TRights R = Rights;
+    R.Octal = OctalEdit->Text;
+    Rights = R;
+  }
+  UpdateControls();
+  OctalEdit->Modified = false;
+}
+//---------------------------------------------------------------------------
+void __fastcall TRightsFrame::UpdateOctalEdit()
+{
+  TRights R = Rights;
+  OctalEdit->Text = R.IsUndef ? UnicodeString() : R.Octal;
+  OctalEdit->Modified = false;
+  OctalEdit->SelectAll();
+}
+//---------------------------------------------------------------------------
+void __fastcall TRightsFrame::OctalEditChange(TObject *)
+{
+  if (OctalEdit->Modified && OctalEdit->Text.Length() >= 3)
+  {
+    try
+    {
+      UpdateByOctal();
+    }
+    catch(...)
+    {
+      OctalEdit->Modified = true;
+    }
+  }
+}
+//---------------------------------------------------------------------------
+void __fastcall TRightsFrame::OctalEditExit(TObject *)
+{
+  if (!Visible)
+  {
+    // should happen only if popup is closed by esc key
+    DebugAssert(Popup);
+
+    // cancel changes
+    ForceUpdate();
+  }
+  else if (OctalEdit->Modified)
+  {
+    // Now the text in OctalEdit is almost necessarily invalid, otherwise
+    // OctalEditChange would have already cleared Modified flag
+    try
+    {
+      UpdateByOctal();
+    }
+    catch(...)
+    {
+      OctalEdit->SelectAll();
+      OctalEdit->SetFocus();
+      throw;
+    }
+  }
+  else
+  {
+    UpdateControls();
+  }
+}
+//---------------------------------------------------------------------------
+void __fastcall TRightsFrame::CloseButtonClick(TObject *)
+{
+  CloseUp();
+}
+//---------------------------------------------------------------------------

+ 68 - 10
source/forms/Rights.dfm

@@ -1,8 +1,8 @@
 object RightsFrame: TRightsFrame
   Left = 0
   Top = 0
-  Width = 163
-  Height = 87
+  Width = 239
+  Height = 109
   TabOrder = 0
   OnContextPopup = FrameContextPopup
   object OwnerLabel: TLabel
@@ -56,6 +56,13 @@ object RightsFrame: TRightsFrame
     Flat = True
     OnClick = RightsButtonsClick
   end
+  object OctalLabel: TLabel
+    Left = 4
+    Top = 68
+    Width = 29
+    Height = 13
+    Caption = 'O&ctal:'
+  end
   object OwnerReadCheck: TGrayedCheckBox
     Tag = 256
     Left = 58
@@ -104,7 +111,7 @@ object RightsFrame: TRightsFrame
     Caption = 'R'
     ParentShowHint = False
     ShowHint = True
-    TabOrder = 3
+    TabOrder = 4
     OnClick = ControlChange
   end
   object GroupWriteCheck: TGrayedCheckBox
@@ -116,7 +123,7 @@ object RightsFrame: TRightsFrame
     Caption = 'W'
     ParentShowHint = False
     ShowHint = True
-    TabOrder = 4
+    TabOrder = 5
     OnClick = ControlChange
   end
   object GroupExecuteCheck: TGrayedCheckBox
@@ -128,7 +135,7 @@ object RightsFrame: TRightsFrame
     Caption = 'X'
     ParentShowHint = False
     ShowHint = True
-    TabOrder = 5
+    TabOrder = 6
     OnClick = ControlChange
   end
   object OthersReadCheck: TGrayedCheckBox
@@ -140,7 +147,7 @@ object RightsFrame: TRightsFrame
     Caption = 'R'
     ParentShowHint = False
     ShowHint = True
-    TabOrder = 6
+    TabOrder = 8
     OnClick = ControlChange
   end
   object OthersWriteCheck: TGrayedCheckBox
@@ -152,7 +159,7 @@ object RightsFrame: TRightsFrame
     Caption = 'W'
     ParentShowHint = False
     ShowHint = True
-    TabOrder = 7
+    TabOrder = 9
     OnClick = ControlChange
   end
   object OthersExecuteCheck: TGrayedCheckBox
@@ -164,18 +171,69 @@ object RightsFrame: TRightsFrame
     Caption = 'X'
     ParentShowHint = False
     ShowHint = True
-    TabOrder = 8
+    TabOrder = 10
     OnClick = ControlChange
   end
   object DirectoriesXCheck: TCheckBox
     Left = 5
-    Top = 65
+    Top = 89
     Width = 156
     Height = 17
     Caption = 'Add &X to directories'
-    TabOrder = 9
+    TabOrder = 13
     OnClick = ControlChange
   end
+  object OctalEdit: TEdit
+    Left = 55
+    Top = 64
+    Width = 64
+    Height = 21
+    MaxLength = 4
+    TabOrder = 12
+    Text = 'OctalEdit'
+    OnChange = OctalEditChange
+    OnExit = OctalEditExit
+  end
+  object SetUidCheck: TGrayedCheckBox
+    Tag = 2048
+    Left = 169
+    Top = 3
+    Width = 70
+    Height = 17
+    Caption = 'Set UID'
+    TabOrder = 3
+    OnClick = ControlChange
+  end
+  object SetGIDCheck: TGrayedCheckBox
+    Tag = 1024
+    Left = 169
+    Top = 23
+    Width = 70
+    Height = 17
+    Caption = 'Set GID'
+    TabOrder = 7
+    OnClick = ControlChange
+  end
+  object StickyBitCheck: TGrayedCheckBox
+    Tag = 512
+    Left = 169
+    Top = 43
+    Width = 70
+    Height = 17
+    Caption = 'Sticky bit'
+    TabOrder = 11
+    OnClick = ControlChange
+  end
+  object CloseButton: TButton
+    Left = 160
+    Top = 80
+    Width = 75
+    Height = 25
+    Caption = 'Close'
+    TabOrder = 14
+    Visible = False
+    OnClick = CloseButtonClick
+  end
   object RightsPopup: TPopupMenu
     Images = RightsImages
     OnPopup = RightsPopupPopup

+ 14 - 3
source/forms/Rights.h

@@ -56,6 +56,12 @@ __published:
   TPngImageList *RightsImages120;
   TPngImageList *RightsImages144;
   TPngImageList *RightsImages192;
+  TLabel *OctalLabel;
+  TEdit *OctalEdit;
+  TGrayedCheckBox *SetUidCheck;
+  TGrayedCheckBox *SetGIDCheck;
+  TGrayedCheckBox *StickyBitCheck;
+  TButton *CloseButton;
   void __fastcall ControlChange(TObject *Sender);
   void __fastcall RightsButtonsClick(TObject *Sender);
   void __fastcall RightsActionsExecute(TBasicAction *Action,
@@ -64,6 +70,9 @@ __published:
   void __fastcall RightsPopupPopup(TObject *Sender);
   void __fastcall FrameContextPopup(TObject *Sender, TPoint &MousePos,
           bool &Handled);
+  void __fastcall OctalEditChange(TObject * Sender);
+  void __fastcall OctalEditExit(TObject * Sender);
+  void __fastcall CloseButtonClick(TObject * Sender);
 private:
   bool FAllowAddXToDirectories;
   TNotifyEvent FOnChange;
@@ -107,9 +116,9 @@ public:
 
 protected:
   void __fastcall DoChange();
-  virtual void __fastcall UpdateControls();
+  void __fastcall UpdateControls();
   virtual void __fastcall SetEnabled(bool Value);
-  virtual void __fastcall ForceUpdate();
+  void __fastcall ForceUpdate();
   virtual void __fastcall CreateParams(TCreateParams & Params);
   virtual void __fastcall CreateWnd();
   virtual void __fastcall Dispatch(void * Message);
@@ -118,10 +127,12 @@ protected:
   void __fastcall WMContextMenu(TWMContextMenu & Message);
   bool __fastcall IsAncestor(TControl * Control, TControl * Ancestor);
   DYNAMIC void __fastcall DoExit();
-  virtual void __fastcall SetPopup(bool value);
+  void __fastcall SetPopup(bool value);
   void __fastcall DoCloseUp();
   bool __fastcall HasFocus();
   bool __fastcall DirectoriesXEffective();
+  void __fastcall UpdateOctalEdit();
+  void __fastcall UpdateByOctal();
 
   __property TRights::TState States[TRights::TRight Right] = { read = GetStates, write = SetStates };
 };

+ 0 - 117
source/forms/RightsExt.cpp

@@ -1,117 +0,0 @@
-//---------------------------------------------------------------------------
-#include <vcl.h>
-#pragma hdrstop
-
-#include "RightsExt.h"
-#include <Common.h>
-//---------------------------------------------------------------------------
-#pragma package(smart_init)
-#pragma link "Rights"
-#pragma link "GrayedCheckBox"
-#pragma link "PngImageList"
-#ifndef NO_RESOURCES
-#pragma resource "*.dfm"
-#endif
-//---------------------------------------------------------------------------
-__fastcall TRightsExtFrame::TRightsExtFrame(TComponent* Owner)
-  : TRightsFrame(Owner)
-{
-}
-//---------------------------------------------------------------------------
-void __fastcall TRightsExtFrame::UpdateControls()
-{
-  if (!OctalEdit->Focused())
-  {
-    UpdateOctalEdit();
-  }
-  TRightsFrame::UpdateControls();
-}
-//---------------------------------------------------------------------------
-void __fastcall TRightsExtFrame::UpdateByOctal()
-{
-  if (!OctalEdit->Text.IsEmpty())
-  {
-    TRights R = Rights;
-    R.Octal = OctalEdit->Text;
-    Rights = R;
-  }
-  UpdateControls();
-  OctalEdit->Modified = false;
-}
-//---------------------------------------------------------------------------
-void __fastcall TRightsExtFrame::UpdateOctalEdit()
-{
-  TRights R = Rights;
-  OctalEdit->Text = R.IsUndef ? UnicodeString() : R.Octal;
-  OctalEdit->Modified = false;
-  OctalEdit->SelectAll();
-}
-//---------------------------------------------------------------------------
-void __fastcall TRightsExtFrame::ForceUpdate()
-{
-  TRightsFrame::ForceUpdate();
-  UpdateOctalEdit();
-}
-//---------------------------------------------------------------------------
-void __fastcall TRightsExtFrame::OctalEditChange(TObject * /*Sender*/)
-{
-  if (OctalEdit->Modified && OctalEdit->Text.Length() >= 3)
-  {
-    try
-    {
-      UpdateByOctal();
-    }
-    catch(...)
-    {
-      OctalEdit->Modified = true;
-    }
-  }
-}
-//---------------------------------------------------------------------------
-void __fastcall TRightsExtFrame::OctalEditExit(TObject * /*Sender*/)
-{
-  if (!Visible)
-  {
-    // should happen only if popup is closed by esc key
-    DebugAssert(Popup);
-
-    // cancel changes
-    ForceUpdate();
-  }
-  else if (OctalEdit->Modified)
-  {
-    // Now the text in OctalEdit is almost necessarily invalid, otherwise
-    // OctalEditChange would have already cleared Modified flag
-    try
-    {
-      UpdateByOctal();
-    }
-    catch(...)
-    {
-      OctalEdit->SelectAll();
-      OctalEdit->SetFocus();
-      throw;
-    }
-  }
-  else
-  {
-    UpdateControls();
-  }
-}
-//---------------------------------------------------------------------------
-void __fastcall TRightsExtFrame::SetPopup(bool value)
-{
-  if (Popup != value)
-  {
-    TRightsFrame::SetPopup(value);
-    CloseButton->Visible = value;
-    CloseButton->Cancel = value;
-    CloseButton->Default = value;
-  }
-}
-//---------------------------------------------------------------------------
-void __fastcall TRightsExtFrame::CloseButtonClick(TObject * /*Sender*/)
-{
-  CloseUp();
-}
-//---------------------------------------------------------------------------

+ 0 - 85
source/forms/RightsExt.dfm

@@ -1,85 +0,0 @@
-inherited RightsExtFrame: TRightsExtFrame
-  Width = 239
-  Height = 109
-  object OctalLabel: TLabel [6]
-    Left = 4
-    Top = 68
-    Width = 29
-    Height = 13
-    Caption = 'O&ctal:'
-    FocusControl = OctalEdit
-  end
-  inherited GroupReadCheck: TGrayedCheckBox
-    TabOrder = 4
-  end
-  inherited GroupWriteCheck: TGrayedCheckBox
-    TabOrder = 5
-  end
-  inherited GroupExecuteCheck: TGrayedCheckBox
-    TabOrder = 6
-  end
-  inherited OthersReadCheck: TGrayedCheckBox
-    TabOrder = 8
-  end
-  inherited OthersWriteCheck: TGrayedCheckBox
-    TabOrder = 9
-  end
-  inherited OthersExecuteCheck: TGrayedCheckBox
-    TabOrder = 10
-  end
-  inherited DirectoriesXCheck: TCheckBox
-    Top = 89
-    TabOrder = 13
-  end
-  object OctalEdit: TEdit [17]
-    Left = 55
-    Top = 64
-    Width = 64
-    Height = 21
-    MaxLength = 4
-    TabOrder = 12
-    Text = 'OctalEdit'
-    OnChange = OctalEditChange
-    OnExit = OctalEditExit
-  end
-  object SetUidCheck: TGrayedCheckBox [18]
-    Tag = 2048
-    Left = 169
-    Top = 3
-    Width = 70
-    Height = 17
-    Caption = 'Set UID'
-    TabOrder = 3
-    OnClick = ControlChange
-  end
-  object SetGIDCheck: TGrayedCheckBox [19]
-    Tag = 1024
-    Left = 169
-    Top = 23
-    Width = 70
-    Height = 17
-    Caption = 'Set GID'
-    TabOrder = 7
-    OnClick = ControlChange
-  end
-  object StickyBitCheck: TGrayedCheckBox [20]
-    Tag = 512
-    Left = 169
-    Top = 43
-    Width = 70
-    Height = 17
-    Caption = 'Sticky bit'
-    TabOrder = 11
-    OnClick = ControlChange
-  end
-  object CloseButton: TButton [21]
-    Left = 160
-    Top = 80
-    Width = 75
-    Height = 25
-    Caption = 'Close'
-    TabOrder = 14
-    Visible = False
-    OnClick = CloseButtonClick
-  end
-end

+ 0 - 44
source/forms/RightsExt.h

@@ -1,44 +0,0 @@
-//---------------------------------------------------------------------------
-#ifndef RightsExtH
-#define RightsExtH
-//---------------------------------------------------------------------------
-#include <Classes.hpp>
-#include <Controls.hpp>
-#include <StdCtrls.hpp>
-#include <Forms.hpp>
-#include "Rights.h"
-#include <ActnList.hpp>
-#include <Buttons.hpp>
-#include <ImgList.hpp>
-#include <Menus.hpp>
-#include "GrayedCheckBox.hpp"
-#include "PngImageList.hpp"
-#include <System.Actions.hpp>
-//---------------------------------------------------------------------------
-class TRightsExtFrame : public TRightsFrame
-{
-__published:
-  TLabel *OctalLabel;
-  TEdit *OctalEdit;
-  TGrayedCheckBox *SetUidCheck;
-  TGrayedCheckBox *SetGIDCheck;
-  TGrayedCheckBox *StickyBitCheck;
-  TButton *CloseButton;
-  void __fastcall OctalEditChange(TObject *Sender);
-  void __fastcall OctalEditExit(TObject *Sender);
-  void __fastcall CloseButtonClick(TObject *Sender);
-
-public:
-  __fastcall TRightsExtFrame(TComponent* Owner);
-
-protected:
-  virtual void __fastcall UpdateControls();
-  virtual void __fastcall ForceUpdate();
-  virtual void __fastcall SetPopup(bool value);
-
-private:
-  void __fastcall UpdateByOctal();
-  void __fastcall UpdateOctalEdit();
-};
-//---------------------------------------------------------------------------
-#endif