国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

2.JUCE——基本程序框架

2019-11-11 05:22:13
字體:
來源:轉載
供稿:網友

一:JUCE程序框架

1.1 使用 PRojucer 新建 JUCE 項目

1.2 新建的項目包含三個文件:

MainComponent.h: 主 Component 頭文件;

MainComponent.cpp:主Component 源文件;

Main.cppapplication應用和窗口文件。

這里需要明白三個概念:Application , Windows 和 Component:

Appilication :應用程序實例,一般一個程序只有一個,繼承 JUCEApplication ;Windows :窗口 ,一個應用程序可以有多個窗口,一般繼承 DocumentWindow ;Component :組件,及各種控件,一般Windows無法自主顯示,常常為其設置一個主Componet,之后其他的子Component加入此主Component 。

二:修改程序框架

原始的JUCE程序將Window作為Application的內部類定義,為了更清晰劃分出各部分,對生成的JUCE GUI Project進行改寫。改寫為:MainWindow.h,MainWindow.cpp和Main.cpp。

MainWindow.h:

/*  ==============================================================================    MainWindow.h    Created: 6 Feb 2017 2:48:03pm    Author:  magewell  ==============================================================================*/#ifndef MAINWINDOW_H_INCLUDED#define MAINWINDOW_H_INCLUDED#include "../JuceLibraryCode/JuceHeader.h"class MainContentComponent;//==============================================================================//This class implements the desktop window that contains an instance of our MainContentComponent class.class MainWindow : public DocumentWindow{public:	MainWindow(String name);	~MainWindow();	//==================================override	void closeButtonPressed() override;private:	ScopedPointer<MainContentComponent> contentComponent;	JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(MainWindow)};#endif  // MAINWINDOW_H_INCLUDED

MainWindow.cpp:

/*  ==============================================================================    MainWindow.cpp    Created: 6 Feb 2017 2:48:03pm    Author:  magewell  ==============================================================================*/#include "MainWindow.h"/********************************************************************* ContentComponent Class********************************************************************/class MainContentComponent : public Component{public:	MainContentComponent()	{	}	~MainContentComponent()	{	}	//=================================================override	void paint(Graphics &g) override	{		g.fillAll(Colour(0xff001F36));		//g.setFont(Font(16.0f));		//g.setColour(Colours::white);		//g.drawText("Hello World!", getLocalBounds(), Justification::centred, true);	}	void resized() override	{		//Rectangle<int> area(getLocalBounds());	}private:	JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(MainContentComponent);};/************************************************************ Main Window Class*************************************************************///Construct/DeConstructMainWindow::MainWindow(String name) : DocumentWindow(name,	Colours::lightgrey,	DocumentWindow::allButtons){	setUsingNativeTitleBar(true);	//resizable	contentComponent = new MainContentComponent();	setContentOwned(contentComponent, false);	setResizable(true, false);	setResizeLimits(600, 600, 10000, 10000);	centreWithSize(getWidth(), getHeight());	setVisible(true);}MainWindow::~MainWindow(){	contentComponent = nullptr;}void MainWindow::closeButtonPressed(){	JUCEApplication::getInstance()->systemRequestedQuit();}Main.cpp:

/*  ==============================================================================    This file was auto-generated!    It contains the basic startup code for a Juce application.  ==============================================================================*/#include "MainWindow.h"//==============================================================================class ArchtureApplication  : public JUCEApplication{public:    //==============================================================================    ArchtureApplication() {}    const String getApplicationName() override       { return ProjectInfo::projectName; }    const String getApplicationVersion() override    { return ProjectInfo::versionString; }    bool moreThanOneInstanceAllowed() override       { return true; }    //==============================================================================    void initialise (const String& commandLine) override    {        // This method is where you should put your application's initialisation code..        mainWindow = new MainWindow (getApplicationName());    }    void shutdown() override    {        // Add your application's shutdown code here..        mainWindow = nullptr; // (deletes our window)    }    //==============================================================================    void systemRequestedQuit() override    {        // This is called when the app is being asked to quit: you can ignore this        // request and let the app carry on running, or call quit() to allow the app to close.        quit();    }    void anotherInstanceStarted (const String& commandLine) override    {        // When another instance of the app is launched while this one is running,        // this method is invoked, and the commandLine parameter tells you what        // the other instance's command-line arguments were.    }private:    ScopedPointer<MainWindow> mainWindow;};//==============================================================================// This macro generates the main() routine that launches the app.START_JUCE_APPLICATION (ArchtureApplication)以后程序基于此框架。


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 莆田市| 崇礼县| 平利县| 长顺县| 洱源县| 石阡县| 都兰县| 北安市| 锡林郭勒盟| 聂拉木县| 泸溪县| 方城县| 山丹县| 营口市| 凤阳县| 中山市| 兴海县| 班玛县| 儋州市| 资溪县| 林口县| 阿克苏市| 涞源县| 十堰市| 宁夏| 波密县| 邻水| 承德市| 建始县| 日土县| 乌苏市| 本溪| 辉南县| 内江市| 白银市| 特克斯县| 巴东县| 德格县| 长海县| 富宁县| 宁夏|