Esempio n. 1
0
NS_IMETHODIMP
HTMLFrameSetElement::SetRows(const nsAString& aRows)
{
  ErrorResult rv;
  SetRows(aRows, rv);
  return rv.StealNSResult();
}
Esempio n. 2
0
/*
     * Initializes the object, assuming that filename, origin, size, etc are already set on the
     * member variables. Makes sure the raster can be opened, sets the block size, NODATA value,
     * pixel size, and the extent of the raster. If not using the full image then makes sure that
     * the subset chosen (based on origin and size) is valid. If using the full image then sets the
     * size and origin is assumed to be 0,0 and is set in the constructor.
     * @param fullImage True if using the full image, False if using a subset.
     */
void Raster::Init(bool bFullImage)
{
    Init();
    GDALDataset * ds = (GDALDataset*) GDALOpen(m_sFilePath, GA_ReadOnly);

    if (ds == NULL)
        throw RasterManagerException(INPUT_FILE_NOT_VALID, CPLGetLastErrorMsg());

    GDALRasterBand * band = ds->GetRasterBand(1);

    double dRMin, dRMax, dRMean, dRStdDev;

    // Get some easy stats that GDAL gives us
    band->GetStatistics( 0 , true, &dRMin, &dRMax, &dRMean, &dRStdDev );
    m_dRasterMax = dRMax;
    m_dRasterMin = dRMin;

    m_dRasterMean = dRMean;
    m_dRasterStdDev = dRStdDev;

    OGRLinearRing ring = OGRLinearRing();
    if (bFullImage)
    {
        SetCols( band->GetXSize() );
        SetRows( band->GetYSize() );

        ring.addPoint(GetLeft(), GetTop());
        ring.addPoint(GetLeft(), GetTop() + (GetCellHeight() * GetRows()));
        ring.addPoint(GetLeft() + (GetCellWidth() * GetCols()), GetTop() + (GetCellHeight() * GetRows()));
        ring.addPoint(GetLeft() + (GetCellWidth() * GetCols()), GetTop());
        ring.closeRings();
    }
    else
    {
        if ((GetLeft() + GetCols() > band->GetXSize()) || (GetTop() + GetRows() > band->GetYSize()))
        {
            QString sErr = QString("Invalid origin ( %1, %2 ) and size ( %5, %6 ) for file: %7")
                    .arg(GetLeft())
                    .arg(GetTop())
                    .arg(GetCols())
                    .arg(GetRows())
                    .arg(FilePath());
            throw RasterManagerException(INPUT_FILE_NOT_VALID, sErr);
        }
        double xMapOrigin = GetLeft() + (GetLeft() * GetCellWidth());
        double yMapOrigin = GetTop() + (GetTop() * GetCellHeight());
        ring.addPoint(xMapOrigin, yMapOrigin);
        ring.addPoint(xMapOrigin, yMapOrigin + (GetCellHeight() * GetRows()));
        ring.addPoint(xMapOrigin + (GetCellWidth() * GetCols()), yMapOrigin + (GetCellHeight() * GetRows()));
        ring.addPoint(xMapOrigin + (GetCellWidth() * GetCols()), yMapOrigin);
        ring.closeRings();
    }
    GDALClose(ds);

}
Esempio n. 3
0
/////////////////////////////////////////////////////////////////////////////
// CMiniCalendarCtrl
CMiniCalendarCtrl::CMiniCalendarCtrl()
:	m_bSizeComputed(FALSE),
	m_bTracking(FALSE),
	m_bHeaderTracking(FALSE),
	m_pCalendarData(NULL),
	m_pWnd(NULL),
	m_pHeaderList(NULL),
	m_pHeaderCell(NULL),
	m_parCells(NULL),
	m_pFont(NULL),
	m_pFontBold(NULL),
	m_iHeaderTimerID(0),
	m_iRows(0),
	m_iFirstDayOfWeek(0),
	m_iHeaderHeight(0),
	m_iIndividualDayWidth(0),
	m_iDaysOfWeekHeight(0),
	m_iDaysHeight(0),
	m_iCurrentMonth(0),
	m_iCurrentYear(0),
	m_cBackColor(0)
{
	m_cBackColor = ::GetSysColor(COLOR_WINDOW);

	m_szMonthSize = CSize(0,0);

	m_rectScrollLeft.SetRectEmpty();
	m_rectScrollRight.SetRectEmpty();

	CCalendarUtils::GetToday(m_dateSelected);

	m_iCurrentMonth = m_dateSelected.GetMonth();
	m_iCurrentYear = m_dateSelected.GetYear();
	ASSERT((m_iCurrentYear >= 100) && (m_iCurrentYear <= 9999)); //From MSDN: The COleDateTime class handles
	ASSERT((m_iCurrentMonth >= 1) && (m_iCurrentMonth <= 12));	 //dates from 1 January 100 to 31 December 9999.

	SetRows(1);

	// set month names
	for (int i = 0; i < 12; i++)
	{
		CString strMonthName = CDateHelper::GetMonthName(i+1, FALSE);
		m_arrMonthNames[i] = strMonthName;
	}

	// set days of week names
	SetFirstDayOfWeek(CDateHelper::GetFirstDayOfWeek());

	m_pFont = new CFont;
	GraphicsMisc::CreateFont(*m_pFont, MINICAL_FONT_NAME, MINICAL_FONT_SIZE);

	m_pFontBold = new CFont;
	GraphicsMisc::CreateFont(*m_pFontBold, MINICAL_FONT_NAME, MINICAL_FONT_SIZE, GMFS_BOLD);
}
Esempio n. 4
0
/*
 * Copy the object. (Note that this simply copies the member properties
 * of the class for assigning the object to a new variable. See the
 * Copy() method for actually copying the raster dataset object to a new
 * file on disk.
*/
void Raster::CopyObject(Raster &src)
{
    Init();

    m_sFilePath = (char *) malloc(strlen(src.FilePath()) * sizeof(char)+1);
    std::strcpy(m_sFilePath, src.FilePath());

    SetTransform(src.GetTop(), src.GetLeft(), src.GetCellWidth(), src.GetCellHeight());

    SetRows(src.GetRows());
    SetCols(src.GetCols());

    SetNoDataValue(src.GetNoDataValuePtr());

    xBlockSize = src.xBlockSize;
    yBlockSize = src.yBlockSize;
}
Esempio n. 5
0
bool
CMotion2DImage<Type>::Init(unsigned nb_rows, unsigned nb_cols)
{
  // Test image size differ
  if ((nb_rows != nrows) || (nb_cols != ncols)) {
    if (bitmap != NULL) {
      delete [] bitmap;
      bitmap = NULL;
    }
  }

  if (nb_rows != nrows) {
    if (row != NULL)  {
      delete [] row;
      row = NULL;
    }
  }

  SetCols(nb_cols) ;
  SetRows(nb_rows) ;

  npixels=ncols*nrows;

  if (bitmap == NULL) bitmap = new Type[npixels] ;
  if (bitmap == NULL)
  {
    cerr << "Error in CMotion2DImage::Init(): cannot allocate memory" << endl;
    return false ;
  }

  if (row == NULL) row = new  Type*[nrows] ;
  if (row == NULL)
  {
    cerr << "Error in CMotion2DImage::Init(): cannot allocate memory" << endl;
    return false;
  }

  unsigned i ;
  for ( i =0  ; i < nrows ; i++)
    row[i] = bitmap + i*ncols ;

  return true;
}
Esempio n. 6
0
wxSizerItem* wxGridBagSizer::Add( wxGBSizerItem *item )
{
    wxCHECK_MSG( !CheckForIntersection(item), NULL,
                 wxT("An item is already at that position") );
    m_children.Append(item);
    item->SetGBSizer(this);
    if ( item->GetWindow() )
        item->GetWindow()->SetContainingSizer( this );

    // extend the number of rows/columns of the underlying wxFlexGridSizer if
    // necessary
    int row, col;
    item->GetEndPos(row, col);
    row++;
    col++;

    if ( row > GetRows() )
        SetRows(row);
    if ( col > GetCols() )
        SetCols(col);

    return item;
}
Esempio n. 7
0
void CMiniCalendarCtrl::OnSize(UINT nType, int cx, int cy) 
{
	SetRows(max(1, (cy / MINICALENDAR_HEIGHT)));

	CWnd::OnSize(nType, cx, cy);
}
Esempio n. 8
0
bool wxToolBar::Realize()
{
    if (m_tools.GetCount() == 0)
        return FALSE;

    int x = m_xMargin + kwxMacToolBarLeftMargin ;
    int y = m_yMargin + kwxMacToolBarTopMargin ;

    int tw, th;
    GetSize(& tw, & th);
    
    int maxWidth = 0 ;
    int maxHeight = 0 ;
    
    int maxToolWidth = 0;
    int maxToolHeight = 0;

    // Find the maximum tool width and height
    wxToolBarToolsList::compatibility_iterator node = m_tools.GetFirst();
    while ( node )
    {
        wxToolBarTool *tool = (wxToolBarTool *)node->GetData();
        wxSize sz = tool->GetSize() ;

        if ( sz.x > maxToolWidth )
            maxToolWidth = sz.x ;
        if (sz.y> maxToolHeight)
            maxToolHeight = sz.y;

        node = node->GetNext();
    }

    bool lastWasRadio = FALSE;
    node = m_tools.GetFirst();
    while (node)
    {
        wxToolBarTool *tool = (wxToolBarTool *)node->GetData();
        wxSize cursize = tool->GetSize() ;
        
        bool isRadio = FALSE;

        if ( tool->IsButton() && tool->GetKind() == wxITEM_RADIO )
        {
            if ( !lastWasRadio )
            {
                if (tool->Toggle(true))
                {
                    DoToggleTool(tool, true);
                }
            }
            else if (tool->IsToggled())
            {
                wxToolBarToolsList::compatibility_iterator nodePrev = node->GetPrevious();
                while ( nodePrev )
                {
                    wxToolBarToolBase *tool = nodePrev->GetData();
                    if ( !tool->IsButton() || (tool->GetKind() != wxITEM_RADIO) )
                        break;
                    if ( tool->Toggle(false) )
                    {
                        DoToggleTool(tool, false);
                    }
                    nodePrev = nodePrev->GetPrevious();
                }
            }
            isRadio = TRUE;
        }
        else
        {
            isRadio = FALSE;
        }
        lastWasRadio = isRadio;

        // for the moment we just do a single row/column alignement
        if ( x + cursize.x > maxWidth )
            maxWidth = x + cursize.x ;
        if ( y + cursize.y > maxHeight )
            maxHeight = y + cursize.y ;
            
        if ( GetWindowStyleFlag() & wxTB_VERTICAL )
        {
            int x1 = x + (maxToolWidth - cursize.x)/2 ;
            tool->SetPosition( wxPoint( x1 , y ) ) ;
        }
        else
        {
            int y1 = y + (maxToolHeight - cursize.y)/2 ;
            tool->SetPosition( wxPoint( x , y1 ) ) ;
        }    
        if ( GetWindowStyleFlag() & wxTB_VERTICAL )
        {
            y += cursize.y ;
            y += kwxMacToolSpacing ;
        }
        else
        {
            x += cursize.x ;
            x += kwxMacToolSpacing ;
        }

        node = node->GetNext();
    }
    
    if ( GetWindowStyleFlag() & wxTB_HORIZONTAL )
    {
        if ( m_maxRows == 0 )
        {
            // if not set yet, only one row
            SetRows(1);
        }
        m_minWidth = maxWidth;
        maxWidth = tw ; 
        maxHeight += m_yMargin + kwxMacToolBarTopMargin;
        m_minHeight = m_maxHeight = maxHeight ;
    }
    else
    {
        if ( GetToolsCount() > 0 && m_maxRows == 0 )
        {
            // if not set yet, have one column
            SetRows(GetToolsCount());
        }
        m_minHeight = maxHeight;
        maxHeight = th ;
        maxWidth += m_xMargin + kwxMacToolBarLeftMargin;
        m_minWidth = m_maxWidth = maxWidth ;
    }
    
    SetSize( maxWidth, maxHeight );
    InvalidateBestSize();
    
    return TRUE;
}
void CArrayInt2D::SetSize(int iNumColumns, int iNumRows)
{
	SetColumns(iNumColumns);
	SetRows(iNumRows);
}