/* * * Zinzala SDK Introduction (Step 5) * * File : step5.cpp * Purpose : Calorie burner calculator * Author : JLV * Creation : 04/07/03 * Last Update : 08/29/04 * * (C) hexaZen 2003-2004 * * This file is part of an example program for Zinzala. It can be * used, distributed and modified without limitation. * */ #include #include #include #include #include #include #include #include #include using namespace zSDK::Cincinella; using namespace zSDK::Farfalla; // Defines units labels const tChar *kDistanceLabels[2] = { "Miles", "Kilometers" }; const tChar *kWeightLabels[2] = { "Pounds", "Kilograms" }; // Define the Application's lWindow class class cCalcWindow : public cWindow { public: cCalcWindow(); protected: void MessageReceived(cMessage *aMessage); }; /* * Method : cCalcWindow * Purpose : Constructor * Inputs : none * Output : none * Side Effects : none * */ cCalcWindow::cCalcWindow() : cWindow(uRect(0,0),"calc",eWinNormal, kFlgResizeToFit | kFlgNotResizable | kFlgNotZoomable, kCurrentWorkspace) { cGroupView *lFrame; cFloatEntryView *lDistance; cFloatEntryView *lWeight; cComboBoxView *lDistanceUnit; cComboBoxView *lWeightUnit; cStringView *result; // Set some settings of the lWindow SetPadding(5,5); SetTitle("Calories-burned Calculator"); MoveTo(10,10); // Create widget to group all the widgets to put on the lWindow lFrame = new cGroupView(uRect(0,0),NULL,eHorizontal,0,kFlgForceEqualSize | kFlgResizeToFit); lFrame->SetSlicing(3); lFrame->SetSpacing(5,5); // Create and set widget to enter the lDistance lDistance = new cFloatEntryView(uRect(60,20),NULL,0,NULL,0,kFlgUpDown); lDistance->SetPrecision(1); // Create and set widget to enter lWeight lWeight = new cFloatEntryView(uRect(60,20),NULL,0,NULL,0,kFlgUpDown); lWeight->SetPrecision(1); // Create and set widget to select lDistance unit lDistanceUnit = new cComboBoxView(uRect(60,20),NULL,NULL,0,kFlgNotEditable); lDistanceUnit->SetItems(kDistanceLabels,2); lDistanceUnit->SetSelectedItem(2); // Create and set widget to select lWeight unit lWeightUnit = new cComboBoxView(uRect(60,20),NULL,NULL,0,kFlgNotEditable); lWeightUnit->SetItems(kWeightLabels,2); lWeightUnit->SetSelectedItem(2); // Create and set widget to display the computation result result = new cStringView(uRect(0,0),NULL,"a string",0,0); result->SetFGColor(kColorBlue); result->SetAlignment(eCenter); // Add all the widget to the group lFrame->AddChild(new cStringView(uRect(0,0),NULL,"Distance ran",0,0)); lFrame->AddChild(lDistance); lFrame->AddChild(lDistanceUnit); lFrame->AddChild(new cStringView(uRect(0,0),NULL,"Weight",0,0)); lFrame->AddChild(lWeight); lFrame->AddChild(lWeightUnit); lFrame->AddChild(new cButtonView(uRect(0,0),NULL,"Compute",NULL,0,0)); lFrame->AddChild(result); // Add the group to the lWindow AddChild(lFrame); } /* * Method : MessageReceived * Purpose : A message has been received by the Window * Inputs : * * cMessage *aMmessage, message received * * Output : none * Side Effects : none * */ void cCalcWindow::MessageReceived(cMessage *aMessage) { switch(aMessage->iWhat) { default: cWindow::MessageReceived(aMessage); } } int main() { // Create the application cApplication lMyApp("hexaZen/phalorieburn",0); if(lMyApp.IsValid()) { // Start the app (and the Photon connection) lMyApp.Run(); // Create lWindow cCalcWindow lWin; // show the lWindow now lWin.Show(); // Wait for the end of the app lMyApp.WaitEnd(); } else fprintf(stderr,"Failed the init the application"); }