예제 #1
0
Surface::Surface(int Width, int Height) : buffer(0), mDirty(true)
{
    //== Use power of 2 texture sizes ==

    mSurfaceWidth = CalculateSize(Width);
    mSurfaceHeight = CalculateSize(Height);

    mSpan = mSurfaceWidth;

    mWidth = Width;
    mHeight = Height;

    buffer = (unsigned char*) malloc(mSurfaceWidth * mSurfaceHeight * BYTESPERPIXEL);

    memset(buffer, 0, mSurfaceWidth * mSurfaceHeight * BYTESPERPIXEL);

    if(buffer==0)
        throw("Unable to allocate surface buffer");

    glGenTextures(1, &mTexture);
    if(mTexture==0)
        throw("Unable to gen OpenGL texture");


    glBindTexture(GL_TEXTURE_2D, mTexture);
    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, mSurfaceWidth, mSurfaceHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, buffer);
    glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
    glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
}
예제 #2
0
// Add more strings to the control.  These are cycled when OnLeft() and OnRight() are called
void CLTGUICycleCtrl::AddString(const char *pString)
{
	
	if ( !pString || !m_pFont || !m_nFontSize || m_stringArray.size() >= kMaxNumStrings)
	{
		ASSERT(0);
		return;
	}



	int x = m_pos.x + (int)((float)m_nHeaderWidth * m_fScale);
	CUIFormattedPolyString *pPolyStr = g_pFontManager->CreateFormattedPolyString(m_pFont,(char *)pString,(float)x,(float)m_pos.y);


	if (pPolyStr)
	{

		pPolyStr->SetCharScreenHeight(m_nFontSize);

		m_stringArray.push_back(pPolyStr);

		//if this is the first string, select it
		if (m_nSelIndex == kNoSelection)
		{
			m_nSelIndex = 0;
			CalculateSize();
		}

	}
}
예제 #3
0
// Sets the currently selected index
void CLTGUICycleCtrl::SetSelIndex(uint8 nIndex)
{
	if (nIndex > kMaxNumStrings || nIndex >= m_stringArray.size())
		return;
	m_nSelIndex=nIndex;
	CalculateSize();
}
예제 #4
0
// Right was pressed
LTBOOL CLTGUICycleCtrl::OnRight ( )
{
	int oldSel = m_nSelIndex;
	if ( m_stringArray.size() <= 1 )
	{
        return LTFALSE;
	}

	uint8 newSel = m_nSelIndex;
	newSel++;
	if ( newSel >= m_stringArray.size() )
	{
		newSel = 0;
	}
	if (newSel != m_nSelIndex)
	{
		SetSelIndex(newSel);
		CalculateSize();

	}
	if (m_pCommandHandler && m_nSelIndex != oldSel)
	{
		m_pCommandHandler->SendCommand(m_nCommandID, m_nParam1, m_nParam2);
	}
    return LTTRUE;
}
예제 #5
0
void Texture::SetTexture( SDL_Texture *text )
{
	SDL_DestroyTexture( texture );

	texture = text;
	CalculateSize( );
}
예제 #6
0
// Remove a character from the end
void CLTGUIEditCtrl::RemoveCharacter()
{
	if (!m_pText)
		return;

	// Check to see have any chars
	if (m_pText->GetLength() < 1)
		return;

	SAFE_STRCPY(szString,m_pText->GetText());

	int nEnd = (int)strlen(szString);
	if (nEnd > m_nCaretPos)
	{
		int nIndex = m_nCaretPos;

		while (nIndex < nEnd)
		{
			szString[nIndex] = szString[nIndex+1];
			nIndex++;
		}

		szString[nIndex]='\0';
		m_pText->SetText(szString);
	}

	CalculateSize();

}
CRecycleBinDeskBand::CRecycleBinDeskBand() :
m_bRequiresSave(false), m_dwViewMode(0), m_bCompositionEnabled(FALSE), m_spSite(nullptr), m_nBandID(0), m_pWindow(nullptr)
{
    LOG("CRecycleBinDeskBan()");

    m_size = CalculateSize();
}
예제 #8
0
void CListEditCtrl::OnKillFocus(CWnd* pNewWnd)
{
    CEdit::OnKillFocus(pNewWnd);

    CString str;
    GetWindowText(str);
    {   // 隣のセルにゴミが残らないように /* BeachMonster 089 */
        CRect rect;
        CalculateSize(rect);
        GetParent()->InvalidateRect(rect);
    }

    // Send Notification to parent of ListView ctrl
    LV_DISPINFO lvDispInfo;
    lvDispInfo.hdr.hwndFrom = GetParent()->m_hWnd;
    lvDispInfo.hdr.idFrom = GetDlgCtrlID();
    lvDispInfo.hdr.code = LVN_ENDLABELEDIT;
    lvDispInfo.item.mask = LVIF_TEXT;
    lvDispInfo.item.iItem = m_iItem;
    lvDispInfo.item.iSubItem = m_iSubItem;
    lvDispInfo.item.pszText = m_bVK_ESCAPE ? NULL : LPTSTR((LPCTSTR)str);
    lvDispInfo.item.cchTextMax = str.GetLength();
    GetParent()->GetParent()->SendMessage( WM_NOTIFY, GetParent()->GetDlgCtrlID(),(LPARAM)&lvDispInfo);
    DestroyWindow();
    AfxGetMainWnd()->SendMessage(WM_USER_SET_STATUS_INPUT_MODE, 0, (LPARAM)" "); /* Misirlou 150 */
}
예제 #9
0
void CLTGUIEditCtrl::SetFixedWidth(uint16 nWidth, LTBOOL bUseFrame)
{
	uint16 nMinWidth = m_nBaseFontSize + 1;
	ASSERT(nWidth >= nMinWidth);
	if (nWidth < nMinWidth)
		nWidth = nMinWidth;
	m_nFixedWidth = nWidth;
	CalculateSize();

	if (m_nFixedWidth)
	{
		m_bUseFrame = bUseFrame;
		if (m_pText)
		{
			float testWidth = m_fScale * m_nFixedWidth;
			int nOldCaret = m_nCaretPos;
			m_nCaretPos = m_pText->GetLength();
			while (m_pText->GetLength() && m_pText->GetWidth() > testWidth )
			{
				m_nCaretPos--;
				RemoveCharacter();				
			}
			if (nOldCaret > m_pText->GetLength())
				m_nCaretPos = m_pText->GetLength();
			else
				m_nCaretPos = nOldCaret;
		}
	}
	else
		m_bUseFrame = LTFALSE;
}
예제 #10
0
void Surface::Resize(int Width, int Height)
{
    if(Width==mWidth && Height==mHeight)
        return;

    if(Width<1 || Height<1)
        return;

    int newSize = CalculateSize(Width);

    if(newSize>mSurfaceWidth || newSize>mSurfaceHeight)
    {
        if(buffer!=0)
            free(buffer);

        mSurfaceWidth = newSize;
        mSurfaceHeight = newSize;
        mSpan = mSurfaceWidth;
        mWidth = Width;
        mHeight = Height;
        buffer = (unsigned char*) malloc(mSurfaceWidth * mSurfaceHeight * BYTESPERPIXEL);
        if(buffer==0)
            throw("Unable to allocate surface buffer");

        mDirty = true;
    }
}
예제 #11
0
		// Calculates the number of extra data objects that can fit in a
		// packet of a given size, or -1 if the size is incorrect.
		static int CalculateExtraDataCount(int packetSize)
		{
			packetSize -= CalculateSize(0);
			if (packetSize < 0)
				return -1;
			if (packetSize % sizeof(TExtraData) != 0)
				return -1;
			return packetSize / sizeof(TExtraData);
		}
