Accueil > > > CALCULATRICE
CALCULATRICE
Information sur la source
Description
Une calculatrice, simple, avec juste la division, multiplication, soustraction et addition.
Pour comprendre les bases de GTK+
Pour le moment, juste l'affichage, bientôt le calcul et surtout des commentaires ...
Source
- #include <stdlib.h>
- #include <gtk/gtk.h>
- #include <stdio.h>
- #include <windows.h>
-
- struct nombre_struct {
- float nombre1;
- float nombre2;
- float resultat;
- bool virgule;
- }nombre;
-
-
- int main(int argc,char **argv)
- {
- GtkWidget *principal;
- GtkWidget *pVBox;
- GtkWidget *pHBox;
- GtkWidget *pButton[17];
- GtkWidget* pLabel;
-
- nombre.nombre1 = 0;
- nombre.nombre2 = 0;
- nombre.resultat = 0;
- nombre.virgule = FALSE;
-
-
- gtk_init(&argc,&argv);
-
- principal = gtk_window_new(GTK_WINDOW_TOPLEVEL);
- gtk_window_set_title(GTK_WINDOW(principal),"Calculatrice By Funcky");
- gtk_window_set_default_size(GTK_WINDOW(principal),200,200);
- gtk_window_set_position (GTK_WINDOW (principal), GTK_WIN_POS_CENTER);
- gtk_widget_realize (principal);
- g_signal_connect (principal, "destroy", gtk_main_quit, NULL);
-
- pButton[7] = gtk_button_new_with_mnemonic("_7");
- pButton[8] = gtk_button_new_with_mnemonic("_8");
- pButton[9] = gtk_button_new_with_mnemonic("_9");
- pButton[10] = gtk_button_new_with_mnemonic("_/");
- pButton[0] = gtk_button_new_with_mnemonic("_0");
- pButton[1] = gtk_button_new_with_mnemonic("_1");
- pButton[2] = gtk_button_new_with_mnemonic("_2");
- pButton[3] = gtk_button_new_with_mnemonic("_3");
- pButton[4] = gtk_button_new_with_mnemonic("_4");
- pButton[5] = gtk_button_new_with_mnemonic("_5");
- pButton[6] = gtk_button_new_with_mnemonic("_6");
- pButton[11] = gtk_button_new_with_mnemonic("_*");
- pButton[12] = gtk_button_new_with_mnemonic("_-");
- pButton[13] = gtk_button_new_with_mnemonic("_+");
- pButton[14] = gtk_button_new_with_mnemonic("_.");
- pButton[15] = gtk_button_new_with_mnemonic("_OK");
- pButton[16] = gtk_button_new_with_mnemonic("_Reset");
-
- pLabel=gtk_label_new("0");
- gtk_label_set_justify(GTK_LABEL(pLabel), GTK_JUSTIFY_RIGHT);
-
- pVBox = gtk_vbox_new(FALSE, 0);
- gtk_container_add(GTK_CONTAINER(principal), pVBox);
-
- pHBox = gtk_hbox_new(TRUE, 0);
- gtk_box_pack_start(GTK_BOX(pVBox), pHBox, TRUE, TRUE, 0);
-
- gtk_box_pack_start(GTK_BOX(pHBox), pLabel, TRUE, TRUE, 0);
-
- pHBox = gtk_hbox_new(TRUE, 0);
- gtk_box_pack_start(GTK_BOX(pVBox), pHBox, TRUE, TRUE, 0);
-
- gtk_box_pack_start(GTK_BOX(pHBox), pButton[7], TRUE, TRUE, 0);
- gtk_box_pack_start(GTK_BOX(pHBox), pButton[8], TRUE, TRUE, 0);
- gtk_box_pack_start(GTK_BOX(pHBox), pButton[9], TRUE, TRUE, 0);
- gtk_box_pack_start(GTK_BOX(pHBox), pButton[10], TRUE, TRUE, 0);
-
- pHBox = gtk_hbox_new(TRUE, 0);
- gtk_box_pack_start(GTK_BOX(pVBox), pHBox, TRUE, TRUE, 0);
-
- gtk_box_pack_start(GTK_BOX(pHBox), pButton[4], TRUE, TRUE, 0);
- gtk_box_pack_start(GTK_BOX(pHBox), pButton[5], TRUE, TRUE, 0);
- gtk_box_pack_start(GTK_BOX(pHBox), pButton[6], TRUE, TRUE, 0);
- gtk_box_pack_start(GTK_BOX(pHBox), pButton[11], TRUE, TRUE, 0);
-
- pHBox = gtk_hbox_new(TRUE, 0);
- gtk_box_pack_start(GTK_BOX(pVBox), pHBox, TRUE, TRUE, 0);
-
- gtk_box_pack_start(GTK_BOX(pHBox), pButton[1], TRUE, TRUE, 0);
- gtk_box_pack_start(GTK_BOX(pHBox), pButton[2], TRUE, TRUE, 0);
- gtk_box_pack_start(GTK_BOX(pHBox), pButton[3], TRUE, TRUE, 0);
- gtk_box_pack_start(GTK_BOX(pHBox), pButton[12], TRUE, TRUE, 0);
-
- pHBox = gtk_hbox_new(TRUE, 0);
- gtk_box_pack_start(GTK_BOX(pVBox), pHBox, TRUE, TRUE, 0);
-
- gtk_box_pack_start(GTK_BOX(pHBox), pButton[0], TRUE, TRUE, 0);
- gtk_box_pack_start(GTK_BOX(pHBox), pButton[14], TRUE, TRUE, 0);
- gtk_box_pack_start(GTK_BOX(pHBox), pButton[13], TRUE, TRUE, 0);
- gtk_box_pack_start(GTK_BOX(pHBox), pButton[15], TRUE, TRUE, 0);
-
- pHBox = gtk_hbox_new(TRUE, 0);
- gtk_box_pack_start(GTK_BOX(pVBox), pHBox, TRUE, TRUE, 0);
-
- gtk_box_pack_start(GTK_BOX(pHBox), pButton[16], TRUE, TRUE, 0);
-
-
- gtk_widget_show_all (principal);
- gtk_main ();
- return 0;
- }
-
#include <stdlib.h>
#include <gtk/gtk.h>
#include <stdio.h>
#include <windows.h>
struct nombre_struct {
float nombre1;
float nombre2;
float resultat;
bool virgule;
}nombre;
int main(int argc,char **argv)
{
GtkWidget *principal;
GtkWidget *pVBox;
GtkWidget *pHBox;
GtkWidget *pButton[17];
GtkWidget* pLabel;
nombre.nombre1 = 0;
nombre.nombre2 = 0;
nombre.resultat = 0;
nombre.virgule = FALSE;
gtk_init(&argc,&argv);
principal = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_title(GTK_WINDOW(principal),"Calculatrice By Funcky");
gtk_window_set_default_size(GTK_WINDOW(principal),200,200);
gtk_window_set_position (GTK_WINDOW (principal), GTK_WIN_POS_CENTER);
gtk_widget_realize (principal);
g_signal_connect (principal, "destroy", gtk_main_quit, NULL);
pButton[7] = gtk_button_new_with_mnemonic("_7");
pButton[8] = gtk_button_new_with_mnemonic("_8");
pButton[9] = gtk_button_new_with_mnemonic("_9");
pButton[10] = gtk_button_new_with_mnemonic("_/");
pButton[0] = gtk_button_new_with_mnemonic("_0");
pButton[1] = gtk_button_new_with_mnemonic("_1");
pButton[2] = gtk_button_new_with_mnemonic("_2");
pButton[3] = gtk_button_new_with_mnemonic("_3");
pButton[4] = gtk_button_new_with_mnemonic("_4");
pButton[5] = gtk_button_new_with_mnemonic("_5");
pButton[6] = gtk_button_new_with_mnemonic("_6");
pButton[11] = gtk_button_new_with_mnemonic("_*");
pButton[12] = gtk_button_new_with_mnemonic("_-");
pButton[13] = gtk_button_new_with_mnemonic("_+");
pButton[14] = gtk_button_new_with_mnemonic("_.");
pButton[15] = gtk_button_new_with_mnemonic("_OK");
pButton[16] = gtk_button_new_with_mnemonic("_Reset");
pLabel=gtk_label_new("0");
gtk_label_set_justify(GTK_LABEL(pLabel), GTK_JUSTIFY_RIGHT);
pVBox = gtk_vbox_new(FALSE, 0);
gtk_container_add(GTK_CONTAINER(principal), pVBox);
pHBox = gtk_hbox_new(TRUE, 0);
gtk_box_pack_start(GTK_BOX(pVBox), pHBox, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(pHBox), pLabel, TRUE, TRUE, 0);
pHBox = gtk_hbox_new(TRUE, 0);
gtk_box_pack_start(GTK_BOX(pVBox), pHBox, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(pHBox), pButton[7], TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(pHBox), pButton[8], TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(pHBox), pButton[9], TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(pHBox), pButton[10], TRUE, TRUE, 0);
pHBox = gtk_hbox_new(TRUE, 0);
gtk_box_pack_start(GTK_BOX(pVBox), pHBox, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(pHBox), pButton[4], TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(pHBox), pButton[5], TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(pHBox), pButton[6], TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(pHBox), pButton[11], TRUE, TRUE, 0);
pHBox = gtk_hbox_new(TRUE, 0);
gtk_box_pack_start(GTK_BOX(pVBox), pHBox, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(pHBox), pButton[1], TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(pHBox), pButton[2], TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(pHBox), pButton[3], TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(pHBox), pButton[12], TRUE, TRUE, 0);
pHBox = gtk_hbox_new(TRUE, 0);
gtk_box_pack_start(GTK_BOX(pVBox), pHBox, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(pHBox), pButton[0], TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(pHBox), pButton[14], TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(pHBox), pButton[13], TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(pHBox), pButton[15], TRUE, TRUE, 0);
pHBox = gtk_hbox_new(TRUE, 0);
gtk_box_pack_start(GTK_BOX(pVBox), pHBox, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(pHBox), pButton[16], TRUE, TRUE, 0);
gtk_widget_show_all (principal);
gtk_main ();
return 0;
}
Sources du même auteur
Sources de la même categorie
Commentaires et avis
Discussions en rapport avec ce code source dans le forum
Calculatrice ms visual c++ [ par Fino ]
Bonjour,quelqu'un aurait-il le source d'une calculatrice faite avec ms visual c++ comme la calc.exe de ms dans windows.si oui pouvez m'en envoyer un e
Probleme d affichage [ par Scythale ]
Lorsque j'execute ce programme voici ce que dit mon compilateur(borland C++): you have accidentely use the old dummy version of OwlMain.Je n'arrive pa
calculatrice en c++ TRES URGENT!!! [ par zouz ]
Il faut que je réalise une calculatrice en programmation.Le fonctionnement est comparable à une calculatrice de poche tel que nous avons l'habitude d'
Une calculatrice en C++ sous windows [ par Juan-Marco ]
Bonjour à tousVoila mon premier post sur ce forums Je connais bien les boucles, les variables et les structures. Je connais un peut moins les classes.
calculatrice pour debutant en C [ par kwuy ]
j'ai ecrit une version de ma calculatrice mais je voudrais en faire une avec ligne de commande du genre : 12 + 5 - 4 *9 etc et avoir le resultatcommen
Calculatrice Win32 Borland OWL C++ 5.x [ par bobby03 ]
J'ai ajouté une barre menu, mais je suis incapable d'activer mon MessageBox À propos. Ça ajoute même une erreur sur le code existant qui fonctionne tr
Calculatrice Inverse Polonaise [ par vpieplu ]
J'ai un probleme. Je n'arrive pas a coder la calculatrice ... Je ne sais qu'elle commande mettre dans les fonctions + - * / Sin Inv Cos C'est super UR
calculatrice en C [ par a20syl92 ]
20sylsylnet@netcourrier.comBonjour,J'aimerais réaliser, en langage C, un logiciel capable d'évaluer des expressions arithmétiques, en respectant les p
Calculatrice (postfixé) : pb a l'execution [ par filipuce ]
Bonjourvoila g fé une petite calculatrice (+,-,*,/ avec parentheses)sous linux pas de probleme, compilation et execution.mais en retouranant sous wind
Une calculatrice en C... [ par vegetalain ]
bonjour.voila, je débute en C++ et c un vrai cauchemar... j'ai pris sur le net une source de calculatrice. y'a des fichier ".c" et ".h" et aussi des f
|
Derniers Blogs
SIMULER FACILEMENT L'ENVOI DE MAILSIMULER FACILEMENT L'ENVOI DE MAIL par JeremyJeanson
il m'a été demandé, à plusieurs reprises, comment je faisais pour simuler l'envoi de mail lors de mes démos de Workflow Foundation. Ma solution est plutôt simple : j'utilise la configuration par défaut du SmtpClient et j'oriente les mails vers un dossier ...
Cliquez pour lire la suite de l'article par JeremyJeanson VOTEZ POUR LE TOP 10 DES INFLUENCEURS SHAREPOINT FRANCOPHONES !VOTEZ POUR LE TOP 10 DES INFLUENCEURS SHAREPOINT FRANCOPHONES ! par Patrick Guimonet
Si ce n'est déjà fait (comme plus de 600 personnes déjà), il est encore temps de voter pour le concours TOP 10 des influenceurs SharePoint francophones ! Il est organisé par harmon.ie et accessible ici : http://harmon.ie/top-...
Cliquez pour lire la suite de l'article par Patrick Guimonet [CONF'SHAREPOINT] DERNIER RAPPEL ! :-)[CONF'SHAREPOINT] DERNIER RAPPEL ! :-) par Patrick Guimonet
La Conf'SharePoint en chiffres c'est : 3 jours de SharePoint ! 4 parcours et 60 sessions 17 partenaires représentant toutes les fac...
Cliquez pour lire la suite de l'article par Patrick Guimonet [ #SHAREPOINT 2013 ] LES MODèLES DE SITES STANDARDS.[ #SHAREPOINT 2013 ] LES MODèLES DE SITES STANDARDS. par Patrick Guimonet
C'est un point peu mis en avant mais SharePoint 2013 a été l'occasion de remettre de l'ordre dans les modèles de sites. Tout d'abord, un certain nombre de modèles ont été tout simplement rendus obsolètes (cf. Fonctionnalités déco...
Cliquez pour lire la suite de l'article par Patrick Guimonet
Forum
PB PACMAN C++PB PACMAN C++ par garfield95
Cliquez pour lire la suite par garfield95
Logiciels
Easy-Planning (4.5.0.11)EASY-PLANNING (4.5.0.11)Easy-Planning permet de créer des plannings sous la représentation de diagrammes et est adapté a... Cliquez pour télécharger Easy-Planning CVEasy (3.1.0.51)CVEASY (3.1.0.51)PHMSD-CVEasy est un logiciel d'aide à la rédaction de CV d'une simplicité déconcertante.
PHMSD-C... Cliquez pour télécharger CVEasy LettresFaciles 2011 (8.6.0.31)LETTRESFACILES 2011 (8.6.0.31)LettresFaciles est un logiciel facilitant la création et la rédaction de lettres types.
Son inte... Cliquez pour télécharger LettresFaciles 2011 sDEVIS-FACTURES vlPRO (8.4.2.62)SDEVIS-FACTURES VLPRO (8.4.2.62)sDEVIS-FACTURES vlPRO a été mis au point pour les particuliers, créateurs, entrepreneurs, artisa... Cliquez pour télécharger sDEVIS-FACTURES vlPRO Devis-Factures PHMSD (2.1.0.11)DEVIS-FACTURES PHMSD (2.1.0.11)Configuration minimale
Nécessite Windows™ 2000, XP, Windows 7, 8, Vista (Service Pack à... Cliquez pour télécharger Devis-Factures PHMSD
|