Beispiel #1
0
/**
**  Toggle full screen mode.
*/
void ToggleFullScreen()
{
#ifdef USE_MAEMO
	// On Maemo is only supported fullscreen mode
	return;
#endif
#ifdef USE_WIN32
	long framesize;
	SDL_Rect clip;
	Uint32 flags;
	int w;
	int h;
	int bpp;
	unsigned char *pixels = NULL;
	SDL_Color *palette = NULL;
	int ncolors = 0;

	if (!TheScreen) { // don't bother if there's no surface.
		return;
	}

	flags = TheScreen->flags;
	w = TheScreen->w;
	h = TheScreen->h;
	bpp = TheScreen->format->BitsPerPixel;

	if (!SDL_VideoModeOK(w, h, bpp,	flags ^ SDL_FULLSCREEN)) {
		return;
	}

	SDL_GetClipRect(TheScreen, &clip);

	// save the contents of the screen.
	framesize = w * h * TheScreen->format->BytesPerPixel;

#if defined(USE_OPENGL) || defined(USE_GLES)
	if (!UseOpenGL)
#endif
	{
		if (!(pixels = new unsigned char[framesize])) { // out of memory
			return;
		}
		SDL_LockSurface(TheScreen);
		memcpy(pixels, TheScreen->pixels, framesize);

		if (TheScreen->format->palette) {
			ncolors = TheScreen->format->palette->ncolors;
			if (!(palette = new SDL_Color[ncolors])) {
				delete[] pixels;
				return;
			}
			memcpy(palette, TheScreen->format->palette->colors,
				   ncolors * sizeof(SDL_Color));
		}
		SDL_UnlockSurface(TheScreen);
	}

	TheScreen = SDL_SetVideoMode(w, h, bpp, flags ^ SDL_FULLSCREEN);
	if (!TheScreen) {
		TheScreen = SDL_SetVideoMode(w, h, bpp, flags);
		if (!TheScreen) { // completely screwed.
#if defined(USE_OPENGL) || defined(USE_GLES)
			if (!UseOpenGL)
#endif
			{
				delete[] pixels;
				delete[] palette;
			}
			fprintf(stderr, "Toggle to fullscreen, crashed all\n");
			Exit(-1);
		}
	}

#ifndef USE_TOUCHSCREEN
	// Cannot hide cursor on Windows with touchscreen, as it switches
	// to relative mouse coordinates in fullscreen. See above initial
	// call to ShowCursor
	//
	// Windows shows the SDL cursor when starting in fullscreen mode
	// then switching to window mode.  This hides the cursor again.
	SDL_ShowCursor(SDL_ENABLE);
	SDL_ShowCursor(SDL_DISABLE);
#endif

#if defined(USE_OPENGL) || defined(USE_GLES)
	if (UseOpenGL) {
		ReloadOpenGL();
	} else
#endif
	{
		SDL_LockSurface(TheScreen);
		memcpy(TheScreen->pixels, pixels, framesize);
		delete[] pixels;

		if (TheScreen->format->palette) {
			// !!! FIXME : No idea if that flags param is right.
			SDL_SetPalette(TheScreen, SDL_LOGPAL, palette, 0, ncolors);
			delete[] palette;
		}
		SDL_UnlockSurface(TheScreen);
	}

	SDL_SetClipRect(TheScreen, &clip);

	Invalidate(); // Update display
#else // !USE_WIN32
	SDL_WM_ToggleFullScreen(TheScreen);
#endif

	Video.FullScreen = (TheScreen->flags & SDL_FULLSCREEN) ? 1 : 0;
}
void FSingleTileEditorViewportClient::SetTileIndex(int32 InTileIndex)
{
	const int32 OldTileIndex = TileBeingEditedIndex;
	const bool bNewIndexValid = (InTileIndex >= 0) && (InTileIndex < TileSet->GetTileCount());
	TileBeingEditedIndex = bNewIndexValid ? InTileIndex : INDEX_NONE;

	FSpriteGeometryEditMode* GeometryEditMode = ModeTools->GetActiveModeTyped<FSpriteGeometryEditMode>(FSpriteGeometryEditMode::EM_SpriteGeometry);
	check(GeometryEditMode);
	FSpriteGeometryCollection* GeomToEdit = nullptr;
	
	if (TileBeingEditedIndex != INDEX_NONE)
	{
		if (FPaperTileMetadata* Metadata = TileSet->GetMutableTileMetadata(InTileIndex))
		{
			GeomToEdit = &(Metadata->CollisionData);
		}
	}

	// Tell the geometry editor about the new tile (if it exists)
	GeometryEditMode->SetGeometryBeingEdited(GeomToEdit, /*bAllowCircles=*/ true, /*bAllowSubtractivePolygons=*/ false);

	// Update the visual representation
	UPaperSprite* DummySprite = nullptr;
	if (TileBeingEditedIndex != INDEX_NONE)
	{
		DummySprite = NewObject<UPaperSprite>();
 		DummySprite->SpriteCollisionDomain = ESpriteCollisionMode::None;
 		DummySprite->PivotMode = ESpritePivotMode::Center_Center;
 		DummySprite->CollisionGeometry.GeometryType = ESpritePolygonMode::SourceBoundingBox;
 		DummySprite->RenderGeometry.GeometryType = ESpritePolygonMode::SourceBoundingBox;

		FSpriteAssetInitParameters SpriteReinitParams;

		SpriteReinitParams.Texture = TileSet->GetTileSheetTexture();

		//@TODO: Should analyze the texture (*at a higher level, not per tile click!*) to pick the correct material
		FVector2D UV;
		TileSet->GetTileUV(TileBeingEditedIndex, /*out*/ UV);
		SpriteReinitParams.Offset = FIntPoint((int32)UV.X, (int32)(UV.Y));
		SpriteReinitParams.Dimension = TileSet->GetTileSize();
		SpriteReinitParams.SetPixelsPerUnrealUnit(1.0f);
		DummySprite->InitializeSprite(SpriteReinitParams);
	}
	PreviewTileSpriteComponent->SetSprite(DummySprite);

	// Update the default geometry bounds
	const FVector2D HalfTileSize(TileSet->GetTileSize().X * 0.5f, TileSet->GetTileSize().Y * 0.5f);
	FBox2D DesiredBounds(ForceInitToZero);
	DesiredBounds.Min = -HalfTileSize;
	DesiredBounds.Max = HalfTileSize;
	GeometryEditMode->SetNewGeometryPreferredBounds(DesiredBounds);

	// Zoom to fit when we start editing a tile and weren't before, but leave it alone if we just changed tiles, in case they zoomed in or out further
	if ((TileBeingEditedIndex != INDEX_NONE) && (OldTileIndex == INDEX_NONE))
	{
		RequestFocusOnSelection(/*bInstant=*/ true);
	}

	// Trigger a details panel customization rebuild
	OnSingleTileIndexChanged.Broadcast(TileBeingEditedIndex, OldTileIndex);

	// Redraw the viewport
	Invalidate();
}
Beispiel #3
0
	void CDateTimeUI::SetTime(SYSTEMTIME* pst)
	{
		m_sysTime = *pst;
		Invalidate();
	}
