void ModalComponentManager::bringModalComponentsToFront (bool topOneShouldGrabFocus) { ComponentPeer* lastOne = nullptr; for (int i = 0; i < getNumModalComponents(); ++i) { Component* const c = getModalComponent (i); if (c == nullptr) break; ComponentPeer* peer = c->getPeer(); if (peer != nullptr && peer != lastOne) { if (lastOne == nullptr) { peer->toFront (topOneShouldGrabFocus); if (topOneShouldGrabFocus) peer->grabFocus(); } else peer->toBehind (lastOne); lastOne = peer; } } }
//====================================================================== bool createNativeWindow() { jassert (nativeWindow == nullptr); ComponentPeer* topLevelPeer = component.getTopLevelComponent()->getPeer(); jassert (topLevelPeer != nullptr); if (topLevelPeer != nullptr) { nativeWindow = new NativeWindow ((HWND) topLevelPeer->getNativeHandle(), this); hwnd = nativeWindow->getHandle(); if (hwnd != 0) { hdc = GetDC (hwnd); component.updateContextPosition(); component.showContext (component.isShowing()); return true; } else { nativeWindow = nullptr; } } return false; }
//============================================================================== void handleEvent (ComponentPeer& newPeer, Point<float> positionWithinPeer, Time time, const ModifierKeys newMods, float newPressure) { lastTime = time; const bool pressureChanged = (pressure != newPressure); pressure = newPressure; ++mouseEventCounter; const Point<float> screenPos (newPeer.localToGlobal (positionWithinPeer)); if (isDragging() && newMods.isAnyMouseButtonDown()) { setScreenPos (screenPos, time, pressureChanged); } else { setPeer (newPeer, screenPos, time); if (ComponentPeer* peer = getPeer()) { if (setButtons (screenPos, time, newMods)) return; // some modal events have been dispatched, so the current event is now out-of-date peer = getPeer(); if (peer != nullptr) setScreenPos (screenPos, time, pressureChanged); } } }
void ComponentBoundsConstrainer::setBoundsForComponent (Component* const component, const Rectangle<int>& targetBounds, const bool isStretchingTop, const bool isStretchingLeft, const bool isStretchingBottom, const bool isStretchingRight) { jassert (component != nullptr); Rectangle<int> limits, bounds (targetBounds); BorderSize<int> border; Component* const parent = component->getParentComponent(); if (parent == nullptr) { ComponentPeer* peer = component->getPeer(); if (peer != nullptr) border = peer->getFrameSize(); limits = Desktop::getInstance().getMonitorAreaContaining (bounds.getCentre()); } else { limits.setSize (parent->getWidth(), parent->getHeight()); } border.addTo (bounds); checkBounds (bounds, border.addedTo (component->getBounds()), limits, isStretchingTop, isStretchingLeft, isStretchingBottom, isStretchingRight); border.subtractFrom (bounds); applyBoundsToComponent (component, bounds); }
static Pimpl* getPimpl (HWND hwnd) { if (JuceWindowIdentifier::isJUCEWindow (hwnd)) { ComponentPeer* peer = (ComponentPeer*) GetWindowLongPtr (hwnd, 8); if (peer != nullptr) { SystemTrayIconComponent* const iconComp = dynamic_cast<SystemTrayIconComponent*> (&(peer->getComponent())); if (iconComp != nullptr) return iconComp->pimpl; } } return nullptr; }
void textInputRequired (const Point<int>& position) { ComponentPeer* peer = magnifierComp->getPeer(); if (peer != 0) peer->textInputRequired (position); }
void grabFocus() { ComponentPeer* peer = magnifierComp->getPeer(); if (peer != 0) peer->grabFocus(); }