TextBuffer::TextBuffer(int texttype) : file (File::nonexistent), flags (0), prev (0), thisid (0), matchpos (-1) { // set syntax right away since commands manager needs this // information for adding commands isfms = (texttype == TextIDs::Fomus); setSyntax(texttype); Preferences* prefs=Preferences::getInstance(); manager=new ApplicationCommandManager(); setFont(Font(Font::getDefaultMonospacedFontName(), (float)prefs->getIntProp(T("EditorFontSize"), 16), Font::plain)); if (prefs->getBoolProp("EditorEmacsMode", false)) setFlag(EditFlags::EmacsMode); addKeyListener(manager->getKeyMappings()); addKeyListener(CommandManager::getInstance()->getKeyMappings()); manager->registerAllCommandsForTarget(this); setWantsKeyboardFocus(true); setMultiLine(true); setReturnKeyStartsNewLine(true); setCaretPosition(0); setVisible(true); // add callback for registering changes. //addListener(&listener); }
ItemContainer::ItemContainer(Inventory *inventory, bool forceQuantity): mInventory(inventory), mGridColumns(1), mGridRows(1), mSelectedIndex(-1), mHighlightedIndex(-1), mLastUsedSlot(-1), mSelectionStatus(SEL_NONE), mForceQuantity(forceQuantity), mSwapItems(false), mDescItems(false), mTag(0), mSortType(0), mItemPopup(new ItemPopup), mShowMatrix(nullptr), mClicks(1), mEquipedColor(Theme::getThemeColor(Theme::ITEM_EQUIPPED)), mUnEquipedColor(Theme::getThemeColor(Theme::ITEM_NOT_EQUIPPED)) { setFocusable(true); mSelImg = Theme::getImageFromTheme("selection.png"); if (!mSelImg) logger->log1("Error: Unable to load selection.png"); addKeyListener(this); addMouseListener(this); addWidgetListener(this); }
//============================================================================== MainContentComponent::MainContentComponent() { selectedGame = 1; setWantsKeyboardFocus(true); addKeyListener(this); games.insert(-1, new FroggerGame(this, "Frogger")); games.insert(-1, new TowerGame(this, "Tower")); addAndMakeVisible(&combo); for (int i = 0; i < games.size(); i++) { combo.addItem(games[i]->getName(), i+1); addChildComponent(games[i]); } games[selectedGame]->setVisible(true); combo.setSelectedItemIndex(selectedGame); combo.addListener(this); startTimer(50); setSize (500, 650); }
WorldSelectDialog::WorldSelectDialog(Worlds worlds): Window(_("Select World")) { mWorldListModel = new WorldListModel(worlds); mWorldList = new ListBox(mWorldListModel); ScrollArea *worldsScroll = new ScrollArea(mWorldList); mChangeLoginButton = new Button(_("Change Login"), "login", this); mChooseWorld = new Button(_("Choose World"), "world", this); worldsScroll->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER); place(0, 0, worldsScroll, 3, 5).setPadding(2); place(1, 5, mChangeLoginButton); place(2, 5, mChooseWorld); // Make sure the list has enough height getLayout().setRowHeight(0, 60); reflowLayout(0, 0); if (worlds.size() == 0) // Disable Ok button mChooseWorld->setEnabled(false); else // Select first server mWorldList->setSelected(0); addKeyListener(this); center(); setVisible(true); mChooseWorld->requestFocus(); }
ItemContainer::ItemContainer(Inventory *inventory, bool forceQuantity): mInventory(inventory), mGridColumns(1), mGridRows(1), mSelectedIndex(-1), mHighlightedIndex(-1), mLastUsedSlot(-1), mSelectionStatus(SEL_NONE), mForceQuantity(forceQuantity), mSwapItems(false), mDescItems(false) { mItemPopup = new ItemPopup; setFocusable(true); ResourceManager *resman = ResourceManager::getInstance(); mSelImg = resman->getImage("graphics/gui/selection.png"); if (!mSelImg) logger->error("Unable to load selection.png"); addKeyListener(this); addMouseListener(this); addWidgetListener(this); }
//-------------------------------------------------------------- // constructor mgSimpleField::mgSimpleField( mgControl* parent, const char* cntlName) : mgFieldControl(parent, cntlName) { m_displayCount = 20; // default m_cursorPosn = 0; m_scrollPosn = 0; m_insertMode = true; m_changed = false; m_history = NULL; // not enabled mgStyle* style = getStyle(); // assume style has set all our format elements style->getFontAttr(MG_STYLE_FIELD, getName(), "font", m_font); style->getFrameAttr(MG_STYLE_FIELD, getName(), "upFrame", m_upFrame); style->getFrameAttr(MG_STYLE_FIELD, getName(), "hoverFrame", m_hoverFrame); style->getFrameAttr(MG_STYLE_FIELD, getName(), "downFrame", m_downFrame); style->getFrameAttr(MG_STYLE_FIELD, getName(), "disFrame", m_disFrame); style->getColorAttr(MG_STYLE_FIELD, getName(), "upColor", m_upColor); style->getColorAttr(MG_STYLE_FIELD, getName(), "hoverColor", m_hoverColor); style->getColorAttr(MG_STYLE_FIELD, getName(), "downColor", m_downColor); style->getColorAttr(MG_STYLE_FIELD, getName(), "disColor", m_disColor); m_hasMouse = false; m_changeListeners = NULL; addMouseListener((mgMouseListener*) this); addKeyListener((mgKeyListener*) this); addFocusListener((mgFocusListener*) this); }
GuiTable::GuiTable(const Widget2 *const widget, TableModel *const initial_model, const bool opacity) : Widget(widget), MouseListener(), KeyListener(), mModel(nullptr), mTopWidget(nullptr), mActionListeners2(), mHighlightColor(getThemeColor(ThemeColorId::HIGHLIGHT)), mSelectedRow(-1), mSelectedColumn(-1), mLinewiseMode(false), mWrappingEnabled(false), mOpaque(opacity), mSelectable(true) { mAllowLogic = false; mBackgroundColor = getThemeColor(ThemeColorId::BACKGROUND); setModel(initial_model); setFocusable(true); addMouseListener(this); addKeyListener(this); }
MainAppWindow::MainAppWindow() : DocumentWindow (JUCEApplication::getInstance()->getApplicationName(), Colours::lightgrey, DocumentWindow::allButtons) { setUsingNativeTitleBar (true); setResizable (true, false); setResizeLimits (400, 400, 10000, 10000); #if JUCE_IOS || JUCE_ANDROID setFullScreen (true); #else setBounds ((int) (0.1f * getParentWidth()), (int) (0.1f * getParentHeight()), jmax (850, (int) (0.5f * getParentWidth())), jmax (600, (int) (0.7f * getParentHeight()))); #endif contentComponent = new ContentComponent(); setContentNonOwned (contentComponent, false); setVisible (true); // this lets the command manager use keypresses that arrive in our window to send out commands addKeyListener (getApplicationCommandManager().getKeyMappings()); #if JUCE_WINDOWS || JUCE_LINUX || JUCE_MAC taskbarIcon = new DemoTaskbarComponent(); #endif #if JUCE_ANDROID setOpenGLRenderingEngine(); #endif triggerAsyncUpdate(); }
//============================================================================== MainContentComponent::MainContentComponent() { addKeyListener(this); addAndMakeVisible (&custom); setSize (custom.getWidth(), custom.getHeight()); }
CharacterViewSmall::CharacterViewSmall(CharSelectDialog *const widget, std::vector<CharacterDisplay*> *const entries, const int padding) : CharacterViewBase(widget, padding), mSelectedEntry(nullptr), mPrevious(new Button(this, "<", "prev", this)), mNext(new Button(this, ">", "next", this)), mNumber(new Label(this, "??")), mCharacterEntries(entries) { addKeyListener(widget); if (entries) { FOR_EACHP (std::vector<CharacterDisplay*>::iterator, it, entries) { add(*it); } const int sz = static_cast<signed>(mCharacterEntries->size()); mSelected = 0; mSelectedEntry = (*mCharacterEntries)[mSelected]; mSelectedEntry->setVisible(true); mNumber->setCaption(strprintf("%d / %d", mSelected + 1, sz)); mNumber->adjustSize(); }
TabbedArea::TabbedArea(const Widget2 *const widget) : ActionListener(), BasicContainer(widget), KeyListener(), MouseListener(), WidgetListener(), mArrowButton(), mSelectedTab(nullptr), mTabContainer(new BasicContainer2(widget)), mWidgetContainer(new BasicContainer2(widget)), mTabsToDelete(), mTabs(), mTabsWidth(0), mVisibleTabsWidth(0), mTabScrollIndex(0), mRightMargin(0), mOpaque(Opaque_false), mEnableScrollButtons(false), mFollowDownScroll(false), mBlockSwitching(true), mResizeHeight(true) { setFocusable(true); addKeyListener(this); addMouseListener(this); }
void Slider::init() { mAllowLogic = false; setFocusable(true); setFrameSize(1); addMouseListener(this); addKeyListener(this); setFrameSize(0); // Load resources if (mInstances == 0) { if (theme) { for (int mode = 0; mode < 2; mode ++) theme->loadRect(buttons[mode], data[mode], "slider.xml", 0, 8); } updateAlpha(); } mInstances++; if (buttons[0].grid[HGRIP]) setMarkerLength(buttons[0].grid[HGRIP]->getWidth()); }
MLAppWindow::MLAppWindow() : mpAppView(0), DocumentWindow (MLProjectInfo::projectName, Colour::fromHSV(0.5f, 0.0f, 0.30f, 1.f), DocumentWindow::allButtons, true), mpConstrainer(0), mUsingGL(false), mGridUnitsX(0.), mGridUnitsY(0.) { setResizable(true, false); setResizeLimits (400, 300, 8192, 8192); commandManager.registerAllCommandsForTarget (JUCEApplication::getInstance()); // this lets the command manager use keypresses that arrive in our window to send // out commands addKeyListener (commandManager.getKeyMappings()); mpBorder = std::unique_ptr<MLAppBorder>(new MLAppBorder()); setContentOwned(mpBorder.get()->getComponent(), false); mpConstrainer = new MLBoundsConstrainer(); setConstrainer (mpConstrainer); setUsingNativeTitleBar (true); // tells our menu bar model that it should watch this command manager for // changes, and send change messages accordingly. //&mBorder->setApplicationCommandManagerToWatch (&commandManager); //setVisible (true); }
TabbedArea::TabbedArea(bool hide) : Container(), mHideWhenOneTab(hide), mSelectedTab(NULL) { setFocusable(false); addKeyListener(this); addMouseListener(this); mTabContainer = new Container(); mTabContainer->setOpaque(false); mWidgetContainer = new Container(); mWidgetContainer->setOpaque(false); add(mTabContainer); add(mWidgetContainer); mProtFocusListener = new ProtectedFocusListener(); addFocusListener(mProtFocusListener); mProtFocusListener->blockKey(SDLK_LEFT); mProtFocusListener->blockKey(SDLK_RIGHT); mProtFocusListener->blockKey(SDLK_UP); mProtFocusListener->blockKey(SDLK_DOWN); }
CtrlrLuaMethodEditor::CtrlrLuaMethodEditor (CtrlrPanel &_owner) : owner(_owner), methodEditArea (nullptr), methodTree(nullptr), resizer(nullptr), caseCansitive(true), lookInString("Current"), searchInString("Editor"), findDialogActive(false), currentSearchString(String::empty) { addAndMakeVisible (resizer = new StretchableLayoutResizerBar (&layoutManager, 1, true)); addAndMakeVisible (methodTree = new CtrlrValueTreeEditorTree ("LUA METHOD TREE")); addAndMakeVisible (methodEditArea = new CtrlrLuaMethodEditArea(*this)); methodTree->setRootItem (new CtrlrValueTreeEditorItem(*this, getMethodManager().getManagerTree(), Ids::luaMethodName)); getMethodManager().setMethodEditor (this); methodTree->setMultiSelectEnabled (true); layoutManager.setItemLayout (0, -0.001, -1.0, -0.29); layoutManager.setItemLayout (1, 8, 8, 8); layoutManager.setItemLayout (2, -0.001, -1.0, -0.69); addKeyListener (this); getMethodManager().setMethodEditor (this); componentTree.addListener (this); setSize (700, 600); }
//============================================================================== MainContentComponent::MainContentComponent() { setSize (500, 400); load_but = new TextButton(("play")); (*load_but).setBounds(10, 10, 50, 20); addAndMakeVisible(load_but); (*load_but).addListener(this); calc_but = new TextButton(("Calc.")); (*calc_but).setBounds(100, 10, 50, 20); addAndMakeVisible(calc_but); (*calc_but).addListener(this); addKeyListener(this); setWantsKeyboardFocus(true); out_buf = new float[512]; key_count = 7; // amount of notes in tuning (per octave?) <-- maak een slider voor keuze aantal tonen? mirror_tuning = true; // invert intervals around 3/2 <-- maak schakelaar voor keuze inverteren? peak_tresh = 0.01; // peakdetection treshold <-- maak een slider/draaiknop voor treshold? }
InventoryWindow::InventoryWindow(int invSize): Window(_("Inventory")), mMaxSlots(invSize), mSplit(false), mItemDesc(false) { setWindowName("Inventory"); setResizable(true); setCloseButton(true); setSaveVisible(true); setDefaultSize(387, 307, ImageRect::CENTER); setMinWidth(316); setMinHeight(179); addKeyListener(this); std::string longestUseString = getFont()->getWidth(_("Equip")) > getFont()->getWidth(_("Use")) ? _("Equip") : _("Use"); if (getFont()->getWidth(longestUseString) < getFont()->getWidth(_("Unequip"))) { longestUseString = _("Unequip"); } mUseButton = new Button(longestUseString, "use", this); mDropButton = new Button(_("Drop"), "drop", this); mSplitButton = new Button(_("Split"), "split", this); mItems = new ItemContainer(player_node->getInventory()); mItems->addSelectionListener(this); gcn::ScrollArea *invenScroll = new ScrollArea(mItems); invenScroll->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER); mTotalWeight = -1; mMaxWeight = -1; mUsedSlots = -1; mSlotsLabel = new Label(_("Slots:")); mWeightLabel = new Label(_("Weight:")); mSlotsBar = new ProgressBar(0.0f, 100, 20, gcn::Color(225, 200, 25)); mWeightBar = new ProgressBar(0.0f, 100, 20, gcn::Color(0, 0, 255)); place(0, 0, mWeightLabel).setPadding(3); place(1, 0, mWeightBar, 3); place(4, 0, mSlotsLabel).setPadding(3); place(5, 0, mSlotsBar, 2); place(0, 1, invenScroll, 7).setPadding(3); place(0, 2, mUseButton); place(1, 2, mDropButton); place(2, 2, mSplitButton); Layout &layout = getLayout(); layout.setRowHeight(1, Layout::AUTO_SET); loadWindowState(); }
//================================================================================================= 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); }
CheckBox::CheckBox() { setMarked(false); setFocusable(true); addMouseListener(this); addKeyListener(this); }
RadioButton::RadioButton() { setSelected(false); setFocusable(true); addMouseListener(this); addKeyListener(this); }
Moblet::Moblet() : mRun(true) { //printf("Moblet::Moblet - %x", this); //environment = this; addKeyListener(this); addPointerListener(this); addCloseListener(this); addCustomEventListener(this); }
CheckBox::CheckBox() { setSelected(false); SetFocusable(true); addMouseListener(this); addKeyListener(this); }
FFScrollArea::FFScrollArea() { setScrollPolicy(ShowNever, ShowNever); addKeyListener(this); setFocusable(false); setFrameSize(0); }
CharSelectDialog::CharSelectDialog(LoginData *loginData): Window(_("Account and Character Management")), mLocked(false), mUnregisterButton(0), mChangeEmailButton(0), mCharacterEntries(0), mLoginData(loginData), mCharHandler(Net::getCharHandler()) { setCloseButton(false); mAccountNameLabel = new Label(loginData->username); mSwitchLoginButton = new Button(_("Switch Login"), "switch", this); mChangePasswordButton = new Button(_("Change Password"), "change_password", this); int optionalActions = Net::getLoginHandler()->supportedOptionalActions(); ContainerPlacer place; place = getPlacer(0, 0); place(0, 0, mAccountNameLabel, 2); place(0, 1, mSwitchLoginButton); if (optionalActions & Net::LoginHandler::Unregister) { mUnregisterButton = new Button(_("Unregister"), "unregister", this); place(3, 1, mUnregisterButton); } place(0, 2, mChangePasswordButton); if (optionalActions & Net::LoginHandler::ChangeEmail) { mChangeEmailButton = new Button(_("Change Email"), "change_email", this); place(3, 2, mChangeEmailButton); } place = getPlacer(0, 1); for (int i = 0; i < (int)mLoginData->characterSlots; i++) { mCharacterEntries.push_back(new CharacterDisplay(this)); place(i % SLOTS_PER_ROW, (int)i / SLOTS_PER_ROW, mCharacterEntries[i]); } reflowLayout(); addKeyListener(this); center(); setVisible(true); Net::getCharHandler()->setCharSelectDialog(this); mCharacterEntries[0]->requestFocus(); }
MultiSelector::MultiSelector() : mCurrentSelection(0), mFrameCounter(0) { setFocusable(true); mSelectorImage = gcn::Image::load(ResourceHandler::getInstance()->getRealFilename("menu-selector.bmp")); addKeyListener(this); }
GlassCanvas::GlassCanvas() : GlassContainer(), GlassWidget(this) { setOpaque(false); //for GlassWidget addActionListener(this); addMouseListener(this); addFocusListener(this); addKeyListener(this); }
//============================================================================== 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 }
ClickLabel::ClickLabel() { mGuiFont = static_cast<FIFE::GuiFont*> (getFont()); // setAlignment(Graphics::LEFT); setTextWrapping(false); setFrameSize(0); addMouseListener(this); addKeyListener(this); addFocusListener(this); }
ListBox::ListBox(ListModel *listModel) { mSelected = -1; setWidth(100); setListModel(listModel); setFocusable(true); addMouseListener(this); addKeyListener(this); }
PointEditor::PointEditor() { selectedPoint = -1; addKeyListener(this); setWantsKeyboardFocus(true); paintTransport = false; paintTransportExternal = false; }