Пример #1
0
void CClipMonView::ReDrawBkBuffer()
{
	if (!m_bUseBkBuffer)
	{
		return;
	}
	CSize szView = GetScrollViewSize();
	if (szView.cx == 0 || szView.cy == 0)
	{
		return;
	}
	
	CRect rcClient;
	TxGetClientRect(rcClient);
	CRect rcViewShowBuffer(rcClient);
	rcViewShowBuffer.MoveToXY(0,0);

	rcViewShowBuffer.OffsetRect(GetScrollPos(SB_HORZ), GetScrollPos(SB_VERT));
	
	CRect rcBk(0,0, m_szbmpBackBuffer.cx, m_szbmpBackBuffer.cy);
	rcBk = GetCenterRect(rcViewShowBuffer, rcBk);
	
	if (rcBk.left < 0)
	{
		rcBk.MoveToX(0);
	}
	if (rcBk.top < 0)
	{
		rcBk.MoveToY(0);
	}
	m_rcViewBkBuffer = rcBk;
	m_BkBufferlock.Lock();
	ASSERT(m_pBmpBackBuffer != NULL);
	Graphics gc(m_pBmpBackBuffer);
	SolidBrush bkBrush(m_drawParam.bkColor);
	Rect rCet = CRect2Rect(CRect(0,0, rcBk.Width(),  rcBk.Height()));
	gc.FillRectangle(&bkBrush, rCet);
	CRect rcView(0, 0, szView.cx, szView.cy);
	//calc In Bound Item
	int nBegin = (rcBk.top - rcView.top) / m_drawParam.nItemHeight;
	int nCount = rcBk.Height() /m_drawParam.nItemHeight +1;
	VECTMPITEM vData;
	g_monDataMgr.GetRangeData(nBegin, nCount, vData);
	nCount = vData.size();
	if (nCount == 0)
	{
		return;
	}
	CTxListHeader& headerCtrl = GetListHeader();
	int nTopPos = rcView.top + (nBegin * m_drawParam.nItemHeight)- rcBk.top;
	Gdiplus::StringFormat fmt;
	fmt.SetAlignment(StringAlignmentCenter);
	fmt.SetLineAlignment(StringAlignmentCenter);
	fmt.SetTrimming(StringTrimmingEllipsisCharacter);
	fmt.SetFormatFlags(StringFormatFlagsLineLimit|StringFormatFlagsNoWrap);
	Pen pen(g_globalInfo.viewSetting.clrSeparateLine, 1.0);
	Rect rRowBk(0, nTopPos, rcBk.Width(), m_drawParam.nItemHeight);

	for (int i = 0; i < nCount; i++)
	{
		ARGB clr = 0xff000000;
		ARGB clrBk = 0xffffffff;
		vData[i].GetMonColor(clr, clrBk);
		bkBrush.SetColor(clrBk);
		gc.FillRectangle(&bkBrush, rRowBk);
		int nLeftPos = 0-rcBk.left;
		CRect rcItem(nLeftPos,nTopPos, 0, nTopPos + m_drawParam.nItemHeight);
		for (int cIdx = 0;  cIdx < m_ColSetting.m_vTmpCols.size(); cIdx++)
		{
			if (rcItem.left > rcBk.right)
			{
				break;
			}
			rcItem.right = rcItem.left + headerCtrl.GetHeaderWidth(cIdx);
			if (rcItem.right >= rcBk.left)
			{
				ENUM_MONTYPE nMonType = (ENUM_MONTYPE)(m_ColSetting.m_vTmpCols[cIdx].nPosInType);
				if (nMonType != MONTYPE_TIMEREMAIN)
				{
					CString strText = vData[i].GetValue(nMonType);
					GPDrawShadowTextSimple(gc, strText, rcItem, *m_drawParam.pFont, clr, 0, 2,2, &fmt);
					//GPDrawShadowText(gc, strText, rcItem, *m_drawParam.pFont, clr, 0x22000000,0,0,0,0,&fmt);
				}
				//draw separate line
				gc.DrawLine(&pen, rcItem.right-1, rcItem.top, rcItem.right-1, rcItem.bottom);

			}
			rcItem.OffsetRect(rcItem.Width(), 0);

		}
		gc.DrawLine(&pen, rcBk.left, rcItem.bottom-1, rcBk.right, rcItem.bottom-1);
		nTopPos += m_drawParam.nItemHeight;

		rRowBk.Offset(0, m_drawParam.nItemHeight);
	}

	m_BkBufferlock.Unlock();
}
Пример #2
0
	void CContainerUI::HomeLeft()
	{
		SIZE sz = GetScrollPos();
		sz.cx = 0;
		SetScrollPos(sz);
	}
Пример #3
0
/* WM_VSCROLL message processing */
void window::WMVScroll(HWND &hwnd, UINT &message, WPARAM &wParam, LPARAM &lParam)
{
  int
    k,               /* Counter                 */
    cur_pos,         /* Current scroll position */
    new_pos,         /* New scroll position     */
    num_str_to_end;
    char buf[8];
  VEC2 range;

  GetScrollRange(hwnd, SB_VERT, &range.x, &range.y);
  new_pos = cur_pos = GetScrollPos(hwnd, SB_VERT);
  switch(LOWORD(wParam))
  {
  case SB_LINEUP:
    if (new_pos > 0)
    {
      new_pos = cur_pos - 1;
      txt -= vert_scrlb_step;
    }
    break;
  case SB_LINEDOWN:
    if (new_pos < range.y)
    {
      new_pos = cur_pos + 1;
      txt += vert_scrlb_step;
    }
    break;
  case SB_PAGEUP:
    num_str_to_end = cur_pos * vert_scrlb_step;
    if (num_str_to_end > 0)
    {
      if (num_str_to_end > 2 * client_field.y)
      {
        txt -= client_field.y;
        new_pos -= client_field.y / vert_scrlb_step;
      }
      else
      {
        txt -= num_str_to_end;
        new_pos -= num_str_to_end / vert_scrlb_step;
      }
    }
    break;
  case SB_PAGEDOWN:
    num_str_to_end = (txt.num_of_str - cur_pos * vert_scrlb_step)/1;
    if (num_str_to_end > client_field.y)
    {
      if (num_str_to_end > 2 * client_field.y)
      {
        txt += client_field.y;
        new_pos += client_field.y / vert_scrlb_step;
      }
      else
      {
        txt += abs(client_field.y - num_str_to_end);
        new_pos += abs(client_field.y - num_str_to_end) / vert_scrlb_step;
      }
    }
    break;
  case SB_THUMBTRACK:
    new_pos = HIWORD(wParam);
    if ((k = new_pos - cur_pos) > 0)
      txt += abs(k) * vert_scrlb_step;
    else if (k < 0)
      txt -= abs(k) * vert_scrlb_step;
    break;
  }

  sprintf(buf, "%i %%", (int)(cur_pos * 1.0 / range.y * 100));
  SendMessage(hStatWnd, SB_SETTEXT, (WPARAM)1,(LPARAM)buf);

  if (cur_pos != new_pos)
  {
    SetScrollPos(hwnd, SB_VERT, new_pos, TRUE);
    InvalidateRect(hwnd, NULL, TRUE);
  }

} /* End of 'window::WMVScroll' function */
Пример #4
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();
}
Пример #5
0
	void CContainerUI::HomeUp()
	{
		SIZE sz = GetScrollPos();
		sz.cy = 0;
		SetScrollPos(sz);
	}