Beispiel #4
0
void Styler_SearchHL::Delete(unsigned int start_pos, unsigned int end_pos) {
	wxASSERT(0 <= start_pos && start_pos <= m_doc.GetLength());
	if (m_text.empty()) return;

	if (start_pos == end_pos) return;
	wxASSERT(end_pos > start_pos);

	// Check if we have deleted the entire document
	if (m_doc.GetLength() == 0) {
		Invalidate();
		return;
	}

	// Adjust start & end
	unsigned int length = end_pos - start_pos;
	if (m_search_start >= start_pos) {
		if (m_search_start > end_pos) m_search_start -= length;
		else m_search_start = start_pos;
	}
	if (m_search_end > start_pos) {
		if (m_search_end > end_pos) m_search_end -= length;
		else m_search_end = start_pos;
	}
	else return; // Change after search area, no need to re-search

	unsigned int search_start = m_search_start;

	if (!m_matches.empty()) {
		if (start_pos >= m_matches.back().end) {
			// Do a new search from end of last match
			DoSearch(search_start, m_search_end, true);
			return;
		}

		// Find matches touched by deletion and remove those. Update all following
		bool is_first = true;
		vector<interval>::iterator p = m_matches.begin();
		while (p != m_matches.end()) {
			if (p->end > start_pos) {
				// Remember first valid match before pos
				if (is_first) {
					if (p != m_matches.begin()) search_start = (p-1)->end;
					is_first = false;
				}

				if (p->start < end_pos) {
					// pos inside match. Delete and continue
					p = m_matches.erase(p);
					if (p != m_matches.end()) continue; // new iterator
					else break;
				}
				else {
					// Move match to correct position
					p->start -= length;
					p->end -= length;
				}
			}
			++p;
		}
	}

	// Do a new search starting from end of first match before pos
	DoSearch(search_start, m_search_end, false);
}
void FSingleTileEditorViewportClient::MarkTransactionAsDirty()
{
	bManipulationDirtiedSomething = true;
	Invalidate();
}
Beispiel #6
0
bool FBODefinition::Create()
{
#if MYFW_WINDOWS
    if( glGenFramebuffers == 0 )
    {
        return false;
    }
#endif
#if MYFW_IOS || MYFW_ANDROID
    //return false;
#endif

#if !USE_D3D
    GLint maxsize;

    glGetIntegerv( GL_MAX_RENDERBUFFER_SIZE, &maxsize );
    LOGInfo( LOGTag, "CreateFBO - maxsize: %d\n", maxsize );

#if MYFW_ANDROID
    int range[2], precision;
    glGetShaderPrecisionFormat( GL_FRAGMENT_SHADER, GL_HIGH_FLOAT, range, &precision );
    LOGInfo( LOGTag, "CreateFBO - High float precision: %d\n", precision );
    LOGInfo( LOGTag, "CreateFBO - High float range min: %d\n", range[0] );
    LOGInfo( LOGTag, "CreateFBO - High float range max: %d\n", range[1] );
    glGetShaderPrecisionFormat( GL_FRAGMENT_SHADER, GL_MEDIUM_FLOAT, range, &precision );
    LOGInfo( LOGTag, "CreateFBO - Medium float precision: %d\n", precision );
    LOGInfo( LOGTag, "CreateFBO - Medium float range min: %d\n", range[0] );
    LOGInfo( LOGTag, "CreateFBO - Medium float range max: %d\n", range[1] );
    glGetShaderPrecisionFormat( GL_FRAGMENT_SHADER, GL_LOW_FLOAT, range, &precision );
    LOGInfo( LOGTag, "CreateFBO - Low float precision: %d\n", precision );
    LOGInfo( LOGTag, "CreateFBO - Low float range min: %d\n", range[0] );
    LOGInfo( LOGTag, "CreateFBO - Low float range max: %d\n", range[1] );
#endif

    if( m_TextureWidth > (unsigned int)maxsize || m_TextureHeight > (unsigned int)maxsize )
    {
        // requested size is too big.
        return false;
    }

    MyAssert( m_FrameBufferID == 0 );

    // get a framebuffer, render buffer and a texture from opengl.
    glGenFramebuffers( 1, &m_FrameBufferID );
    checkGlError( "glGenFramebuffers" );

    if( m_NeedColorTexture )
    {
        m_pColorTexture = MyNew TextureDefinition();
        glGenTextures( 1, &m_pColorTexture->m_TextureID );
        m_pColorTexture->m_MinFilter = m_MinFilter;
        m_pColorTexture->m_MagFilter = m_MagFilter;
        m_pColorTexture->m_WrapS = GL_CLAMP_TO_EDGE;
        m_pColorTexture->m_WrapT = GL_CLAMP_TO_EDGE;
        m_pColorTexture->m_Width = m_Width;
        m_pColorTexture->m_Height = m_Height;
    }
    checkGlError( "glGenTextures" );

    if( m_DepthBits != 0 )
    {
        m_pDepthTexture = MyNew TextureDefinition();

        MyAssert( m_DepthBits == 16 || m_DepthBits == 24 || m_DepthBits == 32 );

        if( m_DepthIsTexture )
        {
            glGenTextures( 1, &m_pDepthTexture->m_TextureID );
            checkGlError( "glGenTextures" );
        }
        else
        {
            glGenRenderbuffers( 1, &m_pDepthTexture->m_TextureID );
            checkGlError( "glGenRenderbuffers" );
        }

        m_pDepthTexture->m_Width = m_Width;
        m_pDepthTexture->m_Height = m_Height;
    }

    // create the texture
    if( m_pColorTexture && m_pColorTexture->m_TextureID != 0 )
    {
        glBindTexture( GL_TEXTURE_2D, m_pColorTexture->m_TextureID );
        //glTexImage2D( GL_TEXTURE_2D, 0, GL_RGB, m_TextureWidth, m_TextureHeight, 0, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, NULL );
        glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, m_TextureWidth, m_TextureHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL );
        glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
        glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
        glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, m_MinFilter );
        glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, m_MagFilter );
        glBindTexture( GL_TEXTURE_2D, 0 );
        checkGlError( "glBindTexture" );
    }

    // create a depth renderbuffer.
    if( m_pDepthTexture && m_pDepthTexture->m_TextureID != 0 )
    {
#if !MYFW_OPENGLES2
        GLint depthformat = GL_DEPTH_COMPONENT32;
        if( m_DepthBits == 24 )
            depthformat = GL_DEPTH_COMPONENT24;
        else if( m_DepthBits == 16 )
            depthformat = GL_DEPTH_COMPONENT16;
#else
        GLint depthformat = GL_DEPTH_COMPONENT16;
#endif

        if( m_DepthIsTexture )
        {
            glBindTexture( GL_TEXTURE_2D, m_pDepthTexture->m_TextureID );
            checkGlError( "glBindTexture" );
            glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST );
            glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST );
            glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
            glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
            checkGlError( "glTexParameteri" );
            glTexImage2D( GL_TEXTURE_2D, 0, depthformat, m_TextureWidth, m_TextureHeight, 0,
                          GL_DEPTH_COMPONENT, GL_UNSIGNED_BYTE, 0 );
                          //GL_DEPTH_COMPONENT, GL_FLOAT, 0 );
            checkGlError( "glTexImage2D" );
            glBindTexture( GL_TEXTURE_2D, 0 );
            checkGlError( "glBindTexture" );
        }
        else
        {
            glBindRenderbuffer( GL_RENDERBUFFER, m_pDepthTexture->m_TextureID );
            glRenderbufferStorage( GL_RENDERBUFFER, depthformat, m_TextureWidth, m_TextureHeight );
            checkGlError( "glRenderbufferStorageEXT" );
        }
    }

    // attach everything to the FBO
    {
        MyBindFramebuffer( GL_FRAMEBUFFER, m_FrameBufferID, 0, 0 );

        // attach color texture
        if( m_pColorTexture && m_pColorTexture->m_TextureID != 0 )
            glFramebufferTexture2D( GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, m_pColorTexture->m_TextureID, 0 );

        // attach depth renderbuffer
        if( m_pDepthTexture && m_pDepthTexture->m_TextureID != 0 )
        {
            if( m_DepthIsTexture )
            {
                glFramebufferTexture2D( GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, m_pDepthTexture->m_TextureID, 0 );
            }
            else
            {
               glFramebufferRenderbuffer( GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, m_pDepthTexture->m_TextureID );
            }
        }

        MyBindFramebuffer( GL_FRAMEBUFFER, 0, 0, 0 );
        checkGlError( "glBindFramebufferEXT" );
    }

    // any problems?
    GLint status = glCheckFramebufferStatus( GL_FRAMEBUFFER );
    checkGlError( "glCheckFramebufferStatus" );
    if( status != GL_FRAMEBUFFER_COMPLETE )
    {
        LOGInfo( LOGTag, "CreateFBO - error\n" );
        //MyAssert( false );
        Invalidate( true );
        return false;
    }

    LOGInfo( LOGTag, "CreateFBO - complete (%d, %d)\n", m_TextureWidth, m_TextureHeight );
#else
    return false;
