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 130 131 132 133 134 135 136 137
| --***************************************************************
-- Nom du programme : Calculatrice
-- Type : Interface
-- Sujet : Calculatrice construite à partir de GTKADA
--
-- Auteur : Pascal RICHARD
-- Version : 1.0
-- Création : 08/03/2007
-- Dernière modif. : 10/03/2007
--
-- Outils : AIDE - GPS - MSys
-- Remarques : Environnement Windows XP SP2
--****************************************************************
with Glib, Gtk.Main, Gtk.Window, Gtk.Frame, Gtk.GEntry, Gtk.Enums, Gtk.Button, Gtk.Check_Button, Gtk.Table, Gtk.Handlers;
use Glib, Gtk.Main, Gtk.Window, Gtk.Frame, Gtk.GEntry, Gtk.Enums, Gtk.Button, Gtk.Check_Button, Gtk.Table, Gtk.Handlers;
procedure calculatrice is
Table: gtk_table;
Fenetre: gtk_window;
Ecran: Gtk_GEntry;
Frame_affich, Frame_trigo, Frame_ope, Frame_nomb: gtk_frame;
btn_inv : Gtk_Check_Button;
btn_sin, btn_cos, btn_tan : Gtk_Button;
btn_plus, btn_moins, btn_mul, btn_div, btn_virg : Gtk_Button;
btn_sqrt, btn_pcent, btn_car, btn_pun, btn_pu10 : Gtk_Button;
bouton: array(0 .. 9) of Gtk_Button;
G : constant array(0 .. 9) of Guint := (17, 14, 17, 20, 14, 17, 20, 14, 17, 20);
D : constant array(0 .. 9) of Guint := (20, 17, 20, 23, 17, 20, 23, 17, 20, 23);
H : constant array(0 .. 9) of Guint := (16, 13, 13, 13, 10, 10, 10, 7, 7, 7);
B : constant array(0 .. 9) of Guint := (18, 15, 15, 15, 12, 12, 12, 9, 9, 9);
begin
init;
-- Création de la fenetre
gtk_new(fenetre, window_toplevel);
set_size_request(fenetre, 400, 300);
set_position(fenetre, win_pos_center);
gtk_new(Table, 20, 25, true);
add(fenetre, Table);
-- Création d'un Frame "Affichage", suivi
-- de la Création de l'écran d'affichage
gtk_new(Frame_affich, "Affichage");
attach_defaults(Table, Frame_affich, 1, 24, 1, 5);
gtk_new(Ecran);
attach_defaults(Table, Ecran, 7, 23, 2, 4);
-- Création du Frame "Trigonométrie", suivi de la
-- Création des boutons relatifs à ce frame
gtk_new(Frame_trigo, "Trigonometrie");
attach_defaults(Table, frame_trigo, 1, 12, 6, 11);
gtk_new(btn_inv, "Inv");
attach_defaults(Table, btn_inv, 2, 5, 8, 10);
gtk_new(btn_sin, "Sin");
attach_defaults(Table, btn_sin, 5, 7, 8, 10);
gtk_new(btn_cos, "Cos");
attach_defaults(Table, btn_cos, 7, 9, 8, 10);
gtk_new(btn_tan, "Tan");
attach_defaults(Table, btn_tan, 9, 11, 8, 10);
-- Création des boutons du frame "Opérations" - opérations usuelles
-- suivi de la création des boutons relatifs à ce frame
gtk_new(Frame_ope, "Operations");
attach_defaults(Table, frame_ope, 1, 12, 12, 19);
gtk_new(btn_plus, "+");
attach_defaults(Table, btn_plus, 3, 5, 14, 16);
gtk_new(btn_moins, "-");
attach_defaults(Table, btn_moins, 5, 7, 14, 16);
gtk_new(btn_mul, "*");
attach_defaults(Table, btn_mul, 7, 9, 14, 16);
gtk_new(btn_div, "/");
attach_defaults(Table, btn_div, 9, 11, 14, 16);
gtk_new(btn_sqrt, "Sqrt");
attach_defaults(Table, btn_sqrt, 3, 5, 16, 18);
gtk_new(btn_pcent, "%");
attach_defaults(Table, btn_pcent, 5, 7, 16, 18);
gtk_new(btn_car, "x2");
attach_defaults(Table, btn_car, 7, 9, 16, 18);
gtk_new(btn_pun, "x^n");
attach_defaults(Table, btn_pun, 9, 11, 16, 18);
-- Création du Frame "Nombres" suivi de la
-- création des boutons "virgule" et "puissance de 10", suivi de
-- la création d'une boucle pour générer les x boutons chiffres
gtk_new(Frame_nomb, "Nombres");
attach_defaults(Table, Frame_nomb, 13, 24, 6, 19);
gtk_new(btn_virg, ",");
attach_defaults(Table, btn_virg, 14, 17, 16, 18);
gtk_new(btn_pu10, ".10^x");
attach_defaults(Table, btn_pu10, 20, 23, 16, 18);
for j in bouton'range loop
gtk_new(bouton(J), integer'image(J));
end loop;
for J in bouton'range loop
Connect(bouton (J), "pressed", To_Marshaller(widget));
--gtk_new(bouton(J), integer'image(J));
attach_defaults(Table, bouton(J), G(J), D(J), H(J), B(J));
end loop;
show_all(fenetre);
main;
end calculatrice; |
Partager