// ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ // ¥ MouseEventIsOverGameWindow // ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ // returns true if the event passed has a mouse location over the content region of the game window. this will return false for // clicks in the drag region, menu bar, etc. bool CProgram::MouseEventIsOverGameWindow( EventRef inEvent) { CGraphicsContext *gc=GetGraphicsContext(); bool result=true; // if not in graphics mode then all clicks are counted as being over the graphics window - for apps that don't have a window open and yet are waiting for a mouse event if (gc) { if (gc->UsingWindowMode()) { // when using window mode, we should only return true if the event location is in the content part of our window WindowRef window=NULL; Point point; OSStatus err=::GetEventParameter(inEvent,kEventParamMouseLocation,typeQDPoint,0,sizeof(point),0,&point); if (err==noErr) { WindowPartCode part=::MacFindWindow(point,&window); result=(part==inContent && window!=NULL); } } } return result; }
WidgetView::WidgetView(ViewOwner* viewOwner, std::shared_ptr<Viewport2D> viewport) : View(viewOwner, viewport), _gc{GetGraphicsContext()}, _viewport2D{*viewport}, _textureAtlas(_gc->GetTextureAtlas(WIDGET_TEXTURE_ATLAS)), _vertices(this) { }
void* wxGCDCImpl::GetHandle() const { void* cgctx = NULL; wxGraphicsContext* gc = GetGraphicsContext(); if (gc) { cgctx = gc->GetNativeContext(); } return cgctx; }
// ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ // ¥ TBReceiveNextEvent // ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ // use this instead of ReceiveNextEvent to ensure dirty regions are protected OSStatus CProgram::TBReceiveNextEvent( UInt32 inNumTypes, const EventTypeSpec * inList, EventTimeout inTimeout, Boolean inPullEvent, EventRef * outEvent) { OSStatus err=noErr; // clear rgn so no auto blits happen during event processing if (GetGraphicsContext()) GetGraphicsContext()->ClearQDDirtyRgn(); err=::ReceiveNextEvent(inNumTypes,inList,inTimeout,inPullEvent,outEvent); // fill rgn so no time is wasted when qd calls do their invalling thing if (GetGraphicsContext()) GetGraphicsContext()->FillQDDirtyRgn(); return err; }
wxRect wxGCDCImpl::MSWApplyGDIPlusTransform(const wxRect& r) const { wxGraphicsContext* const gc = GetGraphicsContext(); wxCHECK_MSG( gc, r, wxT("Invalid wxGCDC") ); double x = 0, y = 0; gc->GetTransform().TransformPoint(&x, &y); wxRect rect(r); rect.Offset(x, y); return rect; }
wxClientDCImpl::~wxClientDCImpl() { if( GetGraphicsContext() && GetGraphicsContext()->GetNativeContext() && !m_release ) Flush(); }
OpenWarSurface::OpenWarSurface(glm::vec2 size, float pixelDensity) : Surface(size, pixelDensity), _buttonRendering(nullptr), _editorModel(nullptr), _editorGesture(nullptr), _buttonsTopLeft(nullptr), _buttonsTopRight(nullptr), _buttonGesture(nullptr), _buttonItemHand(nullptr), _buttonItemPaint(nullptr), _buttonItemErase(nullptr), _buttonItemSmear(nullptr), _buttonItemHills(nullptr), _buttonItemTrees(nullptr), _buttonItemWater(nullptr), _buttonItemFords(nullptr), _scriptHintRenderer(nullptr), _battleLayer(nullptr) { _battleLayer = new BattleLayer(); _battleLayer->SetContainer(this); _buttonRendering = new ButtonRendering(renderers::singleton, pixelDensity); _buttonsTopLeft = new ButtonGrid(_buttonRendering, ButtonAlignment::TopLeft); _buttonsTopRight = new ButtonGrid(_buttonRendering, ButtonAlignment::TopRight); _buttonsTopLeft->SetContainer(this); _buttonsTopRight->SetContainer(this); _buttonGesture = new ButtonGesture(this); _buttonGesture->buttonViews.push_back(_buttonsTopLeft); _buttonGesture->buttonViews.push_back(_buttonsTopRight); ButtonArea* toolButtonArea = _buttonsTopLeft->AddButtonArea(4); _buttonItemHand = toolButtonArea->AddButtonItem(_buttonRendering->buttonEditorToolHand); _buttonItemSmear = toolButtonArea->AddButtonItem(_buttonRendering->buttonEditorToolSmear); _buttonItemPaint = toolButtonArea->AddButtonItem(_buttonRendering->buttonEditorToolPaint); _buttonItemErase = toolButtonArea->AddButtonItem(_buttonRendering->buttonEditorToolErase); ButtonArea* featureButtonArea = _buttonsTopLeft->AddButtonArea(4); _buttonItemHills = featureButtonArea->AddButtonItem(_buttonRendering->buttonEditorToolHills); _buttonItemTrees = featureButtonArea->AddButtonItem(_buttonRendering->buttonEditorToolTrees); _buttonItemWater = featureButtonArea->AddButtonItem(_buttonRendering->buttonEditorToolWater); _buttonItemFords = featureButtonArea->AddButtonItem(_buttonRendering->buttonEditorToolFords); _buttonItemHand->SetAction([this]() { SetEditorMode(EditorMode::Hand); }); _buttonItemPaint->SetAction([this]() { SetEditorMode(EditorMode::Paint); }); _buttonItemErase->SetAction([this]() { SetEditorMode(EditorMode::Erase); }); _buttonItemSmear->SetAction([this]() { SetEditorMode(EditorMode::Smear); }); _buttonItemHills->SetAction([this]() { SetEditorFeature(TerrainFeature::Hills); }); _buttonItemTrees->SetAction([this]() { SetEditorFeature(TerrainFeature::Trees); }); _buttonItemWater->SetAction([this]() { SetEditorFeature(TerrainFeature::Water); }); _buttonItemFords->SetAction([this]() { SetEditorFeature(TerrainFeature::Fords); }); _buttonItemHand->SetKeyboardShortcut('1'); _buttonItemSmear->SetKeyboardShortcut('2'); _buttonItemPaint->SetKeyboardShortcut('3'); _buttonItemErase->SetKeyboardShortcut('4'); _buttonItemHills->SetKeyboardShortcut('5'); _buttonItemTrees->SetKeyboardShortcut('6'); _buttonItemWater->SetKeyboardShortcut('7'); _buttonItemFords->SetKeyboardShortcut('8'); OnFrameChanged(); UpdateButtonsAndGestures(); _scriptHintRenderer = new GradientLineShape3(GetGraphicsContext()); }