summaryrefslogtreecommitdiff
path: root/fpcdocs/gtk4ex/fxbitmaps.pp
blob: ac0d6f69bee1456ec73a2d2169e7a79852ece0b8 (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
Unit fxbitmaps;

{$mode objfpc}

Interface

uses glib,gdk,gtk;

Const
  DeleteXpmHeight=16;
  DeleteXpmColors=2;
  DeleteXpmArraySize=DeleteXpmHeight+DeleteXpmColors+1;
  DeleteXpm : Array[1..DeleteXpmArraySize] of Pchar = (
    '16 16 2 1',        { 16x16 bitmap using 2 colors, 1 char per color}
    '. c #000000',      { First color: Black  }
    '# c None',         { Second color : Transparent}
    '################', { The bitmap }
    '################',
    '##...#########.#',
    '##....######..##',
    '###....####..###',
    '#####...##..####',
    '######.....#####',
    '#######...######',
    '######.....#####',
    '#####...##..####',
    '####...####..###',
    '###...######.###',
    '##....#######.##',
    '##...###########',
    '###.##########.#',
    '################'
    );

  PropertiesXpmHeight = 16;
  PropertiesXpmColors = 4;
  PropertiesXpmArraySize = PropertiesXpmHeight+PropertiesXpmColors+1;
  PropertiesXpm : Array [1..PropertiesXpmArraySize] of PChar = (
    '16 16 4 1',        { 16x16 bitmap using 2 colors, 1 char per color}
    '. c #000000',      { First color : Black }
    '# c #000080',      { Second color : Light Blue }
    'a c None',         { Third color : Transparent }
    'b c #f8fcf8',      { Last color : greyish }
    'aaaaaaaaaaaaaaaa',
    'aaaaaaa......a##',
    'aaaaaa.aaaaaa.##',
    'aaaaa.a.aaaaaa##',
    '.....a.a.aaaaa##',
    '.bb.a.a.a.aaa.##',
    '.b.a.b.a.a...a##',
    '.b..bbb.a.b.aaaa',
    '.bbbbbbb.bb.aaaa',
    '.bbbbbbbbbb.aaaa',
    '.b..b.....b.aaaa',
    '.bbbbbbbbbb.aaaa',
    '.b..b.....b.aaaa',
    '.bbbbbbbbbb.aaaa',
    '............aaaa',
    'aaaaaaaaaaaaaaaa'
);

function CreateWidgetFromXPM (Window : PGtkWidget; Data : PPChar) : PgtkWidget;

Implementation

function CreateWidgetFromXPM (Window : PGtkWidget; Data : PPChar) : PGtkWidget;

Var
  mask   : PGdkBitmap;
  pixmap : PGdkPixMap;

begin
  pixmap:=gdk_pixmap_create_from_xpm_d(window^.window,@mask,nil,ppgchar(Data));
  Result:=gtk_pixmap_new(Pixmap,Mask);
  gtk_widget_show(Result);
end;

end.