예제 #12
0
void Pump::SetResources( float p_Count )
{
	if( p_Count > 1.0f )
	{
		p_Count = 1.0f;
	}

	m_Resources = p_Count;
	CalculateSize( );
}
예제 #13
0
		// Allocates a new variadic packet.
		static std::shared_ptr<TPacketType> Allocate(PacketGuid guid, int extraDataCount)
		{
			auto packetSize = CalculateSize(extraDataCount);
			auto buffer = new uint8_t[packetSize];
			new (buffer) VariadicPacket<TData, TExtraData>(guid, extraDataCount);
			return std::shared_ptr<TPacketType>(reinterpret_cast<TPacketType*>(buffer), [](TPacketType* x)
			{
				delete[] reinterpret_cast<uint8_t*>(x);
			});
		}
/**
* Method to set the bounding box
*
* @params maxx x max coord
* @params minx x min coord
* @params maxy y max coord
* @params miny y min coord
* @params maxz z max coord
* @params minz z min coord
*
*/
void BoundingBox::SetBoundingBox(GLfloat maxx, GLfloat minx, GLfloat maxy, GLfloat miny, GLfloat maxz, GLfloat minz)
{
	m_fMaxx = maxx;
	m_fMinx = minx;
	m_fMaxy = maxy;
	m_fMiny = miny;
	m_fMaxz = maxz;
	m_fMinz = minz;

	CalculateSize();
}
/**
* Initializate bounding box
*/
void BoundingBox::Init()
{
	m_fMaxx = -99999.0f;
	m_fMinx = 99999.0f;
	m_fMaxy = -99999.0f;
	m_fMiny = 99999.0f;
	m_fMaxz = -99999.0f;
	m_fMinz = 99999.0f;

	CalculateSize();
}
예제 #16
0
// Remove a string at a specific index
void CLTGUICycleCtrl::RemoveString(uint8 nIndex)
{
	if (nIndex > kMaxNumStrings || nIndex >= m_stringArray.size())
		return;
	g_pFontManager->DestroyPolyString(m_stringArray.at(nIndex));

	FPStringArray::iterator iter = m_stringArray.begin() + nIndex;
	m_stringArray.erase(iter);

	if (m_nSelIndex >= (int)m_stringArray.size())
	{
		m_nSelIndex = (int)m_stringArray.size()-1;
		CalculateSize();
	}
	else if (m_nSelIndex > nIndex)
	{
		m_nSelIndex--;
		CalculateSize();
	}
}
예제 #17
0
void CLTGUIColumnCtrl::SetScale(float fScale)
{
    CLTGUICtrl::SetScale(fScale);
    m_nFontSize = (uint8)(m_fScale * (float)m_nBaseFontSize);
    for (int i=0; i < GetNumColumns(); i++)
    {
        m_columnArray[i]->SetScale(fScale);
    }
    CalculateSize();

}
예제 #18
0
 void EnclosedRenderableContainerWidget::SetArea(const Vector2& Size)
 {
     Vector2 OldSize = WidgetBack->GetActualSize();
     Vector2 Position = WidgetBack->GetActualPosition();
     WidgetBack->SetActualSize(Size);
     for( AreaRenderableInfoIterator it = AreaRenderables.begin() ; it != AreaRenderables.end() ; it++ )
     {
         (*it).Offset = CalculateOffset(Size,OldSize,(*it).Offset,(*it).Anchor);
         if((*it).Tether != RT_TetherNone)
             (*it).Object->SetActualSize(CalculateSize(Size,OldSize,(*it).Object->GetActualSize(),(*it).Tether));
         (*it).Object->SetActualPosition(Position+(*it).Offset);
     }
     for( WidgetInfoIterator it = Widgets.begin() ; it != Widgets.end() ; it++ )
     {
         (*it).Offset = CalculateOffset(Size,OldSize,(*it).Offset,(*it).Anchor);
         if((*it).Tether != RT_TetherNone)
             (*it).Object->SetActualSize(CalculateSize(Size,OldSize,(*it).Object->GetActualSize(),(*it).Tether));
         (*it).Object->SetActualPosition(Position+(*it).Offset);
     }
 }
