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

首頁(yè) > 學(xué)院 > 開發(fā)設(shè)計(jì) > 正文

2.JUCE——基本程序框架

2019-11-11 04:49:12
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友

一:JUCE程序框架

1.1 使用 PRojucer 新建 JUCE 項(xiàng)目

1.2 新建的項(xiàng)目包含三個(gè)文件:

MainComponent.h: 主 Component 頭文件;

MainComponent.cpp:主Component 源文件;

Main.cppapplication應(yīng)用和窗口文件。

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

Appilication :應(yīng)用程序?qū)嵗话阋粋€(gè)程序只有一個(gè),繼承 JUCEApplication ;Windows :窗口 ,一個(gè)應(yīng)用程序可以有多個(gè)窗口,一般繼承 DocumentWindow ;Component :組件,及各種控件,一般Windows無(wú)法自主顯示,常常為其設(shè)置一個(gè)主Componet,之后其他的子Component加入此主Component 。

二:修改程序框架

原始的JUCE程序?qū)indow作為Application的內(nèi)部類定義,為了更清晰劃分出各部分,對(duì)生成的JUCE GUI Project進(jìn)行改寫。改寫為: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)以后程序基于此框架。


發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 谷城县| 峨眉山市| 大厂| 湘西| 岳池县| 自治县| 苍山县| 丹凤县| 北宁市| 武鸣县| 米泉市| 福建省| 洪湖市| 茂名市| 鄱阳县| 项城市| 高密市| 乌拉特后旗| 华坪县| 巩义市| 金寨县| 饶河县| 丰台区| 且末县| 双城市| 乐平市| 德保县| 越西县| 右玉县| 洪泽县| 霍邱县| 南汇区| 长顺县| 应用必备| 霍城县| 通山县| 通山县| 永兴县| 卓尼县| 洞头县| 车险|