Пример #6
0
BOOL CALLBACK PaletteDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
   BOOL  msgProcessed;
   RECT  r;
   HWND  hCtrl;

   msgProcessed = FALSE;
   switch (message) 
   {
      case WM_INITDIALOG:
         GetWindowRect(hDlg, &r);
         r.left = (GetSystemMetrics(SM_CXSCREEN) - (r.right - r.left)) / 2;
         r.top  = (GetSystemMetrics(SM_CYSCREEN) - (r.bottom - r.top)) / 2;
         SetWindowPos(hDlg, NULL, r.left,r.top,0,0, SWP_NOSIZE | SWP_NOZORDER);
      
         hCtrl = GetDlgItem(hDlg, IDC_SC_TRANSLUCENCY);
         SetScrollRange(hCtrl, SB_CTL, 0, pal->getMaxTranslucent(), TRUE);
         SetScrollPos(hCtrl, SB_CTL, pal->getTransLevel(), TRUE);

         hCtrl = GetDlgItem(hDlg, IDC_SC_HAZE);
         SetScrollRange(hCtrl, SB_CTL, 0, pal->getMaxHaze(), TRUE);
         SetScrollPos(hCtrl, SB_CTL, pal->getHazeIndex(), TRUE);
         
         hCtrl = GetDlgItem(hDlg, IDC_SC_SHADE);
         SetScrollRange(hCtrl, SB_CTL, 0, pal->getMaxShade(), TRUE);
         SetScrollPos(hCtrl, SB_CTL, curShadeIndex, TRUE);
         
         msgProcessed = TRUE;
         break;

      case WM_COMMAND:            
         switch(LOWORD(wParam))
         {
                      /*
            case IDCANCEL:
            case IDM_PUSHOK:
               EndDialog(hDlg, wParam);         
               msgProcessed = TRUE;
               
               break;  
                        */
            default:
               break;
         }
      
         break;
      case WM_HSCROLL:
         int shift;
         int newPos;
         
         switch(LOWORD(wParam))
         {
            case SB_PAGELEFT:
            case SB_LINELEFT:
               shift = -1;
               break;
            case SB_PAGERIGHT:
            case SB_LINERIGHT:
               shift = 1;
               break;
            case SB_THUMBTRACK:
            case SB_THUMBPOSITION:
               shift = 0;
               newPos = HIWORD(wParam);
               break;
            default:
               return 1;
         }
         hCtrl = (HWND) LOWORD(lParam);
         long ctrlIdx;
         ctrlIdx = GetWindowLong(hCtrl, GWL_ID);
         
         if(shift)
         {
            int min, max;
            newPos = GetScrollPos(hCtrl, SB_CTL);
            newPos += shift;
            GetScrollRange(hCtrl, SB_CTL, &min, &max);
            if(newPos < min)
               newPos = min;
            else if(newPos > max)
               newPos = max;
         }
         SetScrollPos(hCtrl, SB_CTL, newPos, TRUE);
         
         switch(ctrlIdx)
         {
            case IDC_SC_TRANSLUCENCY:
               hCtrl = GetDlgItem(hDlg, IDC_SC_TRANSLUCENCY);
               pal->setTransLevel(GetScrollPos(hCtrl, SB_CTL));
               break;
            case IDC_SC_HAZE:
               
               break;
            case IDC_SC_SHADE:
               break;
         }
         Redraw();
         return 0;
      case WM_CLOSE:
         DestroyWindow(hDlg);
         paletteWindow = 0;
         break;
   }
   return (msgProcessed);               
}
Пример #7
0
void CBirchCtrl::OnPaint() 
{
	CPaintDC dc(this); // Device context for painting
	
	if (!m_birch)
		return;

	// Double-buffering
	CDC*		pDCMem		= new CDC;
	CBitmap*	pOldBitmap	= NULL;
	CBitmap		bmpCanvas;
	CRect		rFrame;

	GetClientRect( rFrame );

	pDCMem->CreateCompatibleDC( &dc );

	bmpCanvas.CreateCompatibleBitmap( &dc, rFrame.Width(), rFrame.Height() );

	pOldBitmap = pDCMem->SelectObject( &bmpCanvas );

	// START DRAW -------------------------------------------------

	// If there is a bitmap loaded, use it
	// Otherwise, paint the background white
    pDCMem->FillSolidRect( rFrame, GetSysColor(COLOR_WINDOW) );

	UINT	nMode		= pDCMem->SetBkMode( TRANSPARENT );
	CFont*	pOldFont	= pDCMem->SelectObject( &m_Font );

	CPen *pOldPen = pDCMem->GetCurrentPen();

	CPen linesPen(PS_SOLID, 1,  m_crConnectingLines),
		marksPen(PS_SOLID,  1, m_crConnectingLines);

	int iLastNodePos = m_iPadding - GetScrollPos( SB_VERT );
	
	HTREENODE curTreeNode = m_birch->GetTopNode()->pFirstChild ;
	while (curTreeNode)
	{
		iLastNodePos = DrawNodesRecursive(	pDCMem, curTreeNode,
			iLastNodePos+1,
			&linesPen,
			&marksPen,
			rFrame );
		curTreeNode = curTreeNode->pNextSibling;
	}

	pDCMem->SelectObject(pOldPen);
	
	pDCMem->SelectObject( pOldFont );
	pDCMem->SetBkMode( nMode );
	
	// END DRAW   -------------------------------------------------

	dc.BitBlt( 0, 0, rFrame.Width(), rFrame.Height(), pDCMem, 0, 0, SRCCOPY );

	pDCMem->SelectObject( pOldBitmap );

	delete pDCMem;

	iLastNodePos+=GetScrollPos( SB_VERT );

	// Has the total document height changed?
	if( iLastNodePos != m_iDocHeight )
	{
		BOOL bInvalidate = ( ( m_iDocHeight < rFrame.Height() ) != ( iLastNodePos < rFrame.Height() ) );
		
		m_iDocHeight = iLastNodePos;

		ResetScrollBar();

		// If the scrollbar has just been hidden/shown, repaint
		if( bInvalidate )
			Invalidate();
	}
}
Пример #8
0
long CALLBACK EXPORT ConsoleFunc(HWND hwnd,unsigned message,WPARAM wParam,
                                 LPARAM lParam)
{
  CONSOLE *con;
  PAINTSTRUCT ps;
  RECT rect;

  switch (message) {
  case WM_CHAR:
    if ((con=Hwnd2Console(hwnd))!=NULL) {
      /* store in a key queue */
      if ((con->keyq_end+1)%KEYQUEUE_SIZE==con->keyq_start) {
        MessageBeep(MB_OK);
        break;
      } /* if */
      con->keyqueue[con->keyq_end]=(short)wParam;
      con->keyq_end=(con->keyq_end+1)%KEYQUEUE_SIZE;
    } /* if */
    break;

  case WM_CREATE:
    /* The "hwnd" member of the CONSOLE structure has not yet been set, which
     * means that Hwnd2Console() cannot work on the real "hwnd". There should
     * at every instant be only one CONSOLE structure with a NULL handle,
     * however.
     */
    if ((con=Hwnd2Console(NULL))!=NULL) {
      con->hwnd=hwnd;
      SetConsoleFont(con,con->cheight);
      GetWindowRect(hwnd, &rect);
      SetRect(&rect,rect.left,rect.top,
              rect.left+con->cwidth*con->columns,
              rect.top+con->cheight*con->winlines);
      AdjustWindowRect(&rect,GetWindowLong(hwnd,GWL_STYLE),FALSE);
      if (con->winlines<con->lines)
        rect.right+=GetSystemMetrics(SM_CXVSCROLL);
      ClampToScreen(&rect);
      SetWindowPos(hwnd,NULL,rect.left,rect.top,rect.right-rect.left,rect.bottom-rect.top,0);
    } /* if */
    break;

  case WM_DESTROY:
    if ((con=Hwnd2Console(hwnd))!=NULL)
      DoDeleteConsole(con);
    /* if there are no consoles left, abort the program */
    if (consoleroot.next==NULL) {
      #if defined __WIN32__ || defined _WIN32 || defined WIN32
        ExitProcess(0);
      #else
        exit(0);
      #endif
    } /* if */
    break;

  case WM_GETMINMAXINFO:
    if ((con=Hwnd2Console(hwnd))!=NULL) {
      MINMAXINFO FAR *lpmmi=(MINMAXINFO FAR*)lParam;
      int rx,ry,hsize,vsize;
      GetClientRect(hwnd,&rect);
      rx= (rect.right < con->columns*con->cwidth) ? con->columns*con->cwidth-rect.right : 0;
      ry= (rect.bottom < con->lines*con->cheight) ? con->lines*con->cheight-rect.bottom : 0;
      hsize= (ry>0) ? GetSystemMetrics(SM_CXVSCROLL) : 0;
      vsize= (rx>0) ? GetSystemMetrics(SM_CYHSCROLL) : 0;
      SetRect(&rect,0,0,con->cwidth*con->columns+hsize,con->cheight*con->lines+vsize);
      AdjustWindowRect(&rect,GetWindowLong(hwnd,GWL_STYLE),FALSE);
      lpmmi->ptMaxTrackSize.x=rect.right-rect.left;
      lpmmi->ptMaxTrackSize.y=rect.bottom-rect.top;
      lpmmi->ptMaxSize=lpmmi->ptMaxTrackSize;
    } /* if */
    break;

  case WM_SYSKEYDOWN:
  case WM_KEYDOWN:
    if ((con=Hwnd2Console(hwnd))!=NULL) {
      TCHAR str[20];
      int i;
      str[0]=__T('\0');
      switch (LOWORD(wParam)) {
      case VK_F1:
      case VK_F2:
      case VK_F3:
      case VK_F4:
      case VK_F5:
      case VK_F6:
      case VK_F7:
      case VK_F8:
      case VK_F9:
      case VK_F10:
      case VK_F11:
      case VK_F12:
        if (LOWORD(wParam)<=VK_F5)
          _stprintf(str,__T("\033[%d~\n"),LOWORD(wParam)-VK_F1+11);
        else if (LOWORD(wParam)==VK_F10)
          _stprintf(str,__T("\033[%d~\n"),LOWORD(wParam)-VK_F6+17);
        else
          _stprintf(str,__T("\033[%d~\n"),LOWORD(wParam)-VK_F11+23);
        break;
      case VK_ADD:
      case VK_SUBTRACT:
        /* check Ctrl key */
        if ((GetKeyState(VK_CONTROL) & 0x8000)!=0) {
          POINT pt;
          int newheight=con->cheight;
          int oldheight=newheight;
          int incr= (LOWORD(wParam)==VK_SUBTRACT) ? -1 : 1;
          do {
            newheight+=incr;
            /* make a new font, re-create a caret and redraw everything */
            SetConsoleFont(con,newheight);
          } while (newheight>5 && (oldheight==con->cheight || con->hfont==NULL));
          if (con->hfont==NULL) /* reset to original on failure */
            SetConsoleFont(con,oldheight);
          GetClientRect(hwnd,&rect);
          DestroyCaret();
          CreateCaret(hwnd,NULL,con->cwidth,2);
          RefreshCaretPos(con);
          /* redraw the window */
          InvalidateRect(hwnd,NULL,TRUE);
          /* resize the window */
          SetRect(&rect,0,0,con->cwidth*con->columns,con->cheight*con->winlines);
          AdjustWindowRect(&rect,GetWindowLong(hwnd,GWL_STYLE),FALSE);
          pt.x=pt.y=0;
          ClientToScreen(hwnd,&pt);
          OffsetRect(&rect,pt.x,pt.y);
          ClampToScreen(&rect);
          SetWindowPos(hwnd,NULL,rect.left,rect.top,rect.right-rect.left,rect.bottom-rect.top,
                       SWP_NOZORDER);
        } /* if */
        break;
      case VK_UP:
        _tcscpy(str,__T("\033[A"));
        break;
      case VK_DOWN:
        _tcscpy(str,__T("\033[B"));
        break;
      case VK_RIGHT:
        _tcscpy(str,__T("\033[C"));
        break;
      case VK_LEFT:
        _tcscpy(str,__T("\033[D"));
        break;
      case VK_HOME:
        _tcscpy(str,__T("\033[1~"));
        break;
      case VK_END:
        _tcscpy(str,__T("\033[4~"));
        break;
      case VK_INSERT:
        _tcscpy(str,__T("\033[2~"));
        break;
      case VK_DELETE:
        _tcscpy(str,__T("\033[3~"));
        break;
      case VK_PRIOR:  /* PageUp */
        _tcscpy(str,__T("\033[5~"));
        break;
      case VK_NEXT:   /* PageDown */
        _tcscpy(str,__T("\033[6~"));
        break;
      default:
        return DefWindowProc(hwnd,message,wParam,lParam);
      } /* switch */
      for (i=0; str[i]!=__T('\0'); i++) {
        if ((con->keyq_end+1)%KEYQUEUE_SIZE!=con->keyq_start) {
          con->keyqueue[con->keyq_end]=(short)str[i];
          con->keyq_end=(con->keyq_end+1)%KEYQUEUE_SIZE;
        } /* if */
      } /* for */
    } /* if */
    break;

  case WM_KILLFOCUS:
    HideCaret(hwnd);
    DestroyCaret();
    break;
  case WM_SETFOCUS:
    if ((con=Hwnd2Console(hwnd))!=NULL) {
      CreateCaret(hwnd,NULL,con->cwidth,2);
      RefreshCaretPos(con);
      ShowCaret(hwnd);
    } /* if */
    break;

  case WM_LBUTTONDOWN:
    SetFocus(hwnd);
    break;

  case WM_PAINT:
    HideCaret(hwnd);
    BeginPaint(hwnd, &ps);
    if ((con=Hwnd2Console(hwnd))!=NULL && con->buffer!=NULL) {
      TCHAR *string;
      string=malloc(con->columns*sizeof(TCHAR));
      if (string!=NULL) {
        int l,c,bpos,start;
        TCHAR attr;
        HFONT hfontOrg;
        int scrollx=GetScrollPos(hwnd,SB_HORZ);
        int scrolly=GetScrollPos(hwnd,SB_VERT);
        GetClientRect(hwnd,&rect);
        hfontOrg=SelectObject(ps.hdc,con->hfont);
        SetBkMode(ps.hdc,OPAQUE);
        for (l=0; l<con->lines; l++) {
          bpos=l*con->columns*2;
          c=0;
          while (c<con->columns) {
            /* find stretches with the same attribute */
            attr=con->buffer[bpos+1];
            start=c;
            while (c<con->columns && con->buffer[bpos+1]==attr) {
              assert(c-start>=0);
              assert(c-start<con->columns);
              string[c-start]=con->buffer[bpos];
              c++;
              bpos+=2;
            } /* if */
            SetTextAttribute(ps.hdc,attr);
            TextOut(ps.hdc,start*con->cwidth-scrollx,l*con->cheight-scrolly,string,c-start);
          } /* while */
        } /* for */
        SelectObject(ps.hdc,hfontOrg);
        free(string);
      } /* if */
    } /* if */
    EndPaint(hwnd, &ps);
    ShowCaret(hwnd);
    break;

  case WM_SIZE:
    if ((con=Hwnd2Console(hwnd))!=NULL) {
      int rx,ry;
      /* add/remove/recalculate scroll bars */
      GetClientRect(hwnd,&rect);
      rx= (rect.right < con->columns*con->cwidth) ? con->columns*con->cwidth-rect.right : 0;
      ry= (rect.bottom < con->lines*con->cheight) ? con->lines*con->cheight-rect.bottom : 0;
      /* adjust scrolling position, if necessary */
      if (GetScrollPos(hwnd,SB_HORZ)>=rx) {
        SetScrollPos(hwnd,SB_HORZ,rx,FALSE);
        InvalidateRect(hwnd,NULL,FALSE);
      } /* if */
      if (GetScrollPos(hwnd,SB_VERT)>=ry) {
        SetScrollPos(hwnd,SB_VERT,ry,FALSE);
        InvalidateRect(hwnd,NULL,FALSE);
      } /* if */
      SetScrollRange(hwnd,SB_HORZ,0,rx,TRUE);
      SetScrollRange(hwnd,SB_VERT,0,ry,TRUE);
    } /* if */
    break;

  case WM_HSCROLL:
    if ((con=Hwnd2Console(hwnd))!=NULL) {
      int scrollx=GetScrollPos(hwnd,SB_HORZ);
      int oldpos=scrollx;
      int min,max;
      GetScrollRange(hwnd,SB_HORZ,&min,&max);
      switch (LOWORD(wParam)) {
      case SB_TOP:
        scrollx=min;
        break;
      case SB_BOTTOM:
        scrollx=max;
        break;
      case SB_LINELEFT:
        scrollx=(scrollx>min) ? scrollx-1 : min;
        break;
      case SB_LINERIGHT:
        scrollx=(scrollx<max) ? scrollx+1 : max;
        break;
      case SB_PAGELEFT:
        scrollx=(scrollx>min) ? scrollx-50 : min;
        break;
      case SB_PAGERIGHT:
        scrollx=(scrollx<max) ? scrollx+50 : max;
        break;
      case SB_THUMBTRACK:
        scrollx=(int)HIWORD(wParam);
        break;
      } /* switch */
      if (oldpos!=scrollx) {
        SetScrollPos(hwnd,SB_HORZ,scrollx,TRUE);
        InvalidateRect(hwnd,NULL,FALSE);
        RefreshCaretPos(con);
      } /* if */
    } /* if */
    break;
  case WM_VSCROLL:
    if ((con=Hwnd2Console(hwnd))!=NULL) {
      int scrolly=GetScrollPos(hwnd,SB_VERT);
      int oldpos=scrolly;
      int min,max;
      GetScrollRange(hwnd,SB_VERT,&min,&max);
      switch (LOWORD(wParam)) {
      case SB_TOP:
        scrolly=min;
        break;
      case SB_BOTTOM:
        scrolly=max;
        break;
      case SB_LINELEFT:
        scrolly=(scrolly>min) ? scrolly-1 : min;
        break;
      case SB_LINERIGHT:
        scrolly=(scrolly<max) ? scrolly+1 : max;
        break;
      case SB_PAGELEFT:
        scrolly=(scrolly>min) ? scrolly-50 : min;
        break;
      case SB_PAGERIGHT:
        scrolly=(scrolly<max) ? scrolly+50 : max;
        break;
      case SB_THUMBTRACK:
        scrolly=(int)HIWORD(wParam);
        break;
      } /* switch */
      if (oldpos!=scrolly) {
        SetScrollPos(hwnd,SB_VERT,scrolly,TRUE);
        InvalidateRect(hwnd,NULL,FALSE);
        RefreshCaretPos(con);
      } /* if */
    } /* if */
    break;

  default:
    return DefWindowProc(hwnd,message,wParam,lParam);
  } /* switch */
  return 0L;
}
Пример #9
0
void CStartupView::RepositionButtons()
{
   int x;
   int y;
   int width;
   int height;

   Gdiplus::Rect gdipRcLogoRegion;
   Gdiplus::Rect gdipRcButtonRegion;
   Gdiplus::Rect gdipRcBottomRegion;
   CalculateRegions(gdipRcLogoRegion, gdipRcButtonRegion, gdipRcBottomRegion);

   width = BUTTON_WIDTH;
   height = BUTTON_HEIGHT1;


   // Close button
   CRect rcButton;
   rcButton.SetRect(gdipRcLogoRegion.Width - 19 , 
      OFFSET_Y, 
      gdipRcLogoRegion.Width - 7 , 
      13 + OFFSET_Y );
   m_btnClose.SetWindowPos(NULL, rcButton.left- GetScrollPos(SB_HORZ), rcButton.top- GetScrollPos(SB_VERT), 
      rcButton.Width(), rcButton.Height(), SWP_NOZORDER);
   m_btnClose.SetTextAndImagePos(CPoint(1,1), CPoint(16, 16));

   // Other buttons

   // Left buttons
   Gdiplus::Rect gdipRcLeftButtons;
   CalculateLeftButtonsRegion(gdipRcLeftButtons);

   x = gdipRcLeftButtons.X;

   y = gdipRcLeftButtons.Y + BUTTON_TITLE_HEIGHT + BUTTON_SUBTITLE_HEIGHT + BUTTON_TOP_SPACE ;
   m_btnRecordPowerPoint.SetWindowPos(NULL, x- GetScrollPos(SB_HORZ), y- GetScrollPos(SB_VERT), width, height, SWP_NOZORDER);
   m_btnRecordPowerPoint.SetTextAndImagePos(CPoint(ICON_X_POS - 1, ICON_Y_POS + 1), CPoint(TEXT_X_POS + 8, TEXT_Y_POS + 7));
 
   y += BUTTON_HEIGHT1+10 ;

   m_btnRecordOther.SetWindowPos(NULL, x- GetScrollPos(SB_HORZ), y- GetScrollPos(SB_VERT), width, height, SWP_NOZORDER);
   m_btnRecordOther.SetTextAndImagePos(CPoint(ICON_X_POS - 1, ICON_Y_POS + 1), CPoint(TEXT_X_POS + 8, TEXT_Y_POS + 7));
   y += BUTTON_HEIGHT1+10 ;

   //y += SEPARATOR_HEIGHT;

   y += BUTTON_HEIGHT1+3 ;//+ BUTTON_TITLE_HEIGHT;

   m_btnNewSourceDoc.SetWindowPos(NULL, x- GetScrollPos(SB_HORZ), y - GetScrollPos(SB_VERT), width, height, SWP_NOZORDER);
   m_btnNewSourceDoc.SetTextAndImagePos(CPoint(ICON_X_POS - 1, ICON_Y_POS + 1), CPoint(TEXT_X_POS + 10, TEXT_Y_POS + 7));
   y += BUTTON_HEIGHT1+10;

   

   m_btnImportPowerPoint.SetWindowPos(NULL, x - GetScrollPos(SB_HORZ), y- GetScrollPos(SB_VERT), width, height, SWP_NOZORDER);
   m_btnImportPowerPoint.SetTextAndImagePos(CPoint(ICON_X_POS - 1, ICON_Y_POS + 1), CPoint(TEXT_X_POS + 10, TEXT_Y_POS + 7));

   // Right buttons
   Gdiplus::Rect gdipRcRightButtons;
   CalculateRightButtonsRegion(gdipRcRightButtons);

   

   x = gdipRcRightButtons.X ;
   y = gdipRcRightButtons.Y + 2 * BUTTON_TITLE_HEIGHT + BUTTON_HEIGHT ;
   //height = BUTTON_HEIGHT;
   m_btnOpenSourceDoc.SetWindowPos(NULL, x- GetScrollPos(SB_HORZ), y- GetScrollPos(SB_VERT), width, height, SWP_NOZORDER);
   m_btnOpenSourceDoc.SetTextAndImagePos(CPoint(ICON_X_POS - 1, ICON_Y_POS - 1), CPoint(TEXT_X_POS + 10, TEXT_Y_POS + 7));
   
   y += 3*BUTTON_HEIGHT+3;
   /*for (int i = 0; i < m_arBtnRecentFiles.GetSize(); ++i)
   {
      y = gdipRcRightButtons.Y + BUTTON_TITLE_HEIGHT + i*(BUTTON_HEIGHT+5);
      m_arBtnRecentFiles[i]->SetWindowPos(NULL, x, y, width, height, SWP_NOZORDER);
      m_arBtnRecentFiles[i]->SetTextAndImagePos(CPoint(ICON_X_POS, ICON_Y_POS), CPoint(TEXT_X_POS, TEXT_Y_POS));
   }*/

   CSize siTotal = GetTotalSize();
   CRect rcClient(0, 0, siTotal.cx, siTotal.cy);  
   //Button Tutorial
   x = rcClient.left + 40 ;//gdipRcBottomRegion.X + 40;
   y = rcClient.bottom - FOOT_HEIGHT - LIGHT_BLUE_HEIGHT ;/*gdipRcBottomRegion.Y + 
      (gdipRcBottomRegion.Height - rcBtnShowAgain.Height()) / 2.0;*/
   m_btnTutorial.SetWindowPos(NULL, x- GetScrollPos(SB_HORZ), y- GetScrollPos(SB_VERT), BUTTON_WIDTH1, BUTTON_HEIGHT1, SWP_NOZORDER);
   m_btnTutorial.SetTextAndImagePos(CPoint(ICON_X_POS - 1, ICON_Y_POS + 1), CPoint(TEXT_X_POS + 10, TEXT_Y_POS + 9));

   //Button Guided Tour
   x = (rcClient.left + rcClient.Width() - BUTTON_WIDTH1) / 2;//gdipRcBottomRegion.X + 40;
   y = rcClient.bottom - FOOT_HEIGHT - LIGHT_BLUE_HEIGHT ;/*gdipRcBottomRegion.Y + 
      (gdipRcBottomRegion.Height - rcBtnShowAgain.Height()) / 2.0;*/
   m_btnGuidedTour.SetWindowPos(NULL, x - GetScrollPos(SB_HORZ), y- GetScrollPos(SB_VERT), BUTTON_WIDTH1, BUTTON_HEIGHT1, SWP_NOZORDER);
   m_btnGuidedTour.SetTextAndImagePos(CPoint(ICON_X_POS - 1, ICON_Y_POS + 1), CPoint(TEXT_X_POS + 10, TEXT_Y_POS + 9));

   //Button Community
   x = rcClient.right - 40 - 13 - BUTTON_WIDTH1;//gdipRcBottomRegion.X + 40;
   y = rcClient.bottom - FOOT_HEIGHT - LIGHT_BLUE_HEIGHT ;/*gdipRcBottomRegion.Y + 
      (gdipRcBottomRegion.Height - rcBtnShowAgain.Height()) / 2.0;*/
   m_btnCommunity.SetWindowPos(NULL, x- GetScrollPos(SB_HORZ), y- GetScrollPos(SB_VERT), BUTTON_WIDTH1, BUTTON_HEIGHT1, SWP_NOZORDER);
   m_btnCommunity.SetTextAndImagePos(CPoint(ICON_X_POS - 1, ICON_Y_POS + 1), CPoint(TEXT_X_POS + 10, TEXT_Y_POS + 9));
  
   if (m_btnBuyNow.m_hWnd != NULL) {
       // //Button Buy Now
       x = rcClient.left + m_pLecturnityLogo->GetWidth() + 10 ;//gdipRcBottomRegion.X + 40;
       y = rcClient.top + OFFSET_Y + 4 ;/*gdipRcBottomRegion.Y + 
                                        (gdipRcBottomRegion.Height - rcBtnShowAgain.Height()) / 2.0;*/
       m_btnBuyNow.SetWindowPos(NULL, x- GetScrollPos(SB_HORZ), y- GetScrollPos(SB_VERT), 120, 56, SWP_NOZORDER);
       m_btnBuyNow.SetTextAndImagePos(CPoint( 1, 1), CPoint(56, TEXT_Y_POS + 17));
   }
   
   // Place checkbox 40 pixel from right border (horizontally)
   // in the middle of the bottom region (vertically)
   CRect rcBtnShowAgain;
   m_btnShowAgain.GetClientRect(rcBtnShowAgain);
   
   
   //CRect rcClient(0, 0, siTotal.cx, siTotal.cy);   
   x = rcClient.left + 40 ;//gdipRcBottomRegion.X + 40;
   y = rcClient.bottom - FOOT_HEIGHT;/*gdipRcBottomRegion.Y + 
      (gdipRcBottomRegion.Height - rcBtnShowAgain.Height()) / 2.0;*/
   m_btnShowAgain.SetWindowPos(NULL, x- GetScrollPos(SB_HORZ), y - GetScrollPos(SB_VERT), 250, BUTTON_HEIGHT, SWP_NOZORDER);
   m_btnShowAgain.SetTextAlignment(SS_LEFT);
}
Пример #10
0
void CAnsiWnd::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar) 
{
    int Pos = GetScrollPos(SB_VERT);
    CRect rect;
    switch ( nSBCode ) {
    case SB_LINEUP:
        if ( Pos ) {
            Pos --;
            SetScrollPos(SB_VERT, Pos, TRUE);
			InvalidateRect(NULL, FALSE );
			UpdateWindow();
			/*
            CDC* pDC = GetDC();
            GetClientRect(&rect);
            pDC->ScrollDC(0 ,pDoc->m_nYsize, rect , NULL , NULL , NULL );

            pDC->SetBkMode(OPAQUE);
            pOldFont = pDC->SelectObject(&pDoc->m_fntText);

            pDC->SelectObject(&pDoc->m_fntText);
            RedrawOneLine(pDC , Pos);
            RedrawOneLine(pDC , Pos+1);
            pDC->SelectObject(pOldFont);
            ReleaseDC(pDC);
			*/
        }
        break;
    case SB_LINEDOWN:
        if ( Pos < nScrollSize -1-m_nPageSize ) {
            Pos ++;
            SetScrollPos(SB_VERT, Pos, TRUE);
			InvalidateRect(NULL, FALSE );
			UpdateWindow();
			/*
            CDC* pDC = GetDC();
            GetClientRect(&rect);
            pDC->ScrollDC(0 ,-pDoc->m_nYsize, rect , NULL , NULL , NULL );

            pDC->SetBkMode(OPAQUE);
            pOldFont = pDC->SelectObject(&pDoc->m_fntText);

            pDC->SelectObject(&pDoc->m_fntText);

            RedrawOneLine(pDC , Pos+m_nPageSize);
            pDC->SelectObject(pOldFont);
            ReleaseDC(pDC);
			*/
        }
        break;
    case SB_PAGEDOWN:
        if ( Pos < nScrollSize -1-m_nPageSize ) {
            Pos += m_nPageSize;
            if ( Pos > nScrollSize -1-m_nPageSize ) 
                Pos = nScrollSize -1-m_nPageSize;
            SetScrollPos(SB_VERT, Pos, TRUE);
            InvalidateRect(NULL, FALSE );
            UpdateWindow();
        }
        break;
    case SB_PAGEUP:
        if ( Pos ) {
            Pos -= m_nPageSize;
            if ( Pos < 0 ) 
                Pos = 0;
            SetScrollPos(SB_VERT, Pos, TRUE);
            InvalidateRect(NULL, FALSE );
            UpdateWindow();
        }
        break;
    case SB_THUMBPOSITION:
        SetScrollPos(SB_VERT, nPos, TRUE);
        InvalidateRect(NULL, FALSE );
        UpdateWindow();
        break;
    case SB_THUMBTRACK:
        SetScrollPos(SB_VERT, nPos, TRUE);
        InvalidateRect(NULL, FALSE );
        UpdateWindow();
        break;
    default :
        break;
    };
}
Пример #11
0
void CAnsiWnd::OnLButtonUp(UINT nFlags, CPoint point) 
{
    if ( m_bSelected ) {
        ReleaseCapture();
        m_bSelected = FALSE;
        InvalidateRect(NULL, FALSE);
        UpdateWindow();
        pDoc->m_bFrozen = FALSE;

        // Well, start forming text for Clipboard
        CString ResultStr;

        // Good, getting reall numbers of strings
        int ScrollIndex = GetScrollPos(SB_VERT)+1;
        m_nStartSelectY = max(0, m_nStartSelectY);
        POSITION pos = m_strList.FindIndex(ScrollIndex+m_nStartSelectY);
        ASSERT(pos);
        int i = m_nStartSelectY;
        do { 
            CString tmpStr = m_strList.GetAt(pos);
            const wchar_t* ptr = tmpStr;
            int count = 0;
            if (pDoc->m_bRectangleSelection || i == m_nStartSelectY) {
                // Skip to StartX character
                while ( count < m_nStartSelectX && *ptr){
                    if ( *ptr == L'\x1B' ){
                        ptr = SkipAnsi(ptr);
                    }
                    else {
                        count++;
                        ptr++;
                    }
                } 
                
            }
            // characters skipped now copy nessesary info to string
            do {
                if ( *ptr == L'\n' ) {
                    ptr++;
                    continue;
                }
                if ( *ptr == L'\x1B' ) {
                    ptr = SkipAnsi(ptr);
                    continue;
                } //* en: do not even try
				if ( !(*ptr))
					break;
                if ( count > m_nEndSelectX && (pDoc->m_bRectangleSelection || i == m_nEndSelectY)) 
                    break;
                ResultStr+= *ptr++;
                count++;
            } while ( *ptr );
            if ( i != m_nEndSelectY ) 
                ResultStr +=L"\r\n";
            i++;
            pos = m_strList.FindIndex(ScrollIndex+i);
        } while ( i<=m_nEndSelectY && pos );
        // Put to clipboard
		if (wcslen(ResultStr) != 0)
		{
			VERIFY(OpenClipboard());

			VERIFY(EmptyClipboard());

			HANDLE hData;

			hData = GlobalAlloc(GMEM_ZEROINIT, (ResultStr.GetLength()+1)*sizeof(wchar_t) );
			wchar_t* buff = (wchar_t*)GlobalLock(hData);
			wcscpy (buff, ResultStr);
			GlobalUnlock(hData);
			SetClipboardData(CF_UNICODETEXT, hData);
			CloseClipboard();
		}
    }
	CWnd::OnLButtonUp(nFlags, point);
}
Пример #12
0
LRESULT W_CALLBACK SliderWndProc(HWND hWnd, UINT msg, 
				 WPARAM wParam, LPARAM lParam)
{
    HWND hSBWnd;
    LONG lResult;
    ITEMID idWidget, idVertical, idMin = NULLID, idMax = NULLID;
    ITEMID idDesc, idVisible;
    double fMinV, fMaxV, fValue;
    RECT rCrect;
    double dSliderPos;
    BOOL bCommand = TRUE;
    short nTextHgt, nTitleHgt, nSlideHgt, nSlideLeft;

    switch (msg) {
      case WM_SETFOCUS:
          hSBWnd = GetDlgItem(hWnd, HSLIDERID);
          if (!hSBWnd)
              hSBWnd = GetDlgItem(hWnd, VSLIDERID);
          if (hSBWnd)
              SetFocus(hSBWnd);
          break;

      case WM_HSCROLL:
          hSBWnd = GetDlgItem(hWnd, HSLIDERID);
		  SetFocus(hSBWnd);
          idWidget = KpsGetWidgetFromWindow(hWnd);

          if (hSBWnd)
              dSliderPos = (double) GetScrollPos(hSBWnd, SB_CTL);

          switch (wParam) {
            case SB_LINEUP:
                break;

            case SB_LINEDOWN:
                break;

            case SB_PAGEUP:
                dSliderPos -= 1000;
                break;

            case SB_PAGEDOWN:
                dSliderPos += 1000;
                break;

            case SB_THUMBTRACK:
            case SB_THUMBPOSITION:
                dSliderPos = LOWORD(lParam);
                break;

            default:
                bCommand = FALSE;
                break;
          }
          if (bCommand)
          {
              if (dSliderPos > 10000.0)
                  dSliderPos = 10000.0;
              if (dSliderPos < 0.0)
                  dSliderPos = 0.0;

              GetSliderValue(idWidget, hWnd, wParam, dSliderPos);
          }
          break;
      case WM_VSCROLL:
          hSBWnd = GetDlgItem(hWnd, VSLIDERID);
		  SetFocus(hSBWnd);
          idWidget = KpsGetWidgetFromWindow(hWnd);

          if (hSBWnd)
              dSliderPos = (double) GetScrollPos(hSBWnd, SB_CTL);

          switch (wParam){
            case SB_LINEUP:
                break;
            case SB_LINEDOWN:
                break;
            case SB_PAGEUP:
                dSliderPos -= 1000;
                break;
            case SB_PAGEDOWN:
                dSliderPos += 1000;
                break;
            case SB_THUMBTRACK:
            case SB_THUMBPOSITION:
                dSliderPos = (short) LOWORD(lParam);
                break;

            default:
                bCommand = FALSE;
                break;
          }
          if (bCommand)
          {
              if (dSliderPos < -10000.0)
                  dSliderPos = -10000.0;
              if (dSliderPos > 0.0)
                  dSliderPos = 0.0;

              GetSliderValue(idWidget, hWnd, wParam, dSliderPos);
          }
          break;

      case IDG_RESET:
          idWidget = KpsGetWidgetFromWindow(hWnd);
          idVisible = KppGetSlotValue(idWidget, lpSNs->idVisibleSN);
          if (idVisible != lpIDs->idFalse)
          {
              GetClientRect(hWnd, (LPRECT) & rCrect);
              nSlideLeft = (rCrect.right / 2) - (SLIDERPAD / 2);
              GetSliderParam(hWnd, &nTitleHgt, &nTextHgt, &nSlideHgt);
              idVertical = KppGetSlotValue(idWidget, lpSNs->idVerticalSN);

              if (RetrieveSliderData(idWidget, &idMin, &idMax,
                                     (ITEMID *) NULL,
                                     &fMinV, &fMaxV, &fValue, &idDesc))
              {
                  if (idVertical == lpIDs->idTrue)
                  {
                      hSBWnd = GetDlgItem(hWnd, HSLIDERID);
                      if (hSBWnd)
                          DestroyWindow(hSBWnd);

                      hSBWnd = GetDlgItem(hWnd, VSLIDERID);
                      if (!hSBWnd)
                      {
                          hSBWnd = CreateWindow((LPSTR) "Scrollbar",
                                                (LPSTR) NULL,
                                                WS_CHILD | WS_CLIPSIBLINGS |
                                                SBS_VERT,
                                                nSlideLeft,
                                                nTitleHgt + (2 * HEIGHTPAD),
                                                SLIDERPAD, nSlideHgt,
                                                hWnd, VSLIDERID,
                                                hInstThisDll, (LPSTR) NULL);
                          SetScrollRange(hSBWnd, SB_CTL, -10000, 0, TRUE);
                          SetScrollPos(hSBWnd, SB_CTL, 0, TRUE);
                          ShowWindow(hSBWnd, SW_HIDE);
						  SetProp(hSBWnd, HORIZONTAL, FALSE); 

                          if (!lpOrigSliderProc)
                              lpOrigSliderProc =
                                  (FARPROC) GetClassLong(hSBWnd, GCL_WNDPROC);

                          SetWindowLong(hSBWnd, GWL_WNDPROC,
                                        (LONG) NewSliderProc);
                      }
                      else
                          MoveWindow(hSBWnd, nSlideLeft,
                                     nTitleHgt + (2 * HEIGHTPAD),
                                     SLIDERPAD, nSlideHgt, TRUE);
                  }
                  else
                  {
                      hSBWnd = GetDlgItem(hWnd, VSLIDERID);
                      if (hSBWnd)
                          DestroyWindow(hSBWnd);

                      hSBWnd = GetDlgItem(hWnd, HSLIDERID);
                      if (!hSBWnd)
                      {
                          hSBWnd = CreateWindow((LPSTR) "Scrollbar",
                                                (LPSTR) NULL,
                                                WS_CHILD | WS_CLIPSIBLINGS |
                                                SBS_HORZ,
                                                SLIDERPAD,
                                                nTitleHgt + (2 * HEIGHTPAD),
                                                rCrect.right - (2 * SLIDERPAD),
                                                nSlideHgt,
                                                hWnd, HSLIDERID,
                                                hInstThisDll, (LPSTR) NULL);
                          SetScrollRange(hSBWnd, SB_CTL, 0, 10000, TRUE);
                          ShowWindow(hSBWnd, SW_HIDE);
						  SetProp(hSBWnd, HORIZONTAL, TRUE); 

                          if (!lpOrigSliderProc)
                              lpOrigSliderProc =
                                  (FARPROC) GetClassLong(hSBWnd, GCL_WNDPROC);

                          SetWindowLong(hSBWnd, GWL_WNDPROC,
                                        (LONG) NewSliderProc);
                      }
                      else
                          MoveWindow(hSBWnd, SLIDERPAD, nTitleHgt + (2 * HEIGHTPAD),
                           rCrect.right - (2 * SLIDERPAD), nSlideHgt, TRUE);
                  }
              }
              BringWindowToTop(hWnd);
              hSBWnd = GetDlgItem(hWnd, HSLIDERID);
              if (!hSBWnd)
                  hSBWnd = GetDlgItem(hWnd, VSLIDERID);
              if (hSBWnd)
                  ShowWindow(hSBWnd, SW_SHOW);
          }
          InvalidateRect(hWnd, (LPRECT) NULL, TRUE);
          UpdateWindow(hWnd);
          return (LONG) TRUE;

      case WM_SIZE:
          if (wParam == SIZENORMAL)
              KpsSizeWidget(hWnd, LOWORD(lParam), HIWORD(lParam));
          GetClientRect(hWnd, (LPRECT) &rCrect);
          GetSliderParam(hWnd, &nTitleHgt, &nTextHgt, &nSlideHgt);

          hSBWnd = GetDlgItem(hWnd, VSLIDERID);
          if (hSBWnd != NULL)
          {
              nSlideLeft = (rCrect.right / 2) - (SLIDERPAD / 2);
              MoveWindow(hSBWnd, nSlideLeft, nTitleHgt + (2 * HEIGHTPAD),
                         SLIDERPAD, nSlideHgt, TRUE);
          }
          else
          {
              hSBWnd = GetDlgItem(hWnd, HSLIDERID);
              if (hSBWnd)
              {
                  MoveWindow(hSBWnd, SLIDERPAD, nTitleHgt + (2 * HEIGHTPAD),
                           rCrect.right - (2 * SLIDERPAD), nSlideHgt, TRUE);
              }
          }
          break;

      case WM_PAINT:
          lResult = (LONG) KpsDrawWidget(hWnd);
          hSBWnd = GetDlgItem(hWnd, VSLIDERID);
          if (!hSBWnd)
              hSBWnd = GetDlgItem(hWnd, HSLIDERID);
          if (hSBWnd)
          {
              InvalidateRect(hSBWnd, (LPRECT) NULL, TRUE);
              UpdateWindow(hSBWnd);
          }

          return (LONG) lResult;

      default:
          break;
    }

    return DefWindowProc(hWnd, msg, wParam, lParam);
}
Пример #13
0
void CClipMonView::OnDraw( CDC *pDC)
{
	CRect rcClient;
	TxGetClientRect(rcClient);
	Graphics gc(pDC->GetSafeHdc());
	SolidBrush bkBrush(m_drawParam.bkColor);
	Rect rCet = CRect2Rect(rcClient);
	gc.FillRectangle(&bkBrush, rCet);
	CSize szView = GetScrollViewSize();
	CRect rcView(0, 0, szView.cx, szView.cy);
	rcView.OffsetRect(rcClient.left, rcClient.top);

	if (rcView.IsRectEmpty())
	{
		return;
	}
	rcView.OffsetRect(-GetScrollPos(SB_HORZ), -GetScrollPos(SB_VERT));

	GraphicsContainer container = gc.BeginContainer();
	Rect rClip = CRect2Rect(rcClient);
	gc.SetClip(rClip);
	

	
	if (m_bUseBkBuffer)
	{
		CRect rcBuffToDraw(0,0,rcClient.Width(), rcClient.Height());
		rcBuffToDraw.OffsetRect(GetScrollPos(SB_HORZ), GetScrollPos(SB_VERT));
		if (!IsInRect(rcBuffToDraw, m_rcViewBkBuffer))
		{
			TRACE("\nbufferRedraw %d, %d", rcBuffToDraw.bottom, m_rcViewBkBuffer.bottom);
			ReDrawBkBuffer();
		}
		//draw bkbuffer
		m_BkBufferlock.Lock();
		rcBuffToDraw.OffsetRect(-m_rcViewBkBuffer.left, -m_rcViewBkBuffer.top);
		gc.DrawImage(m_pBmpBackBuffer, rClip, rcBuffToDraw.left, rcBuffToDraw.top, rcBuffToDraw.Width(), rcBuffToDraw.Height(), UnitPixel);
		m_BkBufferlock.Unlock();

	}
	else
	{
		int nBegin = (rcClient.top - rcView.top) / m_drawParam.nItemHeight;
		int nCount = rcClient.Height() /m_drawParam.nItemHeight +1;
		VECTMPITEM vData;
		g_monDataMgr.GetRangeData(nBegin, nCount, vData);
		nCount = vData.size();
		CTxListHeader& headerCtrl = GetListHeader();

		int nTopPos = rcView.top + (nBegin * m_drawParam.nItemHeight);
		Gdiplus::StringFormat fmt;
		fmt.SetAlignment(StringAlignmentNear);
		fmt.SetLineAlignment(StringAlignmentCenter);
		fmt.SetTrimming(StringTrimmingEllipsisCharacter);
		fmt.SetFormatFlags(StringFormatFlagsLineLimit);
		Pen pen(g_globalInfo.viewSetting.clrSeparateLine, 1.0);
		Rect rRowBk(rcClient.left, nTopPos, rcClient.Width(), m_drawParam.nItemHeight);

		for (int i = 0; i < nCount; i++)
		{
			ARGB clr = 0xff000000;
			ARGB clrBk = 0xffffffff;
			vData[i].GetMonColor(clr, clrBk);
			bkBrush.SetColor(clrBk);
			gc.FillRectangle(&bkBrush, rRowBk);
			int nLeftPos = rcView.left;
			CRect rcItem(nLeftPos,nTopPos, 0, nTopPos + m_drawParam.nItemHeight);
			for (int cIdx = 0;  cIdx < m_ColSetting.m_vTmpCols.size(); cIdx++)
			{
				if (rcItem.left > rcClient.right)
				{
					break;
				}
				rcItem.right = rcItem.left + headerCtrl.GetHeaderWidth(cIdx);
				if (rcItem.right >= rcClient.left)
				{
					CString strText = vData[i].GetValue((ENUM_MONTYPE)(m_ColSetting.m_vTmpCols[cIdx].nPosInType));
					GPDrawShadowTextSimple(gc, strText, rcItem, *m_drawParam.pFont, clr, 0, 2,2, &fmt);
					//GPDrawShadowText(gc, strText, rcItem, *m_drawParam.pFont, clr, 0xff000000,0,0,0,0,&fmt);
					//draw separate line
					gc.DrawLine(&pen, rcItem.right-1, rcItem.top, rcItem.right-1, rcItem.bottom);

				}
				rcItem.OffsetRect(rcItem.Width(), 0);

			}
			gc.DrawLine(&pen, rcClient.left, rcItem.bottom-1, rcClient.right, rcItem.bottom-1);
			nTopPos += m_drawParam.nItemHeight;

			rRowBk.Offset(0, m_drawParam.nItemHeight);
		}
	}
	

	//calc In Bound Item
	gc.EndContainer(container);
	ReDrawRemainTime(pDC);

}
Пример #14
0
void CClipMonView::ReDrawRemainTime(CDC* pDC)
{
	CRect rcClient;
	TxGetClientRect(rcClient);
	if (m_scBar[SB_VERT].IsShowing())
	{
		rcClient.DeflateRect(0,0,m_scBar[SB_VERT].GetBarWidth(), 0);
	}
	if (m_scBar[SB_HORZ].IsShowing())
	{
		rcClient.DeflateRect(0,0, 0, m_scBar[SB_HORZ].GetBarWidth());
	}
// 	Rect rCet = CRect2Rect(rcClient);
// 	gc.FillRectangle(&bkBrush, rCet);
	CSize szView = GetScrollViewSize();
	CRect rcView(0, 0, szView.cx, szView.cy);
	rcView.OffsetRect(rcClient.left, rcClient.top);

	if (rcView.IsRectEmpty())
	{
		return;
	}
	rcView.OffsetRect(-GetScrollPos(SB_HORZ), -GetScrollPos(SB_VERT));

	int nBegin = (rcClient.top - rcView.top) / m_drawParam.nItemHeight;
	int nCount = rcClient.Height() /m_drawParam.nItemHeight +1;
	VECTMPITEM vData;
	g_monDataMgr.GetRangeData(nBegin, nCount, vData);
	nCount = vData.size();
	if (nCount <= 0)
	{
		return;
	}
	CTxListHeader& headerCtrl = GetListHeader();

	int nLeftPos = rcView.left;
	int nRightPos = 0;
	for (int cIdx = 0;  cIdx < m_ColSetting.m_vTmpCols.size(); cIdx++)
	{

		ENUM_MONTYPE nMonType =  (ENUM_MONTYPE)(m_ColSetting.m_vTmpCols[cIdx].nPosInType);
		if (nMonType == MONTYPE_TIMEREMAIN)
		{
			nRightPos = nLeftPos + headerCtrl.GetHeaderWidth(cIdx);
			break;
		}
		else
		{
			nLeftPos += headerCtrl.GetHeaderWidth(cIdx);
		}
	}

	if (nRightPos < rcClient.left || nLeftPos > rcClient.right)
	{
		return;
	}

	CPoint ptOffSetBmp;
	int nTopPos = rcView.top + (nBegin * m_drawParam.nItemHeight);
	ptOffSetBmp.x = nLeftPos < 0? -nLeftPos:0;
	ptOffSetBmp.y = nTopPos < rcClient.top? rcClient.top - nTopPos: 0;
	CRect rcRemainTimeClient(nLeftPos, rcClient.top, nRightPos-1, rcClient.bottom);
	Graphics gc(m_pBmpRemainTime);
	SolidBrush bkBrush(m_drawParam.bkColor);
	GraphicsContainer container = gc.BeginContainer();
	int nClipHeight = m_drawParam.nItemHeight*nCount;
	if (nClipHeight < rcClient.Height())
	{
		nClipHeight = rcClient.Height();
	}
	Rect rClip(0,0, rcRemainTimeClient.Width(), nClipHeight);
	gc.SetClip(rClip);
	Rect rDes(nLeftPos, nTopPos, rClip.Width, rClip.Height);
	gc.FillRectangle(&bkBrush, rClip);
	Gdiplus::StringFormat fmt;
	fmt.SetAlignment(StringAlignmentCenter);
	fmt.SetLineAlignment(StringAlignmentCenter);
	fmt.SetTrimming(StringTrimmingEllipsisCharacter);
	fmt.SetFormatFlags(StringFormatFlagsLineLimit);
	Pen pen(g_globalInfo.viewSetting.clrSeparateLine, 1.0);
	Rect rRowBk(0, 0, rcRemainTimeClient.Width(), m_drawParam.nItemHeight);
	CRect rcItem(0,0, rRowBk.Width,rRowBk.Height);
	for (int i = 0; i < nCount; i++)
	{
		ARGB clr = 0xff000000;
		ARGB clrBk = 0xffffffff;
		vData[i].GetMonColor(clr, clrBk);
		bkBrush.SetColor(clrBk);
		gc.FillRectangle(&bkBrush, rRowBk);
		CString strText = vData[i].GetValue(MONTYPE_TIMEREMAIN);
		GPDrawShadowTextSimple(gc, strText, rcItem, *m_drawParam.pFont, clr, 0, 2,2, &fmt);
		//GPDrawShadowText(gc, strText, rcItem, *m_drawParam.pFont, clr, 0xff000000,0,0,0,0,&fmt);
		gc.DrawLine(&pen, rcItem.left, rcItem.bottom-1, rcItem.right, rcItem.bottom-1);
		nTopPos += m_drawParam.nItemHeight;
		rcItem.OffsetRect(0, m_drawParam.nItemHeight);
		rRowBk.Offset(0, m_drawParam.nItemHeight);
	}

	gc.EndContainer(container);

	Graphics gcDes(pDC->GetSafeHdc());
	CRect rcDesClip(rcRemainTimeClient);
	Rect rDesClip = CRect2Rect(rcDesClip);
	gcDes.SetClip(rDesClip);
	gcDes.DrawImage(m_pBmpRemainTime, rDesClip, ptOffSetBmp.x, ptOffSetBmp.y, (INT)rDesClip.Width, (INT)rDesClip.Height, UnitPixel);

}
Пример #15
0
void EPropWnd::SetScrollPage()
{
	TR( _T("EPropWnd::SetScrollPage()"), _T(""));

	CSize PageSize = GetScrollPageSize();

	if( PageSize.cx==0 && PageSize.cy==0 )
	{
		SetScrollPos ( SB_HORZ , 0     );
		SetScrollPos ( SB_VERT , 0     );
		ShowScrollBar( SB_BOTH , FALSE );
	}
	else
	{
		CRect wr;
		GetWindowRect(&wr);
		CSize ClientSize = wr.Size();

		bool bEnableH = false;
		bool bEnableV = false;

		if( PageSize.cx > ClientSize.cx )
		{
			ClientSize.cy -= GetSystemMetrics(SM_CYHSCROLL);
			bEnableH = true;
		}

		if( PageSize.cy > ClientSize.cy )
		{
			ClientSize.cx -= GetSystemMetrics(SM_CXVSCROLL);
			bEnableV = true;

			if( bEnableH == false )
			{
				if( PageSize.cx > ClientSize.cx )
				{
					ClientSize.cy -= GetSystemMetrics(SM_CYHSCROLL);
					bEnableH = true;
				}
			}
		}

		//
		//
		//

		SCROLLINFO si;
		si.cbSize = sizeof(si);
		si.fMask  = SIF_PAGE | SIF_POS | SIF_RANGE;

		//
		// horizontal scroller
		//

		si.nPage  = bEnableH ? ClientSize.cx         : 0;
		si.nMin   = bEnableH ? 0                     : 0;
		si.nMax   = bEnableH ? PageSize.cx-1         : 0;
		si.nPos   = bEnableH ? GetScrollPos(SB_HORZ) : 0;
		SetScrollInfo( SB_HORZ , &si );
		ShowScrollBar( SB_HORZ , bEnableH );

		//
		// vertical scroller
		//

		si.nPage  = bEnableV ? ClientSize.cy         : 0;
		si.nMin   = bEnableV ? 0                     : 0;
		si.nMax   = bEnableV ? PageSize.cy-1         : 0;
		si.nPos   = bEnableV ? GetScrollPos(SB_VERT) : 0;
		SetScrollInfo( SB_VERT , &si );
		ShowScrollBar( SB_VERT , bEnableV );
	}
}
Пример #16
0
void BuildGraph::OnPaint(wxPaintEvent& event)
{
	wxBufferedPaintDC dc(this);

    PrepareDC(dc);

    dc.SetBackground(wxBrush(wxColor(255,255,255), wxSOLID));
    dc.Clear();

	int MaxWidth=GetSize().x;
	int MaxHeight=0;

	int ScrollPosH=GetScrollPos(wxHORIZONTAL);
	int ScrollPosV=GetScrollPos(wxVERTICAL);

	wxFont font = dc.GetFont();
	font.SetWeight(0);
	font.SetUnderlined(false);
	dc.SetFont(font);
	dc.SetPen(wxPen(wxColor(192,192,192)));
	//dc.SetBrush(wxBrush(wxColor(192,192,192)));
	dc.SetBrush(wxBrush(wxColor(0,0,0,0),wxTRANSPARENT));

	wxString TriDot="...";
	long TriDotSize;
	dc.GetTextExtent(TriDot,&TriDotSize,0);

	int AgentNum=1;
	EventsAccess.Wait();
	for (unsigned int i=0;i<Events.Count();i++)
	{
		
		if (Events[i]->AgentId+1>AgentNum)
			AgentNum=Events[i]->AgentId+1;

		float sec = (float)(Events[i]->StartTime-StartTime)/1000.0;

		wxColour blockcolour;
		wxColour blockcolourdest;

		wxString Text;	

		float FinishTime;
		bool Finish;
		if (Events[i]->StartTime>Events[i]->FinishTime)
		{
			blockcolour = wxColour(172,172,255);
			blockcolourdest = wxColour(232,232,255);
			FinishTime=GetTickCount();
			Finish=false;
		}else{
			if (Events[i]->Type==0) // Blue
			{
				blockcolour = wxColour(80,255,255);
				blockcolourdest = wxColour(192,255,255);
			}else if (Events[i]->Type==1) // Green
			{
				blockcolour = wxColour(80,255,80);
				blockcolourdest = wxColour(200,255,200);
			}else if (Events[i]->Type==2) // Yellow
			{
				blockcolour = wxColour(255,255,64);
				blockcolourdest = wxColour(255,255,184);
			}else{ // Red
				blockcolour = wxColour(255,48,48);
				blockcolourdest = wxColour(255,172,172);
			}
			FinishTime=Events[i]->FinishTime;
			Finish=true;
		}
		float BlockWidth = (FinishTime-Events[i]->StartTime)*TimeRatio/1000.0;
		float BlockWidth2 = BlockWidth; 
		if (BlockWidth<0)
			BlockWidth=0;

		if (Finish==false)
			Text.Printf("%s (%.2f%%)",Events[i]->Name,100.0*Events[i]->Current/Events[i]->Size);
		else
			Text.Printf("%s (%.2f)",Events[i]->Name,(FinishTime-Events[i]->StartTime)/1000.0);

		long size;
		dc.GetTextExtent(Text,&size,NULL);

		if (Finish==false)
		{
			BlockWidth = BlockWidth>size+6?BlockWidth:size+6;
			//BlockWidth = Events[i]->Size/((long)Events[i]->Current+1)*(FinishTime-Events[i]->StartTime)*TimeRatio/1000.0;
		}

		int cornerL,cornerR;
		if (StartPixelsWidth+TimeRatio*sec<ScrollPosH)
			cornerL=-1;
		else if (StartPixelsWidth+TimeRatio*sec>ScrollPosH+GetSize().x)
			cornerL=1;
		else
			cornerL=0;

		if (StartPixelsWidth+TimeRatio*sec+BlockWidth<ScrollPosH)
			cornerR=-1;
		else if (StartPixelsWidth+TimeRatio*sec+BlockWidth>ScrollPosH+GetSize().x)
			cornerR=1;
		else
			cornerR=0;

		if (BlockWidth>=0.5 && ((StartPixelsHeight+AgentsSpace+(AgentsSpace+BlockHeight)*Events[i]->AgentId>ScrollPosV && 
			StartPixelsHeight+AgentsSpace+(AgentsSpace+BlockHeight)*Events[i]->AgentId<ScrollPosV+GetSize().y)
			|| (StartPixelsHeight+AgentsSpace+(AgentsSpace+BlockHeight)*Events[i]->AgentId+BlockHeight>ScrollPosV && 
			StartPixelsHeight+AgentsSpace+(AgentsSpace+BlockHeight)*Events[i]->AgentId+BlockHeight<ScrollPosV+GetSize().y))
			&&
			(cornerR==0 || cornerL==0 || (cornerL==-1 && cornerR==1)) )
		{
			dc.DrawRectangle(StartPixelsWidth+TimeRatio*sec+1,StartPixelsHeight+AgentsSpace+(AgentsSpace+BlockHeight)*Events[i]->AgentId,BlockWidth-1,BlockHeight);

			dc.GradientFillLinear(wxRect(StartPixelsWidth+TimeRatio*sec+2,StartPixelsHeight+AgentsSpace+(AgentsSpace+BlockHeight)*Events[i]->AgentId+1,BlockWidth2-3,BlockHeight-2),blockcolour,blockcolourdest,wxNORTH);

			if (size<=BlockWidth-7 || Finish==false)
				dc.DrawText(Text,StartPixelsWidth+TimeRatio*sec+4,StartPixelsHeight+AgentsSpace+(AgentsSpace+BlockHeight)*Events[i]->AgentId+3);
			else{
				if (TriDotSize<=BlockWidth-7)
				{
					//	dc.DrawText(TriDot,StartPixelsWidth+TimeRatio*sec+3,StartPixelsHeight+AgentsSpace+(AgentsSpace+BlockHeight)*Events[i]->AgentId+3);

					wxString Temp;
					for (int j=Text.Len()-TriDot.Len();j>=0;j--)
					{
						Temp=Text.Left(j);
						dc.GetTextExtent(Temp,&size,NULL);
						if (size+TriDotSize<=BlockWidth-7)
						{
							dc.DrawText(Temp+TriDot,StartPixelsWidth+TimeRatio*sec+4,StartPixelsHeight+AgentsSpace+(AgentsSpace+BlockHeight)*Events[i]->AgentId+3);
							break;
						}
					}
				}
			}
		}

		if (MaxWidth < StartPixelsWidth+TimeRatio*sec+3+BlockWidth+5)
			MaxWidth = StartPixelsWidth+TimeRatio*sec+3+BlockWidth+5;
	}
	EventsAccess.Post();

	//Draw time
	font.SetPointSize(10);
	dc.SetFont(font);
	dc.SetPen(wxPen(wxColour()));
	int itenum=(MaxWidth-StartPixelsWidth)/TimeRatio;

	int modul=1;
	if (TimeRatio!=0)
		modul = 50.0/TimeRatio;

	int i=(ScrollPosH-StartPixelsWidth)/TimeRatio;
	if (i<1)
		i=1;
	int j=modul;
	for (;i<itenum;i++)
	{
		if (j==0)
		{
			int x=StartPixelsWidth+i*TimeRatio;
			if (x>=ScrollPosH)
			{
				dc.DrawLine(x,0,x,5);
				wxString str;
				
				str.Printf("%d:%02d",i/60,i-60*(i/60));
				long size;
				dc.GetTextExtent(str,&size,NULL);
				dc.DrawText(str,x-size/2,5);
			}
			j=modul;
			if (x>GetSize().x+ScrollPosH)
				break;
		}else
			j--;
	}

	//Draw Agents

	dc.SetBrush(wxBrush(wxColour(255,255,255)));
	dc.SetPen(wxPen(wxColour(255,255,255)));
	dc.DrawRectangle(ScrollPosH,ScrollPosV,StartPixelsWidth-10,GetSize().y);
	dc.SetPen(wxPen(wxColour(192,192,192),1,wxDOT));

	for (int i=0;i<AgentNum;i++)
	{
		wxString str;
		str.Printf("Agent %d",i+1);
		
		dc.DrawText(str,5+ScrollPosH,StartPixelsHeight+AgentsSpace+(AgentsSpace+BlockHeight)*i+3);

		dc.DrawLine(ScrollPosH,StartPixelsHeight+AgentsSpace+(AgentsSpace+BlockHeight)*i+BlockHeight,ScrollPosH+StartPixelsWidth-10,StartPixelsHeight+AgentsSpace+(AgentsSpace+BlockHeight)*i+BlockHeight);
	}

	dc.SetPen(wxPen());
	dc.DrawLine(ScrollPosH+StartPixelsWidth-10,GetScrollPos(wxVERTICAL),ScrollPosH+StartPixelsWidth-10,GetSize().y+GetScrollPos(wxVERTICAL));

	MaxHeight=AgentsSpace*2+(AgentNum+1)*(AgentsSpace+BlockHeight);

	//Deplacement auto de la scrollbar horizontal

	int sh = /*GetScrollPageSize(wxHORIZONTAL)*/0;
	//MaxWidth+=sh;

	//test.Printf("%d %d", GetScrollPos(wxHORIZONTAL),GetScrollLines(wxHORIZONTAL)-GetSize().x);
	int HorizPos;
	if (GetScrollPos(wxHORIZONTAL)>=GetScrollLines(wxHORIZONTAL)-GetSize().x /*&& GetScrollPageSize(wxHORIZONTAL)>GetSize().x*/) 
		HorizPos=MaxWidth;
	else
		HorizPos=GetScrollPos(wxHORIZONTAL);

	//if (GetScrollLines(wxHORIZONTAL)<GetSize().x)
		HorizPos=GetScrollPos(wxHORIZONTAL);

	SetScrollbars(1,1,MaxWidth,MaxHeight,HorizPos,GetScrollPos(wxVERTICAL),true);
}
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();
}
Пример #18
0
wxPoint wxJigsawEditorCanvas::GetScrollPosition()
{
	return wxPoint(GetScrollPos(wxHORIZONTAL),GetScrollPos(wxVERTICAL));
}
Пример #19
0
void CFriendsUI::DoEvent(TEventUI& event) 
{
	if (!IsMouseEnabled() && event.Type > UIEVENT__MOUSEBEGIN && event.Type < UIEVENT__MOUSEEND)
	{
		if (m_pParent != NULL)
			m_pParent->DoEvent(event);
		else
			CVerticalLayoutUI::DoEvent(event);
		return;
	}

	if (event.Type == UIEVENT_TIMER && event.wParam == SCROLL_TIMERID)
	{
		if (delay_left_ > 0)
		{
			--delay_left_;
			SIZE sz = GetScrollPos();
			LONG lDeltaY =  (LONG)(CalculateDelay((double)delay_left_ / delay_number_) * delay_deltaY_);
			if ((lDeltaY > 0 && sz.cy != 0)  || (lDeltaY < 0 && sz.cy != GetScrollRange().cy ))
			{
				sz.cy -= lDeltaY;
				SetScrollPos(sz);
				return;
			}
		}
		delay_deltaY_ = 0;
		delay_number_ = 0;
		delay_left_ = 0;
		m_pManager->KillTimer(this, SCROLL_TIMERID);
		return;
	}
	if (event.Type == UIEVENT_SCROLLWHEEL)
	{
		LONG lDeltaY = 0;
		if (delay_number_ > 0)
			lDeltaY =  (LONG)(CalculateDelay((double)delay_left_ / delay_number_) * delay_deltaY_);
		switch (LOWORD(event.wParam))
		{
		case SB_LINEUP:
			if (delay_deltaY_ >= 0)
				delay_deltaY_ = lDeltaY + 8;
			else
				delay_deltaY_ = lDeltaY + 12;
			break;
		case SB_LINEDOWN:
			if (delay_deltaY_ <= 0)
				delay_deltaY_ = lDeltaY - 8;
			else
				delay_deltaY_ = lDeltaY - 12;
			break;
		}
		if
			(delay_deltaY_ > 100) delay_deltaY_ = 100;
		else if
			(delay_deltaY_ < -100) delay_deltaY_ = -100;

		delay_number_ = (DWORD)sqrt((double)abs(delay_deltaY_)) * 5;
		delay_left_ = delay_number_;
		m_pManager->SetTimer(this, SCROLL_TIMERID, 50U);
		return;
	}

	CListUI::DoEvent(event);
}
Пример #20
0
LRESULT CALLBACK ScrollWndProc (
    HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam
) {
    Gwidget_t *widget, *child;
    WINDOWPOS *wpos;
    PIXpoint_t po;
    RECT r;
    int dummy, dx, dy, wi;

    if (Gnocallbacks || !(widget = findwidget (hwnd, G_SCROLLWIDGET)))
        return (DefWindowProc(hwnd, message, wparam, lparam));
    switch (message) {
    case WM_WINDOWPOSCHANGED:
        wpos = (WINDOWPOS *) lparam;
        if (!(wpos->flags & SWP_NOSIZE))
            handleresize (widget);
        break;
    case WM_HSCROLL:
    case WM_VSCROLL:
        for (wi = 0; wi < Gwidgetn; wi++) {
            child = &Gwidgets[wi];
            if (child->inuse && child->pwi == widget - &Gwidgets[0])
                break;
        }
        if (wi == Gwidgetn)
            return (DefWindowProc(hwnd, message, wparam, lparam));
        GetClientRect (widget->w, &r);
        GetScrollRange (widget->w, SB_HORZ, &dummy, &dx);
        GetScrollRange (widget->w, SB_VERT, &dummy, &dy);
        po.x = GetScrollPos (widget->w, SB_HORZ);
        po.y = GetScrollPos (widget->w, SB_VERT);
        switch (message) {
        case WM_HSCROLL:
            switch (LOWORD (wparam)) {
            case SB_BOTTOM:        po.x = dx;                  break;
            case SB_LINEDOWN:      po.x += 10;                 break;
            case SB_LINEUP:        po.x -= 10;                 break;
            case SB_PAGEDOWN:      po.x += (r.right - r.left); break;
            case SB_PAGEUP:        po.x -= (r.right - r.left); break;
            case SB_THUMBPOSITION: po.x = HIWORD (wparam);     break;
            case SB_THUMBTRACK:    po.x = HIWORD (wparam);     break;
            case SB_TOP:           po.x = 0;                   break;
            }
            po.x = min (po.x, dx);
            po.x = max (po.x, 0);
            SetScrollPos (widget->w, SB_HORZ, po.x, TRUE);
            SetWindowPos (
                child->w, (HWND) NULL, -po.x, -po.y, 0, 0,
                SWP_NOSIZE | SWP_NOZORDER
            );
            break;
        case WM_VSCROLL:
            switch (LOWORD (wparam)) {
            case SB_BOTTOM:        po.y = dy;                  break;
            case SB_LINEDOWN:      po.y += 10;                 break;
            case SB_LINEUP:        po.y -= 10;                 break;
            case SB_PAGEDOWN:      po.y += (r.bottom - r.top); break;
            case SB_PAGEUP:        po.y -= (r.bottom - r.top); break;
            case SB_THUMBPOSITION: po.y = HIWORD (wparam);     break;
            case SB_THUMBTRACK:    po.y = HIWORD (wparam);     break;
            case SB_TOP:           po.y = 0;                   break;
            }
            po.y = min (po.y, dy);
            po.y = max (po.y, 0);
            SetScrollPos (widget->w, SB_VERT, po.y, TRUE);
            SetWindowPos (
                child->w, (HWND) NULL, -po.x, -po.y, 0, 0,
                SWP_NOSIZE | SWP_NOZORDER
            );
            break;
        }
        break;
    default:
        return (DefWindowProc (hwnd, message, wparam, lparam));
    }
    return 0;
}
Пример #21
0
LRESULT CDocWindow::OnScroll(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
	UINT ScrollCode = LOWORD(wParam);
	UINT TrackCode = HIWORD(wParam);
	// SB_LINERIGHT, SB_LINEDOWN	Scrolls one line right/down
	// SB_LINELEFT, SB_LINEUP		Scrolls one line up/left
	// SB_PAGERIGHT, SB_PAGEDOWN	Scrolls one page right/down
	// SB_PAGELEFT, SB_PAGEUP		Scrolls one page left/up
	// SB_LEFT, SB_TOP				Scrolls to the start
	// SB_RIGHT, SB_BOTTOM			Scrolls to the end
	// SB_ENDSCROLL					Ends scroll
	// SB_THUMBPOSITION				The user has dragged the scroll box (thumb) and released the mouse button
	//								The high-order word indicates the position of the scroll box at the end of the drag operation
	// SB_THUMBTRACK				The user is dragging the scroll box
	//								This message is sent repeatedly until the user releases the mouse button
	//								The high-order word indicates the position that the scroll box has been dragged to

	int nMin = 0;
	int nMax = 0;
	if (uMsg == WM_HSCROLL)
	{
		GetScrollRange(SB_HORZ, &nMin, &nMax);
		int nPage = GetScrollPage(SB_HORZ);
		int nPos = GetScrollPos(SB_HORZ);
		switch (ScrollCode)
		{
			case SB_LINERIGHT:
			case SB_LINELEFT:
			{
				if (SB_LINERIGHT == ScrollCode)
					nPos += 100;
				else
					nPos -= 100;
				break;
			}
			case SB_PAGERIGHT:
			case SB_PAGELEFT:
			{
				if (SB_PAGERIGHT == ScrollCode)
					nPos += nPage;
				else
					nPos -= nPage;
				break;
			}
			case SB_RIGHT:
			case SB_LEFT:
			{
				if (SB_RIGHT == ScrollCode)
					nPos = nMax;
				else
					nPos = nMin;

				break;
			}
			case SB_THUMBTRACK:
			case SB_THUMBPOSITION:
			{
				nPos = TrackCode;
				break;
			}

			default:
				return S_OK;
		}

		if (nPos > nMax + 1 - nPage)
			nPos = nMax + 1 - nPage;
		if (nPos < nMin)
			nPos = nMin;

		SetScrollPos(SB_HORZ, nPos, true);
	}
	else
	if (uMsg == WM_VSCROLL)
	{
		GetScrollRange(SB_VERT, &nMin, &nMax);
		int nPage = GetScrollPage(SB_VERT);
		int nPos = GetScrollPos(SB_VERT);
		switch (ScrollCode)
		{
			case SB_LINEDOWN:
			case SB_LINEUP:
			{
				if (SB_LINEDOWN == ScrollCode)
					nPos += 100;
				else
					nPos -= 100;
				break;
			}
			case SB_PAGEDOWN:
			case SB_PAGEUP:
			{
				if (SB_PAGEDOWN == ScrollCode)
					nPos += nPage;
				else
					nPos -= nPage;
				break;
			}
			case SB_BOTTOM:
			case SB_TOP:
			{
				if (SB_BOTTOM == ScrollCode)
					nPos = nMax;
				else
					nPos = nMin;

				break;
			}
			case SB_THUMBTRACK:
			case SB_THUMBPOSITION:
			{
				nPos = TrackCode;
				break;
			}

			default:
				return S_OK;
		}

		if (nPos > nMax + 1 - nPage)
			nPos = nMax + 1 - nPage;
		if (nPos < nMin)
			nPos = nMin;

		SetScrollPos(SB_VERT, nPos, true);
	}

	SetupPageView(false/*bSetScrollbars*/);
	return S_OK;
}
Пример #22
0
static void handleresize (Gwidget_t *widget) {
    Gwidget_t *parent, *child;
    PIXsize_t ps1, ps2;
    PIXpoint_t po;
    DWORD wflags1, wflags2;
    RECT r;
    int dx, dy, wi, i;

    wflags1 = SWP_NOMOVE | SWP_NOZORDER;
    wflags2 = SWP_NOSIZE | SWP_NOZORDER;
    GetWindowRect (widget->w, &r);
    ps1.x = r.right - r.left, ps1.y = r.bottom - r.top;
    ps2 = ps1;
    /* first, take care of parent */
    parent = (widget->pwi == -1) ? NULL : &Gwidgets[widget->pwi];
    if (!parent)
        goto handlechildren;
    switch (parent->type) {
    case G_VIEWWIDGET:
        Gadjustwrect (parent, &ps1);
        if (ps1.x != ps2.x || ps1.y != ps2.y) {
            Gnocallbacks = TRUE;
            SetWindowPos (widget->w, (HWND) NULL, 0, 0, ps1.x, ps1.y, wflags1);
            Gnocallbacks = FALSE;
        }
        break;
    case G_ARRAYWIDGET:
        Gnocallbacks = TRUE;
        Gawresize (parent);
        Gnocallbacks = FALSE;
        break;
    case G_SCROLLWIDGET:
        Gnocallbacks = TRUE;
        for (i = 0; i  < 2; i++) {
            Gadjustwrect (parent, &ps1);
            if (ps1.x > ps2.x || ps1.y > ps2.y)
                SetWindowPos (
                    widget->w, (HWND) NULL, 0, 0, ps1.x, ps1.y, wflags1
                );
            GetClientRect (parent->w, &r);
            ps2.x = r.right - r.left, ps2.y = r.bottom - r.top;
            dx = max (0, ps1.x - ps2.x);
            dy = max (0, ps1.y - ps2.y);
            SetScrollRange (parent->w, SB_HORZ, 0, dx, TRUE);
            SetScrollRange (parent->w, SB_VERT, 0, dy, TRUE);
            po.x = GetScrollPos (parent->w, SB_HORZ);
            po.y = GetScrollPos (parent->w, SB_VERT);
            po.x = min (po.x, dx);
            po.x = max (po.x, 0);
            SetScrollPos (parent->w, SB_HORZ, po.x, TRUE);
            po.y = min (po.y, dy);
            po.y = max (po.y, 0);
            SetScrollPos (parent->w, SB_VERT, po.y, TRUE);
            SetWindowPos (widget->w, (HWND) NULL, -po.x, -po.y, 0, 0, wflags2);
            ps2 = ps1;
        }
        Gnocallbacks = FALSE;
        break;
    }

handlechildren:
    for (wi = 0; wi < Gwidgetn; wi++) {
        child = &Gwidgets[wi];
        if (child->inuse && child->pwi == widget - &Gwidgets[0])
            break;
    }
    if (wi == Gwidgetn)
        return;
    GetWindowRect (child->w, &r);
    ps1.x = r.right - r.left, ps1.y = r.bottom - r.top;
    ps2 = ps1;
    switch (widget->type) {
    case G_VIEWWIDGET:
        Gadjustwrect (widget, &ps1);
        if (ps1.x != ps2.x || ps1.y != ps2.y)
            SetWindowPos (child->w, (HWND) NULL, 0, 0, ps1.x, ps1.y, wflags1);
        break;
    case G_ARRAYWIDGET:
        Gawresize (widget);
        break;
    case G_SCROLLWIDGET:
        Gadjustwrect (widget, &ps1);
        if (ps1.x > ps2.x || ps1.y > ps2.y)
            SetWindowPos (child->w, (HWND) NULL, 0, 0, ps1.x, ps1.y, wflags1);
        GetClientRect (widget->w, &r);
        ps2.x = r.right - r.left, ps2.y = r.bottom - r.top;
        dx = max (0, ps1.x - ps2.x);
        dy = max (0, ps1.y - ps2.y);
        SetScrollRange (widget->w, SB_HORZ, 0, dx, TRUE);
        SetScrollRange (widget->w, SB_VERT, 0, dy, TRUE);
        po.x = GetScrollPos (widget->w, SB_HORZ);
        po.y = GetScrollPos (widget->w, SB_VERT);
        po.x = min (po.x, dx);
        po.x = max (po.x, 0);
        SetScrollPos (widget->w, SB_HORZ, po.x, TRUE);
        po.y = min (po.y, dy);
        po.y = max (po.y, 0);
        SetScrollPos (widget->w, SB_VERT, po.y, TRUE);
        SetWindowPos (child->w, (HWND) NULL, -po.x, -po.y, 0, 0, wflags2);
        break;
    }
}
Пример #23
0
LRESULT CALLBACK
ScrollboxWinProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
    switch (message)
    {
        case WM_SIZE:
            if (hwnd == hScrollbox)
            {
                UpdateScrollbox();
            }
            break;
        case WM_HSCROLL:
            if (hwnd == hScrollbox)
            {
                SCROLLINFO si;
                si.cbSize = sizeof(SCROLLINFO);
                si.fMask = SIF_ALL;
                GetScrollInfo(hScrollbox, SB_HORZ, &si);
                switch (LOWORD(wParam))
                {
                    case SB_THUMBTRACK:
                    case SB_THUMBPOSITION:
                        si.nPos = HIWORD(wParam);
                        break;
                    case SB_LINELEFT:
                        si.nPos -= 5;
                        break;
                    case SB_LINERIGHT:
                        si.nPos += 5;
                        break;
                    case SB_PAGELEFT:
                        si.nPos -= si.nPage;
                        break;
                    case SB_PAGERIGHT:
                        si.nPos += si.nPage;
                        break;
                }
                SetScrollInfo(hScrollbox, SB_HORZ, &si, TRUE);
                MoveWindow(hScrlClient, -GetScrollPos(hScrollbox, SB_HORZ),
                           -GetScrollPos(hScrollbox, SB_VERT), imgXRes * zoom / 1000 + 6,
                           imgYRes * zoom / 1000 + 6, TRUE);
            }
            break;

        case WM_VSCROLL:
            if (hwnd == hScrollbox)
            {
                SCROLLINFO si;
                si.cbSize = sizeof(SCROLLINFO);
                si.fMask = SIF_ALL;
                GetScrollInfo(hScrollbox, SB_VERT, &si);
                switch (LOWORD(wParam))
                {
                    case SB_THUMBTRACK:
                    case SB_THUMBPOSITION:
                        si.nPos = HIWORD(wParam);
                        break;
                    case SB_LINEUP:
                        si.nPos -= 5;
                        break;
                    case SB_LINEDOWN:
                        si.nPos += 5;
                        break;
                    case SB_PAGEUP:
                        si.nPos -= si.nPage;
                        break;
                    case SB_PAGEDOWN:
                        si.nPos += si.nPage;
                        break;
                }
                SetScrollInfo(hScrollbox, SB_VERT, &si, TRUE);
                MoveWindow(hScrlClient, -GetScrollPos(hScrollbox, SB_HORZ),
                           -GetScrollPos(hScrollbox, SB_VERT), imgXRes * zoom / 1000 + 6,
                           imgYRes * zoom / 1000 + 6, TRUE);
            }
            break;

        default:
            return DefWindowProc(hwnd, message, wParam, lParam);
    }

    return 0;
}
Пример #24
0
/**
 * @param hdc - drawing context.
 * @param prcPaint - the rectangle where the painting is requested.
 */
