Esempio n. 1
0
LRESULT CFilePreviewCtrl::OnComplete(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
{
    KillTimer(0);
    SetupScrollbars();
    InvalidateRect(NULL);
    return 0;
}
Esempio n. 2
0
void InstanceCtrl::ToggleGroup ( int index )
{
	GroupVisual & gv = m_groups[index];
	gv.SetExpanded(!gv.IsExpanded());
	ReflowAll();
	SetupScrollbars();
	Refresh();
}
Esempio n. 3
0
//-------------------------------------------------------------------//
// OnSize()																				//
//-------------------------------------------------------------------//
void CScrollDialog::OnSize(UINT nType, int cx, int cy) 
{
	inherited::OnSize(nType, cx, cy);
	if (m_bInitialized)
	{
		ResetScrollbars();
		SetupScrollbars();					
    }
}
Esempio n. 4
0
LRESULT CFilePreviewCtrl::OnSize(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
{
    SetupScrollbars();

    InvalidateRect(NULL, FALSE);
    UpdateWindow();

    return 0;
}
Esempio n. 5
0
/// Call Thaw to refresh
void InstanceCtrl::Thaw()
{
	m_freezeCount --;
	
	if (m_freezeCount == 0)
	{
		ReflowAll();
		SetupScrollbars();
		Refresh();
	}
}
Esempio n. 6
0
/// Sizing
void InstanceCtrl::OnSize(wxSizeEvent& event)
{
	int old_rows = GetItemsPerRow();
	int new_rows = CalculateItemsPerRow();
	if (old_rows != new_rows)
	{
		SetItemsPerRow(new_rows);
		ReflowAll();
	}
	SetupScrollbars();
	RecreateBuffer();
	event.Skip();
}
Esempio n. 7
0
void TextView::Smeg(BOOL fAdvancing)
{
	m_pTextDoc->init_linebuffer();

	m_nLineCount   = m_pTextDoc->linecount();

	UpdateMetrics();
	UpdateMarginWidth();
	SetupScrollbars();

	UpdateCaretOffset(m_nCursorOffset, fAdvancing, &m_nCaretPosX, &m_nCurrentLine);
	
	m_nAnchorPosX = m_nCaretPosX;
	ScrollToPosition(m_nCaretPosX, m_nCurrentLine);
	RepositionCaret();
}
Esempio n. 8
0
//
//	Child window procedure
//
LRESULT CALLBACK ChildWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
	static int count;
	char ach[80];

	switch(msg)
	{
	case WM_VSCROLL:

		switch(LOWORD(wParam))
		{
		case SB_LINEUP:		nVScrollPos --;					break;
		case SB_LINEDOWN:	nVScrollPos ++;					break;
		case SB_PAGEUP:		nVScrollPos -= nVScrollPage;	break;
		case SB_PAGEDOWN:	nVScrollPos += nVScrollPage;	break;
		case SB_TOP:		nVScrollPos = 0;				break;
		case SB_BOTTOM:		nVScrollPos = nVScrollMax -1;	break;
		case SB_THUMBTRACK: nVScrollPos = HIWORD(wParam);	break;
		}

		wsprintf(ach, "WM_VSCROLL %d\n", count++);
		OutputDebugString(ach);

		if(nVScrollPos < 0) 
			nVScrollPos = 0;

		if(nVScrollPos > nVScrollMax - nVScrollPage + 1) 
			nVScrollPos = nVScrollMax - nVScrollPage + 1;

		CoolSB_SetScrollPos(hwnd, SB_VERT, nVScrollPos, TRUE);

		return 0;

	case WM_HSCROLL:

		wsprintf(ach, "WM_HSCROLL %d\n", count++);
		OutputDebugString(ach);

		switch(LOWORD(wParam))
		{
		case SB_LINEUP:		nHScrollPos --;					break;
		case SB_LINEDOWN:	nHScrollPos ++;					break;
		case SB_PAGEUP:		nHScrollPos -= nHScrollPage;	break;
		case SB_PAGEDOWN:	nHScrollPos += nHScrollPage;	break;
		case SB_TOP:		nHScrollPos = 0;				break;
		case SB_BOTTOM:		nHScrollPos = nHScrollMax -1;	break;
		case SB_THUMBTRACK: nHScrollPos = HIWORD(wParam);	break;
		}

		if(nHScrollPos < 0) 
			nHScrollPos = 0;

		if(nHScrollPos > nHScrollMax - nHScrollPage + 1) 
			nHScrollPos = nHScrollMax - nHScrollPage + 1;

		CoolSB_SetScrollPos(hwnd, SB_HORZ, nHScrollPos, TRUE);

		return 0;

	case WM_SIZE:
		SetupScrollbars(hwnd);
		return 0;
	}

	return DefWindowProc(hwnd, msg, wParam, lParam);
}
Esempio n. 9
0
void CDocWindow::SetupPageView(bool bSetScrollbars)
{
	#define OUTSIDE_PADDING_X 10
	#define OUTSIDE_PADDING_Y 10

	if (!m_hWnd)
		return;

	if (!m_pClientDC)
		return;

	if (m_PageRect.IsRectEmpty())
		return;
		
	// Suspend any selection tracking
	m_Select.SuspendTracking();

	// Clear the old page from the offscreen DC
	m_pClientDC->Clear();

	// Invalidate the old page rect (m_PageViewRect) before we change it
	InvalidatePage();

	// Now figure out how much window area we have for the document display
	CRect WndRect;
	GetClientRect(&WndRect);
	
	// Subtract the outside padding
	WndRect.bottom -= m_ShadowSize.cx;
	WndRect.right -= m_ShadowSize.cy;
	WndRect.InflateRect(-OUTSIDE_PADDING_X, -OUTSIDE_PADDING_Y);

	// Convert to Document coordinates
	m_pClientDC->GetDeviceMatrix().Inverse().Transform(WndRect);

	int xVisible = WndRect.Width();
	int yVisible = WndRect.Height();

	// Fit the extended page into the available window space
	int dxPage = m_PageRect.Width();
	int dyPage = m_PageRect.Height();
	if (!dxPage) dxPage = 1;
	if (!dyPage) dyPage = 1;
	double fxPageScale = (double)xVisible / dxPage;
	double fyPageScale = (double)yVisible / dyPage;
	double fFitInWindowScale = min(fxPageScale, fyPageScale);
	if (!fFitInWindowScale) fFitInWindowScale = 1.0;

	// Default the scroll position to the center of the current page
	int xPos = -1;
	int yPos = -1;

	// Special setting to indicate a zoom into the center of the SELECTED OBJECT
	if (m_fZoomScale == -1.0 && m_Select.GetSelected())
	{
		CRect DestRect = m_Select.GetSelected()->GetDestRectTransformed();
		int dxObject = DestRect.Width();
		int dyObject = DestRect.Height();
		if (!dxObject) dxObject = 1;
		if (!dyObject) dyObject = 1;
		double fxObjectScale = (double)xVisible / dxObject;
		double fyObjectScale = (double)yVisible / dyObject;
		double fFitScaleObject = min(fxObjectScale, fyObjectScale);
		m_fZoomScale = fFitScaleObject / fFitInWindowScale;
		m_iZoom = dtoi(m_fZoomScale - 1.0);
		
		// Set the (x,y) position to be the center of the object
		xPos = (DestRect.left + DestRect.right) / 2;
		yPos = (DestRect.top + DestRect.bottom) / 2;
	}
	
	// Special setting to indicate a zoom into the width of the FULL PAGE
	if (m_fZoomScale <= 0)
	{
		m_fZoomScale = fxPageScale / fFitInWindowScale;
		m_iZoom = dtoi(m_fZoomScale - 1.0);
	}

	// Compute the scale and adjust the visible area
	double fScale = fFitInWindowScale * m_fZoomScale;
	xVisible = dtoi((double)xVisible / fScale);
	yVisible = dtoi((double)yVisible / fScale);

	// If the (x,y) position was set to the object center, adjust it by 1/2 the visible area
	if (xPos >= 0 || yPos >= 0)
	{
		xPos -= xVisible / 2;
		yPos -= yVisible / 2;
	}

	// Setup the scrollbars
	if (bSetScrollbars)
		SetupScrollbars(xPos, yPos, dxPage, dyPage, xVisible, yVisible, true/*bRedraw*/);

	// Get the updated position
	xPos = GetScrollPos(SB_HORZ);
	yPos = GetScrollPos(SB_VERT);

	// Calculate a view matrix
	int xExcess = xVisible - dxPage; if (xExcess < 0) xExcess = 0;
	int yExcess = yVisible - dyPage; if (yExcess < 0) yExcess = 0;
	CAGMatrix ViewMatrix;
	ViewMatrix.Translate(xExcess/2 - xPos, yExcess/2 - yPos);
	ViewMatrix.Scale(fScale, fScale);
	ViewMatrix.Translate(WndRect.left, WndRect.top);
	m_pClientDC->SetViewingMatrix(ViewMatrix);

	// Compute the new page view rectangle (screen coordinates)
	CSize PageSize(m_PageRect.Width(), m_PageRect.Height());
	m_pClientDC->SetClipToView(PageSize, &m_PageViewRect, true/*bIncludeRawDC*/);

	// Invalidate the new page rect (m_PageViewRect) now that we've changed it
	InvalidatePage();

	// Resume any selection tracking
	m_Select.ResumeTracking();
}
Esempio n. 10
0
//FIXME: doing this for every single change seems like a waste :/
// Also, pure fail :D
void InstanceCtrl::ReloadAll()
{
	// nuke all... lol
	m_groups.Clear();
	
	int totalitems = m_instList->size();
	
	/// sort items into groups
	std::map<InstanceGroup *, InstanceItemArray> sorter;
	for (int i = 0; i < totalitems ; i++)
	{
		auto inst = m_instList->operator[](i);
		InstanceGroup *group =  m_instList->GetInstanceGroup(inst);

		if (sorter.count(group))
		{
			auto & list = sorter[group];
			list.Add(InstanceVisual(inst, i));
		}
		else
		{
			InstanceItemArray arr;
			arr.Add(InstanceVisual(inst, i));
			sorter[group] = arr;
		}
	}
	
	m_itemIndexes.resize(totalitems);

	// sort items in each group
	auto iter = sorter.begin();
	while (iter != sorter.end())
	{
		InstanceGroup* group = (*iter).first;
		
		GroupVisual grpv(group);
		grpv.items = (*iter).second;

		switch (settings->GetInstSortMode())
		{
		case Sort_Name:
			grpv.items.Sort(NameSort);
			break;

		case Sort_LastLaunch:
			grpv.items.Sort(LastLaunchSort);
			break;
		}

		m_groups.Add(grpv);
		iter++;
	}
	
	// sort the groups and construct a mapping from IDs to indexes
	m_groups.Sort(NameSort);
	for(int i = 0; i < m_groups.size(); i++)
	{
		GroupVisual & grp = m_groups[i];
		grp.SetIndex(i);
		for(int j = 0; j < grp.items.size(); j++)
		{
			InstanceVisual & iv = grp.items[j];
			int ID = iv.GetID();
			m_itemIndexes[ID] = VisualCoord(i,j);
		}
	}
	
	int selectedIdx = m_instList->GetSelectedIndex();
	if(selectedIdx == -1)
	{
		if(m_focusItem == m_selectedItem)
			m_focusItem.makeVoid();
		m_selectedItem.makeVoid();
	}
	else
	{
		VisualCoord selectedIndex = m_itemIndexes[selectedIdx];
		if(m_focusItem == m_selectedItem)
			m_focusItem = selectedIndex;
		m_selectedItem = selectedIndex;
	}
	
	// Disable group headers in single column mode. Groups are still there, but their existence is hidden.
	if (GetWindowStyle() & wxINST_SINGLE_COLUMN)
	{
		for (int i = 0; i < m_groups.size(); i++)
		{
			m_groups[i].no_header = true;
			m_groups[i].always_show = true;
		}
	}
	
	// everything got changed (probably not, but we can't know that). Redo all of the layout stuff.
	ReflowAll();
	SetupScrollbars();
	Refresh();
	
	// and reset the intended navigation column
	int row, col;
	GetRowCol(m_selectedItem, row, col);
	m_intended_column = col;
}
Esempio n. 11
0
BOOL CFilePreviewCtrl::SetFile(LPCTSTR szFileName, PreviewMode mode, TextEncoding enc)
{
    // If we are currently processing some file in background,
    // stop the worker thread
    if(m_hWorkerThread!=NULL)
    {
        m_bCancelled = TRUE;
        m_bmp.Cancel();
        WaitForSingleObject(m_hWorkerThread, INFINITE);
        m_hWorkerThread = NULL;
    }

    CAutoLock lock(&m_csLock);

    m_sFileName = szFileName;

    if(mode==PREVIEW_AUTO)
        m_PreviewMode = DetectPreviewMode(m_sFileName);
    else
        m_PreviewMode = mode;

    if(szFileName==NULL)
    {
        m_fm.Destroy();
    }
    else
    {
        if(!m_fm.Init(m_sFileName))
        {
            m_sFileName.Empty();
            return FALSE;
        }
    }

    CRect rcClient;
    GetClientRect(&rcClient);

    HDC hDC = GetDC();
    HFONT hOldFont = (HFONT)SelectObject(hDC, m_hFont);

    LOGFONT lf;
    ZeroMemory(&lf, sizeof(LOGFONT));
    GetObject(m_hFont, sizeof(LOGFONT), &lf);
    m_xChar = lf.lfWidth;
    m_yChar = lf.lfHeight;

    SelectObject(hDC, hOldFont);

    m_nVScrollPos = 0;
    m_nVScrollMax = 0;
    m_nHScrollPos = 0;
    m_nHScrollMax = 0;
    m_aTextLines.clear();
    m_uNumLines = 0;
    m_nMaxDisplayWidth = 0;
    m_bmp.Destroy();

    if(m_PreviewMode==PREVIEW_HEX)
    {
        if(m_fm.GetSize()!=0)
        {
            m_nMaxDisplayWidth =
                8 +				//adress
                2 +				//padding
                m_nBytesPerLine * 3 +	//hex column
                1 +				//padding
                m_nBytesPerLine;	//ascii column
        }

        m_uNumLines = m_fm.GetSize() / m_nBytesPerLine;

        if(m_fm.GetSize() % m_nBytesPerLine)
            m_uNumLines++;
    }
    else if(m_PreviewMode==PREVIEW_TEXT)
    {
        if(enc==ENC_AUTO)
            m_TextEncoding = DetectTextEncoding(m_sFileName, m_nEncSignatureLen);
        else
        {
            m_TextEncoding = enc;
            // Determine the length of the signature.
            int nSignatureLen = 0;
            TextEncoding enc2 = DetectTextEncoding(m_sFileName, nSignatureLen);
            if(enc==enc2)
                m_nEncSignatureLen = nSignatureLen;
        }

        m_bCancelled = FALSE;
        m_hWorkerThread = CreateThread(NULL, 0, WorkerThread, this, 0, NULL);
        ::SetTimer(m_hWnd, 0, 250, NULL);
    }
    else if(m_PreviewMode==PREVIEW_IMAGE)
    {
        m_bCancelled = FALSE;
        m_hWorkerThread = CreateThread(NULL, 0, WorkerThread, this, 0, NULL);
        ::SetTimer(m_hWnd, 0, 250, NULL);
    }

    SetupScrollbars();
    InvalidateRect(NULL, FALSE);
    UpdateWindow();

    return TRUE;
}