~ubuntu-branches/ubuntu/saucy/lazarus/saucy

« back to all changes in this revision

Viewing changes to designer/anchoreditor.pas

  • Committer: Package Import Robot
  • Author(s): Paul Gevers, Abou Al Montacir, Bart Martens, Paul Gevers
  • Date: 2013-06-08 14:12:17 UTC
  • mfrom: (1.1.9)
  • Revision ID: package-import@ubuntu.com-20130608141217-7k0cy9id8ifcnutc
Tags: 1.0.8+dfsg-1
[ Abou Al Montacir ]
* New upstream major release and multiple maintenace release offering many
  fixes and new features marking a new milestone for the Lazarus development
  and its stability level.
  - The detailed list of changes can be found here:
    http://wiki.lazarus.freepascal.org/Lazarus_1.0_release_notes
    http://wiki.lazarus.freepascal.org/Lazarus_1.0_fixes_branch
* LCL changes:
  - LCL is now a normal package.
      + Platform independent parts of the LCL are now in the package LCLBase
      + LCL is automatically recompiled when switching the target platform,
        unless pre-compiled binaries for this target are already installed.
      + No impact on existing projects.
      + Linker options needed by LCL are no more added to projects that do
        not use the LCL package.
  - Minor changes in LCL basic classes behaviour
      + TCustomForm.Create raises an exception if a form resource is not
        found.
      + TNotebook and TPage: a new implementation of these classes was added.
      + TDBNavigator: It is now possible to have focusable buttons by setting
        Options = [navFocusableButtons] and TabStop = True, useful for
        accessibility and for devices with neither mouse nor touch screen.
      + Names of TControlBorderSpacing.GetSideSpace and GetSpace were swapped
        and are now consistent. GetSideSpace = Around + GetSpace.
      + TForm.WindowState=wsFullscreen was added
      + TCanvas.TextFitInfo was added to calculate how many characters will
        fit into a specified Width. Useful for word-wrapping calculations.
      + TControl.GetColorResolvingParent and
        TControl.GetRGBColorResolvingParent were added, simplifying the work
        to obtain the final color of the control while resolving clDefault
        and the ParentColor.
      + LCLIntf.GetTextExtentExPoint now has a good default implementation
        which works in any platform not providing a specific implementation.
        However, Widgetset specific implementation is better, when available.
      + TTabControl was reorganized. Now it has the correct class hierarchy
        and inherits from TCustomTabControl as it should.
  - New unit in the LCL:
      + lazdialogs.pas: adds non-native versions of various native dialogs,
        for example TLazOpenDialog, TLazSaveDialog, TLazSelectDirectoryDialog.
        It is used by widgetsets which either do not have a native dialog, or
        do not wish to use it because it is limited. These dialogs can also be
        used by user applications directly.
      + lazdeviceapis.pas: offers an interface to more hardware devices such
        as the accelerometer, GPS, etc. See LazDeviceAPIs
      + lazcanvas.pas: provides a TFPImageCanvas descendent implementing
        drawing in a LCL-compatible way, but 100% in Pascal.
      + lazregions.pas. LazRegions is a wholly Pascal implementation of
        regions for canvas clipping, event clipping, finding in which control
        of a region tree one an event should reach, for drawing polygons, etc.
      + customdrawncontrols.pas, customdrawndrawers.pas,
        customdrawn_common.pas, customdrawn_android.pas and
        customdrawn_winxp.pas: are the Lazarus Custom Drawn Controls -controls
        which imitate the standard LCL ones, but with the difference that they
        are non-native and support skinning.
  - New APIs added to the LCL to improve support of accessibility software
    such as screen readers.
* IDE changes:
  - Many improvments.
  - The detailed list of changes can be found here:
    http://wiki.lazarus.freepascal.org/New_IDE_features_since#v1.0_.282012-08-29.29
    http://wiki.lazarus.freepascal.org/Lazarus_1.0_release_notes#IDE_Changes