void CTextView::DrawTextView(HDC hdc, const RECT* prcPaint)
{
	RECT rcClient = {};
	if (prcPaint == NULL)
	{
		GetClientRect(m_hwnd, &rcClient);
		prcPaint = &rcClient;
	}
	if (IsRectEmpty(prcPaint))
		return;

#ifdef USE_MEM_DC
	int nClientWidth = prcPaint->right - prcPaint->left;
	int nClientHeight = prcPaint->bottom - prcPaint->top;
	HBITMAP hbmpMem;
	hbmpMem = CreateCompatibleBitmap(hdc, nClientWidth, nClientHeight);
	if (hbmpMem == NULL)
		return;
	HDC hdcMem;
	hdcMem = CreateCompatibleDC(hdc);
	if (hdcMem == NULL)
	{
		DeleteBitmap(hbmpMem);
		return;
	}
	SetViewportOrgEx(hdcMem, -prcPaint->left, -prcPaint->top, NULL);
	HBITMAP hbmpSafe = SelectBitmap(hdcMem, hbmpMem);
#else
	// CS_PARENTDC sets the clipping rectangle of the child window to that of the parent window
	// so that the child can draw on the parent. Text view inherits this style from sub-classed
	// static control. This causes problems with unclipped TabbedTextOut() output.
	HRGN hrgn = CreateRectRgnIndirect(prcPaint);
	SelectClipRgn(hdc, hrgn);
	DeleteRgn(hrgn);
	HDC hdcMem = hdc;
#endif

	FillRect(hdcMem, prcPaint, g_pResManager->m_hbrWindowBrush);

	COLORREF rgbOldTextColor = SetTextColor(hdcMem, GetSysColor(COLOR_WINDOWTEXT));
	COLORREF rgbOldBackground = SetBkColor(hdcMem, GetSysColor(COLOR_WINDOW));
	HFONT hOldFont = g_pResManager->m_hFixedFont ? SelectFont(hdcMem, g_pResManager->m_hFixedFont) : NULL;
	TEXTMETRIC tmetr;
	::GetTextMetrics(hdcMem, &tmetr);

	DWORD dwNumLines = (DWORD)m_arrLines.GetCount();
	DWORD dwTopLineNum = GetScrollPos(m_hwnd, SB_VERT);
	DWORD dwTopVisLineNum = dwTopLineNum + prcPaint->top / tmetr.tmHeight;
	BOOL bSizeChanged = FALSE;

	if (dwTopVisLineNum < dwNumLines)
	{
		int nHorPos = tmetr.tmAveCharWidth - GetScrollPos(m_hwnd, SB_HORZ);
		int nVertPos = prcPaint->top - prcPaint->top % tmetr.tmHeight;
		DWORD dwNumVisLines = prcPaint->bottom / tmetr.tmHeight;
		if (prcPaint->bottom % tmetr.tmHeight)
			++dwNumVisLines;
		DWORD dwBottomVisLineNum = dwTopLineNum + dwNumVisLines - 1;
		if (dwBottomVisLineNum >= dwNumLines)
			dwBottomVisLineNum = dwNumLines - 1;

		for (DWORD dwLineNum = dwTopVisLineNum; dwLineNum <= dwBottomVisLineNum; ++dwLineNum)
		{
			bSizeChanged |= CacheLine(dwLineNum, hdc, tmetr);
			const CLineInfo& rLineInfo = m_arrLines[(size_t)dwLineNum];
			int nTextWidth = LOWORD(TabbedTextOut(hdcMem, nHorPos, nVertPos, m_pTextCache + rLineInfo.m_dwTextStart, rLineInfo.m_dwLength, 0, NULL, -nHorPos));
			if (rLineInfo.m_bTruncated)
				TextOut(hdcMem, nHorPos + nTextWidth, nVertPos, g_szEllipsis, g_dwEllipsisLength);
			nVertPos += tmetr.tmHeight;
		}
	}

	SetTextColor(hdcMem, rgbOldTextColor);
	SetBkColor(hdcMem, rgbOldBackground);
	if (hOldFont)
		SelectFont(hdcMem, hOldFont);

#ifdef USE_MEM_DC
	BitBlt(hdc, prcPaint->left, prcPaint->top, nClientWidth, nClientHeight, hdcMem, prcPaint->left, prcPaint->top, SRCCOPY);
	SelectBitmap(hdcMem, hbmpSafe);
	DeleteDC(hdcMem);
	DeleteBitmap(hbmpMem);
#endif

	if (bSizeChanged)
		RedrawWindow(m_hwnd, NULL, NULL, RDW_FRAME | RDW_INVALIDATE);
}
Пример #25
0
	void CContainerUI::EndDown()
	{
		SIZE sz = GetScrollPos();
		sz.cy = GetScrollRange().cy;
		SetScrollPos(sz);
	}