#endif

    return true;
}
Beispiel #7
0
static bool
_nc_mouse_parse(SCREEN *sp, int runcount)
/* parse a run of atomic mouse events into a gesture */
{
    MEVENT *eventp = sp->_mouse_eventp;
    MEVENT *next, *ep;
    MEVENT *first_valid = NULL;
    MEVENT *first_invalid = NULL;
    int n;
    int b;
    bool merge;
    bool endLoop;

    TR(MY_TRACE, ("_nc_mouse_parse(%d) called", runcount));

    /*
     * When we enter this routine, the event list next-free pointer
     * points just past a run of mouse events that we know were separated
     * in time by less than the critical click interval. The job of this
     * routine is to collapse this run into a single higher-level event
     * or gesture.
     *
     * We accomplish this in two passes.  The first pass merges press/release
     * pairs into click events.  The second merges runs of click events into
     * double or triple-click events.
     *
     * It's possible that the run may not resolve to a single event (for
     * example, if the user quadruple-clicks).  If so, leading events
     * in the run are ignored if user does not call getmouse in a loop (getting
     * them from newest to older).
     *
     * Note that this routine is independent of the format of the specific
     * format of the pointing-device's reports.  We can use it to parse
     * gestures on anything that reports press/release events on a per-
     * button basis, as long as the device-dependent mouse code puts stuff
     * on the queue in MEVENT format.
     */

    /*
     * Reset all events that were not set, in case the user sometimes calls
     * getmouse only once and other times until there are no more events in
     * queue.
     *
     * This also allows reaching the beginning of the run.
     */
    ep = eventp;
    for (n = runcount; n < EV_MAX; n++) {
	Invalidate(ep);
	ep = NEXT(ep);
    }

#ifdef TRACE
    if (USE_TRACEF(TRACE_IEVENT)) {
	_trace_slot(sp, "before mouse press/release merge:");
	_tracef("_nc_mouse_parse: run starts at %ld, ends at %ld, count %d",
		RunParams(sp, eventp, ep),
		runcount);
	_nc_unlock_global(tracef);
    }
#endif /* TRACE */

    /* first pass; merge press/release pairs */
    endLoop = FALSE;
    while (!endLoop) {
	next = NEXT(ep);
	if (next == eventp) {
	    /* Will end the loop, but compact before */
	    endLoop = TRUE;
	} else {

#define MASK_CHANGED(x) (!(ep->bstate & MASK_PRESS(x)) \
		      == !(next->bstate & MASK_RELEASE(x)))

	    if (ValidEvent(ep) && ValidEvent(next)
		&& ep->x == next->x && ep->y == next->y
		&& (ep->bstate & BUTTON_PRESSED)
		&& (!(next->bstate & BUTTON_PRESSED))) {
		bool changed = TRUE;

		for (b = 1; b <= MAX_BUTTONS; ++b) {
		    if (!MASK_CHANGED(b)) {
			changed = FALSE;
			break;
		    }
		}

		if (changed) {
		    merge = FALSE;
		    for (b = 1; b <= MAX_BUTTONS; ++b) {
			if ((sp->_mouse_mask & MASK_CLICK(b))
			    && (ep->bstate & MASK_PRESS(b))) {
			    next->bstate &= ~MASK_RELEASE(b);
			    next->bstate |= MASK_CLICK(b);
			    merge = TRUE;
			}
		    }
		    if (merge) {
			Invalidate(ep);
		    }
		}
	    }
	}

	/* Compact valid events */
	if (!ValidEvent(ep)) {
	    if ((first_valid != NULL) && (first_invalid == NULL)) {
		first_invalid = ep;
	    }
	} else {
	    if (first_valid == NULL) {
		first_valid = ep;
	    } else if (first_invalid != NULL) {
		*first_invalid = *ep;
		Invalidate(ep);
		first_invalid = NEXT(first_invalid);
	    }
	}

	ep = next;
    }

    if (first_invalid != NULL) {
	eventp = first_invalid;
    }
#ifdef TRACE
    if (USE_TRACEF(TRACE_IEVENT)) {
	_trace_slot(sp, "before mouse click merge:");
	if (first_valid == NULL) {
	    _tracef("_nc_mouse_parse: no valid event");
	} else {
	    _tracef("_nc_mouse_parse: run starts at %ld, ends at %ld, count %d",
		    RunParams(sp, eventp, first_valid),
		    runcount);
	    _nc_unlock_global(tracef);
	}
    }
#endif /* TRACE */

    /*
     * Second pass; merge click runs.  We merge click events forward in the
     * queue.  For example, double click can be changed to triple click.
     *
     * NOTE: There is a problem with this design!  If the application
     * allows enough click events to pile up in the circular queue so
     * they wrap around, it will cheerfully merge the newest forward
     * into the oldest, creating a bogus doubleclick and confusing
     * the queue-traversal logic rather badly.  Generally this won't
     * happen, because calling getmouse() marks old events invalid and
     * ineligible for merges.  The true solution to this problem would
     * be to timestamp each MEVENT and perform the obvious sanity check,
     * but the timer element would have to have sub-second resolution,
     * which would get us into portability trouble.
     */
    first_invalid = NULL;
    endLoop = (first_valid == NULL);
    ep = first_valid;
    while (!endLoop) {
	next = NEXT(ep);

	if (next == eventp) {
	    /* Will end the loop, but check event type and compact before */
	    endLoop = TRUE;
	} else if (!ValidEvent(next)) {
	    continue;
	} else {
	    /* merge click events forward */
	    if ((ep->bstate & BUTTON_CLICKED)
		&& (next->bstate & BUTTON_CLICKED)) {
		merge = FALSE;
		for (b = 1; b <= MAX_BUTTONS; ++b) {
		    if ((sp->_mouse_mask & MASK_DOUBLE_CLICK(b))
			&& (ep->bstate & MASK_CLICK(b))
			&& (next->bstate & MASK_CLICK(b))) {
			next->bstate &= ~MASK_CLICK(b);
			next->bstate |= MASK_DOUBLE_CLICK(b);
			merge = TRUE;
		    }
		}
		if (merge) {
		    Invalidate(ep);
		}
	    }

	    /* merge double-click events forward */
	    if ((ep->bstate & BUTTON_DOUBLE_CLICKED)
		&& (next->bstate & BUTTON_CLICKED)) {
		merge = FALSE;
		for (b = 1; b <= MAX_BUTTONS; ++b) {
		    if ((sp->_mouse_mask & MASK_TRIPLE_CLICK(b))
			&& (ep->bstate & MASK_DOUBLE_CLICK(b))
			&& (next->bstate & MASK_CLICK(b))) {
			next->bstate &= ~MASK_CLICK(b);
			next->bstate |= MASK_TRIPLE_CLICK(b);
			merge = TRUE;
		    }
		}
		if (merge) {
		    Invalidate(ep);
		}
	    }
	}

	/* Discard event if it does not match event mask */
	if (!(ep->bstate & sp->_mouse_mask2)) {
	    Invalidate(ep);
	}

	/* Compact valid events */
	if (!ValidEvent(ep)) {
	    if (ep == first_valid) {
		first_valid = next;
	    } else if (first_invalid == NULL) {
		first_invalid = ep;
	    }
	} else if (first_invalid != NULL) {
	    *first_invalid = *ep;
	    Invalidate(ep);
	    first_invalid = NEXT(first_invalid);
	}

	ep = next;
    }

    if (first_invalid == NULL) {
	first_invalid = eventp;
    }
    sp->_mouse_eventp = first_invalid;

#ifdef TRACE
    if (first_valid != NULL) {
	if (USE_TRACEF(TRACE_IEVENT)) {
	    _trace_slot(sp, "after mouse event queue compaction:");
	    _tracef("_nc_mouse_parse: run starts at %ld, ends at %ld, count %d",
		    RunParams(sp, first_invalid, first_valid),
		    runcount);
	    _nc_unlock_global(tracef);
	}
	for (ep = first_valid; ep != first_invalid; ep = NEXT(ep)) {
	    if (ValidEvent(ep))
		TR(MY_TRACE,
		   ("_nc_mouse_parse: returning composite mouse event %s at slot %ld",
		    _nc_tracemouse(sp, ep),
		    (long) IndexEV(sp, ep)));
	}
    }
