Розроблення додатка – гра «Перший мільйон»

Автор: Пользователь скрыл имя, 26 Октября 2013 в 20:25, курсовая работа

Краткое описание

Дана курсова робота розроблена для дисципліни «Кросплатформне програмування». Що ж таке крос-платформне програмування? Кросплатформне програмне забезпечення – це ПЗ, працююче більш ніж на одній апаратній платформі і / або операційній системі. Типовим прикладом є програмне забезпечення, призначене для роботи в операційних системах Linux і Windows одночасно.

Оглавление

Вступ 3
Розділ І. Аналіз предметної області 4
Розділ ІІ. Теоретичні відомості 5
• Знайомство з Juce 5
• Візуальний редактор компонувань The Jucer 7
Розділ ІІІ. Створення додатку 14
• Розробка інтерфейсу 14
• Приклад реалізації роботи додатку 17
Висновок 22
Список використаних джерел 23
Додаток 1. Текст програми 24

Файлы: 1 файл

kursach.docx

— 2.61 Мб (Скачать)

    label3->setFont (Font (L"Times New Roman", 19.6000f, Font::bold));

    label3->setJustificationType (Justification::centred);

    label3->setEditable (false, false, false);

    label3->setColour (Label::textColourId, Colour (0xfffffefe));

    label3->setColour (Label::outlineColourId, Colour (0x0));

    label3->setColour (TextEditor::textColourId, Colours::black);

    label3->setColour (TextEditor::backgroundColourId, Colour (0x0));

label3->setVisible(false);

 

addAndMakeVisible (label4 = new Label (L" new label2",

                                          L"Язык разметки?"));

    label4->setFont (Font (L"Times New Roman", 19.6000f, Font::bold));

    label4->setJustificationType (Justification::centred);

    label4->setEditable (false, false, false);

    label4->setColour (Label::textColourId, Colour (0xfffffefe));

    label4->setColour (Label::outlineColourId, Colour (0x0));

    label4->setColour (TextEditor::textColourId, Colours::black);

    label4->setColour (TextEditor::backgroundColourId, Colour (0x0));

label4->setVisible(false);

 

addAndMakeVisible (label5 = new Label (L" new label2",

                                          L"Сколько поставить за эту работу?:)"));

    label5->setFont (Font (L"Times New Roman", 19.6000f, Font::bold));

    label5->setJustificationType (Justification::centred);

    label5->setEditable (false, false, false);

    label5->setColour (Label::textColourId, Colour (0xfffffefe));

    label5->setColour (Label::outlineColourId, Colour (0x0));

    label5->setColour (TextEditor::textColourId, Colours::black);

    label5->setColour (TextEditor::backgroundColourId, Colour (0x0));

label5->setVisible(false);

 

    addAndMakeVisible (textButton = new TextButton (L"new button"));

    textButton->setButtonText (L"Си");

    textButton->setRadioGroupId (1);

    textButton->addListener (this);

    textButton->setColour (TextButton::buttonColourId, Colour (0xff000048));

    textButton->setColour (TextButton::buttonOnColourId, Colours::blue);

    textButton->setColour (TextButton::textColourOnId, Colours::white);

    textButton->setColour (TextButton::textColourOffId, Colours::white);

 

    addAndMakeVisible (textButton5 = new TextButton (L"new button"));

    textButton5->setButtonText (L"4");

    textButton5->setRadioGroupId (2);

    textButton5->addListener (this);

    textButton5->setColour (TextButton::buttonColourId, Colour (0xff000048));

    textButton5->setColour (TextButton::buttonOnColourId, Colours::blue);

    textButton5->setColour (TextButton::textColourOnId, Colours::white);

    textButton5->setColour (TextButton::textColourOffId, Colours::white);

textButton5->setVisible(false);

 

addAndMakeVisible (textButton9 = new TextButton (L"new button"));

    textButton9->setButtonText (L"Стейк");

    textButton9->setRadioGroupId (3);

    textButton9->addListener (this);

    textButton9->setColour (TextButton::buttonColourId, Colour (0xff000048));

    textButton9->setColour (TextButton::buttonOnColourId, Colours::blue);

    textButton9->setColour (TextButton::textColourOnId, Colours::white);

    textButton9->setColour (TextButton::textColourOffId, Colours::white);