Пример #26
0
BOOL CBigScrollView::OnScroll(UINT nScrollCode, UINT nPos, BOOL bDoScroll)
{
	// calc new x position
	int x = GetScrollPos(SB_HORZ);
	int xOrig = x;

	switch (LOBYTE(nScrollCode))
	{
		case SB_TOP:
			x = 0;
			break;
		case SB_BOTTOM:
			x = INT_MAX;
			break;
		case SB_LINEUP:
			x -= m_lineDev.cx;
			break;
		case SB_LINEDOWN:
			x += m_lineDev.cx;
			break;
		case SB_PAGEUP:
			x -= m_pageDev.cx;
			break;
		case SB_PAGEDOWN:
			x += m_pageDev.cx;
			break;
		case SB_THUMBTRACK:
		{
			SCROLLINFO si;
			si.fMask = SIF_TRACKPOS;
			si.cbSize = sizeof(SCROLLINFO);
			GetScrollInfo(SB_HORZ,&si,SIF_TRACKPOS);
			x = si.nTrackPos;
			break;
		}
	}

	// calc new y position
	int y = GetScrollPos(SB_VERT);
	int yOrig = y;

	switch (HIBYTE(nScrollCode))
	{
		case SB_TOP:
			y = 0;
			break;
		case SB_BOTTOM:
			y = INT_MAX;
			break;
		case SB_LINEUP:
			y -= m_lineDev.cy;
			break;
		case SB_LINEDOWN:
			y += m_lineDev.cy;
			break;
		case SB_PAGEUP:
			y -= m_pageDev.cy;
			break;
		case SB_PAGEDOWN:
			y += m_pageDev.cy;
			break;
		case SB_THUMBTRACK:
		{
			SCROLLINFO si;
			si.fMask = SIF_TRACKPOS;
			si.cbSize = sizeof(SCROLLINFO);
			GetScrollInfo(SB_VERT,&si,SIF_TRACKPOS);
			y = si.nTrackPos;
			break;
		}
	}

	BOOL bResult = OnScrollBy(wxSize(x - xOrig, y - yOrig), bDoScroll);
	if (bResult && bDoScroll)
		UpdateWindow();

	return bResult;
}
Пример #27
0
	void CContainerUI::EndRight()
	{
		SIZE sz = GetScrollPos();
		sz.cx = GetScrollRange().cx;
		SetScrollPos(sz);
	}