#endif /* TRACE */

    /* after all this, do we have a valid event? */
    return ValidEvent(PREV(first_invalid));
}
void EventSheetEditor::OnMouseMove(UINT nFlags, CPoint point) 
{
	if(!m_pHeader)
		return;
	m_ObjectHeaderTooltip.ShowAt(point, *this);

	m_Mouse = point;
	m_pHeader->OnMouseMove(point);
	if(m_pHeader->m_isDrag)
		Invalidate();

	else
	{
		// Is is possible we might be dragging.
		if(!m_Drag.IsDragging && m_leftDown)
		{
			if(	( (point.x - m_Drag.StoredPos.x)*(point.x - m_Drag.StoredPos.x)
				+(point.y - m_Drag.StoredPos.y)*(point.y - m_Drag.StoredPos.y)) >  8)
			{
				switch (m_Drag.dragtype)
				{
					case EVENT:
					{
						SelectedEventVector  m_SelectedEvents;
						CreateEventSelectionVectorLimited(m_SelectedEvents,(*m_pEventList));
						CEditorDragEvents* Events = new CEditorDragEvents;

						Events->pEd = this;
						Events->m_pSelectedEvents = &m_SelectedEvents;

						DROPEFFECT de = DROPEFFECT_COPY;
						m_pDDMgr->PrepareDrop(DO_DRAGDROP,"Construct Events",Events,&de);				
					
						// wait till the drop is done...then....
						m_Drag.dragtype = -1;
						m_Drag.IsDragging = false;
						Invalidate();
					}
					break;

					case CONDITION:
					{
						SelectedConditionVector m_SelectedConditions;
						CreateConditionSelectionVector(m_SelectedConditions,(*m_pEventList));
						CEditorDragConditions* Conditions = new CEditorDragConditions;

						Conditions->pEd = this;
						Conditions->m_pSelectedConditions = &m_SelectedConditions;

						DROPEFFECT de = DROPEFFECT_COPY;
						m_pDDMgr->PrepareDrop(DO_DRAGDROP,"Construct Conditions",Conditions,&de);				
					
						// wait till the drop is done..then...
						m_Drag.dragtype = -1;
						m_Drag.IsDragging = false;
						Invalidate();
						m_SelectedConditions.clear();
					
					}
					break;

					case ACTION:
					{
						SelectedActionVector m_SelectedActions;
						CreateActionSelectionVector(m_SelectedActions,(*m_pEventList));
						CEditorDragActions* Actions = new CEditorDragActions;
						
						Actions->pEd = this;
						Actions->m_pSelectedActions = &m_SelectedActions;

						DROPEFFECT de = DROPEFFECT_COPY;
						m_pDDMgr->PrepareDrop(DO_DRAGDROP,"Construct Actions",Actions,&de);				
					
						// wait till the drop is done..then...
						m_Drag.dragtype = -1;
						m_Drag.IsDragging = false;
						Invalidate();
						m_SelectedActions.clear();
					}
					break;	

					case OBJECT:
					{
						CEditorDragObject* Objects = new CEditorDragObject;
						Objects->pEd = (EventSheetEditor*)this;
						Objects->ObjectIdentifier = m_pHeader->GetObjectAtX(m_Drag.StoredPos.x)->oid;

						DROPEFFECT de = DROPEFFECT_COPY;
						m_pDDMgr->PrepareDrop(DO_DRAGDROP,"Construct Object",Objects,&de);				
					
						// wait till the drop is done..then...
						m_Drag.dragtype = -1;
						m_Drag.IsDragging = false;
						Invalidate();
					}
					break;	

					default:
					break;
				}
			}
		}
		else
		{
			//Tooltips
			CEditorEvent* pMyEvent = EventAt(point);

			if(pMyEvent)
			{
				SelectedActionVector actions;
				CEditorAction* pAction = pMyEvent->actionAt(point, actions, this);
				CEditorCondition* pCondition = pMyEvent->conditionAt(point, this);
				if(pMyEvent->m_displayActionType(this) < 2)	//only grid and chrono should show the tooltip
				{	
					if(pAction)
					{
						
						CPoint pt = (actions[0])->m_rect(this).TopLeft();
						pt.x += 16;
						pt.y = (actions[0])->m_rect(this).bottom-4;
						if(!m_InsertBefore.IsWindowVisible())
							m_ActionTooltip.ShowAt(pt,actions,*this);		
					}
					else
					{
						m_ActionTooltip.Hide();
					}

				}
				else
				{
						


				}
			}
			else
				m_ActionTooltip.Hide();
			
		}
	}

	SelectedConditionVector SelectedConditions;
	CreateConditionSelectionVector(SelectedConditions,(*m_pEventList));

	for(int c = 0; c < SelectedConditions.size(); c++)
		InvalidateRect(SelectedConditions[c]->m_rect(this));

	SelectedActionVector SelectedActions;
	CreateActionSelectionVector(SelectedActions,(*m_pEventList));

	for(int a = 0; a < SelectedActions.size(); a++)
		InvalidateRect(SelectedActions[a]->m_rect(this));

	SelectedEventVector SelectedEvents;
	CreateEventSelectionVector(SelectedEvents,(*m_pEventList));

	for(int e = 0; e < SelectedEvents.size(); e++)
		InvalidateRect(SelectedEvents[e]->m_rect(this));

	////////////////////////
	// Change to a hand cursor if overlapping "new action"
	bool useHandCursor = false;
	static CEditorEvent* pLastEvent = NULL;

	if (pLastEvent)
	{
		pLastEvent->mouseOverNewAction = false;
		pLastEvent->mouseOverFooter = false;

	}

	if (!(point.x >= m_pHeader->m_Split - 2 && point.x <= m_pHeader->m_Split + 5))
	{
		CEditorEvent* pEvent = this->EventAt(point);
		if(pEvent)
		{
			pEvent->mouseOverNewAction = false;
			pEvent->mouseOverFooter = false;

			if(pEvent->canAddActions())
			{
				if(pEvent->m_gridRec(this).PtInRect(point))
				{
					useHandCursor = true;
					pEvent->mouseOverNewAction = true;
				}
			}
			if(pEvent->m_type == 2 && pEvent->m_open(this)) // Group
			{
				CRect Footer = pEvent->m_rect(this);
				Footer.top = Footer.bottom - 17;
				Footer.left += EVENT_INDENT * 2;


				if(Footer.PtInRect(point))
				{
					useHandCursor = true;
					pEvent->mouseOverFooter = true;
				}
			}


			pLastEvent = pEvent;

			this->Invalidate();
		}
	}
	////////////////////////
	// Change to a hand cursor if overlapping "new event to group"


	static HCURSOR handCursor = LoadCursor(NULL, IDC_HAND);
	static HCURSOR arrowCursor = LoadCursor(NULL, IDC_ARROW);

	if (useHandCursor)
		SetCursor(handCursor);
	//else
	//	SetCursor(arrowCursor);
	////////////////////////

	int objid = 0;
	CPoint pt = point;   // copy!	
	CRect myrect;
	GetWindowRect(&myrect);


	CRect rect;
	rect.top = pt.y;
	rect.left = pt.x;
	rect.right = pt.x + 20;
	rect.bottom = pt.y + 20;

	CScrollView::OnMouseMove(nFlags, point);
}
 /*****************************************************************************
 * Function - Update
 * DESCRIPTION: Check if pointer pSubject is one of the subjects observed.
 * If it is then put the pointer in queue and request task time for sub task.
 *
 *****************************************************************************/
 void InputFunctionState::Update(Subject* pSubject)
 {
   Invalidate();
 }