예제 #19
0
파일: xwindow.cpp 프로젝트: Klom/ekiga
void 
XWindow::SetWindow (int x, 
                    int y, 
                    unsigned int windowWidth, 
                    unsigned int windowHeight)
{
  PTRACE(4, "X11\tSetWindow " << x << "," << y << " " << windowWidth << "x" << windowHeight);
  XLockDisplay (_display);
  XMoveResizeWindow (_display, _XWindow, x, y, windowWidth, windowHeight);
  XUnlockDisplay (_display);
  CalculateSize (windowWidth, windowHeight, true);
}
예제 #20
0
void CLTGUIEditCtrl::SetScale(float fScale)
{
	CLTGUICtrl::SetScale(fScale);
	m_nFontSize = (uint8)(m_fScale * (float)m_nBaseFontSize);
	if (m_pText)
	{
		m_pText->SetPosition((float)m_pos.x,(float)m_pos.y);
		m_pText->SetCharScreenHeight(m_nFontSize);
	}
	CalculateSize();

}
/**
* Method to append a pint to the bounding box and resize it if necesary
*
* @params x x coord
* @params y y coord
* @params z z coord
* 
*/
void BoundingBox::AppendPoint(GLfloat x, GLfloat y, GLfloat z)
{

	if(x > m_fMaxx ) m_fMaxx = x;
	if(x < m_fMinx ) m_fMinx = x;
	if(y > m_fMaxy ) m_fMaxy = y;
	if(y < m_fMiny ) m_fMiny = y;
	if(z > m_fMaxz ) m_fMaxz = z;
	if(z < m_fMinz ) m_fMinz = z;

	CalculateSize();
}
예제 #22
0
void CLTGUIColumnCtrl::SetBasePos ( LTIntPt pos )
{
    CLTGUICtrl::SetBasePos(pos);
    LTIntPt tmpPos = m_basePos;
    for (int i=0; i < GetNumColumns(); i++)
    {
        m_columnArray[i]->SetBasePos(tmpPos);
        tmpPos.x += (m_columnArray[i]->GetFixedWidth() + (m_nBaseFontSize/2) );
    }

    CalculateSize();

}
예제 #23
0
파일: QLabel.cpp 프로젝트: sbc100/OpenQuick
//------------------------------------------------------------------------------
void QLabel::init()
{
	// This needs to be called after the LUA variables have been submitted to
    // the object.  TODO we want to support TTF rendering, but not through the
    // CQabelTTF class as the implimentation they chose is teh suck!
	QAssert(font != NULL, "label font is null");

    // Create and retain the node
    CCLabelNode *node = new CCLabelNode(this);
    m_CCNode = node;
    m_CCNode->retain();

    // Set the width to the box width if one is specified
    float width = GetCalculatedWidth();
    float text_width = width - textBorderLeft - textBorderRight;
    float height = GetCalculatedHeight();

    // Get the alignment information
    cocos2d::CCTextAlignment halign_val;
    cocos2d::CCVerticalTextAlignment valign_val;
    GetCurrentAlignment( &halign_val, &valign_val);

    // Create the label and add it to the node (node holds the reference)
    m_CCFontNode = CCLabelBMFont::create( text.c_str(),
                                          font->get_fileName().c_str(),
                                          text_width,
                                          halign_val);
    m_CCNode->addChild(m_CCFontNode);

    // Calculate the size of the text if we aren't rendering into a box
    CalculateSize();

    // Now set the anchor and position of the CQabel
    SetAlignmentAnchors( halign_val, valign_val);

    m_CCNode->setPosition( x, y);
	m_CCNode->setAnchorPoint(ccp(xAnchor, yAnchor));

    m_CachedWidth = width;
    m_CachedHeight = height;
    m_CachedHAlignment = hAlignment;
	m_CachedVAlignment = vAlignment;

    m_CachedTextBorderTop = textBorderTop;
    m_CachedTextBorderBottom = textBorderBottom;
    m_CachedTextBorderLeft = textBorderLeft;
    m_CachedTextBorderRight = textBorderRight;

    m_CachedTextXScale = textXScale;
    m_CachedTextYScale = textYScale;
}
예제 #24
0
bool CGUITextureBase::Process(unsigned int currentTime)
{
  bool changed = false;
  // check if we need to allocate our resources
  changed |= AllocateOnDemand();

  if (m_texture.size() > 1)
    changed |= UpdateAnimFrame(currentTime);

  if (m_invalid)
    changed |= CalculateSize();

  return changed;
}
예제 #25
0
    void GridLayout::Layout(View* host)
    {
        DCHECK(host_ == host);
        // SizeRowsAndColumns sets the size and location of each row/column, but
        // not of the views.
        gfx::Size pref;
        SizeRowsAndColumns(true, host_->width(), host_->height(), &pref);

        // Size each view.
        for(std::vector<ViewState*>::iterator i=view_states_.begin();
            i!=view_states_.end(); ++i)
        {
            ViewState* view_state = *i;
            ColumnSet* column_set = view_state->column_set;
            View* view = (*i)->view;
            DCHECK(view);
            int x = column_set->columns_[view_state->start_col]->Location() +
                left_inset_;
            int width = column_set->GetColumnWidth(view_state->start_col,
                view_state->col_span);
            CalculateSize(view_state->pref_width, view_state->h_align,
                &x, &width);
            int y = rows_[view_state->start_row]->Location() + top_inset_;
            int height = LayoutElement::TotalSize(view_state->start_row,
                view_state->row_span, &rows_);
            if(view_state->v_align==BASELINE && view_state->baseline!=-1)
            {
                y += rows_[view_state->start_row]->max_ascent() - view_state->baseline;
                height = view_state->pref_height;
            }
            else
            {
                CalculateSize(view_state->pref_height, view_state->v_align, &y, &height);
            }
            view->SetBounds(x, y, width, height);
        }
    }
