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

« back to all changes in this revision

Viewing changes to lcl/interfaces/gtk2/gtk2wscustommemo.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:
2
2
 
3
3
{ Callbacks }
4
4
 
5
 
procedure Gtk2WS_MemoChanged(AGtkTextBuffer: PGtkTextBuffer; WidgetInfo: PWidgetInfo); cdecl;
 
5
procedure Gtk2WS_MemoChanged({%H-}AGtkTextBuffer: PGtkTextBuffer; WidgetInfo: PWidgetInfo); cdecl;
6
6
var
7
7
  Mess: TLMessage;
8
8
begin
98
98
  SignalConnect(AWidgetInfo^.CoreWidget, 'paste-clipboard', @Gtk2WS_MemoPasteFromClip, AWidgetInfo);
99
99
end;
100
100
 
101
 
function Gtk2TranslateScrollStyle(SS:TScrollStyle):TPoint;
102
 
begin
103
 
  case SS of
104
 
    ssAutoBoth: Result:=Point(GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
105
 
    ssAutoHorizontal: Result:=Point(GTK_POLICY_AUTOMATIC, GTK_POLICY_NEVER);
106
 
    ssAutoVertical: Result:=Point(GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
107
 
    ssBoth: Result:=Point(GTK_POLICY_ALWAYS, GTK_POLICY_ALWAYS);
108
 
    ssHorizontal: Result:=Point(GTK_POLICY_ALWAYS, GTK_POLICY_NEVER);
109
 
    ssNone: Result:=Point(GTK_POLICY_NEVER, GTK_POLICY_NEVER);
110
 
    ssVertical: Result:=Point(GTK_POLICY_NEVER, GTK_POLICY_ALWAYS);
111
 
  end;
112
 
end;
113
 
 
114
101
class function TGtk2WSCustomMemo.CreateHandle(const AWinControl: TWinControl;
115
102
  const AParams: TCreateParams): TLCLIntfHandle;
116
103
var
120
107
  SS:TPoint;
121
108
begin
122
109
  Widget := gtk_scrolled_window_new(nil, nil);
123
 
  Result := TLCLIntfHandle(PtrUInt(Widget));
 
110
  Result := TLCLIntfHandle({%H-}PtrUInt(Widget));
124
111
  if Result = 0 then Exit;
125
112
  {$IFDEF DebugLCLComponents}
126
113
  DebugGtkWidgets.MarkCreated(Widget,dbgsName(AWinControl));
127
114
  {$ENDIF}
128
115
 
129
 
  WidgetInfo := CreateWidgetInfo(Pointer(Result), AWinControl, AParams);
 
116
  WidgetInfo := CreateWidgetInfo({%H-}Pointer(Result), AWinControl, AParams);
130
117
 
131
118
  TempWidget := gtk_text_view_new();
132
119
  gtk_container_add(PGtkContainer(Widget), TempWidget);
165
152
var
166
153
TextView: PGtkTextView;
167
154
begin
168
 
  TextView := PGtkTextView(GetWidgetInfo(Pointer(ACustomMemo.Handle), False)^.CoreWidget);
 
155
  TextView := PGtkTextView(GetWidgetInfo({%H-}Pointer(ACustomMemo.Handle), False)^.CoreWidget);
169
156
  Result := TGtk2MemoStrings.Create(TextView, ACustomMemo);
170
157
end;
171
158
 
174
161
var
175
162
  TextView: PGtkTextView;
176
163
begin
177
 
  TextView := PGtkTextView(GetWidgetInfo(Pointer(ACustomEdit.Handle), False)^.CoreWidget);
 
164
  TextView := PGtkTextView(GetWidgetInfo({%H-}Pointer(ACustomEdit.Handle), False)^.CoreWidget);
178
165
  gtk_text_view_set_justification(TextView, aGtkJustification[AAlignment]);
179
166
end;
180
167
 
185
172
begin
186
173
  if not WSCheckHandleAllocated(AWinControl, 'SetColor') then
187
174
    Exit;
188
 
  AWidget := PGtkWidget(AWinControl.Handle);
 
175
  AWidget := {%H-}PGtkWidget(AWinControl.Handle);
189
176
  AWidget := GetWidgetInfo(AWidget, True)^.CoreWidget;
190
177
  Gtk2WidgetSet.SetWidgetColor(AWidget,
191
178
    AWinControl.Font.Color,
201
188
  if not WSCheckHandleAllocated(AWinControl, 'SetFont') then
202
189
    Exit;
203
190
 
204
 
  AWidget:= PGtkWidget(AWinControl.Handle);
 
191
  AWidget:= {%H-}PGtkWidget(AWinControl.Handle);
205
192
  AWidget:= GetWidgetInfo(AWidget)^.CoreWidget;
206
193
 
207
194
  if AWidget <> nil then
245
232
  if not WSCheckHandleAllocated(ACustomMemo, 'SetWantTabs') then
246
233
    Exit;
247
234
 
248
 
  TextView := PGtkTextView(GetWidgetInfo(Pointer(ACustomMemo.Handle), False)^.CoreWidget);
 
235
  TextView := PGtkTextView(GetWidgetInfo({%H-}Pointer(ACustomMemo.Handle), False)^.CoreWidget);
249
236
  gtk_text_view_set_accepts_tab(TextView, NewWantTabs);
250
237
end;
251
238
 
268
255
begin
269
256
  if not WSCheckHandleAllocated(ACustomMemo, 'SetWordWrap') then
270
257
    Exit;
271
 
  TextView := PGtkTextView(GetWidgetInfo(Pointer(ACustomMemo.Handle), False)^.CoreWidget);
 
258
  TextView := PGtkTextView(GetWidgetInfo({%H-}Pointer(ACustomMemo.Handle), False)^.CoreWidget);
272
259
  if NewWordWrap then
273
260
    gtk_text_view_set_wrap_mode(PGtkTextView(TextView), GTK_WRAP_WORD)
274
261
  else
278
265
class procedure TGtk2WSCustomMemo.SetCharCase(const ACustomEdit: TCustomEdit;
279
266
  NewCase: TEditCharCase);
280
267
begin
281
 
  // TODO: implement me!
 
268
  // TODO: TGtk2WSCustomMemo.SetCharCase: implement me!
282
269
end;
283
270
 
284
271
class procedure TGtk2WSCustomMemo.SetScrollbars(const ACustomMemo: TCustomMemo;
285
272
  const NewScrollbars: TScrollStyle);
286
 
var SS:TPoint;
287
 
    ScrollWidget: PGtkScrolledWindow;
 
273
var
 
274
  SS:TPoint;
 
275
  ScrollWidget: PGtkScrolledWindow;
288
276
begin
289
277
  if not WSCheckHandleAllocated(ACustomMemo, 'SetScrollBars') then Exit;
290
278
  SS:=Gtk2TranslateScrollStyle(NewScrollBars);
291
 
  ScrollWidget:=PGtkScrolledWindow(ACustomMemo.Handle);
 
279
  ScrollWidget:={%H-}PGtkScrolledWindow(ACustomMemo.Handle);
292
280
  gtk_scrolled_window_set_policy(ScrollWidget ,SS.X, SS.Y);
293
281
end;
294
282
 
297
285
var
298
286
  Widget: PGtkWidget;
299
287
begin
300
 
  Widget:=PGtkWidget(ACustomEdit.Handle);
 
288
  Widget:={%H-}PGtkWidget(ACustomEdit.Handle);
301
289
  if GtkWidgetIsA(Widget, GTK_TYPE_ENTRY) then
302
290
    gtk_entry_set_max_length(GTK_ENTRY(Widget), guint16(NewLength));
303
291
end;
307
295
var
308
296
  TextView: PGtkTextView;
309
297
begin
310
 
 
311
298
  if not WSCheckHandleAllocated(ACustomEdit, 'SetReadOnly') then
312
299
    Exit;
313
300
 
314
 
  TextView := PGtkTextView(GetWidgetInfo(Pointer(ACustomEdit.Handle), False)^.CoreWidget);
 
301
  TextView := PGtkTextView(GetWidgetInfo({%H-}Pointer(ACustomEdit.Handle), False)^.CoreWidget);
315
302
  if TextView <> nil then
316
 
    gtk_text_view_set_editable(TextView, not ACustomEdit.ReadOnly);
 
303
    gtk_text_view_set_editable(TextView, not NewReadOnly);
317
304
end;
318
305
 
319
306
class procedure TGtk2WSCustomMemo.SetText(const AWinControl: TWinControl;
324
311
begin
325
312
  if not WSCheckHandleAllocated(AWinControl, 'SetText') then
326
313
    Exit;
327
 
  TextBuf := gtk_text_view_get_buffer(PGtkTextView(GetWidgetInfo(Pointer(AWinControl.Handle), True)^.CoreWidget));
 
314
  TextBuf := gtk_text_view_get_buffer(PGtkTextView(GetWidgetInfo({%H-}Pointer(AWinControl.Handle), True)^.CoreWidget));
328
315
  gtk_text_buffer_set_text(TextBuf, PChar(AText), -1);
329
316
  gtk_text_buffer_get_start_iter(TextBuf, @StartIter);
330
317
  gtk_text_buffer_place_cursor(TextBuf, @StartIter);
352
339
  if not WSCheckHandleAllocated(ACustomEdit, 'GetSelStart') then
353
340
    Exit;
354
341
 
355
 
  TextView := PGtkTextView(GetWidgetInfo(Pointer(ACustomEdit.Handle), False)^.CoreWidget);
 
342
  TextView := PGtkTextView(GetWidgetInfo({%H-}Pointer(ACustomEdit.Handle), False)^.CoreWidget);
356
343
  TextBuffer := gtk_text_view_get_buffer(TextView);
357
344
  TextMark := gtk_text_buffer_get_insert(TextBuffer);
358
345
  gtk_text_buffer_get_iter_at_mark(TextBuffer, @TextIter, TextMark);
385
372
  if Result = -1 then
386
373
  begin
387
374
    Result := 0;
388
 
    TextView := PGtkTextView(GetWidgetInfo(Pointer(ACustomEdit.Handle), False)^.CoreWidget);
 
375
    TextView := PGtkTextView(GetWidgetInfo({%H-}Pointer(ACustomEdit.Handle), False)^.CoreWidget);
389
376
    TextBuffer := gtk_text_view_get_buffer(TextView);
390
377
    if not gtk_text_buffer_get_selection_bounds(TextBuffer, @StartIter, @EndIter) then Exit;
391
378
 
403
390
  Result := Point(0, 0);
404
391
  if not WSCheckHandleAllocated(ACustomEdit, 'GetCaretPos') then
405
392
    Exit;
406
 
  TextView := PGtkTextView(GetWidgetInfo(Pointer(ACustomEdit.Handle), False)^.CoreWidget);
 
393
  TextView := PGtkTextView(GetWidgetInfo({%H-}Pointer(ACustomEdit.Handle), False)^.CoreWidget);
407
394
  TextBuffer := gtk_text_view_get_buffer(TextView);
408
395
  TextMark := gtk_text_buffer_get_insert(TextBuffer);
409
396
  gtk_text_buffer_get_iter_at_mark(TextBuffer, @TextIter, TextMark);
421
408
begin
422
409
  if not WSCheckHandleAllocated(ACustomEdit, 'SetCaretPos') then
423
410
    Exit;
424
 
  TextView := PGtkTextView(GetWidgetInfo(Pointer(ACustomEdit.Handle), False)^.CoreWidget);
 
411
  TextView := PGtkTextView(GetWidgetInfo({%H-}Pointer(ACustomEdit.Handle), False)^.CoreWidget);
425
412
  TextBuffer := gtk_text_view_get_buffer(TextView);
426
413
 
427
414
  if (NewPos.X < 0) or (NewPos.Y < 0)