Beispiel #10
0
//绘画背景
BOOL CPlazaViewItem::OnEraseBkgnd(CDC * pDC)
{
	Invalidate(FALSE);
	UpdateWindow();
	return TRUE;
}
void EventSheetEditor::OnLButtonDown(UINT nFlags, CPoint pt) 
{
	if (!(pt.x >= m_pHeader->m_Split - 2 && pt.x <= m_pHeader->m_Split + 5))
	{
		CEditorEvent* pEvent = EventAt(pt);
		if(pEvent)
		{
			if(pEvent->canAddActions())
			{
				if(pEvent->mouseOverNewAction)
				{
					AddAction(pEvent, -1);
					return;
				}
				if(pEvent->mouseOverFooter)
				{
					AddCondition(false, NULL, true, pEvent);
					return;
				}		
			}
		}
	}

	if(KillFocusOnInlineEditor())
		return;
	m_ActionTooltip.Hide();

	CEditorEvent* pMyEventParent = NULL;
	CEditorEvent* pMyEvent = EventAt(pt, &pMyEventParent);
	m_leftDown = true;
	
	//if(m_pHeader->m_rect.PtInRect(pt))
	if(pt.x >= m_pHeader->m_Split - 2 && pt.x <= m_pHeader->m_Split + 5)
	{
		m_InsertAfter.Hide();
		m_InsertBefore.Hide();
		m_InsertSub.Hide();
		m_ActionTooltip.Hide();
		m_pHeader->OnLeftClick(pt);
		if(m_pHeader->m_isDrag)
		{
			SetCapture();
		}
		else // basically just if we arn't doing something interesting in the header...
		{
			if(!m_CtrlDown)
			{
				DeselectEvents();
				DeselectActions();
				DeselectConditions();
			}
		}



		for(int a = 0; a < m_pHeader->m_Objects.size(); a ++ )
		{
			if(m_pHeader->m_Objects.at(a).m_rect.PtInRect(pt))
			{
				m_Drag.dragtype = OBJECT;
				m_Drag.StoredPos = pt;
				m_Drag.CtrlDown = false;
			}
		}
	}
	else if(pMyEvent)
	{
		if(pMyEvent->PtInOnOffButton(pt, this))
		{
			// The user is clicked the + button
			pMyEvent->m_open(this) = pMyEvent->m_open(this) ? false:true;
			Invalidate();
			
		}

		else
		{
			///////////////
			// Select Condition
			
			CEditorCondition* pMyCondition = pMyEvent->conditionAt(pt, this);
			if(pMyCondition)
			{
				// find index
				int index = 0;
				for(int a = 0; a < pMyEvent->m_Conditions.size() ; a ++ )
					if(pMyEvent->m_Conditions[a] == pMyCondition)
						index = a;

				//Deselect selected events or actions
				DeselectEvents();
				DeselectActions();
				

				// Now the conditions
	
				if(pMyCondition->m_select(this)) // if we clicked on something already selected...wait till release
					m_ClickedSelectedCondition = true;
				else
				{
					if(!m_CtrlDown)
					{
						DeselectConditions();
					}
					pMyCondition->m_select(this) = true;
					InvalidateRect(pMyCondition->m_rect(this));
				}

				if( m_ShiftDown && m_FocusCondition)
				{
					bool b1 = false, b2 = false, b3 = false;
					RecursiveSelect(NULL, m_FocusCondition,NULL ,NULL ,pMyCondition ,NULL,b1,b2,b3, this->m_pEventList);
				}

				m_FocusCondition = pMyCondition;
				m_FocusEvent = pMyEvent;

				if(m_CtrlDown)
				{
					m_InsertAfter.Hide();
					m_InsertBefore.Hide();
					m_InsertSub.Hide();
				}
				else
				{	
					if(m_ClickedSelectedCondition)
					{
						CPoint point  = pMyCondition->m_rect(this).TopLeft();
						point.x = pt.x - 50;
						point.y -= 19;
						if(pMyEvent->m_displayConditionType(this) == 1)
						{
							point.y += 19;
							point.x = pMyCondition->m_rect(this).TopLeft().x - 100;
						}
						m_InsertBefore.ShowAt(point, pMyCondition, *this);
						m_InsertBefore.pEventEditor = (EventSheetEditor*)(this);


						point.y += 19 + pMyCondition->m_rect(this).Height();
						if(pMyEvent->m_displayConditionType(this) == 1)
						{
							point.y -= 19 + pMyCondition->m_rect(this).Height();
							point.x = pMyCondition->m_rect(this).right;
						}

						m_InsertAfter.ShowAt(point, pMyCondition, *this);
						m_InsertAfter.pEventEditor = (EventSheetEditor*)(this);

						m_InsertAfter.m_pInsertEventSpot = m_InsertBefore.m_pInsertEventSpot = pMyEvent;

						m_InsertAfter.m_InsertType       = m_InsertBefore.m_InsertType       = CONDITION;
						m_InsertAfter.m_InsertIndex      = m_InsertBefore.m_InsertIndex      = index;
						m_InsertAfter.m_IsAfter = true;
						m_InsertBefore.m_IsAfter = false;
						m_ActionTooltip.Hide();
					}
				}


				// We may be wanting to drag these conditions...
				m_Drag.dragtype = CONDITION;
				m_Drag.StoredPos = pt;
				m_Drag.IsDragging = false;
			}
			else
			{
				/////////////////////
				// Select Action

				SelectedActionVector actions;
				
				CEditorAction* pMyAction = pMyEvent->actionAt(pt, actions, this);

				if(pMyAction)
				{
					int index = 0;
					for(int a = 0; a < pMyEvent->m_Actions.size() ; a ++ )
						if (pMyEvent->m_Actions[a] == pMyAction)
							index = a;
			

					//Deselect selected events or conditions
					DeselectEvents();
					DeselectConditions();

					if(pMyAction->m_select(this)) // if we clicked on something already selected...wait till release
						m_ClickedSelectedAction = true;

					else
					{
						if(!m_CtrlDown)
						{
							DeselectActions();
						}
						pMyAction->m_select(this) = true;
						InvalidateRect(pMyAction->m_rect(this));						
					}
					if( m_ShiftDown && m_FocusAction)
					{
						bool b1 = false, b2 = false, b3 = false;
						RecursiveSelect(m_FocusAction,NULL ,NULL ,pMyAction , NULL ,NULL,b1,b2,b3, this->m_pEventList);
					}
					m_FocusAction = pMyAction;
					m_FocusEvent = pMyEvent;
					
					// We may be wanting to drag these conditions...
					m_Drag.dragtype = ACTION;
					m_Drag.StoredPos = pt;
					m_Drag.IsDragging = false;

		
					if(m_CtrlDown)
					{
						m_InsertAfter.Hide();
						m_InsertBefore.Hide();
						m_InsertSub.Hide();
					}
					else
					{

						if(m_ClickedSelectedAction)
						{
							CPoint point = pMyAction->m_rect(this).TopLeft();
							point.x = pt.x - 50;
							point.y -= 19;

							if(pMyEvent->m_displayActionType(this) == 1)
							{
								point.y += 19;
								point.x = pMyAction->m_rect(this).TopLeft().x - 100;
							}

							m_InsertBefore.ShowAt(point, pMyAction, *this);
							m_InsertBefore.pEventEditor = (EventSheetEditor*)(this);

							point.y += 19 + pMyAction->m_rect(this).Height();
						
							if(pMyEvent->m_displayActionType(this) == 1)
							{
								point.y -= 19 + pMyAction->m_rect(this).Height();
								point.x = pMyAction->m_rect(this).right;
							}

							m_InsertAfter.ShowAt(point, pMyCondition, *this);
							m_InsertAfter.pEventEditor = (EventSheetEditor*)(this);

							m_InsertAfter.m_pInsertEventSpot = m_InsertBefore.m_pInsertEventSpot = pMyEvent;
							m_InsertAfter.m_InsertType       = m_InsertBefore.m_InsertType       = ACTION;
							m_InsertAfter.m_InsertIndex      = m_InsertBefore.m_InsertIndex      = index;
							m_InsertAfter.m_IsAfter = true;
							m_InsertBefore.m_IsAfter = false;

							m_ActionTooltip.Hide();
						}


					}	
				}

				/////////////////////
				// Select Event

				else if(pMyEvent->m_handle(this).PtInRect(pt)) 
				{
					//Deselect selected actions or conditions
					DeselectActions();
					DeselectConditions();

					m_InsertAfter.Hide();
					m_InsertBefore.Hide();
					m_InsertSub.Hide();
					m_ActionTooltip.Hide();


					// Now select the events
					
					if(pMyEvent->m_select(this)) // if we clicked on something already selected...wait till release
						m_ClickedSelectedEvent = true;
					else
					{
					// User is clicking on an event
						if(!m_CtrlDown)
						{
							DeselectEvents();
						}
						
						pMyEvent->Select(true, this);
						InvalidateRect(pMyEvent->m_rect(this));
						
					}
					if( m_ShiftDown && m_FocusEvent)
					{
						bool b1 = false, b2 = false, b3 = false;
						RecursiveSelect(NULL, NULL, m_FocusEvent, NULL,NULL, pMyEvent,b1,b2,b3, this->m_pEventList);
					}
					m_FocusEvent = pMyEvent;
					// We may be wanting to drag these events...
					m_Drag.dragtype = EVENT;
					m_Drag.StoredPos = pt;
					m_Drag.IsDragging = false;

					if(pt.x > this->m_pHeader->m_Split) //prevent dragging events unless the mouse is in condition column
						m_Drag.dragtype = -1;

					if(m_CtrlDown)
					{
						m_InsertAfter.Hide();
						m_InsertBefore.Hide();
						m_InsertSub.Hide();
					}
					else
					{	
						if(m_ClickedSelectedEvent)
						{
							// find index
							int index = 0;
							FindEventListEventExistsIn(pMyEvent, m_pEventList, index);
						
							CPoint point  = pMyEvent->m_rect(this).TopLeft();
							point.x += 24;
							point.y -= 20;

							m_InsertBefore.ShowAt(point, pMyEvent, *this);
							m_InsertBefore.pEventEditor = (EventSheetEditor*)(this);


							point.y += 20 + pMyEvent->m_rect(this).Height();
							
							m_InsertAfter.ShowAt(point, pMyEvent, *this);
							m_InsertAfter.pEventEditor = (EventSheetEditor*)(this);

							point.x += 101;
							
							if(pMyEvent->canAddEvents())
							{
								m_InsertSub.ShowAt(point, pMyEvent, *this);
								m_InsertSub.pEventEditor = (EventSheetEditor*)(this);
							}

							m_InsertAfter.m_pInsertEventSpot = m_InsertBefore.m_pInsertEventSpot = pMyEventParent;
							m_InsertSub.m_pInsertEventSpot = pMyEvent;
							m_InsertAfter.m_InsertType       = m_InsertBefore.m_InsertType       = m_InsertSub.m_InsertType       = EVENT;
							m_InsertAfter.m_InsertIndex      = m_InsertBefore.m_InsertIndex      = m_InsertSub.m_InsertIndex      = index;

							m_InsertAfter.m_IsAfter = true;
							m_InsertBefore.m_IsAfter = false;

							m_InsertSub.m_IsAfter = true;
							m_InsertSub.m_IsSub = true;


							m_ActionTooltip.Hide();
						}
					}
					
				}
				else
				{
					if(!m_CtrlDown)
					{
						DeselectEvents();
						DeselectActions();
						DeselectConditions();
					}


				}
			}
		}
	}
	else
	{
		if(!m_CtrlDown)
		{
			DeselectActions();
			DeselectConditions();
			DeselectEvents();

			m_InsertAfter.Hide();
			m_InsertBefore.Hide();
			m_InsertSub.Hide();
			m_ActionTooltip.Hide();
		}
	}
	CScrollView::OnLButtonDown(nFlags, pt);
}
Beispiel #12
0
void CSkinSliderCtrl::StartLoopArrow()
{
	m_bLoopArrow = TRUE;
	Invalidate();
}
Beispiel #13
0
void CSkinSliderCtrl::StopLoopArrow()
{
	m_bLoopArrow = FALSE;
	Invalidate();
}
void CHoverButton::OnMouseHover(WPARAM wparam, LPARAM lparam) 
{
	// TODO: Add your message handler code here and/or call default
	m_bHover=TRUE;
	Invalidate();
}
Beispiel #15
0
void CWndImage::SetBackgroundBrush(CBrush & brush)
{
  m_backBrush = (HBRUSH) brush.m_hObject;
  Invalidate();
}
Beispiel #16
0
// Sets the image to use in a list box item
//
// Parameters:
//		[IN]	nIndex
//				Specifies the zero-based index of the item.
//		[IN]	nImage
//				Specifies the zero-based index of the image
//				inside the imagelist to use.
//		[IN]	bRepaint
//				If TRUE the control will be repainted.
//
void CListBoxST::SetImage(int nIndex, int nImage, BOOL bRepaint)
{
  ReplaceItemData(nIndex, 0, NULL, nImage, 0, MASK_NIMAGE);
  
  if (bRepaint)	Invalidate();
} // End of SetImage
Beispiel #17
0
void CWndImage::SetBackgroundBrush(HBRUSH brush)
{
  m_backBrush = brush;
  Invalidate();
}
Beispiel #18
0
void CMyHeaderCtrl::OnLButtonUp(UINT nFlags, CPoint point)
{
	m_bLButtonDown = false;
	Invalidate();
	__super::OnLButtonUp(nFlags, point);
}
Beispiel #19
0
FBODefinition::~FBODefinition()
{
    this->Remove();

    Invalidate( true );
}
Beispiel #20
0
/**
**  Display update.
**
**  This functions updates everything on screen. The map, the gui, the
**  cursors.
*/
void UpdateDisplay()
{
	if (GameRunning || Editor.Running == EditorEditing) {
		// to prevent empty spaces in the UI
#if defined(USE_OPENGL) || defined(USE_GLES)
		Video.FillRectangleClip(ColorBlack, 0, 0, Video.ViewportWidth, Video.ViewportHeight);
#else
		Video.FillRectangleClip(ColorBlack, 0, 0, Video.Width, Video.Height);
#endif
		DrawMapArea();
		DrawMessages();

		if (CursorState == CursorStateRectangle) {
			DrawCursor();
		}

		//Wyrmgus start
		if (CursorBuilding && CursorOn == CursorOnMap) {
			DrawBuildingCursor();
		}
		//Wyrmgus end
	
		if ((Preference.BigScreen && !BigMapMode) || (!Preference.BigScreen && BigMapMode)) {
			UiToggleBigMap();
		}

		if (!BigMapMode) {
			for (size_t i = 0; i < UI.Fillers.size(); ++i) {
				UI.Fillers[i].G->DrawSubClip(0, 0,
											 UI.Fillers[i].G->Width,
											 UI.Fillers[i].G->Height,
											 UI.Fillers[i].X, UI.Fillers[i].Y);
			}
			DrawMenuButtonArea();
			DrawUserDefinedButtons();

			UI.Minimap.Draw();
			UI.Minimap.DrawViewportArea(*UI.SelectedViewport);

			UI.InfoPanel.Draw();
			DrawResources();
			DrawDayTime();
			UI.StatusLine.Draw();
			UI.StatusLine.DrawCosts();
			UI.ButtonPanel.Draw();
		}
		
		DrawTimer();
		
		//Wyrmgus start
		//draw worker icon if there are idle workers
		if (UI.IdleWorkerButton && !ThisPlayer->FreeWorkers.empty()) {
			int worker_unit_type_id = PlayerRaces.GetFactionClassUnitType(ThisPlayer->Race, ThisPlayer->Faction, GetUnitTypeClassIndexByName("worker"));
			if (worker_unit_type_id != -1) {
				const CUnitType &type = *UnitTypes[worker_unit_type_id];
				
				const PixelPos pos(UI.IdleWorkerButton->X, UI.IdleWorkerButton->Y);
				const int flag = (ButtonAreaUnderCursor == ButtonAreaIdleWorker && ButtonUnderCursor == 0) ? (IconActive | (MouseButtons & LeftButton)) : 0;
								 
				VariationInfo *varinfo = type.GetDefaultVariation(*ThisPlayer);
				if (varinfo && varinfo->Icon.Icon) { // check if the default variation is valid, and if it is, then make the button use the variation's icon
					varinfo->Icon.Icon->DrawUnitIcon(*UI.IdleWorkerButton->Style, flag, pos, ".", ThisPlayer->Index, type.GetDefaultHairColor(*ThisPlayer));
				} else {
					type.Icon.Icon->DrawUnitIcon(*UI.IdleWorkerButton->Style, flag, pos, ".", ThisPlayer->Index, type.GetDefaultHairColor(*ThisPlayer));
				}
			}
		}
		
		//draw icon if there are units with available level up upgrades
		if (UI.LevelUpUnitButton && !ThisPlayer->LevelUpUnits.empty()) {
			const PixelPos pos(UI.LevelUpUnitButton->X, UI.LevelUpUnitButton->Y);
			const int flag = (ButtonAreaUnderCursor == ButtonAreaLevelUpUnit && ButtonUnderCursor == 0) ? (IconActive | (MouseButtons & LeftButton)) : 0;
								 
			ThisPlayer->LevelUpUnits[0]->GetIcon().Icon->DrawUnitIcon(*UI.LevelUpUnitButton->Style, flag, pos, "", ThisPlayer->Index, ThisPlayer->LevelUpUnits[0]->GetHairColor());
		}
		
		//draw icon if the player has a custom hero
		for (int i = 0; i < PlayerHeroMax; ++i) {
			if (UI.HeroUnitButtons[i] && (int) ThisPlayer->Heroes.size() > i) {
				const PixelPos pos(UI.HeroUnitButtons[i]->X, UI.HeroUnitButtons[i]->Y);
				const int flag = (ButtonAreaUnderCursor == ButtonAreaHeroUnit && ButtonUnderCursor == i) ? (IconActive | (MouseButtons & LeftButton)) : 0;
									 
				ThisPlayer->Heroes[i]->GetIcon().Icon->DrawUnitIcon(*UI.HeroUnitButtons[i]->Style, flag, pos, "", ThisPlayer->Index, ThisPlayer->Heroes[i]->GetHairColor());
			}
		}
		
		DrawPopups();
		//Wyrmgus end
	//Wyrmgus start
	} else if (GrandStrategy && !GameRunning && GameResult == GameNoResult) { //grand strategy mode
		if (!GrandStrategyGamePaused) {
			//scroll map if mouse is in the scroll area
			int scroll_up = 7; //the scroll area in the upper part of the screen is smaller to allow clicking on the menu buttons and etc. more comfortably
			int scroll_down = (Video.Height - 16);
			int scroll_left = 15;
			int scroll_right = (Video.Width - 16);
			bool scrolled = false;
			if (CursorScreenPos.y < scroll_up) {
				if (WorldMapOffsetY > 0) {
					if (GrandStrategyMapHeightIndent == 0) {
						WorldMapOffsetY = WorldMapOffsetY - 1;
					}
					GrandStrategyMapHeightIndent -= 32;
				} else if (WorldMapOffsetY == 0 && GrandStrategyMapHeightIndent == -32) { //this is to make the entire y 0 tiles be shown scrolling to the northmost part of the map
					GrandStrategyMapHeightIndent -= 32;
				}
				GameCursor = UI.ArrowN.Cursor;
				scrolled = true;
			} else if (CursorScreenPos.y > scroll_down) {
				if (WorldMapOffsetY < GetWorldMapHeight() - 1 - ((UI.MapArea.EndY - UI.MapArea.Y) / 64)) {
					if (GrandStrategyMapHeightIndent == -32) {
						WorldMapOffsetY = WorldMapOffsetY + 1;
					}
					GrandStrategyMapHeightIndent += 32;
				} else if (WorldMapOffsetY == GetWorldMapHeight() - 1 - ((UI.MapArea.EndY - UI.MapArea.Y) / 64) && GrandStrategyMapHeightIndent == 0) {
					GrandStrategyMapHeightIndent += 32;
				}
				GameCursor = UI.ArrowS.Cursor;
				scrolled = true;
			}
			if (CursorScreenPos.x < scroll_left) {
				if (WorldMapOffsetX > 0) {
					if (GrandStrategyMapWidthIndent == 0) {
						WorldMapOffsetX = WorldMapOffsetX - 1;
					}
					GrandStrategyMapWidthIndent -= 32;
				} else if (WorldMapOffsetX == 0 && GrandStrategyMapWidthIndent == -32) { //this is to make the entire x 0 tiles be shown scrolling to the westmost part of the map
					GrandStrategyMapWidthIndent -= 32;
				}
				if (GameCursor == UI.ArrowN.Cursor) {
					GameCursor = UI.ArrowNW.Cursor;
				} else if (GameCursor == UI.ArrowS.Cursor) {
					GameCursor = UI.ArrowSW.Cursor;
				} else {
					GameCursor = UI.ArrowW.Cursor;
				}
				scrolled = true;
			} else if (CursorScreenPos.x > scroll_right) {
				if (WorldMapOffsetX < GetWorldMapWidth() - 1 - ((UI.MapArea.EndX - UI.MapArea.X) / 64)) {
					if (GrandStrategyMapWidthIndent == -32) {
						WorldMapOffsetX = WorldMapOffsetX + 1;
					}
					GrandStrategyMapWidthIndent += 32;
				} else if (WorldMapOffsetX == GetWorldMapWidth() - 1 - ((UI.MapArea.EndX - UI.MapArea.X) / 64) && GrandStrategyMapWidthIndent == 0 && (UI.MapArea.EndX - UI.MapArea.X + 1) % 64 == 32) {
					GrandStrategyMapWidthIndent += 32;
				}
				if (GameCursor == UI.ArrowN.Cursor) {
					GameCursor = UI.ArrowNE.Cursor;
				} else if (GameCursor == UI.ArrowS.Cursor) {
					GameCursor = UI.ArrowSE.Cursor;
				} else {
					GameCursor = UI.ArrowE.Cursor;
				}
				scrolled = true;
			}
			if (scrolled) {
				if (GrandStrategyMapWidthIndent <= -64) {
					GrandStrategyMapWidthIndent = 0;
				}
				if (GrandStrategyMapHeightIndent <= -64) {
					GrandStrategyMapHeightIndent = 0;
				}
				if (GrandStrategyMapWidthIndent > 0) {
					GrandStrategyMapWidthIndent *= -1;
				}
				if (GrandStrategyMapHeightIndent > 0) {
					GrandStrategyMapHeightIndent *= -1;
				}
			} else {
				GameCursor = UI.Point.Cursor;
			}
		}
		
		bool draw_grand_strategy = true;
		
#if defined(USE_OPENGL) || defined(USE_GLES)
		if (UseOpenGL) {
		} else
#endif
		{
			if (GrandStrategyGamePaused) {
				draw_grand_strategy = false;
			}
		}
		
		if (draw_grand_strategy) {
			//draw map
			GrandStrategyGame.DrawMap();
			
			// Fillers
			for (size_t i = 0; i != UI.Fillers.size(); ++i) {
				UI.Fillers[i].G->DrawClip(UI.Fillers[i].X, UI.Fillers[i].Y);
			}
			
			GrandStrategyGame.DrawMinimap();
			
			GrandStrategyGame.DrawInterface();
			
			if (UI.MapArea.Contains(CursorScreenPos) && GrandStrategyGame.WorldMapTiles[GrandStrategyGame.GetTileUnderCursor().x][GrandStrategyGame.GetTileUnderCursor().y] && !GrandStrategyGamePaused) {
				GrandStrategyGame.DrawTileTooltip(GrandStrategyGame.GetTileUnderCursor().x, GrandStrategyGame.GetTileUnderCursor().y);
				
				CGrandStrategyProvince *province = GrandStrategyGame.WorldMapTiles[GrandStrategyGame.GetTileUnderCursor().x][GrandStrategyGame.GetTileUnderCursor().y]->Province;
				if (province != NULL && province != GrandStrategyGame.SelectedProvince) {
					if (GrandStrategyGame.SelectedUnits.size() > 0 || !SelectedHero.empty()) {
						std::string tooltip;
						if (GrandStrategyGame.SelectedProvince->CanAttackProvince(province)) {
							if (
								province->Owner == NULL
								&& GrandStrategyGame.SelectedProvince->Owner->OwnedProvinces.size() == 1
								&& PlayerRaces.Factions[GrandStrategyGame.SelectedProvince->Owner->Civilization][GrandStrategyGame.SelectedProvince->Owner->Faction]->Type == FactionTypeTribe
							) {
								tooltip += "Migrate to ";
							} else {
								tooltip += "Attack ";
							}
						} else if (GrandStrategyGame.SelectedProvince->Owner == province->Owner) {
							tooltip += "Move units to ";
						}
						if (!tooltip.empty()) {
							tooltip += province->GetCulturalName();
							DrawGenericPopup(tooltip, CursorScreenPos.x, CursorScreenPos.y);
						}
					}
				}
			}
		}
	//Wyrmgus end
	}

	DrawPieMenu(); // draw pie menu only if needed

	DrawGuichanWidgets();
	
	if (CursorState != CursorStateRectangle) {
		DrawCursor();
	}

	//
	// Update changes to display.
	//
	Invalidate();
}
Beispiel #21
0
 void SetDistance(double _distance) {
   distance = _distance;
   Invalidate();
 }
