mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-28 09:20:46 +02:00
AJ: started GNOME interface & modified gtk interface so everything is public/protected
git-svn-id: trunk@1138 -
This commit is contained in:
parent
d4288a0cf3
commit
78b7453174
@ -53,7 +53,7 @@ uses
|
||||
|
||||
type
|
||||
TgtkObject = class(TInterfaceBase)
|
||||
private
|
||||
protected
|
||||
FKeyStateList: TList; // Keeps track of which keys are pressed
|
||||
FDeviceContexts: TDynHashArray;// hasharray of HDC
|
||||
FGDIObjects: TDynHashArray; // hasharray of PGdiObject
|
||||
@ -84,76 +84,76 @@ type
|
||||
|
||||
Function CreateSystemFont : hFont;
|
||||
|
||||
Procedure HookSignals(Sender : TObject); //hooks all signals for controls
|
||||
procedure CreateComponent(Sender : TObject);
|
||||
procedure DestroyLCLControl(Sender : TObject);
|
||||
procedure AddChild(Parent,Child : Pointer; Left,Top: Integer);
|
||||
procedure ResizeChild(Sender : TObject; Left,Top,Width,Height : Integer);
|
||||
procedure AssignSelf(Child ,Data : Pointer);
|
||||
procedure ReDraw(Child : Pointer);
|
||||
procedure SetClipboardWidget(TargetWidget: PGtkWidget);
|
||||
Procedure HookSignals(Sender : TObject); virtual; //hooks all signals for controls
|
||||
procedure CreateComponent(Sender : TObject);virtual;
|
||||
procedure DestroyLCLControl(Sender : TObject);virtual;
|
||||
procedure AddChild(Parent,Child : Pointer; Left,Top: Integer);virtual;
|
||||
procedure ResizeChild(Sender : TObject; Left,Top,Width,Height : Integer);virtual;
|
||||
procedure AssignSelf(Child ,Data : Pointer);virtual;
|
||||
procedure ReDraw(Child : Pointer);virtual;
|
||||
procedure SetClipboardWidget(TargetWidget: PGtkWidget);virtual;
|
||||
|
||||
// device contexts
|
||||
function IsValidDC(const DC: HDC): Boolean;
|
||||
function NewDC: TDeviceContext;
|
||||
procedure DisposeDC(aDC: TDeviceContext);
|
||||
function IsValidDC(const DC: HDC): Boolean;virtual;
|
||||
function NewDC: TDeviceContext;virtual;
|
||||
procedure DisposeDC(aDC: TDeviceContext);virtual;
|
||||
|
||||
// GDIObjects
|
||||
function IsValidGDIObject(const GDIObject: HGDIOBJ): Boolean;
|
||||
function IsValidGDIObject(const GDIObject: HGDIOBJ): Boolean;virtual;
|
||||
function IsValidGDIObjectType(const GDIObject: HGDIOBJ;
|
||||
const GDIType: TGDIType): Boolean;
|
||||
function NewGDIObject(const GDIType: TGDIType): PGdiObject;
|
||||
procedure DisposeGDIObject(GdiObject: PGdiObject);
|
||||
procedure SelectGDKBrushProps(DC: HDC);
|
||||
procedure SelectGDKTextProps(DC: HDC);
|
||||
procedure SelectGDKPenProps(DC: HDC);
|
||||
function CreateDefaultBrush: PGdiObject;
|
||||
function CreateDefaultFont: PGdiObject;
|
||||
function CreateDefaultPen: PGdiObject;
|
||||
const GDIType: TGDIType): Boolean;virtual;
|
||||
function NewGDIObject(const GDIType: TGDIType): PGdiObject;virtual;
|
||||
procedure DisposeGDIObject(GdiObject: PGdiObject);virtual;
|
||||
procedure SelectGDKBrushProps(DC: HDC);virtual;
|
||||
procedure SelectGDKTextProps(DC: HDC);virtual;
|
||||
procedure SelectGDKPenProps(DC: HDC);virtual;
|
||||
function CreateDefaultBrush: PGdiObject;virtual;
|
||||
function CreateDefaultFont: PGdiObject;virtual;
|
||||
function CreateDefaultPen: PGdiObject;virtual;
|
||||
|
||||
// images
|
||||
procedure LoadXPMFromLazResource(const ResourceName: string;
|
||||
Window: PGdkWindow; var PixmapImg, PixmapMask: PGdkPixmap);
|
||||
procedure LoadFromXPMFile(Bitmap: TObject; Filename: PChar);
|
||||
procedure LoadFromPixbufFile(Bitmap: TObject; Filename: PChar);
|
||||
procedure LoadFromPixbufData(Bitmap : hBitmap; Data : PByte);
|
||||
Window: PGdkWindow; var PixmapImg, PixmapMask: PGdkPixmap);virtual;
|
||||
procedure LoadFromXPMFile(Bitmap: TObject; Filename: PChar);virtual;
|
||||
procedure LoadFromPixbufFile(Bitmap: TObject; Filename: PChar);virtual;
|
||||
procedure LoadFromPixbufData(Bitmap : hBitmap; Data : PByte);virtual;
|
||||
function InternalGetDIBits(DC: HDC; Bitmap: HBitmap; StartScan, NumScans: UINT;
|
||||
BitSize : Longint; Bits: Pointer; var BitInfo: BitmapInfo; Usage: UINT; DIB : Boolean): Integer;
|
||||
BitSize : Longint; Bits: Pointer; var BitInfo: BitmapInfo; Usage: UINT; DIB : Boolean): Integer;virtual;
|
||||
|
||||
procedure SetRCFilename(const AValue: string);
|
||||
procedure ParseRCFile;
|
||||
procedure SetRCFilename(const AValue: string);virtual;
|
||||
procedure ParseRCFile;virtual;
|
||||
|
||||
procedure ShowHide(Sender : TObject);
|
||||
procedure ShowHide(Sender : TObject);virtual;
|
||||
procedure GetNoteBookCloseBtnPixmap(Window: PGdkWindow;
|
||||
var Img, Mask: PGdkPixmap);
|
||||
procedure AddDummyNoteBookPage(NoteBookWidget: PGtkNoteBook);
|
||||
procedure RemoveDummyNoteBookPage(NoteBookWidget: PGtkNotebook);
|
||||
procedure UpdateNotebookPageTab(ANoteBook, APage: TObject);
|
||||
procedure AddNBPage(ANoteBook, APage: TObject; Index: Integer);
|
||||
procedure RemoveNBPage(ANoteBook: TObject; Index: Integer);
|
||||
procedure MoveNBPage(ANoteBook, APage: TObject; NewIndex: Integer);
|
||||
var Img, Mask: PGdkPixmap);virtual;
|
||||
procedure AddDummyNoteBookPage(NoteBookWidget: PGtkNoteBook);virtual;
|
||||
procedure RemoveDummyNoteBookPage(NoteBookWidget: PGtkNotebook);virtual;
|
||||
procedure UpdateNotebookPageTab(ANoteBook, APage: TObject);virtual;
|
||||
procedure AddNBPage(ANoteBook, APage: TObject; Index: Integer);virtual;
|
||||
procedure RemoveNBPage(ANoteBook: TObject; Index: Integer);virtual;
|
||||
procedure MoveNBPage(ANoteBook, APage: TObject; NewIndex: Integer);virtual;
|
||||
|
||||
procedure SetText(Child,Data : Pointer);
|
||||
procedure SetColor(Sender : TObject);
|
||||
Procedure SetPixel(Sender : TObject; Data : Pointer);
|
||||
Procedure GetPixel(Sender : TObject; Data : Pointer);
|
||||
function GetValue(Sender : TObject; Data : pointer) : integer;
|
||||
function SetValue(Sender : TObject; Data : pointer) : integer;
|
||||
function SetProperties (Sender: TObject) : integer;
|
||||
procedure AttachMenu(Sender: TObject);
|
||||
procedure SetText(Child,Data : Pointer);virtual;
|
||||
procedure SetColor(Sender : TObject);virtual;
|
||||
Procedure SetPixel(Sender : TObject; Data : Pointer);virtual;
|
||||
Procedure GetPixel(Sender : TObject; Data : Pointer);virtual;
|
||||
function GetValue(Sender : TObject; Data : pointer) : integer;virtual;
|
||||
function SetValue(Sender : TObject; Data : pointer) : integer;virtual;
|
||||
function SetProperties (Sender: TObject) : integer;virtual;
|
||||
procedure AttachMenu(Sender: TObject);virtual;
|
||||
procedure SetColorDialogColor(ColorSelection: PGtkColorSelection;
|
||||
Color: TColor);
|
||||
Color: TColor);virtual;
|
||||
|
||||
function HashPaintMessage(p: pointer): integer;
|
||||
function FindPaintMessage(HandleWnd: HWnd): PLazQueueItem;
|
||||
function HashPaintMessage(p: pointer): integer;virtual;
|
||||
function FindPaintMessage(HandleWnd: HWnd): PLazQueueItem;virtual;
|
||||
|
||||
procedure SetResizeRequest(Widget: PGtkWidget);
|
||||
procedure UnsetResizeRequest(Widget: PGtkWidget);
|
||||
procedure SetResizeRequest(Widget: PGtkWidget);virtual;
|
||||
procedure UnsetResizeRequest(Widget: PGtkWidget);virtual;
|
||||
|
||||
procedure SetWindowSizeAndPosition(Window: PGtkWindow;
|
||||
AWinControl: TWinControl);
|
||||
function LCLtoGtkMessagePending: boolean;
|
||||
procedure SendCachedGtkMessages;
|
||||
AWinControl: TWinControl);virtual;
|
||||
function LCLtoGtkMessagePending: boolean;virtual;
|
||||
procedure SendCachedGtkMessages;virtual;
|
||||
procedure SetCallback(Msg : LongInt; Sender : TObject); override;
|
||||
procedure RemoveCallbacks(Sender : TObject); override;
|
||||
public
|
||||
@ -178,286 +178,15 @@ type
|
||||
|
||||
{$I gtklistslh.inc}
|
||||
|
||||
function GetDCOffset(DC: TDeviceContext): TPoint;
|
||||
function GetSysGCValues(Color : TColorRef) : TGDKGCValues;
|
||||
|
||||
implementation
|
||||
|
||||
uses
|
||||
Graphics, Buttons, Menus, GTKWinApiWindow, StdCtrls, ComCtrls, CListBox,
|
||||
KeyMap, Calendar, Arrow, Spin, CommCtrl, ExtCtrls, Dialogs, FileCtrl,
|
||||
LResources, Math;
|
||||
|
||||
|
||||
procedure RaiseException(const Msg: string); forward;
|
||||
function DeliverPostMessage(const Target: Pointer; var TheMessage): GBoolean; forward;
|
||||
function DeliverMessage(const Target: Pointer; var AMessage): Integer; forward;
|
||||
LResources, Math, gtkglobals, gtkproc;
|
||||
|
||||
{$I gtklistsl.inc}
|
||||
|
||||
|
||||
{const
|
||||
TARGET_ENTRYS = 3;
|
||||
}
|
||||
|
||||
var
|
||||
// target_table : array[0..TARGET_ENTRYS - 1] of TgtkTargetEntry;
|
||||
|
||||
//drag icons
|
||||
//TrashCan_Open : PgdkPixmap;
|
||||
//TrashCan_Open_Mask : PGdkPixmap;
|
||||
//TrashCan_Closed : PGdkPixmap;
|
||||
//TrashCan_Closed_Mask : PGdkPixmap;
|
||||
Drag_Icon : PgdkPixmap;
|
||||
Drag_Mask : PgdkPixmap;
|
||||
|
||||
//Dragging : Boolean;
|
||||
|
||||
MCaptureHandle: HWND;
|
||||
|
||||
const
|
||||
DblClickTime = 250;// 250 miliseconds or less between clicks is a double click
|
||||
DblClickThreshold = 3;// max Movement between two clicks of a DblClick
|
||||
|
||||
type
|
||||
TLastMouseClick = record
|
||||
Down: boolean;
|
||||
TheTime: TDateTime; // last Down time
|
||||
ClickCount: integer;
|
||||
Component: TComponent;
|
||||
Window: PGdkWindow;
|
||||
WindowPoint: TPoint;
|
||||
end;
|
||||
|
||||
const
|
||||
EmptyLastMouseClick: TLastMouseClick =
|
||||
(Down: false; TheTime: -1; ClickCount: 0; Component: nil;
|
||||
Window: nil; WindowPoint: (X: 0; Y: 0));
|
||||
|
||||
var
|
||||
LastLeft, LastMiddle, LastRight: TLastMouseClick;
|
||||
LastFileSelectRow : gint;
|
||||
|
||||
|
||||
// mouse cursors
|
||||
Cursor_Watch : pGDKCursor;
|
||||
Cursor_Arrow : pGDKCursor;
|
||||
Cursor_Cross : pGDKCursor;
|
||||
Cursor_Hand1 : pGDKCursor;
|
||||
Cursor_XTerm : pGDKCursor;
|
||||
Cursor_StdArrow : pGDKCursor;
|
||||
Cursor_HSplit : pGDKCursor;
|
||||
Cursor_VSplit : pGDKCursor;
|
||||
Cursor_SizeNWSE : pGDKCursor;
|
||||
Cursor_SizeNS : pGDKCursor;
|
||||
Cursor_SizeNESW : pGDKCursor;
|
||||
Cursor_SizeWE : pGDKCursor;
|
||||
Cursor_SizeAll : pGDKCursor;
|
||||
Cursor_Help : pGDKCursor;
|
||||
|
||||
Styles : TStrings;
|
||||
|
||||
const
|
||||
KEYMAP_VKUNKNOWN = $10000;
|
||||
KEYMAP_TOGGLE = $20000;
|
||||
KEYMAP_EXTENDED = $40000;
|
||||
|
||||
// PDB: note this is a hack. Windows maintains a system wide
|
||||
// system color table we will have to have our own
|
||||
// to be able to do the translations required from
|
||||
// window manager to window manager this means every
|
||||
// application will carry its own color table
|
||||
// we set the defaults here to reduce the initial
|
||||
// processing of creating a default table
|
||||
// MWE: Naaaaah, not a hack, just something temporary
|
||||
const
|
||||
SysColorMap: array [0..MAX_SYS_COLORS] of DWORD = (
|
||||
$C0C0C0, {COLOR_SCROLLBAR}
|
||||
$808000, {COLOR_BACKGROUND}
|
||||
$800000, {COLOR_ACTIVECAPTION}
|
||||
$808080, {COLOR_INACTIVECAPTION}
|
||||
$C0C0C0, {COLOR_MENU}
|
||||
$FFFFFF, {COLOR_WINDOW}
|
||||
$000000, {COLOR_WINDOWFRAME}
|
||||
$000000, {COLOR_MENUTEXT}
|
||||
$000000, {COLOR_WINDOWTEXT}
|
||||
$FFFFFF, {COLOR_CAPTIONTEXT}
|
||||
$C0C0C0, {COLOR_ACTIVEBORDER}
|
||||
$C0C0C0, {COLOR_INACTIVEBORDER}
|
||||
$808080, {COLOR_APPWORKSPACE}
|
||||
$800000, {COLOR_HIGHLIGHT}
|
||||
$FFFFFF, {COLOR_HIGHLIGHTTEXT}
|
||||
$D0D0D0, {COLOR_BTNFACE}
|
||||
$808080, {COLOR_BTNSHADOW}
|
||||
$808080, {COLOR_GRAYTEXT}
|
||||
$000000, {COLOR_BTNTEXT}
|
||||
$C0C0C0, {COLOR_INACTIVECAPTIONTEXT}
|
||||
$F0F0F0, {COLOR_BTNHIGHLIGHT}
|
||||
$000000, {COLOR_3DDKSHADOW}
|
||||
$C0C0C0, {COLOR_3DLIGHT}
|
||||
$000000, {COLOR_INFOTEXT}
|
||||
$E1FFFF, {COLOR_INFOBK}
|
||||
$000000, {unasigned}
|
||||
$000000, {COLOR_HOTLIGHT}
|
||||
$000000, {COLOR_GRADIENTACTIVECAPTION}
|
||||
$000000 {COLOR_GRADIENTINACTIVECAPTION}
|
||||
); {end _SysColors}
|
||||
|
||||
const
|
||||
FormStyleMap : array[TFormBorderStyle] of integer = (
|
||||
GTK_WINDOW_DIALOG, // bsNone
|
||||
GTK_WINDOW_TOPLEVEL,// bsSingle
|
||||
GTK_WINDOW_TOPLEVEL,// bsSizeable
|
||||
GTK_WINDOW_DIALOG, // bsDialog
|
||||
GTK_WINDOW_DIALOG, // bsToolWindow
|
||||
GTK_WINDOW_DIALOG // bsSizeToolWin
|
||||
);
|
||||
FormResizableMap : array[TFormBorderStyle] of gint = (
|
||||
0, // bsNone
|
||||
1, // bsSingle
|
||||
1, // bsSizeable
|
||||
0, // bsDialog
|
||||
0, // bsToolWindow
|
||||
1 // bsSizeToolWin
|
||||
);
|
||||
//unused: FormBorderWidth : array[TFormBorderStyle] of gint = (0, 1, 2, 1, 1, 2);
|
||||
|
||||
type
|
||||
|
||||
//Defined in gtksignal.c
|
||||
PGtkHandler = ^TGtkHandler;
|
||||
TGtkHandler = record
|
||||
id: guint;
|
||||
next: PGtkHandler;
|
||||
prev: PGtkHandler;
|
||||
flags: guint; // --> blocked : 20 bits,
|
||||
// object_signal : 1 bit,
|
||||
// after : 1 bit,
|
||||
// no_marshal : 1 bit
|
||||
ref_count: guint16;
|
||||
signal_id: guint16;
|
||||
func: TGtkSignalFunc;
|
||||
func_data: gpointer;
|
||||
destroy_func: TGtkSignalDestroy;
|
||||
end;
|
||||
|
||||
const
|
||||
bmSignalAfter = $00200000;
|
||||
|
||||
type
|
||||
{ lazarus GtkInterface definition for additional timer data, not in gtk }
|
||||
PGtkITimerInfo = ^TGtkITimerinfo;
|
||||
TGtkITimerInfo = record
|
||||
Handle : hWND;
|
||||
IDEvent : Cardinal;
|
||||
TimerFunc: TFNTimerProc;
|
||||
end;
|
||||
|
||||
|
||||
var
|
||||
gtk_handler_quark: TGQuark;
|
||||
FOldTimerData: TList; // list of PGtkITimerinfo
|
||||
|
||||
|
||||
// Internal Paint message:
|
||||
const
|
||||
LM_GTKPaint = LM_INTERFACEFIRST;
|
||||
|
||||
type
|
||||
TLMGtkPaint = packed record
|
||||
Msg: Cardinal;
|
||||
Widget: PGtkWidget;
|
||||
Unused1: integer;
|
||||
Unused2: integer;
|
||||
end;
|
||||
|
||||
|
||||
const
|
||||
TARGET_STRING = 1;
|
||||
TARGET_ROOTWIN = 2;
|
||||
|
||||
{off $DEFINE DEBUG_CLIPBOARD}
|
||||
var
|
||||
// All clipboard events are handled by only one widget - the ClipboardWidget
|
||||
// This widget is typically the main form
|
||||
ClipboardWidget: PGtkWidget;
|
||||
// each selection has an gtk identifier (an atom)
|
||||
ClipboardTypeAtoms: array[TClipboardType] of cardinal;
|
||||
// each active request will procduce an TClipboardEventData stored in this list
|
||||
ClipboardSelectionData: TList; // list of PClipboardEventData
|
||||
// each selection can have an user defined handler (normally set by the lcl)
|
||||
ClipboardHandler: array[TClipboardType] of TClipboardRequestEvent;
|
||||
// boolean array, telling what gtk format is automatically supported by
|
||||
// gtk interface and not by the program (the lcl)
|
||||
ClipboardExtraGtkFormats: array[TClipboardType,TGtkClipboardFormat] of boolean;
|
||||
// lists of supported targets
|
||||
ClipboardTargetEntries: array[TClipboardType] of PGtkTargetEntry;
|
||||
ClipboardTargetEntryCnt: array[TClipboardType] of integer;
|
||||
|
||||
// each main widget that was resized by the gtk is stored here
|
||||
// (hasharray of PGtkWidget)
|
||||
FWidgetsResized: TDynHashArray;
|
||||
// each fixed widget that was resized by the gtk is stored here
|
||||
// (hasharray of PGtkWidget)
|
||||
FFixWidgetsResized: TDynHashArray;
|
||||
|
||||
const
|
||||
aGtkJustification: array[TAlignment] of TGTKJustification =
|
||||
(GTK_JUSTIFY_LEFT,GTK_JUSTIFY_RIGHT,GTK_JUSTIFY_CENTER);
|
||||
|
||||
aGtkSelectionMode: Array[Boolean] of TGtkSelectionMode =
|
||||
(GTK_SELECTION_SINGLE,GTk_SELECTION_EXTENDED);
|
||||
|
||||
{ file dialog }
|
||||
|
||||
type
|
||||
PFileSelHistoryEntry = ^TFileSelHistoryEntry;
|
||||
TFileSelHistoryEntry = record
|
||||
Filename: PChar;
|
||||
MenuItem: PGtkWidget;
|
||||
end;
|
||||
|
||||
PFileSelFilterEntry = ^TFileSelFilterEntry;
|
||||
TFileSelFilterEntry = record
|
||||
Description: PChar;
|
||||
Mask: PChar;
|
||||
FilterIndex: integer;
|
||||
MenuItem: PGtkWidget;
|
||||
end;
|
||||
|
||||
{ Menu }
|
||||
|
||||
type
|
||||
TCheckMenuItemDrawProc =
|
||||
procedure (check_menu_item:PGtkCheckMenuItem; area:PGdkRectangle); cdecl;
|
||||
|
||||
TMenuSizeRequestProc =
|
||||
procedure (widget:PGtkWidget; requisition:PGtkRequisition); cdecl;
|
||||
|
||||
const
|
||||
OldCheckMenuItemDrawProc: TCheckMenuItemDrawProc = nil;
|
||||
OldMenuSizeRequestProc: TMenuSizeRequestProc = nil;
|
||||
OldCheckMenuItemToggleSize: integer = 0;
|
||||
|
||||
|
||||
// some callbacks
|
||||
function gtkRealizeCB(Widget: PGtkWidget; Data: Pointer): GBoolean; cdecl; forward;
|
||||
function gtkRealizeAfterCB(Widget: PGtkWidget; Data: Pointer): GBoolean; cdecl; forward;
|
||||
function gtkMouseBtnPress(widget: PGtkWidget; event : pgdkEventButton;
|
||||
data: gPointer) : GBoolean; forward; cdecl;
|
||||
function gtkMotionNotify(Widget:PGTKWidget; event: PGDKEventMotion;
|
||||
data: gPointer): GBoolean; forward; cdecl;
|
||||
function gtkMouseBtnRelease(widget: PGtkWidget; event : pgdkEventButton;
|
||||
data: gPointer) : GBoolean; forward; cdecl;
|
||||
function gtkDrawAfter(Widget: PGtkWidget; area: PGDKRectangle;
|
||||
data: gPointer) : GBoolean; forward; cdecl;
|
||||
function gtkExposeEventAfter(Widget: PGtkWidget; Event : PGDKEventExpose;
|
||||
Data: gPointer): GBoolean; forward; cdecl;
|
||||
|
||||
|
||||
{$I dragicons.inc}
|
||||
{$I gtkproc.inc}
|
||||
{$I gtkcallback.inc}
|
||||
{$I gtkobject.inc}
|
||||
{$I gtkwinapi.inc}
|
||||
|
||||
@ -525,6 +254,9 @@ end.
|
||||
{ =============================================================================
|
||||
|
||||
$Log$
|
||||
Revision 1.84 2002/10/08 23:44:00 lazarus
|
||||
AJ: started GNOME interface & modified gtk interface so everything is public/protected
|
||||
|
||||
Revision 1.83 2002/10/08 13:42:23 lazarus
|
||||
MG: added TDevContextColorType
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user