Example #1
0
//=================================================================================================
MainWindow::MainWindow()
    : DocumentWindow (JUCEApplication::getInstance()->getApplicationName(),
                      Colours::lightgrey,
                      DocumentWindow::allButtons)
{   
    // 创建基础组件和读写文档的对象
    baseComponent = new BaseComponent();
    appDoc = LoadAndSaveDoc::getInstance();
    appDoc->addChangeListener(this);  // FileBasedDocument 对象绑定可变捕获器
    
    // 获取全局性的撤销管理器、命令管理器和程序属性
    undoManager     = AppSingleton::getInstance()->getUndoManager(); 
    commandManager  = AppSingleton::getInstance()->getCommandManager();
    appProperties   = AppSingleton::getInstance()->getAppProperties();
    
    // 注册命令目标
    commandManager->registerAllCommandsForTarget (JUCEApplication::getInstance());
    commandManager->registerAllCommandsForTarget (this); 

    // 获取所有命令默认的快捷键
    commandManager->getKeyMappings()->resetToDefaultMappings();

    // 获取用户自定义的快捷键
    ScopedPointer<XmlElement> keys(appProperties->getUserSettings()->getXmlValue("keyMappings")); 

    if (keys != nullptr)        
        commandManager->getKeyMappings()->restoreFromXml(*keys);

    // 本类绑定按键捕获器
    addKeyListener (commandManager->getKeyMappings());

    // 设置本类的默认属性
    centreWithSize (1280, 800);
    setResizable(true, false);
    setResizeLimits(800, 600, 4096, 4096);
    setVisible (true);
    setUsingNativeTitleBar(true);

    // 主菜单随时关注命令的变化
    setApplicationCommandManagerToWatch(commandManager);

    // 设置主菜单  
#ifdef JUCE_MAC
    setMacMainMenu(this);
#else
    setMenuBar(this);   
#endif

    // 恢复上次退出时的窗口状态
    restoreWindowStateFromString(appProperties->getUserSettings()->getValue("mainWindowState"));
    setName(AppString::appNameOnTitleBar + TRANS("Untitled"));      // 设置标题栏默认显示的文本

    // 设置并添加基础组件
    baseComponent->setSize(getWidth(), getHeight());
    setContentOwned(baseComponent, false);  

    // 设置当前进程为高优先级
    Process::setPriority (Process::HighPriority);
}
Example #2
0
//==============================================================================
MainWindow::MainWindow()
    : DocumentWindow ("The Jucer",
                      Colours::azure,
                      DocumentWindow::allButtons)
{
    if (oldLook == 0)
        oldLook = new OldSchoolLookAndFeel();

    setContentOwned (multiDocHolder = new MultiDocHolder(), false);

    setApplicationCommandManagerToWatch (commandManager);

   #if JUCE_MAC
    setMacMainMenu (this);
   #else
    setMenuBar (this);
   #endif

    setResizable (true, false);

    centreWithSize (700, 600);

    // restore the last size and position from our settings file..
    restoreWindowStateFromString (StoredSettings::getInstance()->getProps()
                                    .getValue ("lastMainWindowPos"));

    // Register all the app commands..
    {
        commandManager->registerAllCommandsForTarget (JUCEApplication::getInstance());
        commandManager->registerAllCommandsForTarget (this);

        // use a temporary one of these to harvest its commands..
        JucerDocumentHolder tempDesignHolder (ObjectTypes::createNewDocument (0));
        commandManager->registerAllCommandsForTarget (&tempDesignHolder);
    }

    commandManager->getKeyMappings()->resetToDefaultMappings();

    XmlElement* const keys = StoredSettings::getInstance()->getProps().getXmlValue ("keyMappings");

    if (keys != 0)
    {
        commandManager->getKeyMappings()->restoreFromXml (*keys);
        delete keys;
    }

    addKeyListener (commandManager->getKeyMappings());

    // don't want the window to take focus when the title-bar is clicked..
    setWantsKeyboardFocus (false);

   #ifndef JUCE_DEBUG
    // scan for fonts before the app gets started rather than glitching later
    FontPropertyComponent::preloadAllFonts();
   #endif
}
Example #3
0
CodeWindow::~CodeWindow(){
	setMenuBar(0);
	setApplicationCommandManagerToWatch(nullptr);
	commandManager.deleteInstance();
	deleteAndZero(textEditor);
}
Example #4
0
//==============================================================================
CodeWindow::CodeWindow(String name):DocumentWindow (name, Colours::black,
							  DocumentWindow::allButtons),
							  fontSize(15),
							  showOutput(true),
							  csoundOutputText(""),
							  debugMessage(""),
							  firstTime(true),
							  font(String("Courier New"), 15, 1),
							  showingHelp(false)
{  
	setApplicationCommandManagerToWatch(&commandManager);
	commandManager.registerAllCommandsForTarget(this);
	addKeyListener(commandManager.getKeyMappings());
	
	textEditor = new CsoundCodeEditor("csound", csoundDoc, &csoundToker);

	restoreWindowStateFromString (appProperties->getUserSettings()->getValue ("mainWindowPos"));


	textEditor->addActionListener(this);

	
	this->setTitleBarHeight(20);
	this->setColour(DocumentWindow::backgroundColourId, CabbageUtils::getBackgroundSkin());
	

	setMenuBar(this, 25);	
	
	setVisible(true);

	this->setWantsKeyboardFocus(false);


	if(!appProperties->getUserSettings()->getValue("EditorColourScheme", var(0)).getIntValue())
		setEditorColourScheme("white");
	else if(appProperties->getUserSettings()->getValue("EditorColourScheme", var(0)).getIntValue())
		setEditorColourScheme("dark");

	RecentlyOpenedFilesList recentFiles;
	recentFiles.restoreFromString (appProperties->getUserSettings()
										->getValue ("recentlyOpenedFiles"));

	csdFile = recentFiles.getFile (0);
	csoundDoc.replaceAllContent(csdFile.loadFileAsString());
	
	//cabbageTimer->addActionListener(this);
	//cabbageTimer->startTimedEvent(10, "splash");
	setResizable(true, false);

	String opcodeFile = File(File::getSpecialLocation(File::currentExecutableFile)).getParentDirectory().getFullPathName(); 
	opcodeFile += "/opcodes.txt";
	Logger::writeToLog(opcodeFile);

	if(File(opcodeFile).existsAsFile())
		textEditor->setOpcodeStrings(File(opcodeFile).loadFileAsString());
	//else csound->Message("Could not open opcodes.txt file, parameter display disabled..");

	//set up popup for displaying info regarding opcodes..
	popupDisplay = new PopupDisplay("Poppy");
	popupDisplay->addActionListener(this);
	popupDisplay->setTitleBarHeight(0);
	popupDisplay->addToDesktop(0);
	popupDisplay->setVisible(false);
	
	
htmlHelp = new WebBrowserComponent(false);

setContentNonOwned(textEditor, false);
}
MenuBarModel::~MenuBarModel()
{
    setApplicationCommandManagerToWatch (0);
}
Example #6
0
CtrlrEditor::CtrlrEditor (CtrlrProcessor *_ownerFilter, CtrlrManager &_owner)
	:	AudioProcessorEditor (_ownerFilter), ownerFilter(_ownerFilter),
		owner(_owner), resizer(this, 0),
		tempResult(Result::ok()),
		menuHandlerCalled(false),
		lastCommandInvocationMillis(0)
{
	Rectangle<int> editorRect;
    // http://www.juce.com/forum/topic/applicationcommandmanager-menus-not-active-annoyance#new
    owner.getCommandManager().setFirstCommandTarget (this);

	addAndMakeVisible (menuBar = new MenuBarComponent (this));
	menuBarLookAndFeel = new CtrlrMenuBarLookAndFeel (*this);

	setApplicationCommandManagerToWatch (&owner.getCommandManager());

	owner.getCommandManager().registerAllCommandsForTarget (this);
	owner.getCommandManager().registerAllCommandsForTarget (JUCEApplication::getInstance());
	ScopedPointer <XmlElement> xml(XmlDocument::parse(owner.getProperty(Ids::ctrlrKeyboardMapping)));

	if (xml)
	{
		owner.getCommandManager().getKeyMappings()->restoreFromXml (*xml);
	}

	owner.setEditor (this);

	addAndMakeVisible (&owner.getCtrlrDocumentPanel());

	if (!JUCEApplication::isStandaloneApp())
	{
	    if (owner.getInstanceMode() != InstanceSingleRestriced)
        {
            /* Restricted instances don't get to be resizable */
            addAndMakeVisible (&resizer);
            resizer.setAlwaysOnTop (false);
            resizer.grabKeyboardFocus();
            resizer.toFront (true);
        }
	}

	if (owner.getProperty (Ids::ctrlrEditorBounds).toString() != String::empty)
	{
		if (owner.getInstanceMode() != InstanceSingle
			&& owner.getInstanceMode() != InstanceSingleRestriced)
		{
			editorRect = VAR2RECT(owner.getProperty (Ids::ctrlrEditorBounds));
		}
		else if (owner.getActivePanel())
		{
			editorRect = VAR2RECT(owner.getActivePanel()->getEditor()->getProperty(Ids::uiPanelCanvasRectangle));

			if ((bool)owner.getActivePanel()->getEditor()->getProperty(Ids::uiPanelMenuBarVisible))
				editorRect.setHeight (editorRect.getHeight() + CTRLR_MENUBAR_HEIGHT);
			else
				editorRect.setHeight (editorRect.getHeight());
		}
	}
	else
		editorRect.setSize(640,480);

	setBounds (editorRect);

	lookAndFeelChanged();
	activeCtrlrChanged();
}
Example #7
0
MainMenuModel::MainMenuModel(AppDocumentState &ref)
                        : appDocumentStateRef(ref)
{
    setApplicationCommandManagerToWatch (commandManager);
}
Example #8
0
TextEditorWindow::TextEditorWindow (File file, String text, int synt,
				    String title)
  : DocumentWindow (String::empty, Colours::white, 
		    DocumentWindow::allButtons, true)
{
  isfms = false;
  Preferences* prefs=Preferences::getInstance();
  setMenuBar(this);
  int size=0;
  if (file.existsAsFile())
    {
      String ext=file.getFileExtension();
      String lsp=T(".lisp.lsp.scm.cm.clm.cmn.ins");
      String sal=T(".sal");
      String sal2=T(".sal2");
      String fms=T(".fms");
      if (synt==TextIDs::Empty)
	if (sal.contains(ext))
	  synt=TextIDs::Sal;
	else if (sal2.contains(ext))
	  synt=TextIDs::Sal2;
	else if (lsp.contains(ext))
	  synt=TextIDs::Lisp;
	else if (fms.contains(ext)) {
	  isfms = true; synt=TextIDs::Fomus;
	} else
	  synt=TextIDs::Text; 
      size=(int)file.getSize();
      text=file.loadFileAsString();
    }
  else
    {
      file=File::nonexistent;
      size=text.length();
    }
  if (synt==TextIDs::Empty)
    synt=prefs->getIntProp(T("EditorSyntax"), TextIDs::Lisp);
  TextBuffer* buf=new TextBuffer(synt);
  setTextBuffer(buf);
  setApplicationCommandManagerToWatch(buf->manager);
  setResizable(true, true); 
  // set buffer to standard 74 column width.  + 10 adds space for
  // scrollers to avoid linewrap when scoller appears :/
  centreWithSize(buf->getFont().getStringWidth(T("M"))*74+10, 400); 
  setUsingNativeTitleBar(true);
  setDropShadowEnabled(true);
  setWantsKeyboardFocus(false);  // Buffer has it.
  buf->setFile(file);
  buf->setText(text);
  if (title.isEmpty())
    buf->updateWindowTitle();
  else
    setName(title);

  // flag may have been set by loading editor.
  buf->clearFlag(EditFlags::NeedsSave);
  // arrrrg give up on large buffers since text coloring in juce editors is so slow
  if (size>20000)
    {
      Console::getInstance()->printWarning(T("Cowardly refusing to colorize large buffer for ") + getName().quoted() + T(".\n"));
      buf->setFlag(EditFlags::HiliteOff);
    }
  setVisible(true);
  buf->colorizeAll();
}
Example #9
0
 MainMenuModel()
 {
     setApplicationCommandManagerToWatch (&getCommandManager());
 }
Example #10
0
MainMenuModel::MainMenuModel(ApplicationCommandManager *commandManager)
{
	setApplicationCommandManagerToWatch(commandManager);
	this->commandManager = commandManager;
}