// *** KStowell
void CCTabCtrlBar::OnTabSelChange(NMHDR* pNMHDR, LRESULT* pResult)
{
	SetActiveView(m_tabctrl.GetCurSel());
	Invalidate();
}
Beispiel #23
0
void Styler_SearchHL::ApplyDiff(const vector<cxChange>& WXUNUSED(changes)) {
	Invalidate();
}
Beispiel #24
0
HTMLEventStatus WebDropBox::Event (HTMLEvent *e)
{
    WEBC_DEBUG_ReceiveEvent(this, e);
	switch (e->type)
	{
	case HTML_EVENT_MOUSEDOWN:
		Drop();
		break;

	case HTML_EVENT_FOCUS:
		miLastSelected = miSelected;
		Invalidate();
		break;

	case HTML_EVENT_KEYDOWN:
		if (!(mFlags & DISPLAY_FLAG_DISABLED))
		{
			if (e->data.key == WGK_ESC)
			{
				Invalidate();
				Undrop();
			}
			else if (mState == DROPBOX_STATE_DROPPED)
			{
				return (mListbox.Event(e));
			}
			else
			{
				switch (e->data.key)
				{
				case ' ':
					switch (mState)
					{
					case DROPBOX_STATE_DROPPED:
						Invalidate();
						Undrop();
						break;

					case DROPBOX_STATE_NORMAL:
						Invalidate();
						Drop();
						break;
					}
					break;

				case WGK_CR:
					if (miLastSelected != miSelected)
					{
						miLastSelected = miSelected;
						NotifySelectChange();
					}
					break;

				case WGK_LNDN:
					SetSelected(GetSelected() + 1);
					Invalidate();
					break;

				case WGK_LNUP:
					SetSelected(GetSelected() - 1);
					Invalidate();
					break;

				default:
					{
						long index = mListbox.NextIndexStartingWith((WebChar) e->data.key);
						if (index >= 0)
						{
							SetSelected(index);
							Invalidate();
						}
						break;
					}
				}
			}
		}
		break;

	case HTML_EVENT_UNFOCUS:
		Invalidate();
		Undrop();
		if (miLastSelected != miSelected)
		{
			miLastSelected = miSelected;
			NotifySelectChange();
		}
		break;

	default:
		break;
	}
	return HTML_EVENT_STATUS_DONE;
}
void FSingleTileEditorViewportClient::InvalidateViewportAndHitProxies()
{
	Invalidate();
}
Beispiel #26
0
void WebDropBox::Drop(void)
{
	WEBC_ASSERT(GetManager());
	if (mState == DROPBOX_STATE_DROPPED)
	{
		return;
	}

	int spaceUp, spaceDown;
	CalculateAvailableSpace(&spaceUp, &spaceDown);

	int neededSpace = mListbox.GetTotalTextHeight() +
		mListbox.GetMargin() + mListbox.GetPadding() * 2 +
		mListbox.GetBorder() * 2;

	WebRect rect;
	if (spaceDown >= neededSpace || spaceDown > spaceUp)
	{
		DISPLAY_INT space = EBSMIN(spaceDown, neededSpace);
		rect.top = Height() - DROPBOX_MARGIN;
		rect.left = DROPBOX_MARGIN;
		rect.right = Width() - DROPBOX_MARGIN - 1;
		rect.bottom = rect.top + space - 1;
	}
	else
	{
		DISPLAY_INT space = EBSMIN(spaceUp, neededSpace);
		rect.top = -space;
		rect.left = DROPBOX_MARGIN;
		rect.right = Width() - DROPBOX_MARGIN - 1;
		rect.bottom = DROPBOX_MARGIN - 1;
	}


	SetFlag(DISPLAY_FLAG_DIRTY);
	Invalidate();
	mState = DROPBOX_STATE_DROPPED;

	if (mpParent)
	{
		DISPLAY_INT left,top;
		mpParent->GetDisplayPosition(this, &left, &top);
		rect.Shift(left,top);
	}

	mListbox.Move(&rect);
	DisplayManager *m = GetManager();
	WebGraphics *gc = m? m->GetGraphics() : 0;
	if (gc)
	{
		mListbox.SetupScrollBars(gc);
	}

	// we need to make sure the list box appears on top of everything.
	DisplayElement *parent = this;
	while (parent->mpParent)
	{
		parent = parent->mpParent;
	}
	parent->InsertLast(&mListbox);

	mListbox.Invalidate();
}
void FSingleTileEditorViewportClient::ToggleShowStats()
{
	bShowStats = !bShowStats;
	Invalidate();
}
Beispiel #28
0
void CWndImage::Recalc(bool invalidate)
{
  if (!::IsWindow(m_hWnd)) return;

  CRect & src = m_srcRect;
  CRect & dst = m_dstRect;
  CRect r;

  GetClientRect(&r);
  CSize wndSize = r.Size();

  if (wndSize.cx == 0 || wndSize.cy == 0 || src.IsRectEmpty()) 
    dst.SetRectEmpty();
  else {

    dst.left = dst.top = 0;
    switch (m_bltMode) 
    {
      default           :
      case bltNormal    :  dst.right = src.Width(); dst.bottom = src.Height(); break;
      case bltStretch   :  dst.right = wndSize.cx; dst.bottom = wndSize.cy; break;
      case bltCustom    :  dst.right  = (int)(src.Width() * m_zoomX);
                           dst.bottom = (int)(src.Height() * m_zoomY);
                           break;

      case bltFitX      :
      case bltFitY      :
      case bltFitXY     :
      case bltFitSm     : {
                            double zoom = 1;
                            double zoomX = ((double) wndSize.cx) / src.Width();
                            double zoomY = ((double) wndSize.cy) / src.Height();

                            if (m_bltMode == bltFitX) zoom = zoomX;
                            else if (m_bltMode == bltFitY) zoom = zoomY;
                            else    // for stretchXY take smaller, for stretchSm take larger:
                              zoom = ((m_bltMode == bltFitXY) ^ (zoomX > zoomY)) ? 
                                                zoomX : zoomY;  

                            m_zoomX = m_zoomY = zoom;       // so user can query these values

                            dst.right  = (int)(src.Width() * zoom);
                            dst.bottom = (int)(src.Height() * zoom);
                            break;
                        }
      case bltTile      :   break;

    }

    switch (m_alignX) 
    {
      case bltCenter :  m_origin.x = (wndSize.cx-dst.Width()) / 2; break;
      case bltRight  :  m_origin.x =  wndSize.cx-dst.Width();      break;
      case bltLeft   :  m_origin.x =  0;      break;
    }
    dst.left += m_origin.x;
    dst.right += m_origin.x;

    switch (m_alignY) 
    {
      case bltCenter :  m_origin.y = (wndSize.cy-dst.Height()) / 2; break;
      case bltRight  :  m_origin.y =  wndSize.cy-dst.Height();      break;
      case bltTop    :  m_origin.y = 0; break;
    }
    dst.top += m_origin.y;
    dst.bottom += m_origin.y;
  }

  if (m_bltMode == bltTile) {
    dst.SetRect(0,0, wndSize.cx, wndSize.cy);
  }

  if (invalidate)
      Invalidate();

}
Beispiel #29
0
	void CDateTimeUI::SetReadOnly(bool bReadOnly)
	{
		m_bReadOnly = bReadOnly;
		Invalidate();
	}
Beispiel #30
0
	void COptionUI::SetForeImage(LPCTSTR pStrImage)
	{
		m_sForeImage = pStrImage;
		Invalidate();
	}