summaryrefslogtreecommitdiff
path: root/packages/extra/ptc/x11/x11displayd.inc
blob: 9848461d1a760e3b6dceac36007ba3f65d7766a3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
Type
  TX11FlagsEnum = (PTC_X11_FULLSCREEN,
                   PTC_X11_LEAVE_DISPLAY,
                   PTC_X11_LEAVE_WINDOW,
                   PTC_X11_TRY_DGA,
                   PTC_X11_TRY_XF86VIDMODE,
                   PTC_X11_TRY_XRANDR,
                   PTC_X11_TRY_XSHM,
                   PTC_X11_DITHER,
                   PTC_X11_FULLSCREEN_CURSOR_VISIBLE,
                   PTC_X11_WINDOWED_CURSOR_INVISIBLE);
  TX11Flags = Set Of TX11FlagsEnum;

Type
  TX11Display = Class(TObject)
  Protected
    Function NextEvent(Var AEvent : TPTCEvent; AWait : Boolean; Const AEventMask : TPTCEventMask) : Boolean; Virtual; Abstract;
    Function PeekEvent(AWait : Boolean; Const AEventMask : TPTCEventMask) : TPTCEvent; Virtual; Abstract;

    Function GetX11Format(Const AFormat : TPTCFormat) : TPTCFormat;

    { initialise the keyboard mapping table }
    Procedure SetKeyMapping;

    { Data access }
    Function GetWidth : Integer;
    Function GetHeight : Integer;
    Function GetPitch : Integer; Virtual; Abstract;
    Function GetFormat : TPTCFormat;
    Function GetArea : TPTCArea;

    { Conversion object }
    FCopy : TPTCCopy;
    FClear : TPTCClear;
    FPalette : TPTCPalette;

    FArea : TPTCArea;
    FClip : TPTCArea;

    FEventQueue : TEventQueue;

    FFlags : TX11Flags;
    FWidth, FHeight : DWord;
    FFormat : TPTCFormat;

    FDisplay : PDisplay;
    FScreen : Integer;

    FCMap : TColormap;
    FColours : PXColor;

    FFunctionKeys : PInteger;
    FNormalKeys : PInteger;

    {m_thread : pthread_t;}
  Public
    Constructor Create(ADisplay : PDisplay; AScreen : Integer; Const AFlags : TX11Flags); Virtual;
    Destructor Destroy; Override;

    Procedure Open(ATitle : String; AWidth, AHeight : Integer; Const AFormat : TPTCFormat); Virtual; Abstract;

    { This will always return a windowed console. The first version
      fills the whole window, the second one has a custom size }
    Procedure Open(AWindow : TWindow; Const AFormat : TPTCFormat); Virtual; Abstract;
    Procedure Open(AWindow : TWindow; Const AFormat : TPTCFormat; AX, AY, AWidth, AHeight : Integer); Virtual; Abstract;

    Procedure Close; Virtual; Abstract;

    Procedure Update; Virtual; Abstract;
    Procedure Update(Const AArea : TPTCArea); Virtual; Abstract;

    Function Lock : Pointer; Virtual; Abstract;
    Procedure Unlock; Virtual; Abstract;

    { load pixels to console }
    Procedure Load(Const APixels : Pointer; AWidth, AHeight, APitch : Integer;
                   Const AFormat : TPTCFormat; Const APalette : TPTCPalette); Virtual;
    Procedure Load(Const APixels : Pointer; AWidth, AHeight, APitch : Integer;
                   Const AFormat : TPTCFormat; Const APalette : TPTCPalette;
                   Const ASource, ADestination : TPTCArea); Virtual;

    { save console pixels }
    Procedure Save(APixels : Pointer; AWidth, AHeight, APitch : Integer;
                   Const AFormat : TPTCFormat; Const APalette : TPTCPalette); Virtual;
    Procedure Save(APixels : Pointer; AWidth, AHeight, APitch : Integer;
                   Const AFormat : TPTCFormat; Const APalette : TPTCPalette;
                   Const ASource, ADestination : TPTCArea); Virtual;

    { clear surface }
    Procedure Clear(Const AColor : TPTCColor); Virtual;
    Procedure Clear(Const AColor : TPTCColor; Const AArea : TPTCArea); Virtual;

    { Console palette }
    Procedure Palette(Const APalette : TPTCPalette); Virtual; Abstract;
    Function Palette : TPTCPalette; Virtual;

    { console clip area }
    Procedure Clip(Const AArea : TPTCArea);

    { cursor control }
    Procedure SetCursor(AVisible : Boolean); Virtual; Abstract;

    { Data access }
    Function Clip : TPTCArea;

    Function IsFullScreen : Boolean; Virtual; Abstract;

    { Set flags (only used internally now!) }
    Procedure SetFlags(AFlags : TX11Flags);

    Procedure GetModes(Var AModes : TPTCModeDynArray); Virtual; Abstract;

    { X11 helper functions for your enjoyment }

    { return the display we are using }
    Function GetX11Display : PDisplay;

    { return the screen we are using }
    Function GetX11Screen : Integer;

    { return our window (0 if DGA) }
    Function GetX11Window : TWindow; Virtual; Abstract;

    Property Width : Integer Read GetWidth;
    Property Height : Integer Read GetHeight;
    Property Pitch : Integer Read GetPitch;
    Property Area : TPTCArea Read GetArea;
    Property Format : TPTCFormat Read GetFormat;
  End;