void CGUIPanelContainer::ValidateOffset() { if (!m_layout) return; // first thing is we check the range of our offset // don't validate offset if we are scrolling in case the tween image exceed <0, 1> range if (GetOffset() > (int)GetRows() - m_itemsPerPage || (!m_scroller.IsScrolling() && m_scroller.GetValue() > ((int)GetRows() - m_itemsPerPage) * m_layout->Size(m_orientation))) { SetOffset(std::max(0, (int)GetRows() - m_itemsPerPage)); m_scroller.SetValue(GetOffset() * m_layout->Size(m_orientation)); } if (GetOffset() < 0 || (!m_scroller.IsScrolling() && m_scroller.GetValue() < 0)) { SetOffset(0); m_scroller.SetValue(0); } }
void CSimpleReport::RowDelete() { int idx = RowGetFocused(); GetRecords()->RemoveAt(idx); Populate(); SetFocusedRow(GetRows()->GetAt(idx)); SetFocus(); }
NS_IMETHODIMP HTMLFrameSetElement::GetRows(nsAString& aRows) { nsString rows; GetRows(rows); aRows = rows; return NS_OK; }
CBaseTexture::CBaseTexture(const CBaseTexture ©) { m_imageWidth = copy.m_imageWidth; m_imageHeight = copy.m_imageHeight; m_textureWidth = copy.m_textureWidth; m_textureHeight = copy.m_textureHeight; m_format = copy.m_format; m_orientation = copy.m_orientation; m_hasAlpha = copy.m_hasAlpha; m_pixels = NULL; m_loadedToGPU = false; if (copy.m_pixels) { m_pixels = new unsigned char[GetPitch() * GetRows()]; memcpy(m_pixels, copy.m_pixels, GetPitch() * GetRows()); } }
void CGUIBaseContainer::SetPageControlRange() { if (m_pageControl) { CGUIMessage msg(GUI_MSG_LABEL_RESET, GetID(), m_pageControl, m_itemsPerPage, GetRows()); SendWindowMessage(msg); } }
void StatWin::ReSize() { wxSize cs = GetParent()->GetClientSize(); wxSize new_size; new_size.x = cs.x; new_size.y = 22 * GetRows(); SetSize(new_size); }
void BaseGrid::ScrollTo(int y) { int nextY = mid(0, y, GetRows() - 1); if (yPos != nextY) { yPos = nextY; scrollBar->SetThumbPosition(yPos); Refresh(false); } }
NS_IMETHODIMP HTMLFrameSetElement::GetRows(nsAString& aRows) { DOMString rows; GetRows(rows); rows.ToString(aRows); return NS_OK; }
bool NFCRecord::Clear() { for (int i = GetRows() - 1; i >= 0; i--) { Remove(i); } return true; }
bool NFCRecord::ValidRow(int nRow) const { if (nRow >= GetRows() || nRow < 0) { return false; } return true; }
/////////////////////////// // Gets first selected row int BaseGrid::GetFirstSelRow() { int nrows = GetRows(); for (int i=0;i<nrows;i++) { if (IsInSelection(i,0)) { return i; } } return -1; }
//--------------------------------------------------------------------------- bool IValue::operator!=(const IValue &a_Val) const { char_type type1 = GetType(), type2 = a_Val.GetType(); if (type1 == type2 || (IsScalar() && a_Val.IsScalar())) { switch (GetType()) { case 's': return GetString() != a_Val.GetString(); case 'i': case 'f': return GetFloat() != a_Val.GetFloat(); case 'c': return (GetFloat() != a_Val.GetFloat()) || (GetImag() != a_Val.GetImag()); case 'b': return GetBool() != a_Val.GetBool(); case 'v': return true; case 'm': if (GetRows() != a_Val.GetRows() || GetCols() != a_Val.GetCols()) { return true; } else { for (int i = 0; i < GetRows(); ++i) { if (const_cast<IValue*>(this)->At(i) != const_cast<IValue&>(a_Val).At(i)) return true; } return false; } default: ErrorContext err; err.Errc = ecINTERNAL_ERROR; err.Pos = -1; err.Type2 = GetType(); err.Type1 = a_Val.GetType(); throw ParserError(err); } // switch this type } else { return true; } }
///////////// // Scroll to void BaseGrid::ScrollTo(int y) { int w,h; GetClientSize(&w,&h); int nextY = MID(0,y,GetRows()+2 - h/lineHeight); if (yPos != nextY) { yPos = nextY; if (scrollBar->IsEnabled()) scrollBar->SetThumbPosition(yPos); Refresh(false); } }
CMotion2DImage<Type> CMotion2DImage<Type>::operator-(const CMotion2DImage<Type> &image) { CMotion2DImage<Type> D(GetRows(),GetCols()); for (unsigned i=0; i<npixels; i++) { D.bitmap[i] = bitmap[i] - image.bitmap[i]; } return D; }
void BaseGrid::OnSubtitlesOpen() { BeginBatch(); ClearMaps(); UpdateMaps(); if (GetRows()) { int row = context->ass->GetScriptInfoAsInt("Active Line"); if (row < 0 || row >= GetRows()) row = 0; SetActiveLine(GetDialogue(row)); SelectRow(row); } ScrollTo(context->ass->GetScriptInfoAsInt("Scroll Position")); EndBatch(); SetColumnWidths(); }
void CSimpleReport::RowSetFocused(CXTPReportRecord* pRec) { CXTPReportRows* pRows = GetRows(); for (int i = 0; i < pRows->GetCount(); i++) { CXTPReportRow* pRow = pRows->GetAt(i); if (pRow->GetRecord() == pRec) { SetFocusedRow(pRow); return; } } }
int Table::GetWidth(int zoom) const { int cx = 0; for(int i = 0; i < GetRows(); i++) { const Array<TableCell>& row = cell[i]; int x = 0; for(int j = 0; j < row.GetCount(); j++) x = max(x, row[j].GetWidth(zoom) / row[j].GetRatio()); cx = max(cx, x * GetTotalRatio(row)); } return cx + 2 * GetFrameWidth(); }
// Result = A' * Vec void TNGraphMtx::PMultiplyT(const TFltV& Vec, TFltV& Result) const { const int RowN = GetRows(); Assert(Vec.Len() >= RowN && Result.Len() >= RowN); const THash<TInt, TNGraph::TNode>& NodeH = Graph->NodeH; for (int i = 0; i < RowN; i++) Result[i] = 0.0; for (int j = 0; j < RowN; j++) { const TIntV& RowV = NodeH[j].OutNIdV; for (int i = 0; i < RowV.Len(); i++) { Result[RowV[i]] += Vec[j]; } } }
NS_IMETHODIMP nsHTMLTableSectionElement::InsertRow(PRInt32 aIndex, nsIDOMHTMLElement** aValue) { *aValue = nsnull; if (aIndex < -1) { return NS_ERROR_DOM_INDEX_SIZE_ERR; } nsCOMPtr<nsIDOMHTMLCollection> rows; GetRows(getter_AddRefs(rows)); PRUint32 rowCount; rows->GetLength(&rowCount); if (aIndex > (PRInt32)rowCount) { return NS_ERROR_DOM_INDEX_SIZE_ERR; } PRBool doInsert = (aIndex < PRInt32(rowCount)) && (aIndex != -1); // create the row nsCOMPtr<nsINodeInfo> nodeInfo; nsContentUtils::NameChanged(mNodeInfo, nsGkAtoms::tr, getter_AddRefs(nodeInfo)); nsCOMPtr<nsIContent> rowContent = NS_NewHTMLTableRowElement(nodeInfo); if (!nodeInfo) { return NS_ERROR_OUT_OF_MEMORY; } nsCOMPtr<nsIDOMNode> rowNode(do_QueryInterface(rowContent)); NS_ASSERTION(rowNode, "Should implement nsIDOMNode!"); nsCOMPtr<nsIDOMNode> retChild; nsresult rv; if (doInsert) { nsCOMPtr<nsIDOMNode> refRow; rows->Item(aIndex, getter_AddRefs(refRow)); rv = InsertBefore(rowNode, refRow, getter_AddRefs(retChild)); } else { rv = AppendChild(rowNode, getter_AddRefs(retChild)); } if (retChild) { CallQueryInterface(retChild, aValue); } return NS_OK; }
void CDXTexture::LoadToGPU() { if (!m_pixels) { // nothing to load - probably same image (no change) return; } if (m_texture.Get() == NULL) { CreateTextureObject(); if (m_texture.Get() == NULL) { CLog::Log(LOGDEBUG, "CDXTexture::CDXTexture: Error creating new texture for size %d x %d", m_textureWidth, m_textureHeight); return; } } D3DLOCKED_RECT lr; if (m_texture.LockRect( 0, &lr, NULL, D3DLOCK_DISCARD )) { unsigned char *dst = (unsigned char *)lr.pBits; unsigned char *src = m_pixels; unsigned int dstPitch = lr.Pitch; unsigned int srcPitch = GetPitch(); unsigned int minPitch = std::min(srcPitch, dstPitch); unsigned int rows = GetRows(); if (srcPitch == dstPitch) { memcpy(dst, src, srcPitch * rows); } else { for (unsigned int y = 0; y < rows; y++) { memcpy(dst, src, minPitch); src += srcPitch; dst += dstPitch; } } } else { CLog::Log(LOGERROR, __FUNCTION__" - failed to lock texture"); } m_texture.UnlockRect(0); delete [] m_pixels; m_pixels = NULL; m_loadedToGPU = true; }
// Result = A * B(:,ColId) void TUNGraphMtx::PMultiply(const TFltVV& B, int ColId, TFltV& Result) const { const int RowN = GetRows(); Assert(B.GetRows() >= RowN && Result.Len() >= RowN); const THash<TInt, TUNGraph::TNode>& NodeH = Graph->NodeH; for (int j = 0; j < RowN; j++) { const TIntV& RowV = NodeH[j].NIdV; Result[j] = 0.0; for (int i = 0; i < RowV.Len(); i++) { Result[j] += B(RowV[i], ColId); } } }
int Raster::Uniform(const char * pOutputRaster, double fValue) { // Open up the Input File GDALDataset * pInputDS = (GDALDataset*) GDALOpen(m_sFilePath, GA_ReadOnly); if (pInputDS == NULL) throw RasterManagerException( INPUT_FILE_ERROR, "Input file could not be opened"); GDALRasterBand * pRBInput = pInputDS->GetRasterBand(1); // Create the output dataset for writing GDALDataset * pOutputDS = CreateOutputDS(pOutputRaster, this); GDALRasterBand * pOutputRB = pOutputDS->GetRasterBand(1); // Assign our buffers double * pInputLine = (double*) CPLMalloc(sizeof(double) * GetCols()); double * pOutputLine = (double*) CPLMalloc(sizeof(double) * GetCols()); // Loop over rows for (int i=0; i < GetRows(); i++) { // Populate the buffer pRBInput->RasterIO(GF_Read, 0, i, GetCols(), 1, pInputLine, GetCols(), 1, GDT_Float64, 0, 0); // Loop over columns for (int j=0; j < GetCols(); j++) { if (pInputLine[j] != GetNoDataValue()){ pOutputLine[j] = fValue; } else { pOutputLine[j] = GetNoDataValue(); } } // Write the row pOutputRB->RasterIO(GF_Write, 0, i, GetCols(), 1, pOutputLine, GetCols(), 1, GDT_Float64, 0, 0 ); } CPLFree(pOutputLine); CPLFree(pInputLine); CalculateStats(pOutputDS->GetRasterBand(1)); if ( pInputDS != NULL) GDALClose(pInputDS); if ( pOutputDS != NULL) GDALClose(pOutputDS); return PROCESS_OK; }
void Table::GetValueRects(int zoom, Draw& w, int x, int& y, int cx, Vector<ValueRect>& vr) const { int zfw = DocZoomLn(zoom, GetFrameWidth()); int li = 0; cx -= 2 * zfw + DocZoom(zoom, GetLm()) + DocZoom(zoom, GetRm()); y += zfw; while(li < GetRows()) { Vector<Line> line; int span = 0; for(;;) { int k = li + line.GetCount(); if(k >= GetRows() || line.GetCount() && !KeepLine(k) && span <= 0) break; span = max((line.Add() = GetLine(zoom, k, cx, NULL)).span, span); span--; } y += Span(line); RectLines(zoom, w, x, y, li, line, vr); li += line.GetCount(); } y += zfw; }
int Table::GetHeight(int zoom, int cx) const { int cy = 0; int ln = 0; cx -= DocZoomLn(zoom, GetFrameWidth()) + DocZoomLn(zoom, GetFrameWidth()) + DocZoom(zoom, GetLm()) + DocZoom(zoom, GetRm()); cy += 2 * DocZoomLn(zoom, GetFrameWidth()); while(ln < GetRows()) { Vector<Line> line; int span = 0; for(;;) { int k = ln + line.GetCount(); if(ln + line.GetCount() >= GetRows() || line.GetCount() && !KeepLine(k) && span <= 0) break; span = max((line.Add() = GetLine(zoom, k, cx, NULL)).span, span); span--; } cy += Span(line); ln += line.GetCount(); } return cy; }
CBasicAnimation::CBasicAnimation(ALLEGRO_BITMAP* sheet, size_t rows, size_t cols, double fps) : IAnimationBase(rows, cols, fps) , m_animationSheet(sheet) , m_frame() , m_frameW(DEFAULTFRAMEW) , m_frameH(DEFAULTFRAMEH) { assert(m_animationSheet.IsValid() == true); assert(rows > 0); assert(cols > 0); assert(fps > 0.0); if (!m_animationSheet || !GetRows() || !GetCols() || (GetFPS() <= 0)) abort(); if (m_animationSheet) { m_frameW = m_animationSheet.GetWidth() / GetCols(); m_frameH = m_animationSheet.GetHeight() / GetRows(); FrameChanged(); } }
void CBaseTexture::Update(unsigned int width, unsigned int height, unsigned int pitch, unsigned int format, const unsigned char *pixels, bool loadToGPU) { if (pixels == NULL) return; if (format & XB_FMT_DXT_MASK && !g_Windowing.SupportsDXT()) { // compressed format that we don't support Allocate(width, height, XB_FMT_A8R8G8B8); CDDSImage::Decompress(m_pixels, std::min(width, m_textureWidth), std::min(height, m_textureHeight), GetPitch(m_textureWidth), pixels, format); } else { Allocate(width, height, format); unsigned int srcPitch = pitch ? pitch : GetPitch(width); unsigned int srcRows = GetRows(height); unsigned int dstPitch = GetPitch(m_textureWidth); unsigned int dstRows = GetRows(m_textureHeight); if (srcPitch == dstPitch) memcpy(m_pixels, pixels, srcPitch * std::min(srcRows, dstRows)); else { const unsigned char *src = pixels; unsigned char* dst = m_pixels; for (unsigned int y = 0; y < srcRows && y < dstRows; y++) { memcpy(dst, src, std::min(srcPitch, dstPitch)); src += srcPitch; dst += dstPitch; } } } ClampToEdge(); if (loadToGPU) LoadToGPU(); }
ConnectThree::ConnectThree( const int n_cols, const int n_rows) : m_area(n_cols, std::vector<int>(n_rows,no_player)), m_player(ConnectThree::player1) { Restart(); //assert(m_is_player_human.size() == 3); assert(player1 == 0); assert(player2 == 1); assert(player3 == 2); assert(GetCols() == n_cols); assert(GetRows() == n_rows); }
void CBaseTexture::Update(unsigned int width, unsigned int height, unsigned int pitch, unsigned int format, const unsigned char *pixels, bool loadToGPU) { if (pixels == NULL) return; if (format & XB_FMT_DXT_MASK) return; Allocate(width, height, format); if (m_pixels == nullptr) return; unsigned int srcPitch = pitch ? pitch : GetPitch(width); unsigned int srcRows = GetRows(height); unsigned int dstPitch = GetPitch(m_textureWidth); unsigned int dstRows = GetRows(m_textureHeight); if (srcPitch == dstPitch) memcpy(m_pixels, pixels, srcPitch * std::min(srcRows, dstRows)); else { const unsigned char *src = pixels; unsigned char* dst = m_pixels; for (unsigned int y = 0; y < srcRows && y < dstRows; y++) { memcpy(dst, src, std::min(srcPitch, dstPitch)); src += srcPitch; dst += dstPitch; } } ClampToEdge(); if (loadToGPU) LoadToGPU(); }
std::string CGUIBaseContainer::GetLabel(int info) const { std::string label; switch (info) { case CONTAINER_NUM_PAGES: label = StringUtils::Format("%u", (GetRows() + m_itemsPerPage - 1) / m_itemsPerPage); break; case CONTAINER_CURRENT_PAGE: label = StringUtils::Format("%u", GetCurrentPage()); break; case CONTAINER_POSITION: label = StringUtils::Format("%i", GetCursor()); break; case CONTAINER_CURRENT_ITEM: { if (m_items.size() && m_items[0]->IsFileItem() && (std::static_pointer_cast<CFileItem>(m_items[0]))->IsParentFolder()) label = StringUtils::Format("%i", GetSelectedItem()); else label = StringUtils::Format("%i", GetSelectedItem() + 1); } break; case CONTAINER_NUM_ALL_ITEMS: case CONTAINER_NUM_ITEMS: { unsigned int numItems = GetNumItems(); if (info == CONTAINER_NUM_ITEMS && numItems && m_items[0]->IsFileItem() && (std::static_pointer_cast<CFileItem>(m_items[0]))->IsParentFolder()) label = StringUtils::Format("%u", numItems-1); else label = StringUtils::Format("%u", numItems); } break; case CONTAINER_NUM_NONFOLDER_ITEMS: { int numItems = 0; for (auto item : m_items) { if (!item->m_bIsFolder) numItems++; } label = StringUtils::Format("%u", numItems); } break; default: break; } return label; }
///////////////////////// // Selects visible lines void BaseGrid::SelectVisible() { int rows = GetRows(); bool selectedOne = false; for (int i=0;i<rows;i++) { if (IsDisplayed(GetDialogue(i))) { if (!selectedOne) { SelectRow(i,false); MakeCellVisible(i,0); selectedOne = true; } else { SelectRow(i,true); } } } }