* Debugger / Editor changes:
  - Added pascal sources and breakpoints to the disassembler
  - Added threads dialog.
* Components changes:
  - TAChart: many fixes and new features
  - CodeTool: support Delphi style generics and new syntax extensions.
  - AggPas: removed to honor free licencing. (Closes: Bug#708695)
[Bart Martens]
* New debian/watch file fixing issues with upstream RC release.
[Abou Al Montacir]
* Avoid changing files in .pc hidden directory, these are used by quilt for
  internal purpose and could lead to surprises during build.
[Paul Gevers]
* Updated get-orig-source target and it compinion script orig-tar.sh so that they
  repack the source file, allowing bug 708695 to be fixed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
35
35
interface
36
36
 
37
37
uses
38
 
  Classes, SysUtils, LCLProc, Forms, Controls, Graphics, Dialogs,
39
 
  StdCtrls, Buttons, Spin,
40
 
  IDECommands, PropEdits,
41
 
  LazarusIDEStrConsts, EnvironmentOpts, IDEOptionDefs;
 
38
  Classes, SysUtils, LCLProc, Forms, Controls, Dialogs, StdCtrls, Buttons, Spin,
 
39
  IDECommands, PropEdits, LazarusIDEStrConsts, IDEOptionDefs;
42
40
 
43
41
type
44
42
 
136
134
    procedure AnchorDesignerShow(Sender: TObject);
137
135
    procedure AnchorEnabledCheckBoxChange(Sender: TObject);
138
136
    procedure BorderSpaceSpinEditChange(Sender: TObject);
 
137
    procedure FormDeactivate(Sender: TObject);
139
138
    procedure SiblingComboBoxChange(Sender: TObject);
140
139
    procedure ReferenceSideButtonClicked(Sender: TObject);
141
140
  private
 
141
    Values: TAnchorDesignerValues;
142
142
    FSelection: TPersistentSelectionList;
143
143
    FSelectedControlsList: TList;
144
144
    FUpdating: Boolean;
145
 
  protected
146
 
    procedure KeyUp(var Key: Word; Shift: TShiftState); override;
147
 
    procedure FillComboBoxWithSiblings(AComboBox: TComboBox);
148
 
    function AnchorDesignerNoSiblingText: string;
149
 
    function AnchorDesignerNeighbourText(direction: TAnchorKind): string;
150
 
  public
151
 
    Values: TAnchorDesignerValues;
152
 
    destructor Destroy; override;
153
145
    procedure Refresh(Force: boolean);
154
146
    procedure OnRefreshPropertyValues;
 
147
    procedure OnSetSelection(const ASelection: TPersistentSelectionList);
155
148
    function GetSelectedControls: TList;
156
149
    function FindSibling(const Sibling: string): TControl;
157
 
    class function ControlToStr(AControl: TControl): string;
 
150
    procedure FillComboBoxWithSiblings(AComboBox: TComboBox);
 
151
    function AnchorDesignerNoSiblingText: string;
 
152
    function AnchorDesignerNeighbourText(direction: TAnchorKind): string;
158
153
    procedure CollectValues(const ASelection: TList;
159
154
                            var TheValues: TAnchorDesignerValues;
160
155
                            var SelectedControlCount: integer);
161
 
    procedure OnSetSelection(const ASelection: TPersistentSelectionList);
 
156
  protected
 
157
    procedure KeyUp(var Key: Word; Shift: TShiftState); override;
 
158
  public
 
159
    destructor Destroy; override;
 
160
    class function ControlToStr(AControl: TControl): string;
162
161
    property Selection: TPersistentSelectionList read FSelection;
163
162
  end;
164
163
  
178
177
 
179
178
{$R *.lfm}
180
179
 
181
 
uses 
182
 
  math;
183
180
{ TAnchorDesigner }
184
181
 
185
182
procedure TAnchorDesigner.AnchorDesignerCreate(Sender: TObject);
200
197
  BottomAnchoredCheckBox.Hint:=Format(AnchorEnabledHint,['akBottom']);
201
198
  BottomBorderSpaceSpinEdit.Hint:=lisBottomBorderSpaceSpinEditHint;
202
199
  BottomGroupBox.Caption:=lisBottomGroupBoxCaption;
203
 
  BottomRefBottomSpeedButton.Hint:=lisAnchorToBottomSideKeepBorderSpace;
 
200
  BottomRefBottomSpeedButton.Hint:=lisAnchorBottomToBottomSide;
204
201
  BottomRefCenterSpeedButton.Hint:=lisCenterControlVerticallyRelativeToSibling;
205
 
  BottomRefTopSpeedButton.Hint:=lisAnchorToTopSideKeepBorderSpace;
 
202
  BottomRefTopSpeedButton.Hint:=lisAnchorBottomToTopSide;
206
203
  BottomSiblingComboBox.Hint:=lisBottomSiblingComboBoxHint;
207
204
  BottomSiblingLabel.Caption:=lisSibling;
208
205
 
211
208
  LeftBorderSpaceSpinEdit.Hint:=lisLeftBorderSpaceSpinEditHint;
212
209
  LeftGroupBox.Caption:=lisLeftGroupBoxCaption;
213
210
  LeftRefCenterSpeedButton.Hint:=lisCenterControlHorizontallyRelativeToSibling;
214
 
  LeftRefLeftSpeedButton.Hint:=lisAnchorToLeftSideKeepBorderSpace;
215
 
  LeftRefRightSpeedButton.Hint:=lisAnchorToRightSideKeepBorderSpace;
 
211
  LeftRefLeftSpeedButton.Hint:=lisAnchorLeftToLeftSide;
 
212
  LeftRefRightSpeedButton.Hint:=lisAnchorLeftToRightSide;
216
213
  LeftSiblingComboBox.Hint:=lisLeftSiblingComboBoxHint;
217
214
  LeftSiblingLabel.Caption:=lisSibling;
218
215
 
221
218
  RightBorderSpaceSpinEdit.Hint:=lisRightBorderSpaceSpinEditHint;
222
219
  RightGroupBox.Caption:=lisRightAnchoring;
223
220
  RightRefCenterSpeedButton.Hint:=lisCenterControlHorizontallyRelativeToSibling;
224
 
  RightRefLeftSpeedButton.Hint:=lisAnchorToLeftSideKeepBorderSpace;
225
 
  RightRefRightSpeedButton.Hint:=lisAnchorToRightSideKeepBorderSpace;
 
221
  RightRefLeftSpeedButton.Hint:=lisAnchorRightToLeftSide;
 
222
  RightRefRightSpeedButton.Hint:=lisAnchorRightToRightSide;
226
223
  RightSiblingComboBox.Hint:=lisRightSiblingComboBoxHint;
227
224
  RightSiblingLabel.Caption:=lisSibling;
228
225
 
230
227
  TopAnchoredCheckBox.Hint:=Format(AnchorEnabledHint,['akTop']);
231
228
  TopBorderSpaceSpinEdit.Hint:=lisTopBorderSpaceSpinEditHint;
232
229
  TopGroupBox.Caption:=lisTopAnchoring;
233
 
  TopRefBottomSpeedButton.Hint:=lisAnchorToBottomSideKeepBorderSpace;
 
230
  TopRefBottomSpeedButton.Hint:=lisAnchorTopToBottomSide;
234
231
  TopRefCenterSpeedButton.Hint:=lisCenterControlVerticallyRelativeToSibling;
235
 
  TopRefTopSpeedButton.Hint:= lisAnchorToTopSideKeepBorderSpace;
 
232
  TopRefTopSpeedButton.Hint:= lisAnchorTopToTopSide;
236
233
  TopSiblingComboBox.Hint:=lisTopSiblingComboBoxHint;
237
234
  TopSiblingLabel.Caption:=lisSibling;
238
235
 
318
315
        ReferenceControl,ReferenceSide,CheckPosition))
