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

« back to all changes in this revision

Viewing changes to lcl/include/dbcheckbox.inc

  • 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:
53
53
  FDataLink.ReadOnly:=AValue;
54
54
end;
55
55
 
56
 
procedure TDBCheckBox.SetValueCheck(const AValue: string);
57
 
begin
58
 
  if FValueCheck=AValue then exit;
59
 
  FValueCheck:=AValue;
60
 
  DataChange(Self);
61
 
end;
62
 
 
63
 
procedure TDBCheckBox.SetValueUncheck(const AValue: string);
64
 
begin
65
 
  if FValueUncheck=AValue then exit;
66
 
  FValueUncheck:=AValue;
67
 
  DataChange(Self);
 
56
procedure TDBCheckBox.SetValueChecked(const AValue: string);
 
57
begin
 
58
  if FValueChecked=AValue then exit;
 
59
  FValueChecked:=AValue;
 
60
  DataChange(Self);
 
61
end;
 
62
 
 
63
procedure TDBCheckBox.SetValueUnchecked(const AValue: string);
 
64
begin
 
65
  if FValueUnchecked=AValue then exit;
 
66
  FValueUnchecked:=AValue;
 
67
  DataChange(Self);
 
68
end;
 
69
 
 
70
//check if Word is equal to S or is one of the ; delimitted words in s
 
71
//whitespace between Word and delimiter is ignored (Delphi behavior)
 
72
function FindWord(const Word, S: String): Boolean;
 
73
var
 
74
  I, J, L: Integer;
 
75
  C: Char;
 
76
begin
 
77
  I := Pos(Word, S);
 
78
  Result := I > 0;
 
79
  if Result then
 
80
  begin
 
81
    //forward
 
82
    J := I + Length(Word);
 
83
    L := Length(S);
 
84
    while Result and (J < L) do
 
85
    begin
 
86
      C := S[J];
 
87
      if C = ';' then
 
88
        Break;
 
89
      Result := C = ' ';
 
90
      Inc(J);
 
91
    end;
 
92
    //backward
 
93
    Dec(I);
 
94
    while Result and (I > 0) do
 
95
    begin
 
96
      C := S[I];
 
97
      if C = ';' then
 
98
        Break;
 
99
      Result := C = ' ';
 
100
      Dec(I);
 
101
    end;
 
102
  end;
68
103
end;
69
104
 
70
105
function TDBCheckBox.GetFieldCheckState: TCheckBoxState;
71
106
var
72
107
  FieldText: string;
 
108
  DataLinkField: TField;
73
109
begin
74
 
  if FDatalink.Field=nil then begin
 
110
  DataLinkField := FDataLink.Field;
 
111
  if DatalinkField=nil then begin
75
112
    Result:=cbUnchecked;
76
113
    exit;
77
114
  end;
78
 
  if FDataLink.Field.IsNull then
 
115
  if DataLinkField.IsNull then
79
116
    Result:=cbGrayed
80
 
  else if FDataLink.Field.DataType = ftBoolean then begin
81
 
    if FDataLink.Field.AsBoolean then
 
117
  else if DataLinkField.DataType = ftBoolean then begin
 
118
    if DataLinkField.AsBoolean then
82
119
      Result:=cbChecked
83
120
    else
84
121
      Result:=cbUnchecked;
85
122
  end else begin
86
 
    Result:=cbGrayed;
87
 
    FieldText:=FDatalink.Field.AsString;
88
 
    if AnsiSameText(FValueCheck,FieldText) then
 
123
    FieldText:=UpperCase(DatalinkField.AsString);
 
124
    if FindWord(FieldText,UpperCase(FValueChecked)) then
89
125
      Result:=cbChecked
90
 
    else if AnsiSameText(FValueUncheck,FieldText) then
91
 
      Result:=cbUnchecked;
 
126
    else if FindWord(FieldText,UpperCase(FValueUnchecked)) then
 
127
      Result:=cbUnchecked
 
128
    else
 
129
      Result:=cbGrayed;
92
130
  end;
93
131
end;
94
132
 
97
135
  State:=GetFieldCheckState;
98
136
end;
99
137
 
 
138
procedure TDBCheckBox.DoOnChange;
 
139
begin
 
140
  //avoid reseting value when state changes
 
141
  FDataLink.OnDataChange := nil;
 
142
  if FDatalink.Edit then begin
 
143
    FDatalink.Modified;
 
144
    FDataLink.UpdateRecord;
 
145
  end else
 
146
    State:=GetFieldCheckState;
 
147
  FDataLink.OnDataChange := @DataChange;
 
148
  inherited DoOnChange;
 
149
end;
 
150
 
100
151
procedure TDBCheckBox.UpdateData(Sender: TObject);
101
152
var
102
153
  NewFieldText: string;
108
159
      FDataLink.Field.AsBoolean:=Checked
109
160
    else begin
110
161
      if Checked then
111
 
        NewFieldText:=FValueCheck
 
162
        NewFieldText:=FValueChecked
112
163
      else
113
 
        NewFieldText:=FValueUncheck;
 
164
        NewFieldText:=FValueUnchecked;
114
165
      // ToDo: use Field.Text
115
166
      FDataLink.Field.AsString:=Trim(NewFieldText);
116
167
    end;
117
168
end;
118
169
 
119
 
procedure TDBCheckBox.FocusRequest(Sender: TObject);
120
 
begin
121
 
  //the FieldLink has requested the control
122
 
  //recieve focus for some reason..
123
 
  //perhaps an error occured?
124
 
  SetFocus;
125
 
end;
126
 
 
127
 
procedure TDBCheckBox.Notification(AComponent: TComponent; Operation: TOperation
128
 
  );
 
170
procedure TDBCheckBox.Notification(AComponent: TComponent; Operation: TOperation);
129
171
begin
130
172
  inherited Notification(AComponent, Operation);
131
173
  if (Operation=opRemove) then begin
134
176
  end;
135
177
end;
136
178
 
137
 
procedure TDBCheckBox.Loaded;
138
 
begin
139
 
  inherited Loaded;
140
 
  if (csDesigning in ComponentState) then
141
 
    DataChange(Self);
142
 
end;
143
 
 
144
 
procedure TDBCheckBox.EditingDone;
145
 
begin
146
 
  if FDatalink.Edit then begin
147
 
    FDatalink.Modified;
148
 
    FDataLink.UpdateRecord;
149
 
  end else
150
 
    State:=GetFieldCheckState;
151
 
  inherited EditingDone;
152
 
end;
153
 
 
154
179
procedure TDBCheckBox.CMGetDataLink(var Message: TLMessage);
155
180
begin
156
181
  Message.Result := PtrUInt(FDataLink);
159
184
constructor TDBCheckBox.Create(TheOwner: TComponent);
160
185
begin
161
186
  inherited Create(TheOwner);
162
 
  FValueCheck:='True';
163
 
  FValueUncheck:='False';
 
187
  FValueChecked:='True';
 
188
  FValueUnchecked:='False';
164
189
 
165
190
  ControlStyle:=ControlStyle+[csReplicatable];
166
191
  State:=cbUnchecked;