textButton9->setVisible(false);

 

addAndMakeVisible (textButton13 = new TextButton (L"new button"));

    textButton13->setButtonText (L"VBA");

    textButton13->setRadioGroupId (4);

    textButton13->addListener (this);

    textButton13->setColour (TextButton::buttonColourId, Colour (0xff000048));

    textButton13->setColour (TextButton::buttonOnColourId, Colours::blue);

    textButton13->setColour (TextButton::textColourOnId, Colours::white);

    textButton13->setColour (TextButton::textColourOffId, Colours::white);

textButton13->setVisible(false);

 

addAndMakeVisible (textButton17 = new TextButton (L"new button"));

    textButton17->setButtonText (L"60");

    textButton17->setRadioGroupId (5);

    textButton17->addListener (this);

    textButton17->setColour (TextButton::buttonColourId, Colour (0xff000048));

    textButton17->setColour (TextButton::buttonOnColourId, Colours::blue);

    textButton17->setColour (TextButton::textColourOnId, Colours::white);

    textButton17->setColour (TextButton::textColourOffId, Colours::white);

textButton17->setVisible(false);

 

    addAndMakeVisible (textButton2 = new TextButton (L"new button"));

    textButton2->setButtonText (L"Су");

    textButton2->setRadioGroupId (1);

    textButton2->addListener (this);

    textButton2->setColour (TextButton::buttonColourId, Colour (0xff000048));

    textButton2->setColour (TextButton::textColourOffId, Colours::white);

 

addAndMakeVisible (textButton6 = new TextButton (L"new button"));

    textButton6->setButtonText (L"3");

    textButton6->setRadioGroupId (1);

    textButton6->addListener (this);

    textButton6->setColour (TextButton::buttonColourId, Colour (0xff000048));

    textButton6->setColour (TextButton::textColourOffId, Colours::white);

textButton6->setVisible(false);

 

addAndMakeVisible (textButton10 = new TextButton (L"new button"));

    textButton10->setButtonText (L"Очередь");

    textButton10->setRadioGroupId (1);

    textButton10->addListener (this);

    textButton10->setColour (TextButton::buttonColourId, Colour (0xff000048));

    textButton10->setColour (TextButton::textColourOffId, Colours::white);

textButton10->setVisible(false);

 

addAndMakeVisible (textButton14 = new TextButton (L"new button"));

    textButton14->setButtonText (L"Java");

    textButton14->setRadioGroupId (1);

    textButton14->addListener (this);

    textButton14->setColour (TextButton::buttonColourId, Colour (0xff000048));

    textButton14->setColour (TextButton::textColourOffId, Colours::white);

textButton14->setVisible(false);

 

addAndMakeVisible (textButton18 = new TextButton (L"new button"));

    textButton18->setButtonText (L"75");

    textButton18->setRadioGroupId (1);

    textButton18->addListener (this);

    textButton18->setColour (TextButton::buttonColourId, Colour (0xff000048));

    textButton18->setColour (TextButton::textColourOffId, Colours::white);

textButton18->setVisible(false);

 

    addAndMakeVisible (textButton3 = new TextButton (L"new button"));

    textButton3->setButtonText (L"Се");

    textButton3->setRadioGroupId (1);

    textButton3->addListener (this);

    textButton3->setColour (TextButton::buttonColourId, Colour (0xff000048));

    textButton3->setColour (TextButton::textColourOffId, Colours::white);

 

addAndMakeVisible (textButton7 = new TextButton (L"new button"));

    textButton7->setButtonText (L"2");

    textButton7->setRadioGroupId (1);

    textButton7->addListener (this);

    textButton7->setColour (TextButton::buttonColourId, Colour (0xff000048));

    textButton7->setColour (TextButton::textColourOffId, Colours::white);

textButton7->setVisible(false);

 

