Premier commit
[powerfractal.git] / PoFGui / Main_Win.ada
1 with Gb; use Gb;
2 with Gb.OleInterfaces;
3
4 with Win32, Win32.WinDef, Win32.WinMain, Win32.WinUser, Win32.WinError, System;
5 with Win32.WinGDI, Win32.WinBase, Win32.WinNT, Win32.Utils, Interfaces.C;
6 use  Win32, Win32.WinError, Interfaces.C, System;
7
8 with MSComctlLib_Slider; use MSComctlLib_Slider;
9 package Main_Win is
10   Form            : aliased Gb.MainWindow;
11   Frm_Ensembles   : aliased Gb.Frame;
12   Rad_Mandel      : aliased Gb.RadioButton;
13   Rad_Julia       : aliased Gb.RadioButton;
14   Txt_Cx          : aliased Gb.TextBox(Alignment => Right, AutoScroll => Both, 
15                                        MultiLine => Gb.False, Password => Gb.False, 
16                                        ReadOnly => Gb.False);
17   Txt_Cy          : aliased Gb.TextBox(Alignment => Right, AutoScroll => Both, 
18                                        MultiLine => Gb.False, Password => Gb.False, 
19                                        ReadOnly => Gb.False);
20   Ch_Antialiasing       : aliased Gb.CheckBox;
21   Txt_Iterations  : aliased Gb.TextBox(Alignment => Right, AutoScroll => Both, 
22                                        MultiLine => Gb.False, Password => Gb.False, 
23                                        ReadOnly => Gb.False);
24   But_Redraw      : aliased Gb.Button;
25   Lab_Cx          : aliased Gb.Label;
26   Lab_Cy          : aliased Gb.Label;
27   Pic_Draw        : aliased Gb.Picture;
28   Img_Logo        : aliased Gb.Image;
29   Frm_Iterations  : aliased Gb.Frame;
30   Frm_Part_Droite       : aliased Gb.Frame;
31   Frm_Part_Bas    : aliased Gb.Frame;
32   Slid_Iterations       : aliased MSComctlLib_Slider.SliderCtrl(Parent => Frm_Iterations'access);
33   package Slid_Iterations_Interfaces is new Gb.OleInterfaces(Slid_Iterations'access, "Main_Win_Slid_Iterations");
34   procedure Initialize_Form;
35 end Main_Win;
36
37 with GbOBJECTs; use GbOBJECTs;
38 with Public;
39
40 package body Main_Win is
41   procedure Rad_Mandel_Click is
42   begin
43   
44     if Gb.Value(Rad_Mandel) = 1 then
45        Gb.Value(Rad_Julia, 0);
46        Gb.Enabled(Txt_Cx, 0);
47        Gb.Enabled(Txt_Cy, 0);
48     else
49        Gb.Value(Rad_Julia, 1);
50        Gb.Enabled(Txt_Cx, 1);
51        Gb.Enabled(Txt_Cy, 1);
52     end if;
53   
54   end Rad_Mandel_Click;
55
56   procedure Rad_Julia_Click is
57   begin
58     if Gb.Value(Rad_Julia) = 1 then
59        Gb.Value(Rad_Mandel, 0);
60        Gb.Enabled(Txt_Cx, 1);
61        Gb.Enabled(Txt_Cy, 1);
62     else
63        Gb.Value(Rad_Mandel, 1);
64        Gb.Enabled(Txt_Cx, 0);
65        Gb.Enabled(Txt_Cy, 0);
66     end if;
67   end Rad_Julia_Click;
68
69   procedure Txt_Iterations_Changed is
70   
71    Nb_Iterations : Gb.Long;
72    Nb_Iteration_Min : constant := 10;
73    Nb_Iteration_Max : constant := 1000;
74   
75   begin
76   
77     Nb_Iterations := Gb.Long'Value(Text(Txt_Iterations));
78   
79     if Nb_Iterations >= Nb_Iteration_Min and Nb_Iterations <= Nb_Iteration_Max then
80   
81       Value(Slid_Iterations, Nb_Iterations);
82     
83     end if;
84   
85   end Txt_Iterations_Changed;
86
87   procedure But_Redraw_Click is
88   
89   begin
90   
91        null;
92    --line(Image2, 10, 10,  100,  100 ,  Color(122, 122, 122), 0,1);
93   
94   end But_Redraw_Click;
95
96   procedure Slid_Iterations_Scroll is
97   begin
98   
99   
100       Text(Txt_Iterations,Gb.Long'Image(Value(Slid_Iterations)));
101   
102   
103   end Slid_Iterations_Scroll;
104
105   procedure Form_WindowResized(Flag : Gb.INT; Width : Gb.INT; Height : Gb.INT) is
106   
107   begin
108   --gb.Width(Pic_Draw) + gb.Width(Frm_Part_Droite) + 16
109      if Gb.Width(Main_Win.Form) < 542  then
110         Gb.Width(Main_Win.Form, 542);
111      end if;
112   
113      if Gb.Height(Main_Win.Form) < 369 then
114         Gb.Height(Main_Win.Form, 369);
115      end if;
116   
117   
118      --redimmensionnement de la zone de dessin
119      Gb.Width(Pic_Draw, Gb.Width(Main_Win.Form) - Gb.Width(Frm_Part_Droite) - 16 );
120      Gb.Height(Pic_Draw, Gb.Height(Main_Win.Form) - Gb.Height(Frm_Part_Bas) - 35 );
121      
122      --Deplacement de la frame de droite
123      Gb.Left(Frm_Part_Droite, Gb.Width(Main_Win.Form) - Gb.Width(Frm_Part_Droite) - 9 ); 
124   
125      --Deplacement de la frame du bas
126      Gb.Top(Frm_Part_Bas, Gb.Height(Main_Win.Form) - Gb.Height(Frm_Part_Bas) - 30);
127   
128      --Deplacement du logo (en bas a gauche)
129   
130   
131   
132   
133   end Form_WindowResized;
134
135   procedure Initialize_Form is
136   begin
137     Caption(Frm_Ensembles, "Ensembles");
138     Move(Frm_Ensembles, 6, 10, 89, 134);
139     Parent(Frm_Ensembles, Frm_Part_Droite);
140
141     Rad_Mandel.Click := Rad_Mandel_Click'access;
142     Caption(Rad_Mandel, "Mandelbrot");
143     Value(Rad_Mandel, Gb.True);
144     Move(Rad_Mandel, 8, 18, 77, 13);
145     Parent(Rad_Mandel, Frm_Ensembles);
146
147     Rad_Julia.Click := Rad_Julia_Click'access;
148     Caption(Rad_Julia, "Julia");
149     TabStop(Rad_Julia, Gb.False);
150     Move(Rad_Julia, 8, 59, 61, 13);
151     Parent(Rad_Julia, Frm_Ensembles);
152
153     Enabled(Txt_Cx, Gb.False);
154     Text(Txt_Cx, "0");
155     Move(Txt_Cx, 31, 86, 51, 21);
156     Parent(Txt_Cx, Frm_Ensembles);
157
158     Enabled(Txt_Cy, Gb.False);
159     Text(Txt_Cy, "0");
160     Move(Txt_Cy, 31, 107, 51, 21);
161     Parent(Txt_Cy, Frm_Ensembles);
162
163     Caption(Ch_Antialiasing, "Antialiasing");
164     Move(Ch_Antialiasing, 12, 206, 74, 13);
165     Parent(Ch_Antialiasing, Frm_Part_Droite);
166
167     Txt_Iterations.Changed := Txt_Iterations_Changed'access;
168     Text(Txt_Iterations, "0");
169     Move(Txt_Iterations, 3, 30, 84, 19);
170     Parent(Txt_Iterations, Frm_Iterations);
171
172     But_Redraw.Click := But_Redraw_Click'access;
173     Caption(But_Redraw, "REDRAW");
174     Move(But_Redraw, 7, 244, 88, 20);
175     Parent(But_Redraw, Frm_Part_Droite);
176
177     Caption(Lab_Cx, "Cx");
178     SetFont(Lab_Cx, "MS Sans Serif", 8, Gb.False, Gb.False, Gb.False);
179     Move(Lab_Cx, 14, 89, 14, 21);
180     Parent(Lab_Cx, Frm_Ensembles);
181
182     Caption(Lab_Cy, "Cy");
183     SetFont(Lab_Cy, "MS Sans Serif", 8, Gb.False, Gb.False, Gb.False);
184     Move(Lab_Cy, 14, 109, 16, 21);
185     Parent(Lab_Cy, Frm_Ensembles);
186
187     Cursor(Pic_Draw, Gb.CrossCursor);
188     Move(Pic_Draw, 3, 4, 422, 259);
189
190     Bitmap(Img_Logo, Gb.LoadBitmapResource("Img_Logo_Bitmap"));
191     Border(Img_Logo, Gb.False);
192     Move(Img_Logo, 1, 287, 100, 48);
193     Parent(Img_Logo, Frm_Part_Droite);
194
195     Caption(Frm_Iterations, "Iterations");
196     Move(Frm_Iterations, 7, 145, 89, 51);
197     Parent(Frm_Iterations, Frm_Part_Droite);
198
199     Caption(Frm_Part_Droite, "");
200     Move(Frm_Part_Droite, 429, -2, 104, 341);
201
202     Caption(Frm_Part_Bas, "");
203     Move(Frm_Part_Bas, 3, 264, 423, 75);
204
205     Slid_Iterations.Scroll := Slid_Iterations_Scroll'access;
206     Move(Slid_Iterations, 2, 14, 84, 14);
207
208     Form.WindowResized := Form_WindowResized'access;
209     Icon(Form, Gb.LoadIconResource("Main_Win_Icon"));
210     Caption(Form, "Power Fractal 0.1");
211     MaxButton(Form, Gb.False);
212     Move(Form, 149, 269, 542, 369);
213     Visible(Form, Gb.True);
214   end Initialize_Form;
215 begin
216   Initialize_Form;
217 end Main_Win;
218
219
220 with Gb;
221 with Main_Win;
222
223 procedure PowerFractal is begin
224   Gb.StartApplication;
225 end PowerFractal;
226
227