void CSVWorld::GenericCreator::create() { if (!mLocked) { if (mCloneMode) { std::string id = getId(); std::auto_ptr<CSMWorld::CloneCommand> command (new CSMWorld::CloneCommand ( dynamic_cast<CSMWorld::IdTable&> (*mData.getTableModel(mListId)), mClonedId, id, mClonedType)); mUndoStack.push(command.release()); emit done(); emit requestFocus(id); } else { std::string id = getId(); std::auto_ptr<CSMWorld::CreateCommand> command (new CSMWorld::CreateCommand ( dynamic_cast<CSMWorld::IdTable&> (*mData.getTableModel (mListId)), id)); configureCreateCommand (*command); mUndoStack.push (command.release()); emit done(); emit requestFocus (id); } } }
// called from Client after FocusIn that wasn't initiated by KWin and the client // wasn't allowed to activate void Workspace::restoreFocus() { // this updateXTime() is necessary - as FocusIn events don't have // a timestamp *sigh*, twin's timestamp would be older than the timestamp // that was used by whoever caused the focus change, and therefore // the attempt to restore the focus would fail due to old timestamp updateXTime(); if( should_get_focus.count() > 0 ) requestFocus( should_get_focus.last()); else if( last_active_client ) requestFocus( last_active_client ); }
MessageDialog::MessageDialog(Widget *parent, Type type, const std::string &title, const std::string &message, const std::string &buttonText, const std::string &altButtonText, bool altButton) : Window(parent, title) { setLayout(new BoxLayout(Orientation::Vertical, Alignment::Middle, 10, 10)); setModal(true); Widget *panel1 = new Widget(this); panel1->setLayout(new BoxLayout(Orientation::Horizontal, Alignment::Middle, 10, 15)); int icon = 0; switch (type) { case Type::Information: icon = ENTYPO_ICON_CIRCLED_INFO; break; case Type::Question: icon = ENTYPO_ICON_CIRCLED_HELP; break; case Type::Warning: icon = ENTYPO_ICON_WARNING; break; } Label *iconLabel = new Label(panel1, std::string(utf8(icon).data()), "icons"); iconLabel->setFontSize(50); Label *msgLabel = new Label(panel1, message); msgLabel->setFixedWidth(200); Widget *panel2 = new Widget(this); panel2->setLayout(new BoxLayout(Orientation::Horizontal, Alignment::Middle, 0, 15)); if (altButton) { Button *button = new Button(panel2, altButtonText, ENTYPO_ICON_CIRCLED_CROSS); button->setCallback([&] { if (mCallback) mCallback(1); dispose(); }); } Button *button = new Button(panel2, buttonText, ENTYPO_ICON_CHECK); button->setCallback([&] { if (mCallback) mCallback(0); dispose(); }); center(); requestFocus(); }
void Workspace::setCurrentScreen( int new_screen ) { if (new_screen < 0 || new_screen > numScreens()) return; if ( !options->focusPolicyIsReasonable()) return; closeActivePopup(); Client* get_focus = NULL; for( ClientList::ConstIterator it = focus_chain[currentDesktop()].fromLast(); it != focus_chain[currentDesktop()].end(); --it ) { if( !(*it)->isShown( false ) || !(*it)->isOnCurrentDesktop()) continue; if( !(*it)->screen() == new_screen ) continue; get_focus = *it; break; } if( get_focus == NULL ) get_focus = findDesktop( true, currentDesktop()); if( get_focus != NULL && get_focus != mostRecentlyActivatedClient()) requestFocus( get_focus ); active_screen = new_screen; }
bool DictApplet::eventFilter( QObject *o, QEvent * e) { if (e->type() == QEvent::MouseButtonRelease) emit requestFocus(); return KPanelApplet::eventFilter(o, e); }
void CSVWorld::GenericCreator::create() { if (!mLocked) { std::string id = getId(); std::unique_ptr<CSMWorld::CreateCommand> command; if (mCloneMode) { command.reset (new CSMWorld::CloneCommand ( dynamic_cast<CSMWorld::IdTable&> (*mData.getTableModel(mListId)), mClonedId, id, mClonedType)); } else { command.reset (new CSMWorld::CreateCommand ( dynamic_cast<CSMWorld::IdTable&> (*mData.getTableModel (mListId)), id)); } configureCreateCommand (*command); pushCommand (std::move(command), id); emit done(); emit requestFocus(id); } }
void TabbedArea::mousePressed(MouseEvent& mouseEvent) { if (mouseEvent.isConsumed()) { return; } if (mouseEvent.getButton() == MouseEvent::LEFT) { Widget* widget = mTabContainer->getWidgetAt(mouseEvent.getX(), mouseEvent.getY()); Tab* tab = dynamic_cast<Tab*>(widget); if (tab != NULL) { setSelectedTab(tab); } } // Request focus only if the source of the event // is not focusble. If the source of the event // is focused we don't want to steal the focus. if (!mouseEvent.getSource()->isFocusable()) { requestFocus(); } }
void Workspace::setCurrentScreen(int new_screen) { if (new_screen < 0 || new_screen >= numScreens()) return; if (!options->focusPolicyIsReasonable()) return; closeActivePopup(); Client* get_focus = NULL; for (int i = focus_chain[ currentDesktop()].count() - 1; i >= 0; --i) { Client* ci = focus_chain[ currentDesktop()].at(i); if (!ci->isShown(false) || !ci->isOnCurrentDesktop() || !ci->isOnCurrentActivity()) continue; if (!ci->screen() == new_screen) continue; get_focus = ci; break; } if (get_focus == NULL) get_focus = findDesktop(true, currentDesktop()); if (get_focus != NULL && get_focus != mostRecentlyActivatedClient()) requestFocus(get_focus); active_screen = new_screen; }
// deactivates 'c' and activates next client bool Workspace::activateNextClient( Client* c ) { // if 'c' is not the active or the to-become active one, do nothing if( !( c == active_client || ( should_get_focus.count() > 0 && c == should_get_focus.last()))) return false; closeActivePopup(); if( c != NULL ) { if( c == active_client ) setActiveClient( NULL, Allowed ); should_get_focus.removeAll( c ); } if( focusChangeEnabled()) { if ( options->focusPolicyIsReasonable()) { // search the focus_chain for a client to transfer focus to, // first try to transfer focus to the first suitable window in the group Client* get_focus = NULL; const ClientList windows = ( c != NULL ? c->group()->members() : ClientList()); for ( int i = focus_chain[ currentDesktop() ].size() - 1; i >= 0; --i ) { Client* ci = focus_chain[ currentDesktop() ].at( i ); if( c == ci || !ci->isShown( false ) || !ci->isOnCurrentDesktop()) continue; if( options->separateScreenFocus ) { if( c != NULL && !ci->isOnScreen( c->screen())) continue; if( c == NULL && !ci->isOnScreen( activeScreen())) continue; } if( windows.contains( ci )) { get_focus = ci; break; } if( get_focus == NULL ) get_focus = ci; } if( get_focus == NULL ) get_focus = findDesktop( true, currentDesktop()); if( get_focus != NULL ) requestFocus( get_focus ); else focusToNull(); } else return false; } else // if blocking focus, move focus to the desktop later if needed // in order to avoid flickering focusToNull(); return true; }
bool TextBox::mouseButtonEvent(const Vector2i &p, int button, bool down, int modifiers) { if (button == SDL_BUTTON_LEFT && down && !mFocused) { if (!mSpinnable || spinArea(p) == SpinArea::None) /* not on scrolling arrows */ requestFocus(); } if (mEditable && focused()) { if (down) { mMouseDownPos = p; mMouseDownModifier = modifiers; double time = SDL_GetTicks(); if (time - mLastClick < 0.25) { /* Double-click: select all text */ mSelectionPos = 0; mCursorPos = (int) mValueTemp.size(); mMouseDownPos = Vector2i(-1, -1); } mLastClick = time; } else { mMouseDownPos = Vector2i(-1, -1); mMouseDragPos = Vector2i(-1, -1); } return true; } else if (mSpinnable && !focused()) { if (down) { if (spinArea(p) == SpinArea::None) { mMouseDownPos = p; mMouseDownModifier = modifiers; double time = SDL_GetTicks(); if (time - mLastClick < 0.25) { /* Double-click: reset to default value */ mValue = mDefaultValue; if (mCallback) mCallback(mValue); mMouseDownPos = Vector2i(-1, -1); } mLastClick = time; } else { mMouseDownPos = Vector2i(-1, -1); mMouseDragPos = Vector2i(-1, -1); } } else { mMouseDownPos = Vector2i(-1, -1); mMouseDragPos = Vector2i(-1, -1); } return true; } return false; }
bool Widget::mouseButtonEvent(const Vector2i &p, int button, bool down, int modifiers) { for (auto it = mChildren.rbegin(); it != mChildren.rend(); ++it) { Widget *child = *it; if (child->visible() && child->contains(p - mPos) && child->mouseButtonEvent(p - mPos, button, down, modifiers)) return true; } if (button == GLFW_MOUSE_BUTTON_1 && down && !mFocused) requestFocus(); return false; }
void Window::mousePressed(gcn::MouseEvent &event) { // Let Guichan move window to top and figure out title bar drag gcn::Window::mousePressed(event); if (event.getButton() == gcn::MouseEvent::LEFT) { // Handle window resizing mouseResize = getResizeHandles(event); if (event.getSource() == this) requestFocus(); } }
/** * Called if the chat input loses focus. It will set itself to * invisible as result. */ void focusLost(const gcn::Event &event) { TextField::focusLost(event); if (mFocusGaining || !config.getBoolValue("protectChatFocus")) { processVisible(false); if (chatWindow) chatWindow->updateVisibility(); mFocusGaining = false; return; } mFocusGaining = true; requestFocus(); mFocusGaining = false; }
boolean JListBox::mouseDown(JEvent& e, int x, int y) { if ((e.id == JEvent::MOUSE_DOWN) && (e.modifiers & JEvent::LBUTTON)) { if (e.modifiers & JEvent::DBCLK_MASK) { JEvent event(this, JEvent::ACTION_EVENT); event.key = -1; postJEvent(event); return true; } mousePressed = true; requestFocus(); setCursor(positionToCursor(y)); select(cursor); } return true; }
void TabbedArea::mousePressed(gcn::MouseEvent &mouseEvent) { if (mouseEvent.isConsumed()) return; if (mouseEvent.getButton() == gcn::MouseEvent::LEFT) { gcn::Widget *widget = mTabContainer->getWidgetAt(mouseEvent.getX(), mouseEvent.getY()); gcn::Tab *tab = dynamic_cast<gcn::Tab*>(widget); if (tab) { setSelectedTab(tab); requestFocus(); } } }
bool TextField::onTouchBegan(Touch *touch, Event *unusedEvent) { bool pass = Widget::onTouchBegan(touch, unusedEvent); if (_hitted) { if (isFocusEnabled()) { requestFocus(); } _textFieldRenderer->attachWithIME(); } else { this->didNotSelectSelf(); } return pass; }
void Menu::init() { mGameSelectContainer->setVisible(false); mEraseLabel->setVisible(true); mCancelLabel->setVisible(false); mEraseGameLabel->setVisible(false); mSelectGameLabel->setVisible(true); mMainMultiSelector->requestFocus(); mQueryMultiSelector->setVisible(false); mQueryEraseLabel->setVisible(false); mNoLabel->setVisible(false); mYesLabel->setVisible(false); mStartContainer->setVisible(true); mMainMultiSelector->setSelected(0); requestFocus(); }
void Window::widgetShown(const gcn::Event& event) { mVisible = true; requestMoveToTop(); requestFocus(); int widgetX, widgetY; getAbsolutePosition(widgetX, widgetY); widgetX = gui->getMouseX() - widgetX; widgetY = gui->getMouseY() - widgetY; if (getChildrenArea().isPointInRect(widgetX, widgetY)) { gcn::MouseEvent mouseEvent(this, false, false, false, false, gcn::MouseEvent::MOVED, 0, widgetX, widgetY, 0); mouseMoved(mouseEvent); } }
void NpcDialog::postInit() { Window::postInit(); setVisible(Visible_true); requestFocus(); enableVisibleSound(true); soundManager.playGuiSound(SOUND_SHOW_WINDOW); if (actorManager) { const Being *const being = actorManager->findBeing(mNpcId); if (being) { showAvatar(NPCDB::getAvatarFor(fromInt( being->getSubType(), BeingTypeId))); setCaption(being->getName()); } } config.addListener("logNpcInGui", this); }
bool Console::mouseButtonEvent(const Vector2i &p, int button, bool down, int modifiers) { //std::cout << "mouseButtonEvent " << p.x()<<","<<p.y() << " " << button << " " << // down << " " << modifiers << std::endl; if (button == GLFW_MOUSE_BUTTON_1 && down && !mFocused) { requestFocus(); } if (focused()) { if (down) { mMouseDownPos = p; mMouseDownModifier = modifiers; } else { mMouseDownPos = Vector2i(-1, -1); mMouseDragPos = Vector2i(-1, -1); } return true; } return false; }
void DolphinViewContainer::slotUrlNavigatorLocationChanged(const KUrl& url) { if (KProtocolManager::supportsListing(url)) { setSearchModeEnabled(isSearchUrl(url)); m_view->setUrl(url); if (isActive() && !isSearchUrl(url)) { // When an URL has been entered, the view should get the focus. // The focus must be requested asynchronously, as changing the URL might create // a new view widget. QTimer::singleShot(0, this, SLOT(requestFocus())); } } else if (KProtocolManager::isSourceProtocol(url)) { QString app = "konqueror"; if (url.protocol().startsWith(QLatin1String("http"))) { showErrorMessage(i18nc("@info:status", "Dolphin does not support web pages, the web browser has been launched")); const KConfigGroup config(KSharedConfig::openConfig("kdeglobals"), "General"); const QString browser = config.readEntry("BrowserApplication"); if (!browser.isEmpty()) { app = browser; if (app.startsWith('!')) { // a literal command has been configured, remove the '!' prefix app = app.mid(1); } } } else { showErrorMessage(i18nc("@info:status", "Protocol not supported by Dolphin, Konqueror has been launched")); } const QString secureUrl = KShell::quoteArg(url.pathOrUrl()); const QString command = app + ' ' + secureUrl; KRun::runCommand(command, app, app, this); } else { showErrorMessage(i18nc("@info:status", "Invalid protocol")); } }
void PopupMenu::showPopup(int x, int y) { mModel->clear(); if (mType < BEING) { if (mFloorItem && mType == FLOOR_ITEM) mItem = mFloorItem->getItem(); if (!mItem) return; const std::string &name = mItem->getName(); if (mType <= INVENTORY) { if (mItem->isEquipment()) { if (mItem->isEquipped()) mModel->addLink("use", _("Unequip")); else mModel->addLink("use", _("Equip")); } else mModel->addLink("use", _("Use")); mModel->addLink("drop", _("Drop")); if (tradeWindow && tradeWindow->canTrade() && !tradeWindow->tradingItem(mItem)) mModel->addLink("tradeitem", _("Trade")); if (storageWindow && storageWindow->isVisible()) mModel->addLink("store", _("Store")); if (mType == INVENTORY) mModel->addLink("slotitem", _("Add to Item Shortcuts")); } else if (mType == STORAGE) mModel->addLink("retrieve", _("Retrieve")); else if (mType == FLOOR_ITEM) mModel->addLink("pickup", strprintf(_("Pick Up %s"), name.c_str())); if (mType < FLOOR_ITEM) { if (config.getValue("showItemPopups", true)) mModel->addLink("hideitempopup", _("Hide Item Info")); else mModel->addLink("showitempopup", _("Show Item Info")); } mModel->addLink("chat", _("Add to Chat")); } else if (mType == BEING) { if (!mBeing) return; // Any being's name can be added to chat mModel->addLink("name", _("Add name to chat")); const std::string &name = mBeing->getType() == Being::NPC ? mBeing->getName().substr(0, mBeing->getName().size() - 6) : mBeing->getName(); switch (mBeing->getType()) { case Being::PLAYER: { // Players can be traded with. Later also follow and // add as buddy will be options in this menu. mModel->addLink("trade", strprintf(_("Trade With %s"), name.c_str())); mModel->addLink("attack", strprintf(_("Attack %s"), name.c_str())); mModel->addLink("", "---"); switch (player_relations.getRelation(name)) { case PlayerRelation::NEUTRAL: mModel->addLink("friend", strprintf(_("Befriend %s"), name.c_str())); case PlayerRelation::FRIEND: mModel->addLink("disregard", strprintf(_("Disregard %s"), name.c_str())); mModel->addLink("ignore", strprintf(_("Ignore %s"), name.c_str())); break; case PlayerRelation::IGNORED: mModel->addLink("unignore", strprintf(_("Un-Ignore %s"), name.c_str())); case PlayerRelation::DISREGARDED: mModel->addLink("ignore", strprintf(_("Completely ignore %s"), name.c_str())); break; } //mModel->addLink("follow", _(strprintf("Follow %s"), name.c_str())); /*mModel->addLink("", "---"); mModel->addLink("party", strprintf(_("Invite %s to party"), name.c_str()));*/ } break; case Being::NPC: // NPCs can be talked to (single option, candidate for removal // unless more options would be added) mModel->addLink("talk", strprintf(_("Talk To %s"), name.c_str())); break; case Being::MONSTER: // Monsters can be attacked mModel->addLink("attack", strprintf(_("Attack %s"), name.c_str())); break; default: /* Other beings aren't interesting... */ return; } } else if (mType == EMOTE) { if (mEmote != -1) { mModel->addLink("useemote", _("Use")); mModel->addLink("slotemote", _("Add to Emote Shortcuts")); } } mModel->addLink("", "---"); mModel->addLink("cancel", _("Cancel")); mMappedListBox->adjustSize(); setContentSize(mMappedListBox->getWidth() + (2 * getPadding()), mMappedListBox->getHeight() + getPadding()); if (graphics->getWidth() < (x + getWidth())) x = graphics->getWidth() - getWidth(); if (graphics->getHeight() < (y + getHeight())) y = graphics->getHeight() - getHeight(); setPosition(x, y); setVisible(true); requestFocus(); requestMoveToTop(); }
void Widget::_mouseInputMessage(const MouseInput& mouseInput) { if (mFocusHandler == NULL) { //throw GCN_EXCEPTION("No focushandler set (did you add the widget to the gui?)."); assert(!"No focushandler set (did you add the widget to the gui?)."); } if (!mEnabled || (mFocusHandler->getModalFocused() != NULL && !hasModalFocus())) { return; } int x = mouseInput.x; int y = mouseInput.y; int b = mouseInput.getButton(); int ts = mouseInput.getTimeStamp(); MouseListenerIterator iter; switch(mouseInput.getType()) { case MouseInput::MOTION: for (iter = mMouseListeners.begin(); iter != mMouseListeners.end(); ++iter) { (*iter)->mouseMotion(x, y); } break; case MouseInput::PRESS: if (hasMouse()) { requestFocus(); mFocusHandler->requestDrag(this); } if (b != MouseInput::WHEEL_UP && b != MouseInput::WHEEL_DOWN) { for (iter = mMouseListeners.begin(); iter != mMouseListeners.end(); ++iter) { (*iter)->mousePress(x, y, b); } if (hasMouse()) { if (ts - mClickTimeStamp < 300 && mClickButton == b) { mClickCount++; } else { mClickCount = 0; } mClickButton = b; mClickTimeStamp = ts; } else { mClickButton = 0; } } else if (b == MouseInput::WHEEL_UP) { for (iter = mMouseListeners.begin(); iter != mMouseListeners.end(); ++iter) { (*iter)->mouseWheelUp(x, y); } } else { for (iter = mMouseListeners.begin(); iter != mMouseListeners.end(); ++iter) { (*iter)->mouseWheelDown(x, y); } } setDirty(true); break; case MouseInput::RELEASE: if (isDragged()) { mFocusHandler->dragNone(); } if (b != MouseInput::WHEEL_UP && b != MouseInput::WHEEL_DOWN) { for (iter = mMouseListeners.begin(); iter != mMouseListeners.end(); ++iter) { (*iter)->mouseRelease(x, y, b); } } if (mHasMouse) { if (b == mClickButton) { for (iter = mMouseListeners.begin(); iter != mMouseListeners.end(); ++iter) { (*iter)->mouseClick(x, y, b, mClickCount + 1); } } else { mClickButton = 0; mClickCount = 0; } } else { mClickCount = 0; mClickTimeStamp = 0; } setDirty(true); break; } }
/*--------------------------------------------------------------------------*/ int sci_uicontrol(char *fname, void* pvApiCtx) { SciErr sciErr; int nbRow = 0, nbCol = 0, k = 0; int setStatus = SET_PROPERTY_SUCCEED; int PARENT_NOT_FOUND = -2; int NOT_FOUND = -1; int inputIndex = 0, beginIndex = 0; char *propertyName = NULL; char *styleProperty = NULL; int iPropertiesCount = sizeof(propertiesNames) / sizeof(char**); unsigned long GraphicHandle = 0; int found = 0; /* Does the property exists ? */ int *propertiesValuesIndices = NULL; int iParentType = -1; int *piParentType = &iParentType; int iParentStyle = -1; int *piParentStyle = &iParentStyle; int iParentUID = 0; int iUicontrol = 0; int iCurrentFigure = 0; CheckOutputArgument(pvApiCtx, 0, 1); //init properties index init_property_index(); if (nbInputArgument(pvApiCtx) == 0) { /* Create a pushbutton in current figure */ /* Create a new pushbutton */ GraphicHandle = getHandle(CreateUIControl(NULL)); /* Set current figure as parent */ iCurrentFigure = getCurrentFigure(); if (iCurrentFigure == 0) { iCurrentFigure = createNewFigureWithAxes(); } iUicontrol = getObjectFromHandle(GraphicHandle); setGraphicObjectRelationship(iCurrentFigure, iUicontrol); } else if (nbInputArgument(pvApiCtx) == 1) { /* Create a pushbutton in figure given as parameter */ /* Or give focus to the uicontrol given as parameter */ int* piAddr = NULL; int iType = 0; sciErr = getVarAddressFromPosition(pvApiCtx, 1, &piAddr); if (sciErr.iErr) { Scierror(999, _("%s: Can not read input argument #%d.\n"), fname, 1); return 0; } if (isHandleType(pvApiCtx, piAddr) == FALSE && isStringType(pvApiCtx, piAddr) == FALSE) { OverLoad(1); return FALSE; } #if 0 // Allow XML loading else if (isStringType(pvApiCtx, piAddr)) { char* pstXmlfile = NULL; char* pstExpandedPath = NULL; if (isScalar(pvApiCtx, piAddr) == 0) { Scierror(999, _("%s: Wrong type for input argument #%d: string expected.\n"), fname, 1); return FALSE; } if (getAllocatedSingleString(pvApiCtx, piAddr, &pstXmlfile)) { freeAllocatedSingleString(pstXmlfile); Scierror(999, _("%s: No more memory.\n"), fname); return FALSE; } pstExpandedPath = expandPathVariable(pstXmlfile); freeAllocatedSingleString(pstXmlfile); iUicontrol = xmlload(pstExpandedPath); if (iUicontrol < 1) { Scierror(999, _("%s: can not read file %s.\n"), fname, pstExpandedPath); FREE(pstExpandedPath); return 0; } FREE(pstExpandedPath); GraphicHandle = getHandle(iUicontrol); /* Create return variable */ if (createScalarHandle(pvApiCtx, nbInputArgument(pvApiCtx) + 1, GraphicHandle)) { Scierror(999, _("%s: Memory allocation error.\n"), fname); return 1; } AssignOutputVariable(pvApiCtx, 1) = nbInputArgument(pvApiCtx) + 1; ReturnArguments(pvApiCtx); return TRUE; } #endif // Allow XML loading else /* Get parent ID */ { int* piAddr = NULL; long long hParent = 0; sciErr = getVarAddressFromPosition(pvApiCtx, 1, &piAddr); if (sciErr.iErr) { printError(&sciErr, 0); return 1; } if (isScalar(pvApiCtx, piAddr) == 0) { Scierror(999, _("%s: Wrong size for input argument #%d: A graphic handle expected.\n"), fname, 1); return FALSE; } if (getScalarHandle(pvApiCtx, piAddr, &hParent)) { Scierror(202, _("%s: Wrong type for input argument #%d: Handle matrix expected.\n"), fname, 1); return 1; } iParentUID = getObjectFromHandle((long)hParent); if (iParentUID != 0) { getGraphicObjectProperty(iParentUID, __GO_TYPE__, jni_int, (void **)&piParentType); if (iParentType == __GO_UICONTROL__) /* Focus management */ { GraphicHandle = (unsigned long)hParent; requestFocus(iParentUID); } else if (iParentType == __GO_FIGURE__ || iParentType == __GO_UIMENU__) /* PushButton creation */ { /* Create a new pushbutton */ GraphicHandle = getHandle(CreateUIControl(NULL)); iUicontrol = getObjectFromHandle(GraphicHandle); /* First parameter is the parent */ setGraphicObjectRelationship(iParentUID, iUicontrol); setStatus = callSetProperty(pvApiCtx, iUicontrol, &hParent, sci_handles, 1, 1, (char*)propertiesNames[parent_property]); if (setStatus == SET_PROPERTY_ERROR) { Scierror(999, _("%s: Could not set property '%s'.\n"), fname, propertyName); return FALSE; } } else { Scierror(999, _("%s: Wrong type for input argument #%d: A '%s', '%s' or '%s' handle expected.\n"), fname, 1, "Uicontrol", "Figure", "Uimenu"); return FALSE; } } else { Scierror(999, _("%s: Wrong type for input argument #%d: A '%s', '%s' or '%s' handle expected.\n"), fname, 1, "Uicontrol", "Figure", "Uimenu"); return FALSE; } } } else { if (!checkInputArgumentType(pvApiCtx, 1, sci_handles) && !checkInputArgumentType(pvApiCtx, 1, sci_strings)) { OverLoad(1); return FALSE; } /* Allocate memory to store the position of properties in uicontrol call */ if ((propertiesValuesIndices = (int*)MALLOC(sizeof(int) * iPropertiesCount)) == NULL) { Scierror(999, _("%s: No more memory.\n"), fname); return FALSE; } /* Init all positions to NOT_FOUND */ for (inputIndex = 0; inputIndex < iPropertiesCount; inputIndex++) { propertiesValuesIndices[inputIndex] = NOT_FOUND; /* Property initialized as not found */ } /** * Odd number of input arguments * First input is the parent ID * All event inputs are property names * All odd (except first) inputs are property values */ if (nbInputArgument(pvApiCtx) % 2 == 1) { if ((!checkInputArgumentType(pvApiCtx, 1, sci_handles))) { if ((checkInputArgumentType(pvApiCtx, 1, sci_matrix))) { int* piAddr = NULL; double dblValue = 0; sciErr = getVarAddressFromPosition(pvApiCtx, 1, &piAddr); if (sciErr.iErr) { printError(&sciErr, 0); return 1; } if (isScalar(pvApiCtx, piAddr) == 0) { Scierror(999, _("%s: Wrong size for input argument #%d: A graphic handle expected.\n"), fname, 1); return FALSE; } if (getScalarDouble(pvApiCtx, piAddr, &dblValue)) { Scierror(202, _("%s: Wrong type for argument #%d: A real expected.\n"), fname, 1); return 1; } iParentUID = getFigureFromIndex((int)dblValue); } else { Scierror(999, _("%s: Wrong type for input argument #%d: A '%s' or a '%s' handle expected.\n"), fname, 1, "Figure", "Frame uicontrol"); return FALSE; } } else /* Get parent ID */ { int* piAddr = NULL; long long hParent = 0; sciErr = getVarAddressFromPosition(pvApiCtx, 1, &piAddr); if (sciErr.iErr) { printError(&sciErr, 0); return 1; } if (isScalar(pvApiCtx, piAddr) == 0) { Scierror(999, _("%s: Wrong size for input argument #%d: A '%s' or a '%s' handle expected.\n"), fname, 1, "Figure", "Frame uicontrol"); return FALSE; } if (getScalarHandle(pvApiCtx, piAddr, &hParent)) { Scierror(202, _("%s: Wrong type for input argument #%d: Handle matrix expected.\n"), fname, 1); return 1; } iParentUID = getObjectFromHandle((long)hParent); } if (iParentUID == 0) { Scierror(999, _("%s: Wrong type for input argument #%d: A '%s' or a '%s' handle expected.\n"), fname, 1, "Figure", "Frame uicontrol"); return FALSE; } getGraphicObjectProperty(iParentUID, __GO_TYPE__, jni_int, (void **)&piParentType); if (iParentType != __GO_FIGURE__) { getGraphicObjectProperty(iParentUID, __GO_STYLE__, jni_int, (void **)&piParentStyle); if (iParentType != __GO_UICONTROL__ || (iParentStyle != __GO_UI_FRAME__ && iParentStyle != __GO_UI_TAB__ && iParentStyle != __GO_UI_LAYER__)) { Scierror(999, _("%s: Wrong type for input argument #%d: A '%s' or a '%s' handle expected.\n"), fname, 1, "Figure", "Frame uicontrol"); return FALSE; } } /* First parameter is the parent */ propertiesValuesIndices[parent_property] = 1; // First input parameter which is a property name beginIndex = 2; } /** * Even number of input arguments * All odd inputs are property names * All even inputs are property values */ else { // First input parameter which is a property name beginIndex = 1; } /* Get all properties positions */ for (inputIndex = beginIndex; inputIndex < Rhs; inputIndex = inputIndex + 2) { /* Read property name */ if ((!checkInputArgumentType(pvApiCtx, inputIndex, sci_strings))) { Scierror(999, _("%s: Wrong type for input argument #%d: string expected.\n"), fname, inputIndex); return FALSE; } else { int* piAddr = NULL; sciErr = getVarAddressFromPosition(pvApiCtx, inputIndex, &piAddr); if (sciErr.iErr) { printError(&sciErr, 0); return 1; } if (getAllocatedSingleString(pvApiCtx, piAddr, &propertyName)) { Scierror(202, _("%s: Wrong type for argument #%d: string expected.\n"), fname, inputIndex); return 1; } /* Bug 3031 */ /* We only want to compare propertyName along its length */ /* 'posi' must be matched to 'position' */ found = 0; for (k = 0; k < iPropertiesCount ; k++) { if (strlen(propertyName) <= strlen(propertiesNames[k])) { if (strnicmp(propertyName, propertiesNames[k], strlen(propertyName)) == 0) { propertiesValuesIndices[k] = inputIndex + 1; /* Position of value for property */ found = 1; break; } } } freeAllocatedSingleString(propertyName); if (found == 0) { Scierror(999, _("%s: Unknown property: %s for '%s' handles.\n"), fname, propertyName, "Uicontrol"); return FALSE; } } } if (propertiesValuesIndices[style_property] != NOT_FOUND) /* Style found */ { if ((checkInputArgumentType(pvApiCtx, propertiesValuesIndices[style_property], sci_strings))) { int* piAddr = NULL; sciErr = getVarAddressFromPosition(pvApiCtx, propertiesValuesIndices[style_property], &piAddr); if (sciErr.iErr) { printError(&sciErr, 0); return 1; } if (getAllocatedSingleString(pvApiCtx, piAddr, &styleProperty)) { Scierror(202, _("%s: Wrong type for argument #%d: string expected.\n"), fname, propertiesValuesIndices[style_property]); return 1; } if (strcmp(styleProperty, "frame") == 0) { //check scrollable property to create a scroll frame instead of normal frame if (propertiesValuesIndices[scrollable_property] != NOT_FOUND) { char* pstScroll = NULL; int iScroll = 0; sciErr = getVarAddressFromPosition(pvApiCtx, propertiesValuesIndices[scrollable_property], &piAddr); if (sciErr.iErr) { printError(&sciErr, 0); return 1; } if (isStringType(pvApiCtx, piAddr) == 0 && isBooleanType(pvApiCtx, piAddr) == 0 && isScalar(pvApiCtx, piAddr) == 0) { Scierror(202, _("%s: Wrong type for argument #%d: string or boolean expected.\n"), fname, propertiesValuesIndices[scrollable_property]); return 1; } if (isStringType(pvApiCtx, piAddr)) { if (getAllocatedSingleString(pvApiCtx, piAddr, &pstScroll)) { Scierror(202, _("%s: Wrong type for argument #%d: string expected.\n"), fname, propertiesValuesIndices[scrollable_property]); return 1; } if (strcmp(pstScroll, "on") == 0) { iScroll = 1; } freeAllocatedSingleString(pstScroll); } else { if (getScalarBoolean(pvApiCtx, piAddr, &iScroll)) { Scierror(202, _("%s: Wrong type for argument #%d: string expected.\n"), fname, propertiesValuesIndices[scrollable_property]); return 1; } } if (iScroll) { freeAllocatedSingleString(styleProperty); styleProperty = os_strdup("framescrollable"); } propertiesValuesIndices[scrollable_property] = NOT_FOUND; } } } else { Scierror(999, _("%s: Wrong type for input argument #%d: string expected.\n"), fname, propertiesValuesIndices[style_property]); return FALSE; } } /* Create a new uicontrol */ iUicontrol = CreateUIControl(styleProperty); freeAllocatedSingleString(styleProperty); if (iUicontrol == 0) /* Error in creation */ { Scierror(999, _("%s: Could not create 'Uicontrol' handle.\n"), fname); return FALSE; } GraphicHandle = getHandle(iUicontrol); /* If no parent given then the current figure is the parent */ if (propertiesValuesIndices[parent_property] == NOT_FOUND) { /* Set the parent */ iCurrentFigure = getCurrentFigure(); if (iCurrentFigure == 0) { iCurrentFigure = createNewFigureWithAxes(); } propertiesValuesIndices[parent_property] = PARENT_NOT_FOUND; } /* Read and set all properties */ for (inputIndex = 1; inputIndex < iPropertiesCount; inputIndex++) /* Style has already been set */ { if (propertiesValuesIndices[inputIndex] == PARENT_NOT_FOUND) { //special case for not specified parent //but set relationship at the good moment. setGraphicObjectRelationship(iCurrentFigure, iUicontrol); } else if (propertiesValuesIndices[inputIndex] != NOT_FOUND) { int* piAddr = NULL; sciErr = getVarAddressFromPosition(pvApiCtx, propertiesValuesIndices[inputIndex], &piAddr); if (sciErr.iErr) { printError(&sciErr, 0); return 1; } if (inputIndex == user_data_property || inputIndex == userdata_property) /* User data settings */ { nbRow = -1; nbCol = -1; setStatus = callSetProperty(pvApiCtx, iUicontrol, piAddr, 0, 0, 0, (char*)propertiesNames[inputIndex]); } else /* All other properties */ { /* Read property value */ switch (getInputArgumentType(pvApiCtx, propertiesValuesIndices[inputIndex])) { case sci_matrix: { double* pdblValue = NULL; sciErr = getMatrixOfDouble(pvApiCtx, piAddr, &nbRow, &nbCol, &pdblValue); if (sciErr.iErr) { printError(&sciErr, 0); Scierror(202, _("%s: Wrong type for argument #%d: A real expected.\n"), fname, propertiesValuesIndices[inputIndex]); return 1; } setStatus = callSetProperty(pvApiCtx, iUicontrol, pdblValue, sci_matrix, nbRow, nbCol, (char*)propertiesNames[inputIndex]); break; } case sci_strings: /* Index for String & TooltipString properties: Can be more than one character string */ if ((inputIndex == string_property) || (inputIndex == tooltipstring_property)) { char** pstValue = NULL; if (getAllocatedMatrixOfString(pvApiCtx, piAddr, &nbRow, &nbCol, &pstValue)) { Scierror(202, _("%s: Wrong type for argument #%d: string expected.\n"), fname, propertiesValuesIndices[inputIndex]); return 1; } setStatus = callSetProperty(pvApiCtx, iUicontrol, pstValue, sci_strings, nbRow, nbCol, (char*)propertiesNames[inputIndex]); freeAllocatedMatrixOfString(nbRow, nbCol, pstValue); } else { char* pstValue = NULL; if (getAllocatedSingleString(pvApiCtx, piAddr, &pstValue)) { Scierror(202, _("%s: Wrong type for argument #%d: string expected.\n"), fname, propertiesValuesIndices[inputIndex]); return 1; } nbRow = (int)strlen(pstValue); nbCol = 1; setStatus = callSetProperty(pvApiCtx, iUicontrol, pstValue, sci_strings, nbRow, nbCol, (char*)propertiesNames[inputIndex]); freeAllocatedSingleString(pstValue); } break; case sci_handles: { long long* pHandles = NULL; sciErr = getMatrixOfHandle(pvApiCtx, piAddr, &nbRow, &nbCol, &pHandles); if (sciErr.iErr) { printError(&sciErr, 0); Scierror(202, _("%s: Wrong type for input argument #%d: Handle matrix expected.\n"), fname, propertiesValuesIndices[inputIndex]); return 1; } setStatus = callSetProperty(pvApiCtx, iUicontrol, pHandles, sci_handles, nbRow, nbCol, (char*)propertiesNames[inputIndex]); break; } case sci_tlist: //constraints and border { setStatus = callSetProperty(pvApiCtx, iUicontrol, piAddr, sci_tlist, 1, 1, (char*)propertiesNames[inputIndex]); break; } default: setStatus = SET_PROPERTY_ERROR; break; } } if (setStatus == SET_PROPERTY_ERROR) { Scierror(999, _("%s: Could not set property '%s'.\n"), fname, (char*)propertiesNames[inputIndex]); return FALSE; } } } } if (propertiesValuesIndices != NULL && (propertiesValuesIndices[sliderstep_property] == NOT_FOUND && (propertiesValuesIndices[min_property] != NOT_FOUND || propertiesValuesIndices[max_property] != NOT_FOUND))) /* SliderStep property not set */ { /* Set SliderStep property to [1/100*(Max-Min) 1/10*(Max-Min)] */ double maxValue = 0; double* pdblMaxValue = &maxValue; double minValue = 0; double* pdblMinValue = &minValue; double pdblStep[2]; getGraphicObjectProperty(iUicontrol, __GO_UI_MIN__, jni_double, (void**) &pdblMinValue); getGraphicObjectProperty(iUicontrol, __GO_UI_MAX__, jni_double, (void**) &pdblMaxValue); pdblStep[0] = 0.01 * (maxValue - minValue); pdblStep[1] = 0.1 * (maxValue - minValue); setGraphicObjectProperty(iUicontrol, __GO_UI_SLIDERSTEP__, pdblStep, jni_double_vector, 2); } if ((nbInputArgument(pvApiCtx) < 2) || (propertiesValuesIndices[position_property] == NOT_FOUND)) /* Position property not set */ { double* pdblPosition = NULL; getGraphicObjectProperty(iUicontrol, __GO_POSITION__, jni_double_vector, (void**) &pdblPosition); setGraphicObjectProperty(iUicontrol, __GO_POSITION__, pdblPosition, jni_double_vector, 4); releaseGraphicObjectProperty(__GO_POSITION__, pdblPosition, jni_double_vector, 4); } if ((nbInputArgument(pvApiCtx) < 2) || (propertiesValuesIndices[visible_property] == NOT_FOUND)) /* Visible property not set */ { /* Force the uicontrol to be visible because is invisible by default in the model (See bug #10346) */ int b = (int)TRUE; setGraphicObjectProperty(iUicontrol, __GO_VISIBLE__, &b, jni_bool, 1); } FREE(propertiesValuesIndices); /* Create return variable */ if (createScalarHandle(pvApiCtx, nbInputArgument(pvApiCtx) + 1, GraphicHandle)) { Scierror(999, _("%s: Memory allocation error.\n"), fname); return 1; } AssignOutputVariable(pvApiCtx, 1) = nbInputArgument(pvApiCtx) + 1; ReturnArguments(pvApiCtx); return TRUE; }
// deactivates 'c' and activates next client bool Workspace::activateNextClient(Client* c) { // if 'c' is not the active or the to-become active one, do nothing if (!(c == active_client || (should_get_focus.count() > 0 && c == should_get_focus.last()))) return false; closeActivePopup(); if (c != NULL) { if (c == active_client) setActiveClient(NULL, Allowed); should_get_focus.removeAll(c); } // if blocking focus, move focus to the desktop later if needed // in order to avoid flickering if (!focusChangeEnabled()) { focusToNull(); return true; } if (!options->focusPolicyIsReasonable()) return false; Client* get_focus = NULL; if (options->isNextFocusPrefersMouse()) { get_focus = clientUnderMouse(c ? c->screen() : activeScreen()); if (get_focus && (get_focus == c || get_focus->isDesktop())) { // should rather not happen, but it cannot get the focus. rest of usability is tested above get_focus = 0; } } if (!get_focus) { // no suitable window under the mouse -> find sth. else // first try to pass the focus to the (former) active clients leader if (c && (get_focus = c->transientFor()) && isUsableFocusCandidate(get_focus, c, options->isSeparateScreenFocus())) { raiseClient(get_focus); // also raise - we don't know where it came from } else { // nope, ask the focus chain for the next candidate get_focus = NULL; // reset from the inline assignment above for (int i = focus_chain[ currentDesktop()].size() - 1; i >= 0; --i) { Client* ci = focus_chain[ currentDesktop()].at(i); if (isUsableFocusCandidate(ci, c, options->isSeparateScreenFocus())) { get_focus = ci; break; // we're done } } } } if (get_focus == NULL) // last chance: focus the desktop get_focus = findDesktop(true, currentDesktop()); if (get_focus != NULL) requestFocus(get_focus); else focusToNull(); return true; }
void sfRenderWindow_requestFocus(sfRenderWindow* renderWindow) { CSFML_CALL(renderWindow, requestFocus()); }
NpcDialog::NpcDialog(int npcId) : Window(_("NPC")), mNpcId(npcId), mLogInteraction(config.getBoolValue("logNpcInGui")), mDefaultInt(0), mInputState(NPC_INPUT_NONE), mActionState(NPC_ACTION_WAIT) { // Basic Window Setup setWindowName("NpcText"); setResizable(true); //setupWindow->registerWindowForReset(this); setFocusable(true); setMinWidth(200); setMinHeight(150); setDefaultSize(260, 200, ImageRect::CENTER); // Setup output text box mTextBox = new TextBox; mTextBox->setEditable(false); mTextBox->setOpaque(false); mScrollArea = new ScrollArea(mTextBox); mScrollArea->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER); mScrollArea->setVerticalScrollPolicy(gcn::ScrollArea::SHOW_ALWAYS); // Setup listbox mItemList = new ListBox(this); mItemList->setWrappingEnabled(true); setContentSize(260, 175); mListScrollArea = new ScrollArea(mItemList); mListScrollArea->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER); mItemList->setVisible(true); // Setup string input box mTextField = new TextField(""); mTextField->setVisible(true); // Setup int input box mIntField = new IntTextField; mIntField->setVisible(true); mClearButton = new Button(_("Clear log"), "clear", this); // Setup button mButton = new Button("", "ok", this); //Setup more and less buttons (int input) mPlusButton = new Button(_("+"), "inc", this); mMinusButton = new Button(_("-"), "dec", this); int width = std::max(mButton->getFont()->getWidth(CAPTION_WAITING), mButton->getFont()->getWidth(CAPTION_NEXT)); width = std::max(width, mButton->getFont()->getWidth(CAPTION_CLOSE)); width = std::max(width, mButton->getFont()->getWidth(CAPTION_SUBMIT)); mButton->setWidth(8 + width); mResetButton = new Button(_("Reset"), "reset", this); // Place widgets buildLayout(); center(); loadWindowState(); instances.push_back(this); setVisible(true); requestFocus(); listen(Event::ConfigChannel); PlayerInfo::setNPCInteractionCount(PlayerInfo::getNPCInteractionCount() + 1); }
// deactivates 'c' and activates next client bool Workspace::activateNextClient( Client* c ) { // if 'c' is not the active or the to-become active one, do nothing if( !( c == active_client || ( should_get_focus.count() > 0 && c == should_get_focus.last()))) return false; closeActivePopup(); if( c != NULL ) { if( c == active_client ) { setActiveClient( NULL, Allowed ); } should_get_focus.remove( c ); } if( focusChangeEnabled()) { if ( options->focusPolicyIsReasonable()) { // search the focus_chain for a client to transfer focus to // if 'c' is transient, transfer focus to the first suitable mainwindow Client* get_focus = NULL; const ClientList mainwindows = ( c != NULL ? c->mainClients() : ClientList()); for( ClientList::ConstIterator it = focus_chain[currentDesktop()].fromLast(); it != focus_chain[currentDesktop()].end(); --it ) { if( !(*it)->isShown( false ) || !(*it)->isOnCurrentDesktop()) continue; if( options->separateScreenFocus ) { if( c != NULL && !(*it)->isOnScreen( c->screen())) continue; if( c == NULL && !(*it)->isOnScreen( activeScreen())) continue; } if( mainwindows.contains( *it )) { get_focus = *it; break; } if( get_focus == NULL ) get_focus = *it; } if( get_focus == NULL ) get_focus = findDesktop( true, currentDesktop()); if( get_focus != NULL ) { requestFocus( get_focus ); } else focusToNull(); } else return false; } else // if blocking focus, move focus to the desktop later if needed // in order to avoid flickering focusToNull(); return true; }
DolphinViewContainer::DolphinViewContainer(const KUrl& url, QWidget* parent) : QWidget(parent), m_topLayout(0), m_urlNavigator(0), m_searchBox(0), m_view(0), m_filterBar(0), m_statusBar(0), m_statusBarTimer(0), m_statusBarTimestamp() { hide(); m_topLayout = new QVBoxLayout(this); m_topLayout->setSpacing(0); m_topLayout->setMargin(0); m_urlNavigator = new KUrlNavigator(DolphinSettings::instance().placesModel(), url, this); connect(m_urlNavigator, SIGNAL(urlsDropped(const KUrl&, QDropEvent*)), this, SLOT(dropUrls(const KUrl&, QDropEvent*))); connect(m_urlNavigator, SIGNAL(activated()), this, SLOT(activate())); connect(m_urlNavigator->editor(), SIGNAL(completionModeChanged(KGlobalSettings::Completion)), this, SLOT(saveUrlCompletionMode(KGlobalSettings::Completion))); const GeneralSettings* settings = DolphinSettings::instance().generalSettings(); m_urlNavigator->setUrlEditable(settings->editableUrl()); m_urlNavigator->setShowFullPath(settings->showFullPath()); m_urlNavigator->setHomeUrl(KUrl(settings->homeUrl())); KUrlComboBox* editor = m_urlNavigator->editor(); editor->setCompletionMode(KGlobalSettings::Completion(settings->urlCompletionMode())); m_searchBox = new DolphinSearchBox(this); m_searchBox->hide(); connect(m_searchBox, SIGNAL(closeRequest()), this, SLOT(closeSearchBox())); connect(m_searchBox, SIGNAL(search(QString)), this, SLOT(startSearching(QString))); connect(m_searchBox, SIGNAL(returnPressed(QString)), this, SLOT(requestFocus())); m_view = new DolphinView(url, this); connect(m_view, SIGNAL(urlChanged(const KUrl&)), m_urlNavigator, SLOT(setUrl(const KUrl&))); connect(m_view, SIGNAL(writeStateChanged(bool)), this, SIGNAL(writeStateChanged(bool))); connect(m_view, SIGNAL(requestItemInfo(KFileItem)), this, SLOT(showItemInfo(KFileItem))); connect(m_view, SIGNAL(errorMessage(const QString&)), this, SLOT(showErrorMessage(const QString&))); connect(m_view, SIGNAL(infoMessage(const QString&)), this, SLOT(showInfoMessage(const QString&))); connect(m_view, SIGNAL(itemTriggered(KFileItem)), this, SLOT(slotItemTriggered(KFileItem))); connect(m_view, SIGNAL(redirection(KUrl, KUrl)), this, SLOT(redirect(KUrl, KUrl))); connect(m_view, SIGNAL(startedPathLoading(KUrl)), this, SLOT(slotStartedPathLoading())); connect(m_view, SIGNAL(finishedPathLoading(KUrl)), this, SLOT(slotFinishedPathLoading())); connect(m_view, SIGNAL(itemCountChanged()), this, SLOT(delayedStatusBarUpdate())); connect(m_view, SIGNAL(pathLoadingProgress(int)), this, SLOT(updateProgress(int))); connect(m_view, SIGNAL(infoMessage(const QString&)), this, SLOT(showInfoMessage(const QString&))); connect(m_view, SIGNAL(errorMessage(const QString&)), this, SLOT(showErrorMessage(const QString&))); connect(m_view, SIGNAL(urlIsFileError(const KUrl&)), this, SLOT(openFile(const KUrl&))); connect(m_view, SIGNAL(selectionChanged(const KFileItemList&)), this, SLOT(delayedStatusBarUpdate())); connect(m_view, SIGNAL(operationCompletedMessage(const QString&)), this, SLOT(showOperationCompletedMessage(const QString&))); connect(m_urlNavigator, SIGNAL(urlChanged(const KUrl&)), this, SLOT(slotUrlNavigatorLocationChanged(const KUrl&))); connect(m_urlNavigator, SIGNAL(urlAboutToBeChanged(const KUrl&)), this, SLOT(saveViewState())); connect(m_urlNavigator, SIGNAL(historyChanged()), this, SLOT(slotHistoryChanged())); // initialize status bar m_statusBar = new DolphinStatusBar(this, m_view); connect(m_statusBar, SIGNAL(stopPressed()), this, SLOT(stopLoading())); m_statusBarTimer = new QTimer(this); m_statusBarTimer->setSingleShot(true); m_statusBarTimer->setInterval(300); connect(m_statusBarTimer, SIGNAL(timeout()), this, SLOT(updateStatusBar())); KIO::FileUndoManager* undoManager = KIO::FileUndoManager::self(); connect(undoManager, SIGNAL(jobRecordingFinished(CommandType)), this, SLOT(delayedStatusBarUpdate())); // initialize filter bar m_filterBar = new FilterBar(this); m_filterBar->setVisible(settings->filterBar()); connect(m_filterBar, SIGNAL(filterChanged(const QString&)), this, SLOT(setNameFilter(const QString&))); connect(m_filterBar, SIGNAL(closeRequest()), this, SLOT(closeFilterBar())); connect(m_view, SIGNAL(urlChanged(const KUrl&)), m_filterBar, SLOT(clear())); m_topLayout->addWidget(m_urlNavigator); m_topLayout->addWidget(m_searchBox); m_topLayout->addWidget(m_view); m_topLayout->addWidget(m_filterBar); m_topLayout->addWidget(m_statusBar); setSearchModeEnabled(isSearchUrl(url)); }
bool Entry::onProcessMessage(Message* msg) { switch (msg->type()) { case kTimerMessage: if (hasFocus() && static_cast<TimerMessage*>(msg)->timer() == &m_timer) { // Blinking caret m_state = m_state ? false: true; invalidate(); } break; case kFocusEnterMessage: m_timer.start(); m_state = true; invalidate(); if (m_lock_selection) { m_lock_selection = false; } else { selectAllText(); m_recent_focused = true; } break; case kFocusLeaveMessage: invalidate(); m_timer.stop(); if (!m_lock_selection) deselectText(); m_recent_focused = false; break; case kKeyDownMessage: if (hasFocus() && !isReadOnly()) { // Command to execute EntryCmd cmd = EntryCmd::NoOp; KeyMessage* keymsg = static_cast<KeyMessage*>(msg); KeyScancode scancode = keymsg->scancode(); switch (scancode) { case kKeyLeft: if (msg->ctrlPressed()) cmd = EntryCmd::BackwardWord; else cmd = EntryCmd::BackwardChar; break; case kKeyRight: if (msg->ctrlPressed()) cmd = EntryCmd::ForwardWord; else cmd = EntryCmd::ForwardChar; break; case kKeyHome: cmd = EntryCmd::BeginningOfLine; break; case kKeyEnd: cmd = EntryCmd::EndOfLine; break; case kKeyDel: if (msg->shiftPressed()) cmd = EntryCmd::Cut; else cmd = EntryCmd::DeleteForward; break; case kKeyInsert: if (msg->shiftPressed()) cmd = EntryCmd::Paste; else if (msg->ctrlPressed()) cmd = EntryCmd::Copy; break; case kKeyBackspace: cmd = EntryCmd::DeleteBackward; break; default: // Map common Windows shortcuts for Cut/Copy/Paste #if defined __APPLE__ if (msg->onlyCmdPressed()) #else if (msg->onlyCtrlPressed()) #endif { switch (scancode) { case kKeyX: cmd = EntryCmd::Cut; break; case kKeyC: cmd = EntryCmd::Copy; break; case kKeyV: cmd = EntryCmd::Paste; break; } } else if (keymsg->unicodeChar() >= 32) { // Ctrl and Alt must be unpressed to insert a character // in the text-field. if ((msg->keyModifiers() & (kKeyCtrlModifier | kKeyAltModifier)) == 0) { cmd = EntryCmd::InsertChar; } } break; } if (cmd == EntryCmd::NoOp) break; executeCmd(cmd, keymsg->unicodeChar(), (msg->shiftPressed()) ? true: false); return true; } break; case kMouseDownMessage: captureMouse(); case kMouseMoveMessage: if (hasCapture()) { gfx::Point mousePos = static_cast<MouseMessage*>(msg)->position(); base::utf8_const_iterator utf8_begin = base::utf8_const_iterator(getText().begin()); base::utf8_const_iterator utf8_end = base::utf8_const_iterator(getText().end()); int textlen = base::utf8_length(getText()); int c, x; bool move = true; bool is_dirty = false; // Backward scroll if (mousePos.x < getBounds().x) { if (m_scroll > 0) { m_caret = --m_scroll; move = false; is_dirty = true; invalidate(); } } // Forward scroll else if (mousePos.x >= getBounds().x2()) { if (m_scroll < textlen - getAvailableTextLength()) { m_scroll++; x = getBounds().x + this->border_width.l; for (c=m_scroll; utf8_begin != utf8_end; ++c) { int ch = (c < textlen ? *(utf8_begin+c) : ' '); x += getFont()->charWidth(ch); if (x > getBounds().x2()-this->border_width.r) { c--; break; } } m_caret = c; move = false; is_dirty = true; invalidate(); } } c = getCaretFromMouse(static_cast<MouseMessage*>(msg)); if (static_cast<MouseMessage*>(msg)->left() || (move && !isPosInSelection(c))) { // Move caret if (move) { if (m_caret != c) { m_caret = c; is_dirty = true; invalidate(); } } // Move selection if (m_recent_focused) { m_recent_focused = false; m_select = m_caret; } else if (msg->type() == kMouseDownMessage) m_select = m_caret; } // Show the caret if (is_dirty) { m_timer.start(); m_state = true; } return true; } break; case kMouseUpMessage: if (hasCapture()) { releaseMouse(); MouseMessage* mouseMsg = static_cast<MouseMessage*>(msg); if (mouseMsg->right()) { // This flag is disabled in kFocusEnterMessage message handler. m_lock_selection = true; showEditPopupMenu(mouseMsg->position()); requestFocus(); } } return true; case kDoubleClickMessage: forwardWord(); m_select = m_caret; backwardWord(); invalidate(); return true; case kMouseEnterMessage: case kMouseLeaveMessage: // TODO theme stuff if (isEnabled()) invalidate(); break; } return Widget::onProcessMessage(msg); }