addAndMakeVisible (textButton11 = new TextButton (L"new button"));

    textButton11->setButtonText (L"Список");

    textButton11->setRadioGroupId (1);

    textButton11->addListener (this);

    textButton11->setColour (TextButton::buttonColourId, Colour (0xff000048));

    textButton11->setColour (TextButton::textColourOffId, Colours::white);

textButton11->setVisible(false);

 

addAndMakeVisible (textButton15 = new TextButton (L"new button"));

    textButton15->setButtonText (L"HTML");

    textButton15->setRadioGroupId (1);

    textButton15->addListener (this);

    textButton15->setColour (TextButton::buttonColourId, Colour (0xff000048));

    textButton15->setColour (TextButton::textColourOffId, Colours::white);

textButton15->setVisible(false);

 

addAndMakeVisible (textButton19 = new TextButton (L"new button"));

    textButton19->setButtonText (L"85");

    textButton19->setRadioGroupId (1);

    textButton19->addListener (this);

    textButton19->setColour (TextButton::buttonColourId, Colour (0xff000048));

    textButton19->setColour (TextButton::textColourOffId, Colours::white);

textButton19->setVisible(false);

 

    addAndMakeVisible (textButton4 = new TextButton (L"new button"));

    textButton4->setButtonText (L"С++");

    textButton4->setRadioGroupId (1);

    textButton4->addListener (this);

    textButton4->setColour (TextButton::buttonColourId, Colour (0xff000148));

    textButton4->setColour (TextButton::textColourOffId, Colours::white);

 

addAndMakeVisible (textButton8 = new TextButton (L"new button"));

    textButton8->setButtonText (L"7");

    textButton8->setRadioGroupId (1);

    textButton8->addListener (this);

    textButton8->setColour (TextButton::buttonColourId, Colour (0xff000148));

    textButton8->setColour (TextButton::textColourOffId, Colours::white);

textButton8->setVisible(false);

 

addAndMakeVisible (textButton12 = new TextButton (L"new button"));

    textButton12->setButtonText (L"Код");

    textButton12->setRadioGroupId (1);

    textButton12->addListener (this);

    textButton12->setColour (TextButton::buttonColourId, Colour (0xff000148));

    textButton12->setColour (TextButton::textColourOffId, Colours::white);

textButton12->setVisible(false);

 

addAndMakeVisible (textButton16 = new TextButton (L"new button"));

    textButton16->setButtonText (L"UML");

    textButton16->setRadioGroupId (1);

    textButton16->addListener (this);

    textButton16->setColour (TextButton::buttonColourId, Colour (0xff000148));

    textButton16->setColour (TextButton::textColourOffId, Colours::white);

textButton16->setVisible(false);

 

addAndMakeVisible (textButton20 = new TextButton (L"new button"));

    textButton20->setButtonText (L"90");

    textButton20->setRadioGroupId (1);

    textButton20->addListener (this);

    textButton20->setColour (TextButton::buttonColourId, Colour (0xff000148));

    textButton20->setColour (TextButton::textColourOffId, Colours::white);

textButton20->setVisible(false);

 

    cachedImage__1_png3 = ImageCache::getFromMemory (_1_png3, _1_png3Size);

 

    //[UserPreSize]

    //[/UserPreSize]

 

    setSize (400, 300);

 

 

    //[Constructor] You can add your own custom stuff here..

    //[/Constructor]

}

 

TCentralComponent::~TCentralComponent()

{

    //[Destructor_pre]. You can add your own custom destruction code here..

    //[/Destructor_pre]

 

    deleteAllChildren();

 

//if(pSecondWindow != 0) delete pSecondWindow;

if(pThirdWindow != 0) delete pThirdWindow;

 

    //[Destructor]. You can add your own custom destruction code here..

    //[/Destructor]

}

 

//==============================================================================

void TCentralComponent::paint (Graphics& g)

{

    //[UserPrePaint] Add your own custom painting code here..

    //[/UserPrePaint]

 

    g.fillAll (Colours::white);

 

    g.setColour (Colours::black);

    g.drawImage (cachedImage__1_png3,

                 -1, -2, 401, 306,

                 0, 0, cachedImage__1_png3.getWidth(), cachedImage__1_png3.getHeight());

 

    //[UserPaint] Add your own custom painting code here..

    //[/UserPaint]

}

 

