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

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

2.JUCE——基本程序框架

2019-11-11 05:23:46
字體:
來源:轉載
供稿:網友

一: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)以后程序基于此框架。


上一篇:數據分析之分組拆分

下一篇:名企筆試

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 庆云县| 略阳县| 松桃| 祁东县| 湘乡市| 彰化县| 重庆市| 隆安县| 安图县| 太康县| 海城市| 宜兰县| 晴隆县| 西峡县| 沙雅县| 靖西县| 七台河市| 普宁市| 德州市| 瑞金市| 安康市| 常州市| 门源| 太湖县| 南乐县| 神木县| 桂林市| 海阳市| 郁南县| 东辽县| 黄陵县| 安康市| 栾城县| 驻马店市| 达孜县| 丹江口市| 尼勒克县| 奎屯市| 上虞市| 民乐县| 灵丘县|