Example #1
0
void MultiTabs::Pack()
{
  // Update buttons position
  prev_tab_bt->SetPosition(position.x + MARGIN, position.y + 2);
  next_tab_bt->SetPosition(position.x + size.x - MARGIN - next_tab_bt->GetSizeX(),
                           position.y + 2);

  // Update tabs position
  Point2i tab_pos(position.x + MARGIN, position.y + GetHeaderHeight());
  Point2i tab_size(size.x - 2*MARGIN, size.y - GetHeaderHeight() - MARGIN);

  for (std::vector<Tab>::iterator it=tabs.begin(); it!=tabs.end(); it++) {
    (*it).box->SetPosition(tab_pos);
    (*it).box->SetSize(tab_size);
    (*it).box->Pack();
  }

  // Compute how many tabs can be displayed
  nb_visible_tabs = std::min(uint(tabs.size()), uint(GetSizeX() / TAB_MIN_WIDTH));
  nb_visible_tabs = std::min(nb_visible_tabs, max_visible_tabs);

  if (nb_visible_tabs == 0)
    nb_visible_tabs = 1;

  // Compute tab size in the header
  tab_header_width = ((next_tab_bt->GetPositionX() -
                      (prev_tab_bt->GetPositionX() + prev_tab_bt->GetSizeX()) - 10))
                   / nb_visible_tabs;
}
Example #2
0
// Also here some of the size calculations should go to the back end, and their actual application to a front-end routine
void ResizeWindowControls( int mode )
{
    HWND hDlg = engineOutputDialog; // [HGM] used to be parameter, but routine is called from back-end
    RECT rc;
    int headerHeight = GetHeaderHeight();
//    int labelHeight = GetControlHeight( hDlg, IDC_EngineLabel1 );
//    int labelOffset = H_MARGIN + ICON_SIZE + H_MARGIN;
//    int labelDeltaY = ICON_SIZE - labelHeight;
    int clientWidth;
    int clientHeight;
    int maxControlWidth;
    int npsWidth;

    /* Initialize variables */
    GetClientRect( hDlg, &rc );

    clientWidth = rc.right - rc.left;
    clientHeight = rc.bottom - rc.top;

    maxControlWidth = clientWidth - 2*H_MARGIN;

    npsWidth = GetControlWidth( hDlg, IDC_Engine1_NPS );

    /* Resize controls */
    if( mode == 0 ) {
        /* One engine */
        PositionControlSet( hDlg, H_MARGIN, V_MARGIN, 
            clientWidth, 
            clientHeight - V_MARGIN - LABEL_V_DISTANCE - headerHeight- V_MARGIN,
            IDC_Color1, IDC_EngineLabel1, IDC_Engine1_NPS, IDC_EngineMemo1, IDC_StateIcon1, IDC_StateData1 );

        /* Hide controls for the second engine */
        HideControl( hDlg, IDC_Color2 );
        HideControl( hDlg, IDC_EngineLabel2 );
        HideControl( hDlg, IDC_StateIcon2 );
        HideControl( hDlg, IDC_StateData2 );
        HideControl( hDlg, IDC_Engine2_NPS );
        HideControl( hDlg, IDC_EngineMemo2 );
        SendDlgItemMessage( hDlg, IDC_EngineMemo2, WM_SETTEXT, 0, (LPARAM) "" );
        /* TODO: we should also hide/disable them!!! what about tab stops?!?! */
    }
    else {
        /* Two engines */
        int memo_h = (clientHeight - headerHeight*2 - V_MARGIN*2 - LABEL_V_DISTANCE*2 - SPLITTER_SIZE) / 2;
        int header1_y = V_MARGIN;
        int header2_y = V_MARGIN + headerHeight + LABEL_V_DISTANCE + memo_h + SPLITTER_SIZE;

        PositionControlSet( hDlg, H_MARGIN, header1_y, clientWidth, memo_h,
            IDC_Color1, IDC_EngineLabel1, IDC_Engine1_NPS, IDC_EngineMemo1, IDC_StateIcon1, IDC_StateData1 );

        PositionControlSet( hDlg, H_MARGIN, header2_y, clientWidth, memo_h,
            IDC_Color2, IDC_EngineLabel2, IDC_Engine2_NPS, IDC_EngineMemo2, IDC_StateIcon2, IDC_StateData2 );
    }

    InvalidateRect( GetDlgItem(hDlg,IDC_EngineMemo1), NULL, FALSE );
    InvalidateRect( GetDlgItem(hDlg,IDC_EngineMemo2), NULL, FALSE );
}
// To reduce flicker, refresh only changed columns (except 
// on Mac, which is double-buffered to eliminate flicker.)
void CBOINCListCtrl::RefreshCell(int row, int col) {
    wxRect r;
    
#if (defined (__WXMSW__) && wxCHECK_VERSION(2,8,0))
    GetSubItemRect(row, col, r);
#else
    int i;
    
    GetItemRect(row, r);
#if ! USE_NATIVE_LISTCONTROL
    r.y = r.y - GetHeaderHeight() - 1;
#endif
    for (i=0; i< col; i++) {
        r.x += GetColumnWidth(i);
    }
    r.width = GetColumnWidth(col);
#endif

    RefreshRect(r);
}
Example #4
0
void MathPrintout::BreakPages()
{
  if (m_tree == NULL)
    return ;

  int pageWidth, pageHeight;
  int marginX, marginY;
  int headerHeight = GetHeaderHeight();
  double scale = GetPPIScale();

  GetPageMargins(&marginX, &marginY);
  GetPageSizePixels(&pageWidth, &pageHeight);

  int currentHeight = marginY;
  int skip = SCALE_PX(MC_GROUP_SKIP, scale);;

  GroupCell* tmp = (GroupCell *)m_tree;
  m_pages.push_back(tmp);

  m_numberOfPages = 1;
  while (tmp != NULL)
  {
    tmp->BreakPage(false);

    if (currentHeight + tmp->GetMaxHeight() + skip >= pageHeight - marginY ||
        tmp->GetGroupType() == GC_TYPE_PAGEBREAK)
    {
      if (tmp->GetGroupType() != GC_TYPE_PAGEBREAK)
        currentHeight = marginY + tmp->GetMaxHeight() + headerHeight;
      tmp->BreakPage(true);
      m_pages.push_back(tmp);
      m_numberOfPages++;
    }
    else
      currentHeight += tmp->GetMaxHeight() + skip;

    tmp = (GroupCell *)tmp->m_next;
  }
}
Example #5
0
bool MathPrintout::OnPrintPage(int num)
{
  double screenScaleX, screenScaleY;
  double ppiScale;
  GroupCell* tmp;
  wxDC* dc = GetDC();

  int marginX, marginY;
  GetPageMargins(&marginX, &marginY);


  ppiScale = GetPPIScale();
  GetScreenScale(&screenScaleX, &screenScaleY);

  marginX += SCALE_PX(MC_BASE_INDENT, ppiScale);

  dc->SetUserScale(screenScaleX, screenScaleY);

  // Go to current page
  tmp = (GroupCell *)m_pages[num - 1];

  // Print page
  if (tmp != NULL)
  {
    if (tmp->GetGroupType() == GC_TYPE_PAGEBREAK)
      tmp = (GroupCell *)tmp->m_next;
    if (tmp == NULL)
      return true;

    wxPoint point;
    point.x = marginX;
    point.y = marginY + tmp->GetMaxCenter() + GetHeaderHeight();
    wxConfigBase* config = wxConfig::Get();
    int fontsize = 12;
    int drop = tmp->GetMaxDrop();

    config->Read(wxT("fontsize"), &fontsize);

    PrintHeader(num, dc, ppiScale);
    CellParser parser(*dc, ppiScale);

    parser.SetIndent(marginX);

    while (tmp != NULL && tmp->GetGroupType() != GC_TYPE_PAGEBREAK)
    {
      tmp->Draw(parser, point, fontsize, false);
      if (tmp->m_next != NULL) {
        point.x = marginX;
        point.y += drop + tmp->m_next->GetMaxCenter();
        point.y += SCALE_PX(MC_GROUP_SKIP, ppiScale);
        drop = tmp->m_next->GetMaxDrop();
      }

      tmp = (GroupCell *)tmp->m_next;
      if (tmp == NULL || tmp->BreakPageHere())
        break;
    }
    return true;
  }
  return false;
}
void CBOINCListCtrl::DrawProgressBars()
{
    long topItem, numItems, numVisibleItems, i, row;
    wxRect r, rr;
    int w = 0, x = 0, xx, yy, ww;
    int progressColumn = m_pParentView->GetProgressColumn();
    
#if USE_NATIVE_LISTCONTROL
    wxClientDC dc(this);
    m_bProgressBarEventPending = false;
#else
    wxClientDC dc(GetMainWin());   // Available only in wxGenericListCtrl
#endif

    if (progressColumn < 0) {
        m_iRowsNeedingProgressBars.Clear();
        return;
    }

    int n = (int)m_iRowsNeedingProgressBars.GetCount();
    if (n <= 0) return;
    
    wxColour progressColor = wxTheColourDatabase->Find(wxT("LIGHT BLUE"));
    wxBrush progressBrush(progressColor);
    
    numItems = GetItemCount();
    if (numItems) {
        topItem = GetTopItem();     // Doesn't work properly for Mac Native control in wxMac-2.8.7

        numVisibleItems = GetCountPerPage();
        ++numVisibleItems;

        if (numItems <= (topItem + numVisibleItems)) numVisibleItems = numItems - topItem;

        x = 0;
        for (i=0; i< progressColumn; i++) {
            x += GetColumnWidth(i);
        }
        w = GetColumnWidth(progressColumn);
        
#if USE_NATIVE_LISTCONTROL
        x -= GetScrollPos(wxHORIZONTAL);
#else
        GetMainWin()->CalcScrolledPosition(x, 0, &x, &yy);
#endif
        wxFont theFont = GetFont();
        dc.SetFont(theFont);
        
        for (int i=0; i<n; ++i) {
            row = m_iRowsNeedingProgressBars[i];
            if (row < topItem) continue;
            if (row > (topItem + numVisibleItems -1)) continue;
        

            GetItemRect(row, r);
#if ! USE_NATIVE_LISTCONTROL
            r.y = r.y - GetHeaderHeight() - 1;
#endif
            r.x = x;
            r.width = w;
            r.Inflate(-1, -2);
            rr = r;

            wxString progressString = m_pParentView->GetProgressText(row);
            dc.GetTextExtent(progressString, &xx, &yy);
            
            r.y += (r.height - yy - 1) / 2;
            
            // Adapted from ellipis code in wxRendererGeneric::DrawHeaderButtonContents()
            if (xx > r.width) {
                int ellipsisWidth;
                dc.GetTextExtent( wxT("..."), &ellipsisWidth, NULL);
                if (ellipsisWidth > r.width) {
                    progressString.Clear();
                    xx = 0;
                } else {
                    do {
                        progressString.Truncate( progressString.length() - 1 );
                        dc.GetTextExtent( progressString, &xx, &yy);
                    } while (xx + ellipsisWidth > r.width && progressString.length() );
                    progressString.append( wxT("...") );
                    xx += ellipsisWidth;
                }
            }
            
            dc.SetLogicalFunction(wxCOPY);
            dc.SetBackgroundMode(wxSOLID);
            dc.SetPen(progressColor);
            dc.SetBrush(progressBrush);
            dc.DrawRectangle( rr );

            rr.Inflate(-2, -1);
            ww = rr.width * m_pParentView->GetProgressValue(row);
            rr.x += ww;
            rr.width -= ww;

#if 0
            // Show background stripes behind progress bars
            wxListItemAttr* attr = m_pParentView->FireOnListGetItemAttr(row);
            wxColour bkgd = attr->GetBackgroundColour();
            dc.SetPen(bkgd);
            dc.SetBrush(bkgd);
#else
            dc.SetPen(*wxWHITE_PEN);
            dc.SetBrush(*wxWHITE_BRUSH);
#endif
            dc.DrawRectangle( rr );

            dc.SetPen(*wxBLACK_PEN);
            dc.SetBackgroundMode(wxTRANSPARENT);
            if (xx > (r.width - 7)) {
                dc.DrawText(progressString, r.x, r.y);
            } else {
                dc.DrawText(progressString, r.x + (w - 8 - xx), r.y);
            }
        }
    }
    m_iRowsNeedingProgressBars.Clear();
}
Example #7
0
// CFileOpenDlg::OnInitDialog
//
//		Initialize the dialog
//
BOOL CFileOpenDlg::OnInitDialog() 
{
	CWinApp*		pApp = AfxGetApp();
	HTREEITEM		hItemRoot;
	HIMAGELIST		hImlSys;
	SHFILEINFO		ssfi;
	CWaitCursor		wait;
	TCHAR			szRoot[]	= _T("\\");

	CExDialog::OnInitDialog();

	//
	// Create the toolbar
	//

	if(!m_wndCommandBar.Create(this) ||
	   !m_wndCommandBar.InsertMenuBar(IDR_MAINFRAME) ||
	   !m_wndCommandBar.AddAdornments() ||
	   !m_wndCommandBar.LoadToolBar(IDR_FILEOPEN))
	{
		TRACE0("Failed to create CommandBar\n");
		return -1;      // fail to create
	}
	


	//m_pCmdBar = (CCommandBar*)m_pWndEmptyCB;
	//m_pCmdBar->LoadToolBar(IDR_FILEOPEN);

	//
	// Position the tree.
	//
	GetClientRect(&m_rcTree);
	m_rcTree.top	= GetHeaderHeight() + 1;
	m_rcTree.bottom	= m_ySplit;
	m_treeFolder.MoveWindow(&m_rcTree);

	//
	// Position the list
	//
	GetClientRect(&m_rcList);
	m_rcList.top	= m_ySplit + nTrackHeight + 1;
	m_listFile.MoveWindow(&m_rcList);

	//
	// Hide the OK button
	//
	ModifyStyle(0, WS_NONAVDONEBUTTON, SWP_NOSIZE); 
	//::SHDoneButton(m_hWnd, SHDB_HIDE);

	//
	// Retrieve the small system image list
	//
	hImlSys = (HIMAGELIST)SHGetFileInfo(_T("dummy.txt"), 0, &ssfi,
				sizeof(SHFILEINFO), 
				SHGFI_USEFILEATTRIBUTES | SHGFI_SYSICONINDEX | SHGFI_SMALLICON);
	
	m_imlSystem.Attach(hImlSys);
	m_listFile.SetImageList(&m_imlSystem, LVSIL_SMALL);
	m_treeFolder.SetImageList(&m_imlSystem, TVSIL_NORMAL);
	m_imlSystem.Detach();

	//
	// Initialize the tree
	//
	hItemRoot = TVI_ROOT;//m_treeFolder.InsertItem(GetSystemName(), 0, 1);
	if(hItemRoot)
	{
		TVINSERTSTRUCT	tvi;
		int				iIcon		= GetIconIndex(szRoot);

		tvi.hParent				= TVI_ROOT;
		tvi.hInsertAfter		= TVI_LAST;
		tvi.item.mask			= TVIF_CHILDREN | TVIF_IMAGE | TVIF_SELECTEDIMAGE |
								  TVIF_TEXT | TVIF_PARAM;
		tvi.item.pszText		= szRoot;
		tvi.item.iImage			= iIcon;
		tvi.item.iSelectedImage	= iIcon;
		tvi.item.cChildren		= I_CHILDRENCALLBACK;
		tvi.item.lParam			= -1;

		m_treeFolder.InsertItem(&tvi);

		//m_treeFolder.SetItemData(hItemRoot, 0);

		//EnumDirs(_T("\\"), _T("*"), hItemRoot);
		//m_treeFolder.Expand(hItemRoot, TVE_EXPAND);
	}

	//
	// Initialize the list
	//
	m_listFile.InsertColumn(0, _T("Name"), LVCFMT_LEFT,  80, -1);
	m_listFile.InsertColumn(1, _T("Size"), LVCFMT_RIGHT, 60,  1);
	m_listFile.InsertColumn(2, _T("Date"), LVCFMT_LEFT,  60,  2);
	EnumFiles(szRoot, m_strFilter);
	
	//
	// Initialize the header imagelist
	//
	if(m_imlHeader.Create(IDB_SORT_ARROWS, 16, 8, RGB(255,0,255)))
	{
		CHeaderCtrl*	pHeader = m_listFile.GetHeaderCtrl();

		if(pHeader)
			pHeader->SetImageList(&m_imlHeader);
	}

	SetColumnIcons();

	//
	// Update toolbar buttons
	//
	UpdateControls();
	
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}
Example #8
0
bool MathPrintout::OnPrintPage(int num)
{
  double screenScaleX, screenScaleY;
  double ppiScale;
  GroupCell* tmp;
  wxDC* dc = GetDC();

  int marginX, marginY;
  GetPageMargins(&marginX, &marginY);

  ppiScale = GetPPIScale();
  GetScreenScale(&screenScaleX, &screenScaleY);

  marginX += SCALE_PX(MC_BASE_INDENT, ppiScale);

  dc->SetUserScale(screenScaleX, screenScaleY);

  // Go to current page
  tmp = (GroupCell *)m_pages[num - 1];

  // Print page
  if (tmp != NULL)
  {
    if (tmp->GetGroupType() == GC_TYPE_PAGEBREAK)
      tmp = (GroupCell *)tmp->m_next;
    if (tmp == NULL)
      return true;

    wxPoint point;
    point.x = marginX;
    point.y = marginY + tmp->GetMaxCenter() + GetHeaderHeight();
    wxConfigBase* config = wxConfig::Get();
    int fontsize = 12;
    int drop = tmp->GetMaxDrop();

    config->Read(wxT("fontsize"), &fontsize);

    PrintHeader(num, dc, ppiScale);
    CellParser parser(*dc, ppiScale);

    parser.SetIndent(marginX);
    // Inform the output routines that we are printing
    parser.SetPrinter(true);
    // Make sure that during print nothing is outside the crop rectangle
    MathCell::ClipToDrawRegion(true);
    
    while (tmp != NULL && tmp->GetGroupType() != GC_TYPE_PAGEBREAK)
    {
      // The following line seems to misteriously fix the "subsequent text
      // cells aren't printed" problem on linux.
      // No Idea why, though.
      dc->SetPen(wxPen(wxT("light grey"), 1, wxPENSTYLE_SOLID));
      tmp->Draw(point, fontsize);
      if (tmp->m_next != NULL) {
        point.x = marginX;
        point.y += drop + tmp->m_next->GetMaxCenter();
        point.y += SCALE_PX(MC_GROUP_SKIP, ppiScale);
        drop = tmp->m_next->GetMaxDrop();
      }

      tmp = (GroupCell *)tmp->m_next;
      if (tmp == NULL || tmp->BreakPageHere())
        break;
    }
    MathCell::ClipToDrawRegion(false);
    return true;
  }
  MathCell::ClipToDrawRegion(false);
  return false;
}