예제 #26
0
void CFolderInfo::Update()
{
	DWORD now = GetTickCount();
	if (now - m_LastUpdateTime > UPDATE_TIME_MIN_MS)
	{
		Clear();

		if (!m_Path.empty())
		{
			CalculateSize();
		}

		m_LastUpdateTime = now;
	}
}
		void* c_tag_block_allocations::Realloc(tag_block& instance, int32 new_count, cstring file, uint32 line)
		{
			size_t new_size = CalculateSize(instance.definition, new_count);

			void* address = s_tag_allocation_header::Enabled()
				? s_tag_allocation_header::Get(instance)
				: instance.address;

			address = blam::debug_realloc(address, new_size, file, line);

			if (s_tag_allocation_header::Enabled())
				address = CAST_PTR(s_tag_allocation_header*, address)->GetBody();

			instance.count = new_count;
			return instance.address = address;
		}
		void* c_tag_block_allocations::New(const tag_block_definition* definition, int32 element_count, cstring file, uint32 line)
		{			
			size_t size = CalculateSize(definition, element_count);

			void* address = blam::debug_malloc(size, false, file, line);

			if (s_tag_allocation_header::Enabled())
			{
				auto header = CAST_PTR(s_tag_allocation_header*, address);
				header->Initialize(definition);

				address = header->GetBody();
			}

			return address;
		}
예제 #29
0
int CListEditCtrl::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
    if (CEdit::OnCreate(lpCreateStruct) == -1)
        return -1;

    CFont* font = GetParent()->GetFont();
    SetFont(font);
    SetWindowText(m_strInitText);
    CRect rect;
    if (CalculateSize(rect)) {  /* BeachMonster 089 */
        MoveWindow( &rect );
    }
//	SetFocus();
    SetSel(0, 0);

    return 0;
}
예제 #30
0
// Set the text
void CLTGUIEditCtrl::SetText(const char *pString)
{
	if ( !pString || !m_pLTClient || !m_pFont || !m_nFontSize)
		return;

	if (!m_pText)
		m_pText = g_pFontManager->CreateFormattedPolyString(m_pFont,(char *)pString,(float)m_pos.x,(float)m_pos.y);
	else
		m_pText->SetText((char *)pString);


	if (m_pText)
	{
		m_pText->SetCharScreenHeight(m_nFontSize);
		CalculateSize();
	}
	m_nCaretPos = (uint16)strlen(pString);
}