319
316
      then begin
320
317
        if MessageDlg(lisCCOWarningCaption,
321
 
          lisThisWillCreateACircle, mtWarning, [mbIgnore, mbCancel], 0)<>
 
318
          lisThisWillCreateACircularDependency, mtWarning, [mbIgnore, mbCancel], 0)<>
322
319
            mrIgnore
323
320
        then begin
324
321
          Refresh(false);
390
387
  end;
391
388
end;
392
389
 
 
390
procedure TAnchorDesigner.FormDeactivate(Sender: TObject);
 
391
begin
 
392
  // commit changes made by keyboard
 
393
  if (ActiveControl is TComboBox) then
 
394
    SiblingComboBoxChange(ActiveControl);
 
395
end;
 
396
 
393
397
function compareControlTop(Item1, Item2: pointer): Integer;
394
398
begin
395
399
  if tcontrol(item1).top<tcontrol(item2).top then result:=-1
538
542
        ReferenceControl,ReferenceSide,CheckPosition))
539
543
      then begin
540
544
        if MessageDlg(lisCCOWarningCaption,
541
 
          lisThisWillCreateACircle, mtWarning, [mbIgnore, mbCancel], 0)<>
 
545
          lisThisWillCreateACircularDependency, mtWarning, [mbIgnore, mbCancel], 0)<>