void TCentralComponent::resized()

{

    label->setBounds (72, 192, 256, 40);

label2->setBounds (72, 192, 256, 40);

label3->setBounds (72, 192, 256, 40);

label4->setBounds (72, 192, 256, 40);

label5->setBounds (72, 192, 256, 40);

    textButton->setBounds (59, 248, 136, 24);

textButton5->setBounds (59, 248, 136, 24);

textButton9->setBounds (59, 248, 136, 24);

textButton13->setBounds (59, 248, 136, 24);

textButton17->setBounds (59, 248, 136, 24);

    textButton2->setBounds (205, 248, 136, 24);

textButton6->setBounds (205, 248, 136, 24);

textButton10->setBounds (205, 248, 136, 24);

textButton14->setBounds (205, 248, 136, 24);

textButton18->setBounds (205, 248, 136, 24);

    textButton3->setBounds (59, 276, 136, 24);

textButton7->setBounds (59, 276, 136, 24);

textButton11->setBounds (59, 276, 136, 24);

textButton15->setBounds (59, 276, 136, 24);

textButton19->setBounds (59, 276, 136, 24);

    textButton4->setBounds (205, 276, 136, 24);

textButton8->setBounds (205, 276, 136, 24);

textButton12->setBounds (205, 276, 136, 24);

textButton16->setBounds (205, 276, 136, 24);

textButton20->setBounds (205, 276, 136, 24);

    //[UserResized] Add your own custom resize handling here..

    //[/UserResized]

}

 

void TCentralComponent::buttonClicked (Button* buttonThatWasClicked)

pThirdWindow->pThirdComponent->textEditor->clear();

pThirdWindow->setVisible(true);

//int mark=0;

    if (buttonThatWasClicked == textButton4)

    {

 

label->setVisible(false);textButton->setVisible(false);textButton2->setVisible(false);textButton3->setVisible(false);textButton4->setVisible(false);

label2->setVisible(true);textButton5->setVisible(true);textButton6->setVisible(true);textButton7->setVisible(true);textButton8->setVisible(true);

pThirdWindow->pThirdComponent->textButton->setVisible(true);

pThirdWindow->pThirdComponent->textEditor->insertTextAtCaret("Bank=1000 UAH");

//pThirdWindow->pThirdComponent->textEditor->setText(String(mark*1000),true);

}

else if (buttonThatWasClicked == textButton6)

    {

pThirdWindow->pThirdComponent->textEditor->insertTextAtCaret("Bank=5000 UAH");

label2->setVisible(false);textButton5->setVisible(false);textButton6->setVisible(false);textButton7->setVisible(false);textButton8->setVisible(false);

label3->setVisible(true);textButton9->setVisible(true);textButton10->setVisible(true);textButton11->setVisible(true);textButton12->setVisible(true);

pThirdWindow->pThirdComponent->textButton->setVisible(true);

//pThirdWindow->pThirdComponent->textEditor->clear();

    }

else if (buttonThatWasClicked == textButton11)

    {

pThirdWindow->pThirdComponent->textEditor->insertTextAtCaret("Bank=20000 UAH");

label3->setVisible(false);textButton9->setVisible(false);textButton10->setVisible(false);textButton11->setVisible(false);textButton12->setVisible(false);

label4->setVisible(true);textButton13->setVisible(true);textButton14->setVisible(true);textButton15->setVisible(true);textButton16->setVisible(true);

pThirdWindow->pThirdComponent->textButton->setVisible(true);

//pThirdWindow->pThirdComponent->textEditor->clear();

    }

else if (buttonThatWasClicked == textButton15)

    {

pThirdWindow->pThirdComponent->textEditor->insertTextAtCaret("Bank=50000 UAH");

label4->setVisible(false);textButton13->setVisible(false);textButton14->setVisible(false);textButton15->setVisible(false);textButton16->setVisible(false);

label5->setVisible(true);textButton17->setVisible(true);textButton18->setVisible(true);textButton19->setVisible(true);textButton20->setVisible(true);

pThirdWindow->pThirdComponent->textButton->setVisible(true);

//pThirdWindow->pThirdComponent->textEditor->clear();

    }

