You've already forked lazarus-ccr
108 lines
3.9 KiB
ObjectPascal
108 lines
3.9 KiB
ObjectPascal
![]() |
{
|
||
|
gtk2richmemo.pas
|
||
|
|
||
|
Author: Dmitry 'skalogryz' Boyarintsev
|
||
|
|
||
|
*****************************************************************************
|
||
|
* *
|
||
|
* This file is part of the Lazarus Component Library (LCL) *
|
||
|
* *
|
||
|
* See the file COPYING.modifiedLGPL.txt, included in this distribution, *
|
||
|
* for details about the copyright. *
|
||
|
* *
|
||
|
* This program is distributed in the hope that it will be useful, *
|
||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
|
||
|
* *
|
||
|
*****************************************************************************
|
||
|
}
|
||
|
|
||
|
unit Gtk2RichMemo;
|
||
|
|
||
|
{$mode objfpc}{$H+}
|
||
|
|
||
|
interface
|
||
|
|
||
|
uses
|
||
|
// Bindings
|
||
|
gtk2,
|
||
|
// FCL
|
||
|
Classes, SysUtils,
|
||
|
// LCL
|
||
|
LCLType, Controls,
|
||
|
// Gtk2 widget
|
||
|
GtkDef,
|
||
|
GTKWinApiWindow, GtkGlobals, GtkProc, InterfaceBase,
|
||
|
GtkWSControls,
|
||
|
// RichMemo
|
||
|
WSRichMemo;
|
||
|
|
||
|
{ TGtk2WSCustomRichMemo }
|
||
|
type
|
||
|
TGtk2WSCustomRichMemo = class(TWSCustomRichMemo)
|
||
|
protected
|
||
|
class procedure SetCallbacks(const AGtkWidget: PGtkWidget; const AWidgetInfo: PWidgetInfo);
|
||
|
published
|
||
|
class function CreateHandle(const AWinControl: TWinControl; const AParams: TCreateParams): TLCLIntfHandle; override;
|
||
|
end;
|
||
|
|
||
|
implementation
|
||
|
|
||
|
class procedure TGtk2WSCustomRichMemo.SetCallbacks(
|
||
|
const AGtkWidget: PGtkWidget; const AWidgetInfo: PWidgetInfo);
|
||
|
begin
|
||
|
TGtkWSWinControl.SetCallbacks(PGtkObject(AGtkWidget), TComponent(AWidgetInfo^.LCLObject));
|
||
|
end;
|
||
|
|
||
|
class function TGtk2WSCustomRichMemo.CreateHandle(const AWinControl: TWinControl; const AParams: TCreateParams): TLCLIntfHandle;
|
||
|
var
|
||
|
Widget,
|
||
|
TempWidget: PGtkWidget;
|
||
|
WidgetInfo: PWidgetInfo;
|
||
|
begin
|
||
|
Widget := gtk_scrolled_window_new(nil, nil);
|
||
|
Result := TLCLIntfHandle(PtrUInt(Widget));
|
||
|
if Result = 0 then Exit;
|
||
|
{$IFDEF DebugLCLComponents}
|
||
|
DebugGtkWidgets.MarkCreated(Widget,dbgsName(AWinControl));
|
||
|
{$ENDIF}
|
||
|
|
||
|
WidgetInfo := CreateWidgetInfo(Pointer(Result), AWinControl, AParams);
|
||
|
|
||
|
TempWidget := gtk_text_view_new();
|
||
|
gtk_container_add(PGtkContainer(Widget), TempWidget);
|
||
|
|
||
|
GTK_WIDGET_UNSET_FLAGS(PGtkScrolledWindow(Widget)^.hscrollbar, GTK_CAN_FOCUS);
|
||
|
GTK_WIDGET_UNSET_FLAGS(PGtkScrolledWindow(Widget)^.vscrollbar, GTK_CAN_FOCUS);
|
||
|
gtk_scrolled_window_set_policy(PGtkScrolledWindow(Widget),
|
||
|
GTK_POLICY_AUTOMATIC,
|
||
|
GTK_POLICY_AUTOMATIC);
|
||
|
// add border for memo
|
||
|
gtk_scrolled_window_set_shadow_type(PGtkScrolledWindow(Widget),
|
||
|
BorderStyleShadowMap[TCustomControl(AWinControl).BorderStyle]);
|
||
|
|
||
|
SetMainWidget(Widget, TempWidget);
|
||
|
GetWidgetInfo(Widget, True)^.CoreWidget := TempWidget;
|
||
|
|
||
|
// gtk_text_buffer_set_text(gtk_text_view_get_buffer(PGtkTextView(TempWidget)), PChar(TCustomMemo(AWinControl).Text), -1);
|
||
|
gtk_text_view_set_editable(PGtkTextView(TempWidget), True);
|
||
|
{ //gtk_text_view_set_editable(PGtkTextView(TempWidget), not TCustomMemo(AWinControl).ReadOnly);
|
||
|
//gtk_text_view_set_justification(PGtkTextView(TempWidget), aGtkJustification[TCustomMemo(AWinControl).Alignment]);
|
||
|
if TCustomMemo(AWinControl).WordWrap then
|
||
|
gtk_text_view_set_wrap_mode(PGtkTextView(TempWidget), GTK_WRAP_WORD)
|
||
|
else
|
||
|
gtk_text_view_set_wrap_mode(PGtkTextView(TempWidget), GTK_WRAP_NONE);}
|
||
|
gtk_text_view_set_wrap_mode(PGtkTextView(TempWidget), GTK_WRAP_WORD);
|
||
|
|
||
|
//gtk_text_view_set_accepts_tab(PGtkTextView(TempWidget), TCustomMemo(AWinControl).WantTabs);
|
||
|
gtk_text_view_set_accepts_tab(PGtkTextView(TempWidget), True);
|
||
|
|
||
|
gtk_widget_show_all(Widget);
|
||
|
|
||
|
Set_RC_Name(AWinControl, Widget);
|
||
|
SetCallbacks(Widget, WidgetInfo);
|
||
|
end;
|
||
|
|
||
|
end.
|
||
|
|