542
546
            mrIgnore
543
547
        then begin
544
548
          Refresh(false);
649
653
        ReferenceControl,ReferenceSide,CheckPosition))
650
654
      then begin
651
655
        if MessageDlg(lisCCOWarningCaption,
652
 
          lisThisWillCreateACircle, mtWarning, [mbIgnore, mbCancel], 0)<>
 
656
          lisThisWillCreateACircularDependency, mtWarning, [mbIgnore, mbCancel], 0)<>
653
657
            mrIgnore
654
658
        then begin
655
659
          Refresh(false);
724
728
      end;
725
729
    end;
726
730
  end;
727
 
  sl.Sort;
728
731
  if HasSelectedSiblings then
729
732
    for Kind:=akTop to akBottom do
730
733
      sl.add(AnchorDesignerNeighbourText(Kind));
740
743
  Result:='(nil)';
741
744
end;
742
745
 
743
 
function TAnchorDesigner.AnchorDesignerNeighbourText(direction: TAnchorKind
744
 
  ): string;
 
746
function TAnchorDesigner.AnchorDesignerNeighbourText(direction: TAnchorKind): string;
745
747
begin
746
748
  //todo: add translations
747
749
  case direction of
767
769
begin
768
770
  //debugln('TAnchorDesigner.Refresh A ');
769
771
  if not Force then begin
770
 
    // check if uddate is needed
 
772
    // check if update is needed
771
773
    if not IsVisible then exit;
772
774
  end;
773
775
  if FUpdating then exit;
1053
1055
  CurSide: TAnchorSide;
1054
1056
begin
1055
1057
  FAmbiguousBorderSpace:=false;
1056
 
  FBorderSpace:=AControl.BorderSpacing.GetSideSpace(FAnchorKind);
 
1058
  FBorderSpace:=AControl.BorderSpacing.GetSpace(FAnchorKind);
1057
1059
  FAmbiguousEnabled:=false;
1058
1060
  FEnabled:=(FAnchorKind in AControl.Anchors);
1059
1061
  CurSide:=AControl.AnchorSide[FAnchorKind];
1068
1070
  CurSide: TAnchorSide;
1069
1071
begin
1070
1072
  FAmbiguousBorderSpace:=FAmbiguousBorderSpace
1071
 
            or (FBorderSpace<>AControl.BorderSpacing.GetSideSpace(FAnchorKind));
 
1073
            or (FBorderSpace<>AControl.BorderSpacing.GetSpace(FAnchorKind));
1072
1074
  FAmbiguousEnabled:=FAmbiguousEnabled
1073
1075
                     or (FEnabled<>(FAnchorKind in AControl.Anchors));
1074
1076
  CurSide:=AControl.AnchorSide[FAnchorKind];