Debian Codegraph @

plugins/wlx/simplewlx/src/simplewlx.lpr

raw
1 library SimpleWlx;
2
3 {$mode objfpc}{$H+}
4 {$include calling.inc}
5
6 {$DEFINE GTK2}
7
8 uses
9 Classes,
10 sysutils,
11 {$IFDEF GTK}
12 gtk,gdk,glib,
13 {$ENDIF}
14 {$IFDEF GTK2}
15 gtk2,gdk2,glib2,
16 {$ENDIF}
17 WLXPlugin;
18
19 var List:TStringList;
20
21 //Custom class contains info for plugin windows
22 type
23
24 { TPlugInfo }
25
26 TPlugInfo = class
27 private
28 fControls:TStringList;
29 public
30 fFileToLoad:string;
31 fShowFlags:integer;
32 //etc
33 constructor Create;
34 destructor Destroy; override;
35 function AddControl(AItem:PGtkWidget):integer;
36 end;
37
38 { TPlugInfo }
39
40 constructor TPlugInfo.Create;
41 begin
42 fControls:=TStringlist.Create;
43 end;
44
45 destructor TPlugInfo.Destroy;
46 begin
47 while fControls.Count>0 do
48 begin
49 gtk_widget_destroy(PGtkWidget(fControls.Objects[0]));
50 fControls.Delete(0);
51 end;
52 inherited Destroy;
53 end;
54
55 function TPlugInfo.AddControl(AItem: PGtkWidget): integer;
56 begin
57 fControls.AddObject(inttostr(Integer(AItem)),TObject(AItem));
58 end;
59
60
61 function ListLoad(ParentWin:thandle;FileToLoad:pchar;ShowFlags:integer):thandle; dcpcall;
62 var
63 GFix, GButton1, Gbutton2: PGtkWidget;
64 begin
65 // gFix:=gtk_fixed_new;
66 gFix:=gtk_vbox_new(true,5);
67 gtk_container_add(GTK_CONTAINER(PGtkWidget(ParentWin)),gFix);
68 gtk_widget_show(gFix);
69
70 GButton1:=gtk_button_new_with_label('Yehoo1');
71 gtk_container_add(GTK_CONTAINER(GFix),GButton1);
72 gtk_widget_set_usize(GButton1,10,10);
73 // gtk_widget_set_uposition(GButton1,30,10);
74 gtk_widget_show(GButton1);
75
76 Gbutton2:=gtk_button_new_with_label('Yehoo2');
77 gtk_container_add(GTK_CONTAINER(GFix),Gbutton2 );
78 gtk_widget_set_usize(GButton2,20,20);
79 // gtk_widget_set_uposition(GButton2,50,50);
80 gtk_widget_show(Gbutton2);
81
82 //Create list if none
83 if not assigned(List) then
84 List:=TStringList.Create;
85
86 //add to list new plugin window and it's info
87 List.AddObject(IntToStr(integer(GFix)),TPlugInfo.Create);
88 with TPlugInfo(List.Objects[List.Count-1]) do
89 begin
90 fFileToLoad:=FileToLoad;
91 fShowFlags:=ShowFlags;
92 AddControl(GFix);
93 end;
94
95 Result:= thandle(GFix);
96 end;
97
98 procedure ListCloseWindow(ListWin:thandle); dcpcall;
99 var Index:integer; s:string;
100 begin
101
102
103
104 if assigned(List) then
105 begin
106 writeln('ListCloseWindow quit, List Item count: '+inttostr(List.Count));
107 s:=IntToStr(ListWin);
108 Index:=List.IndexOf(s);
109 if Index>-1 then
110 begin
111 TPlugInfo(List.Objects[index]).Free;
112 List.Delete(Index);
113 writeln('List item n: '+inttostr(Index)+' Deleted');
114 end;
115
116 //Free list if it has zero items
117 If List.Count=0 then FreeAndNil(List);
118 end;
119
120 end;
121
122 exports
123 ListLoad,
124 ListCloseWindow;
125
126 begin
127 end.
128