Example #1
0
//************************************************************************
// CLCDInput::OnFontChanged
//************************************************************************
void CLCDInput::OnFontChanged()
{
	if(m_iFontHeight == 0)
		return;

	if(m_pScrollbar)
		m_pScrollbar->SetSliderSize(m_iLineCount);

	m_iLinePosition = 0;
	m_iLineCount = GetHeight() / m_iFontHeight;

	if(m_pScrollbar)
		m_pScrollbar->SetSliderSize(m_iLineCount);

	m_Marker[0].iLine = 0;
	m_Marker[0].iPosition = 0;
	m_Marker[0].iPosition = (int)m_strText.length();
	
	// Delete all offsets and recalculate them
	m_vLineOffsets.clear();
	// Create a new offset
	SLineEntry offset;
	offset.bLineBreak = false;
	offset.iOffset = 0;
	m_vLineOffsets.push_back(offset);

	UpdateOffsets(0);
	
	UpdateMarker();
	if(m_iLineCount > 0)
		ScrollToMarker();
}
bool VertexBuffer::SetSize(unsigned vertexCount, unsigned elementMask, bool dynamic)
{
    Unlock();

    if (dynamic)
    {
        pool_ = D3DPOOL_DEFAULT;
        usage_ = D3DUSAGE_DYNAMIC | D3DUSAGE_WRITEONLY;
    }
    else
    {
        pool_ = D3DPOOL_MANAGED;
        usage_ = 0;
    }

    vertexCount_ = vertexCount;
    elementMask_ = elementMask;

    UpdateOffsets();

    if (shadowed_ && vertexCount_ && vertexSize_)
        shadowData_ = new unsigned char[vertexCount_ * vertexSize_];
    else
        shadowData_.Reset();

    return Create();
}
void CEspConfigWindow::Display(void)
{
	UpdateOffsets();

	
	CWindow::Display();
}
Example #4
0
VertexBuffer::VertexBuffer(Context* context, bool forceHeadless) :
    Object(context),
    GPUObject(forceHeadless ? nullptr : GetSubsystem<Graphics>())
{
    UpdateOffsets();

    // Force shadowing mode if graphics subsystem does not exist
    if (!graphics_)
        shadowed_ = true;
}
Example #5
0
static void
UpdateOffsets(
    TkWindow *winPtr,
    int deltaX,
    int deltaY)
{
    TkWindow *childPtr;

    if (winPtr->privatePtr == NULL) {
	/*
	 * We haven't called Tk_MakeWindowExist for this window yet. The offset
	 * information will be postponed and calulated at that time. (This will
	 * usually only happen when a mapped parent is being moved but has
	 * child windows that have yet to be mapped.)
	 */

	return;
    }

    winPtr->privatePtr->xOff += deltaX;
    winPtr->privatePtr->yOff += deltaY;

    childPtr = winPtr->childList;
    while (childPtr != NULL) {
	if (!Tk_IsTopLevel(childPtr)) {
	    UpdateOffsets(childPtr, deltaX, deltaY);
	}
	childPtr = childPtr->nextPtr;
    }

    if (Tk_IsContainer(winPtr)) {
	childPtr = TkpGetOtherWindow(winPtr);
	if (childPtr != NULL) {
	    UpdateOffsets(childPtr,deltaX,deltaY);
	}

	/*
	 * TODO: Here we should handle out of process embedding.
	 */
    }
}
Example #6
0
static void
MoveResizeWindow(
    MacDrawable *macWin)
{
    int deltaX = 0, deltaY = 0, parentBorderwidth = 0;
    MacDrawable *macParent = NULL;
    CGrafPtr destPort = TkMacOSXGetDrawablePort((Drawable) macWin);

    /*
     * Find the Parent window, for an embedded window it will be its container.
     */

    if (Tk_IsEmbedded(macWin->winPtr)) {
	TkWindow *contWinPtr = TkpGetOtherWindow(macWin->winPtr);

	if (contWinPtr) {
	    macParent = contWinPtr->privatePtr;
	} else {
	    /*
	     * Here we should handle out of process embedding. At this point,
	     * we are assuming that the changes.x,y is not maintained, if you
	     * need the info get it from Tk_GetRootCoords, and that the
	     * toplevel sits at 0,0 when it is drawn.
	     */
	}
    } else {
	/*
	 * TODO: update all xOff & yOffs
	 */

	macParent = macWin->winPtr->parentPtr->privatePtr;
	parentBorderwidth = macWin->winPtr->parentPtr->changes.border_width;
    }

    if (macParent) {
	deltaX = macParent->xOff + parentBorderwidth +
		macWin->winPtr->changes.x - macWin->xOff;
	deltaY = macParent->yOff + parentBorderwidth +
		macWin->winPtr->changes.y - macWin->yOff;
    }
    if (destPort) {
	TkMacOSXInvalidateWindow(macWin, TK_PARENT_WINDOW);
	if (macParent) {
	    TkMacOSXInvalClipRgns((Tk_Window) macParent->winPtr);
	}
    }
    UpdateOffsets(macWin->winPtr, deltaX, deltaY);
    if (destPort) {
	TkMacOSXInvalidateWindow(macWin, TK_PARENT_WINDOW);
    }
    GenerateConfigureNotify(macWin->winPtr, 0);
}
Example #7
0
bool VertexBuffer::SetSize(unsigned vertexCount, unsigned elementMask, bool dynamic)
{
    Unlock();

    dynamic_ = dynamic;
    vertexCount_ = vertexCount;
    elementMask_ = elementMask;

    UpdateOffsets();

    if (shadowed_ && vertexCount_ && vertexSize_)
        shadowData_ = new unsigned char[vertexCount_ * vertexSize_];
    else
        shadowData_.Reset();

    return Create();
}
Example #8
0
bool VertexBuffer::SetSize(unsigned vertexCount, const PODVector<VertexElement>& elements, bool dynamic)
{
    Unlock();

    vertexCount_ = vertexCount;
    elements_ = elements;
    dynamic_ = dynamic;

    UpdateOffsets();

    if (shadowed_ && vertexCount_ && vertexSize_)
        shadowData_ = new unsigned char[vertexCount_ * vertexSize_];
    else
        shadowData_.Reset();

    return Create();
}
Example #9
0
VertexBuffer::VertexBuffer(Context* context, bool forceHeadless) :
    Object(context),
    GPUObject(forceHeadless ? (Graphics*)0 : GetSubsystem<Graphics>()),
    vertexCount_(0),
    elementMask_(0),
    lockState_(LOCK_NONE),
    lockStart_(0),
    lockCount_(0),
    lockScratchData_(0),
    dynamic_(false),
    shadowed_(false)
{
    UpdateOffsets();

    // Force shadowing mode if graphics subsystem does not exist
    if (!graphics_)
        shadowed_ = true;
}
Example #10
0
VertexBuffer::VertexBuffer(Context* context) :
    Object(context),
    GPUObject(GetSubsystem<Graphics>()),
    vertexCount_(0),
    elementMask_(0),
    pool_(D3DPOOL_MANAGED),
    usage_(0),
    lockState_(LOCK_NONE),
    lockStart_(0),
    lockCount_(0),
    lockScratchData_(0),
    shadowed_(false)
{
    UpdateOffsets();
    
    // Force shadowing mode if graphics subsystem does not exist
    if (!graphics_)
        shadowed_ = true;
}
Example #11
0
void 
XMoveWindow(
    Display* display,		/* Display. */
    Window window,		/* Window. */
    int x,
    int y)
{
    MacDrawable *macWin = (MacDrawable *) window;
    GWorldPtr destPort;

    destPort = TkMacGetDrawablePort(window);
    if (destPort == NULL) {
	return;
    }

    SetPort((GrafPtr) destPort);
    if (Tk_IsTopLevel(macWin->winPtr) && !Tk_IsEmbedded(macWin->winPtr)) {
	/* 
	 * NOTE: we are not adding the new space to the update
	 * region.  It is currently assumed that Tk will need
	 * to completely redraw anway.
	 */
	tkMacMoveWindow((WindowRef) destPort, x, y);

	/* TODO: is the following right? */
	TkMacInvalidateWindow(macWin, TK_WINDOW_ONLY);
	TkMacInvalClipRgns(macWin->winPtr);
    } else {
	int deltaX, deltaY, parentBorderwidth;
	Rect bounds;
	MacDrawable *macParent;
	
        /*
         * Find the Parent window -
         * For an embedded window this will be its container.
         */
         
	if (Tk_IsEmbedded(macWin->winPtr)) {
	    TkWindow *contWinPtr;
	    
	    contWinPtr = TkpGetOtherWindow(macWin->winPtr);
	    if (contWinPtr == NULL) {
	            panic("XMoveWindow could not find container");
	    }
	    macParent = contWinPtr->privatePtr;
	    
	    /*
	     * NOTE: Here we should handle out of process embedding.
	     */
		    
	} else {
	    macParent = macWin->winPtr->parentPtr->privatePtr;   
	    if (macParent == NULL) {
	        return; /* TODO: Probably should be a panic */
	    }
	}

	TkMacInvalClipRgns(macParent->winPtr);
	TkMacInvalidateWindow(macWin, TK_PARENT_WINDOW);

	deltaX = - macWin->xOff;
	deltaY = - macWin->yOff;
	
        /*
	 * If macWin->winPtr is an embedded window, don't offset by its
	 *  parent's borderwidth...
	 */
	 
	if (!Tk_IsEmbedded(macWin->winPtr)) {
	    parentBorderwidth = macWin->winPtr->parentPtr->changes.border_width;
	} else {
	    parentBorderwidth = 0;
	}
	deltaX += macParent->xOff + parentBorderwidth +
	    macWin->winPtr->changes.x;
	deltaY += macParent->yOff + parentBorderwidth +
	    macWin->winPtr->changes.y;
		
	UpdateOffsets(macWin->winPtr, deltaX, deltaY);
	TkMacWinBounds(macWin->winPtr, &bounds);
	InvalRect(&bounds);
    }
}
Example #12
0
void 
XResizeWindow(
    Display* display,		/* Display. */
    Window window, 		/* Window. */
    unsigned int width,
    unsigned int height)
{
    MacDrawable *macWin = (MacDrawable *) window;
    GWorldPtr destPort;

    destPort = TkMacGetDrawablePort(window);
    if (destPort == NULL) {
	return;
    }

    display->request++;
    SetPort((GrafPtr) destPort);
    if (Tk_IsTopLevel(macWin->winPtr)) {
	if (!Tk_IsEmbedded(macWin->winPtr)) {
	    /* 
	     * NOTE: we are not adding the new space to the update
	     * region.  It is currently assumed that Tk will need
	     * to completely redraw anway.
	     */
	    SizeWindow((WindowRef) destPort,
		    (short) width, (short) height, false);
	    TkMacInvalidateWindow(macWin, TK_WINDOW_ONLY);
	    TkMacInvalClipRgns(macWin->winPtr);
	} else {
	    int deltaX, deltaY;
	    
	    /*
	     * Find the Parent window -
	     *    For an embedded window this will be its container.
	     */
	    TkWindow *contWinPtr;
	    
	    contWinPtr = TkpGetOtherWindow(macWin->winPtr);
	    
	    if (contWinPtr != NULL) {
	        MacDrawable *macParent = contWinPtr->privatePtr;

		TkMacInvalClipRgns(macParent->winPtr);	
		TkMacInvalidateWindow(macWin, TK_PARENT_WINDOW);
		
		deltaX = macParent->xOff +
		    macWin->winPtr->changes.x - macWin->xOff;
		deltaY = macParent->yOff +
		    macWin->winPtr->changes.y - macWin->yOff;
		
		UpdateOffsets(macWin->winPtr, deltaX, deltaY);
	    } else {
	        /*
	         * This is the case where we are embedded in
	         * another app.  At this point, we are assuming that
	         * the changes.x,y is not maintained, if you need
		 * the info get it from Tk_GetRootCoords,
	         * and that the toplevel sits at 0,0 when it is drawn.
	         */
		
		TkMacInvalidateWindow(macWin, TK_PARENT_WINDOW);
		UpdateOffsets(macWin->winPtr, 0, 0);
	    }
	         
	}   
    } else {
	/* TODO: update all xOff & yOffs */
	int deltaX, deltaY, parentBorderwidth;
	MacDrawable *macParent = macWin->winPtr->parentPtr->privatePtr;
	
	if (macParent == NULL) {
	    return; /* TODO: Probably should be a panic */
	}
	
	TkMacInvalClipRgns(macParent->winPtr);	
	TkMacInvalidateWindow(macWin, TK_PARENT_WINDOW);

	deltaX = - macWin->xOff;
	deltaY = - macWin->yOff;

	parentBorderwidth = macWin->winPtr->parentPtr->changes.border_width;
	
	deltaX += macParent->xOff + parentBorderwidth +
	    macWin->winPtr->changes.x;
	deltaY += macParent->yOff + parentBorderwidth +
	    macWin->winPtr->changes.y;
        
	UpdateOffsets(macWin->winPtr, deltaX, deltaY);
    }
}
Example #13
0
//************************************************************************
// CLCDInput::ProcessKeyEvent
//************************************************************************
LRESULT CLCDInput::ProcessKeyEvent(int Code, WPARAM wParam, LPARAM lParam)
{
	// Event verarbeiten
	if(Code == HC_ACTION)
	{	
		KBDLLHOOKSTRUCT *key = (KBDLLHOOKSTRUCT *)(lParam);
	
		bool bKeyDown = !(key->flags & LLKHF_UP);
		bool bToggled = (m_acKeyboardState[key->vkCode] & 0x0F) != 0;
		if(bKeyDown)
			bToggled = !bToggled;
		m_acKeyboardState[key->vkCode] = (bKeyDown?0x80:0x00) | (bToggled?0x01:0x00);
		if(key->vkCode == VK_LSHIFT || key->vkCode == VK_RSHIFT)
			m_acKeyboardState[VK_SHIFT] = m_acKeyboardState[key->vkCode];
		else if(key->vkCode == VK_LCONTROL || key->vkCode == VK_RCONTROL)
			m_acKeyboardState[VK_CONTROL] = m_acKeyboardState[key->vkCode];
		else if(key->vkCode == VK_LMENU || key->vkCode == VK_RMENU)
			m_acKeyboardState[VK_MENU] = m_acKeyboardState[key->vkCode];
		
		/*
		if(bKeyDown)
			TRACE(_T("Key pressed: %i\n"),key->vkCode);
		else
			TRACE(_T("Key released: %i\n"),key->vkCode);
		*/
		// Only handle Keyup
		if(bKeyDown)
		{
			// Actions with Control/Menu keys
				if((m_acKeyboardState[VK_LMENU] & 0x80 || m_acKeyboardState[VK_CONTROL] & 0x80)
					&& m_acKeyboardState[VK_SHIFT] & 0x80)
				{
					ActivateKeyboardLayout((HKL)HKL_NEXT,0);//KLF_SETFORPROCESS);
					TRACE(_T("Keyboardlayout switched!\n"));
					return 1;
				}

			int res = 0,size = 0,dir = MARKER_HORIZONTAL,scroll = 0;
/*
			if(key->vkCode == VK_DELETE) {
				dir = MARKER_HOLD;
				res = -1;
				if(m_strText[m_Marker[0].iPosition] == '\r')
					res = -2;
				if(m_strText.length() >= m_Marker[0].iPosition + -res) {
					m_strText.erase(m_Marker[0].iPosition,-res);
					scroll = 1;
					size = 1;
				} else {
					res = 0;
				}
			}
			else */if(key->vkCode == VK_BACK )
			{
				if(m_Marker[0].iPosition != 0)
				{
					res = -1;
					if(m_strText[m_Marker[0].iPosition+res] == '\n')
						res = -2;

					m_strText.erase(m_Marker[0].iPosition+res,-res);	
					scroll = 1;
					size = res;
				}
			}
			// Marker navigation
			else if (key->vkCode == VK_INSERT)
			{
				m_bInsert = !m_bInsert;
			}
			else if(key->vkCode == VK_HOME)
			{
				res = m_vLineOffsets[m_Marker[0].iLine].iOffset - m_Marker[0].iPosition;
				scroll = 1;
			}
			else if(key->vkCode == VK_END)
			{
				if(m_vLineOffsets.size()-1 == m_Marker[0].iLine)
					res = (int)m_strText.length() - m_Marker[0].iPosition;
				else
					res = (m_vLineOffsets[m_Marker[0].iLine+1].iOffset - 1 - m_vLineOffsets[m_Marker[0].iLine+1].bLineBreak) -m_Marker[0].iPosition;

				scroll = 1;
			}
			else if(key->vkCode == VK_UP)
			{
				res = -1;
				dir = MARKER_VERTICAL;
			}
			else if(key->vkCode == VK_DOWN)
			{
				res = 1;
				dir = MARKER_VERTICAL;
			}
			else if(key->vkCode == VK_LEFT)
				res = -1;
			else if(key->vkCode == VK_RIGHT)
				res = 1;

			else
			{

#ifdef _UNICODE
				TCHAR output[4];
#else
				unsigned char output[2];
#endif

				if(key->vkCode == VK_RETURN)
				{
					bool bCtrlDown = (m_acKeyboardState[VK_CONTROL] & 0x80) != 0;
					if( bCtrlDown != (m_iBreakKeys == KEYS_RETURN))
					{
						DeactivateInput();
						//m_pParent->OnInputFinished();
						return 1;
					}
					else
					{
						res = 2;
						output[0] = '\r';
						output[1] = '\n';
						output[2] = 0;
					}
				}
				else
				{
#ifdef _UNICODE
					res = ToUnicode(key->vkCode,key->scanCode,m_acKeyboardState,output,4,0);
#else
					res = ToAscii(  key->vkCode,key->scanCode,m_acKeyboardState,(WORD*)output,0);
#endif
				}

				if(res <= 0)
					res = 0;
				else
				{
					if(output[0] != '\r' && output[0] <= 0x001F)
						return 1;

					if(m_bInsert || m_strText[m_Marker[0].iPosition] == '\r')
						m_strText.insert(m_Marker[0].iPosition,(TCHAR*)output,res);
					else
						m_strText.replace(m_Marker[0].iPosition,res,(TCHAR*)output);
					
					scroll = 1;
					size = res;
				}
			}
			if(res != 0)
			{
				if(dir != MARKER_HOLD) {
					MoveMarker(dir,res);
				}
				UpdateOffsets(size);
				UpdateMarker();
				ScrollToMarker();
				m_lInputTime = GetTickCount();
			}
			//WrapLine();
			// ----
			
			

			// Block this KeyEvent
		}
		return 1; 
	}
	return CallNextHookEx(m_hKBHook, Code, wParam, lParam);
}