else if (buttonThatWasClicked == textButton19)

    {

    pThirdWindow->pThirdComponent->textEditor->insertTextAtCaret("Good, you win 100000 UAH");

pThirdWindow->pThirdComponent->textButton2->setVisible(true);

TCentralComponent::getParentComponent()->setVisible(false);

    }

else

    {

pThirdWindow->pThirdComponent->textEditor->insertTextAtCaret("You Lose:(");

pThirdWindow->pThirdComponent->textButton2->setVisible(true);

TCentralComponent::getParentComponent()->setVisible(false);

    }

TMainForm.cpp

#include "TMainForm.h"

#include "TCentralComponent.h"

#include "TThirdComponent.h"

//---------------------------------------------------------------------

TMainForm::TMainForm() : DocumentWindow(

        JUCEApplication::getInstance()->getApplicationName(),

        Colours::azure,

        DocumentWindow::allButtons)

{

    centreWithSize(500, 400);

    setResizable(true, false);

    setVisible(true);

    setTitleBarButtonsRequired(7, false);

 

    // Динамически создаём экземпляр класса нашего компонента

pThirdComponent = new TThirdComponent();

//pSecondComponent = new TSecondComponent();

pCentralComponent = new TCentralComponent();

 

    // Устанавливаем его в качестве компонента содержимого

setContentOwned(pThirdComponent, true);

//setContentOwned(pSecondComponent, true);

setContentOwned(pCentralComponent, true);

}

//---------------------------------------------------------------------

TMainForm::~TMainForm()

{

}

//---------------------------------------------------------------------

void TMainForm::closeButtonPressed()

{

    JUCEApplication::getInstance()->systemRequestedQuit();

}

//---------------------------------------------------------------------

 

TThirdComponent.cpp

#include "TMainForm.h"

#include "TCentralComponent.h"

#include "TThirdComponent.h"

#include "TThirdForm.h"

 

 

//[MiscUserDefs] You can add your own user definitions and misc code here...

//[/MiscUserDefs]

 

//==============================================================================

TThirdComponent::TThirdComponent ()

    : textEditor (0),

      textButton (0),

  textButton2 (0),

      cachedImage__2_jpg2 (0)

{

    addAndMakeVisible (textEditor = new TextEditor (L"new text editor"));

    textEditor->setMultiLine (true);

    textEditor->setReturnKeyStartsNewLine (true);

    textEditor->setReadOnly (false);

    textEditor->setScrollbarsShown (true);

    textEditor->setCaretVisible (true);

    textEditor->setPopupMenuEnabled (true);

    textEditor->setText (String::empty);

 

    addAndMakeVisible (textButton = new TextButton (L"new button"));

    textButton->setButtonText (L"\x41e\x43a:)");

    textButton->addListener (this);

    textButton->setColour (TextButton::buttonColourId, Colour (0xffff8300));

    textButton->setColour (TextButton::textColourOffId, Colours::red);

textButton->setVisible(false);

 

addAndMakeVisible (textButton2 = new TextButton (L"new button"));

    textButton2->setButtonText (L"Ok");

    textButton2->addListener (this);

    textButton2->setColour (TextButton::buttonColourId, Colour (0xffff8300));

    textButton2->setColour (TextButton::textColourOffId, Colours::red);

textButton2->setVisible(false);

 

    cachedImage__2_jpg2 = ImageCache::getFromMemory (_2_jpg2, _2_jpg2Size);

 

    //[UserPreSize]

    //[/UserPreSize]

 

    setSize (200, 200);

 

 

    //[Constructor] You can add your own custom stuff here..

    //[/Constructor]

}

 

TThirdComponent::~TThirdComponent()

{

    //[Destructor_pre]. You can add your own custom destruction code here..

Информация о работе Розроблення додатка – гра «Перший мільйон»