Пример #28
0
void CHTMLListCtrl::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar) 
{
	//nPos is not valid in case of THUMB type msgs see below url
	//http://support.microsoft.com/kb/q152252/

	int nScrollPos = GetScrollPos(SB_VERT);
	int nLimit = GetScrollLimit(SB_VERT);

	int nScroll = nLimit;

	int SCROLL_AMT_Y = 50;

	switch(nSBCode) {
		case SB_LINEUP:      // Scroll up.      
		case SB_PAGEUP:
			if(nScrollPos <= 0)
			{
				return;
			}
			nScroll = min(nScrollPos,SCROLL_AMT_Y);
			SetScrollPos(SB_VERT,nScrollPos - nScroll);
			break;   
		case SB_LINEDOWN:   // Scroll down.
		case SB_PAGEDOWN:
			if(nScrollPos >= nLimit)
			{
				return;
			}
			nScroll = min(nScroll-nScrollPos,SCROLL_AMT_Y);
			SetScrollPos(SB_VERT,nScrollPos + nScroll);
		    break;
		case SB_THUMBPOSITION:
			{
				HWND hWndScroll;
				if ( pScrollBar == NULL )
					hWndScroll = m_hWnd;
				else
					hWndScroll = pScrollBar->m_hWnd;
				
				SCROLLINFO info;
				info.cbSize = sizeof(SCROLLINFO);
				info.fMask = SIF_TRACKPOS;
				::GetScrollInfo(hWndScroll, SB_VERT, &info);
				
				nPos = info.nTrackPos;

				int nScr = nScrollPos - nPos;
				
				SetScrollPos(SB_VERT,nPos);
			}
			break;
		case SB_THUMBTRACK:
			{
				HWND hWndScroll;
				if ( pScrollBar == NULL )
					hWndScroll = m_hWnd;
				else
					hWndScroll = pScrollBar->m_hWnd;
				
				SCROLLINFO info;
				info.cbSize = sizeof(SCROLLINFO);
				info.fMask = SIF_TRACKPOS;
				::GetScrollInfo(hWndScroll, SB_VERT, &info);
				
				nPos = info.nTrackPos;

				int nScr = nScrollPos - nPos;
				
				SetScrollPos(SB_VERT,nPos,FALSE);
			}
			break;
	}	
	
	Invalidate();
	UpdateWindow();	
	CWnd::OnVScroll(nSBCode, nPos, pScrollBar);
}
Пример #29
0
BOOL CScrollView::OnScroll( UINT nScrollCode, UINT nPos, BOOL bDoScroll )
/***********************************************************************/
{
    CRect rectClient;
    GetClientRect( &rectClient );

    BOOL    bHasX = m_totalDev.cx > rectClient.Width();
    BOOL    bHasY = m_totalDev.cy > rectClient.Height();
    
    int nHorzPos = GetScrollPos( SB_HORZ );
    switch( LOBYTE( nScrollCode ) ) {
    case SB_LEFT:
        nHorzPos = 0;
        break;
    case SB_LINELEFT:
        nHorzPos -= m_lineDev.cx;
        break;
    case SB_LINERIGHT:
        nHorzPos += m_lineDev.cx;
        break;
    case SB_PAGELEFT:
        nHorzPos -= m_pageDev.cx;
        break;
    case SB_PAGERIGHT:
        nHorzPos += m_pageDev.cx;
        break;
    case SB_RIGHT:
        nHorzPos = m_totalDev.cx;
        break;
    case SB_THUMBPOSITION:
        nHorzPos = nPos;
        break;
    case SB_THUMBTRACK:
        nHorzPos = nPos;
        break;
    }
    
    int nVertPos = GetScrollPos( SB_VERT );
    switch( HIBYTE( nScrollCode ) ) {
    case SB_BOTTOM:
        nVertPos = m_totalDev.cy;
        break;
    case SB_LINEDOWN:
        nVertPos += m_lineDev.cy;
        break;
    case SB_LINEUP:
        nVertPos -= m_lineDev.cy;
        break;
    case SB_PAGEDOWN:
        nVertPos += m_pageDev.cy;
        break;
    case SB_PAGEUP:
        nVertPos -= m_pageDev.cy;
        break;
    case SB_THUMBPOSITION:
        nVertPos = nPos;
        break;
    case SB_THUMBTRACK:
        nVertPos = nPos;
        break;
    case SB_TOP:
        nVertPos = 0;
        break;
    }
    if( nVertPos < 0 ) {
        nVertPos = 0;
    }

    return( OnScrollBy( CSize( nHorzPos - GetScrollPos( SB_HORZ ),
                               nVertPos - GetScrollPos( SB_VERT ) ), bDoScroll ) );
}
Пример #30
0
LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)//视窗讯息处理程式
{
	//CS_视窗类别样式
	//CW_建立视窗
	//DT_绘制文字
	//IDI_图示ID
	//IDC_游标ID
	//MB_讯息方块
	//SND_声音
	//WM_视窗讯息
	//WS_视窗样式
	HDC hdc;
	PAINTSTRUCT ps;
	//	RECT rect;

	static int cxChar, cxCaps, cyChar,cyClient,iVscrollPos,iVscrollMax;
	int i,y;
	TCHAR szBuffer[10];
	TEXTMETRIC tm;
	switch (message)
	{
	case WM_CREATE:
		hdc = GetDC(hwnd);

		GetTextMetrics(hdc, &tm);
		cxChar = tm.tmAveCharWidth;
	//	cxCaps = (tm.tmPitchAndFamily & 1 ? 3 : 2)*cxChar/2;150%倍
		cxCaps = (tm.tmPitchAndFamily & 1 ? 3 : 2)*cxChar/2;
		cyChar = tm.tmHeight + tm.tmExternalLeading;
		ReleaseDC(hwnd, hdc);
		SetScrollRange(hwnd, SB_VERT, 0, NUMLINES - 1, FALSE);
		SetScrollPos(hwnd, SB_VERT, iVscrollPos, TRUE);
		return 0;
	case WM_SIZE:
	/*	iVscrollMax = max(0, NUMLINES - cyClient / cyChar);
		SetScrollRange(hwnd, SB_VERT, 0, iVscrollMax, true);*/
		cyClient = HIWORD(lParam);
		return 0;
	case WM_VSCROLL:
		switch (LOWORD(wParam))
		{
		case SB_LINEUP:
			iVscrollPos -= 1;
			break;;
		case SB_LINEDOWN:
			iVscrollPos += 1;
			break;
		case SB_PAGEUP:
			iVscrollPos -= cyClient / cyChar;
			break;
		case SB_PAGEDOWN:
			iVscrollPos += cyClient / cyChar;
			break;
		case SB_THUMBPOSITION:
			iVscrollPos = HIWORD(wParam);
			break;
		default:
			break;
		}
		iVscrollPos = max(0, min(iVscrollPos, NUMLINES - 1));
		if (iVscrollPos!=GetScrollPos(hwnd,SB_VERT))
		{
			SetScrollPos(hwnd, SB_VERT,iVscrollPos, TRUE);
			InvalidateRect(hwnd, NULL, TRUE);
		}
		return 0;
	case WM_PAINT:
		hdc = BeginPaint(hwnd, &ps);
		for (i = 0; i < NUMLINES; i++)
		{
			y = cyChar*(i - iVscrollPos);
			TextOut(hdc, 0, y, sysmetrics[i].szLabel,
				lstrlen(sysmetrics[i].szLabel));

			TextOut(hdc, 22 * cxCaps, y, sysmetrics[i].szDesc, lstrlen(sysmetrics[i].szDesc));
			SetTextAlign(hdc, TA_RIGHT | TA_TOP);
			int ilenth = wsprintf(szBuffer, TEXT("%5d"), GetSystemMetrics(sysmetrics[i].Index));
			TextOut(hdc, 22 * cxCaps + 40 * cxChar, y, szBuffer, ilenth);
			SetTextAlign(hdc, TA_LEFT | TA_TOP);
		}
		EndPaint(hwnd, &ps);
		return 0;
	case WM_DESTROY:
		PostQuitMessage(0);
		return 0;
	}
	//视窗讯息处理程式不予处理的所有讯息提供内定处理
	return DefWindowProc(hwnd, message, wParam, lParam);
}