예제 #1
0
void
TabDisplay::OnPaint(Canvas &canvas)
{
  canvas.Clear(COLOR_BLACK);
  canvas.Select(*look.button.font);

  const unsigned CaptionStyle = DT_CENTER | DT_NOCLIP
      | DT_WORDBREAK;

  const bool is_focused = !HasCursorKeys() || HasFocus();
  for (unsigned i = 0; i < buttons.size(); i++) {
    const TabButton &button = *buttons[i];

    const bool is_down = dragging && i == down_index && !drag_off_button;
    const bool is_selected = i == tab_bar.GetCurrentPage();

    canvas.SetTextColor(look.list.GetTextColor(is_selected, is_focused,
                                               is_down));
    canvas.SetBackgroundColor(look.list.GetBackgroundColor(is_selected,
                                                           is_focused,
                                                           is_down));

    const PixelRect &rc = GetButtonSize(i);
    PaintButton(canvas, CaptionStyle, button.caption, rc, button.bitmap,
                is_down, is_selected);
  }
}
BOOL CreateProgressDialog(HINSTANCE hInstance, HWND hWndParent) {
    HWND hDlg;
    RECT rcClient;
    HWND hBtnNo;
    SIZE sizeButtonN; 
    javacall_result res;

    hDlg = CreateDialog(hInstance, MAKEINTRESOURCE(IDD_INSTALL_PROGRESS),
                        hWndParent, ProgressDlgProc);

    if (!hDlg) {
        MessageBox(hWndParent, _T("Create install progress dialog failed!"),
                   g_szTitle, NULL);
        return FALSE;
    }

    // Get the dimensions of the parent window's client area
    GetClientRect(hWndParent, &rcClient); 

    // Set actual dialog size
    SetWindowPos(hDlg,
                 0, // ignored by means of SWP_NOZORDER
                 0, 0, // x, y
                 rcClient.right, rcClient.bottom, // w, h
                 SWP_NOZORDER | SWP_NOOWNERZORDER |
                     SWP_NOACTIVATE);

    PrintWindowSize(hDlg, _T("Progress dialog"));

    // Get handle to Cancel button (the Cancel button may be absent
    // on the dialog)
    hBtnNo = GetDlgItem(hDlg, IDCANCEL);

    if (hBtnNo) {
        sizeButtonN = GetButtonSize(hBtnNo);

        SetWindowPos(hBtnNo,
                     0, // ignored by means of SWP_NOZORDER
                     rcClient.right - sizeButtonN.cx,  // x
                     rcClient.bottom - sizeButtonN.cy, // y
                     sizeButtonN.cx, sizeButtonN.cy,   // w, h
                     SWP_NOZORDER | SWP_NOOWNERZORDER |
                         SWP_NOACTIVATE);


        PrintWindowSize(hBtnNo, _T("Cancel button"));
    }

    // IMPL_NOTE: dynamic positioning and resizing should be implemented
    //            for the rest controls of the dialog.

    g_hProgressDlg = hDlg;

    return TRUE;
}
예제 #3
0
int
TabDisplay::GetButtonIndexAt(RasterPoint p) const
{
  for (unsigned i = 0; i < GetSize(); i++) {
    const PixelRect &rc = GetButtonSize(i);
    if (rc.IsInside(p))
      return i;
  }

  return -1;
}
예제 #4
0
int CToolPopupPanel::GetHeight(int width)
{
	m_btn_col = width / TOOL_BUTTON_W;
	m_btn_col = (m_btn_col == 0) ? 1 : m_btn_col;

	int num_of_btn = GetButtonSize();
	int row = num_of_btn / m_btn_col;
	if((num_of_btn % m_btn_col) != 0)
		row++;
	return row * TOOL_BUTTON_H;
}
예제 #5
0
bool
TabDisplay::OnMouseMove(PixelScalar x, PixelScalar y, unsigned keys)
{
  if (!dragging)
    return false;

  const PixelRect rc = GetButtonSize(down_index);

  bool not_on_button = !rc.IsInside({ x, y });
  if (drag_off_button != not_on_button) {
    drag_off_button = not_on_button;
    Invalidate(rc);
  }
  return true;
}
예제 #6
0
HRESULT CMenuToolbarBase::GetSizes(SIZE* pMinSize, SIZE* pMaxSize, SIZE* pIntegralSize)
{
    if (pMinSize)
        *pMinSize = m_idealSize;
    if (pMaxSize)
        *pMaxSize = m_idealSize;
    if (pIntegralSize)
        *pIntegralSize = m_itemSize;

    if (m_hasSizes)
        return S_OK;

    TRACE("Sizes out of date, recalculating.\n");

    if (!m_hWnd)
    {
        return S_OK;
    }

    // Obtain the ideal size, to be used as min and max
    GetMaxSize(&m_idealSize);
    GetIdealSize((m_initFlags & SMINIT_VERTICAL) != 0, &m_idealSize);

    TRACE("Ideal Size: (%d, %d) for %d buttons\n", m_idealSize, GetButtonCount());

    // Obtain the button size, to be used as the integral size
    DWORD size = GetButtonSize();
    m_itemSize.cx = GET_X_LPARAM(size);
    m_itemSize.cy = GET_Y_LPARAM(size);
    m_hasSizes = TRUE;

    if (pMinSize)
        *pMinSize = m_idealSize;
    if (pMaxSize)
        *pMaxSize = m_idealSize;
    if (pIntegralSize)
        *pIntegralSize = m_itemSize;

    return S_OK;
}
예제 #7
0
HRESULT CMenuToolbarBase::SetPosSize(int x, int y, int cx, int cy)
{
    // Update the toolbar or pager to fit the requested rect
    // If we have a pager, set the toolbar height to the ideal height of the toolbar
    if (m_pager.m_hWnd)
    {
        SetWindowPos(NULL, x, y, cx, m_idealSize.cy, 0);
        m_pager.SetWindowPos(NULL, x, y, cx, cy, 0);
    }
    else
    {
        SetWindowPos(NULL, x, y, cx, cy, 0);
    }

    // In a vertical menu, resize the buttons to fit the width
    if (m_initFlags & SMINIT_VERTICAL)
    {
        DWORD btnSize = GetButtonSize();
        SetButtonSize(cx, GET_Y_LPARAM(btnSize));
    }

    return S_OK;
}
예제 #8
0
BOOL CMessageBox::OnInitDialog()
{
	__super::OnInitDialog();

	CRect rect(0, 0, 0, 0);

	//determine the required size of the message box
	CSize szText = GetTextSize(m_sMessage);
	CSize szIcon = GetIconSize(m_hIcon);
	CSize szButtons = GetButtonSize();

	CSize szIconText;
	szIconText.cx = szText.cx + szIcon.cx + ((szIcon.cx == 0) ? MESSAGEBOX_ICONMARGIN : (2*MESSAGEBOX_ICONMARGIN));
	szIconText.cy = max(szIcon.cy, szText.cy);

	rect.right = max(szButtons.cx, szIconText.cx);
	rect.right += 2*GetSystemMetrics(SM_CXBORDER);
	rect.right += 2*MESSAGEBOX_BORDERMARGINX;
	rect.bottom = szIconText.cy;
	rect.bottom += szButtons.cy;
	rect.bottom += 2*MESSAGEBOX_BORDERMARGINY + MESSAGEBOX_TEXTBUTTONMARGIN;
	rect.bottom += GetSystemMetrics(SM_CYCAPTION);
	rect.bottom += 2*GetSystemMetrics(SM_CYBORDER);

	MoveWindow(rect);
	CenterWindow();

	GetClientRect(rect);

	//now size and position the buttons as we need them
	ASSERT(!m_sButton1.IsEmpty());		//at least the first button must be there!
	if (m_sButton2.IsEmpty())
	{
		//only one button
		CRect rt;
		GetDlgItem(IDC_MESSAGEBOX_BUTTON1)->GetWindowRect(rt);
		ScreenToClient(rt);
		rt.MoveToX(rect.left + ((rect.Width() - m_szButtons.cx)/2));
		rt.MoveToY(rect.bottom - MESSAGEBOX_BORDERMARGINY - m_szButtons.cy);
		GetDlgItem(IDC_MESSAGEBOX_BUTTON1)->MoveWindow(rt);
		//hide the other two buttons
		GetDlgItem(IDC_MESSAGEBOX_BUTTON2)->ShowWindow(SW_HIDE);
		GetDlgItem(IDC_MESSAGEBOX_BUTTON3)->ShowWindow(SW_HIDE);
	}
	else if (m_sButton3.IsEmpty())
	{
		//two buttons
		CRect rt1;
		CRect rt2;
		GetDlgItem(IDC_MESSAGEBOX_BUTTON1)->GetWindowRect(rt1);
		ScreenToClient(rt1);
		GetDlgItem(IDC_MESSAGEBOX_BUTTON2)->GetWindowRect(rt2);
		ScreenToClient(rt2);
		rt1.MoveToX(rect.left + ((rect.Width() - m_szButtons.cx)/2));
		rt1.MoveToY(rect.bottom - MESSAGEBOX_BORDERMARGINY - m_szButtons.cy);
		rt2.MoveToX(rt1.right + MESSAGEBOX_BUTTONMARGIN);
		rt2.MoveToY(rect.bottom - MESSAGEBOX_BORDERMARGINY - m_szButtons.cy);
		GetDlgItem(IDC_MESSAGEBOX_BUTTON1)->MoveWindow(rt1);
		GetDlgItem(IDC_MESSAGEBOX_BUTTON2)->MoveWindow(rt2);
		//hide the third button
		GetDlgItem(IDC_MESSAGEBOX_BUTTON3)->ShowWindow(SW_HIDE);
	}
	else
	{
		//three buttons
		CRect buttonrect;
		GetDlgItem(IDC_MESSAGEBOX_BUTTON1)->GetWindowRect(buttonrect);
		CRect rt1;
		CRect rt2;
		CRect rt3;
		GetDlgItem(IDC_MESSAGEBOX_BUTTON1)->GetWindowRect(rt1);
		ScreenToClient(rt1);
		GetDlgItem(IDC_MESSAGEBOX_BUTTON2)->GetWindowRect(rt2);
		ScreenToClient(rt2);
		GetDlgItem(IDC_MESSAGEBOX_BUTTON3)->GetWindowRect(rt3);
		ScreenToClient(rt3);
		rt1.MoveToX(rect.left + ((rect.Width() - m_szButtons.cx)/2));
		rt1.MoveToY(rect.bottom - MESSAGEBOX_BORDERMARGINY - m_szButtons.cy);
		rt2.MoveToX(rt1.right + MESSAGEBOX_BUTTONMARGIN);
		rt2.MoveToY(rect.bottom - MESSAGEBOX_BORDERMARGINY - m_szButtons.cy);
		rt3.MoveToX(rt2.right + MESSAGEBOX_BUTTONMARGIN);
		rt3.MoveToY(rect.bottom - MESSAGEBOX_BORDERMARGINY - m_szButtons.cy);
		GetDlgItem(IDC_MESSAGEBOX_BUTTON1)->MoveWindow(rt1);
		GetDlgItem(IDC_MESSAGEBOX_BUTTON2)->MoveWindow(rt2);
		GetDlgItem(IDC_MESSAGEBOX_BUTTON3)->MoveWindow(rt3);
	}
	if (m_bShowCheck)
	{
		CRect rt;
		GetDlgItem(IDC_MESSAGEBOX_CHECKBOX)->GetWindowRect(rt);
		ScreenToClient(rt);
		rt.MoveToX(rect.left + MESSAGEBOX_BORDERMARGINX/*+ ((rect.Width() - szButtons.cx)/2)*/);
		rt.MoveToY(rect.bottom - MESSAGEBOX_BORDERMARGINY - szButtons.cy);
		GetDlgItem(IDC_MESSAGEBOX_CHECKBOX)->MoveWindow(rt);
		GetDlgItem(IDC_MESSAGEBOX_CHECKBOX)->ShowWindow(SW_SHOW);
	}
	else
		GetDlgItem(IDC_MESSAGEBOX_CHECKBOX)->ShowWindow(SW_HIDE);

	SetWindowPos(&CWnd::wndTopMost,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE);
	SetForegroundWindow();
	SetFocus(); //Just playing safe

	if (m_nDefButton == 1)
		GetDlgItem(IDC_MESSAGEBOX_BUTTON1)->SetFocus();
	if (m_nDefButton == 2)
		GetDlgItem(IDC_MESSAGEBOX_BUTTON2)->SetFocus();
	if (m_nDefButton == 3)
		GetDlgItem(IDC_MESSAGEBOX_BUTTON3)->SetFocus();

	return FALSE;  // return TRUE unless you set the focus to a control
	// EXCEPTION: OCX Property Pages should return FALSE
}
예제 #9
0
void CEditMultiLine::OnSize(UINT nType, int cx, int cy)
  {
	CDialog::OnSize(nType, cx, cy);

  if (m_ctlText.m_hWnd &&
      m_ctlCancel.m_hWnd &&
      m_ctlFunctionListButton.m_hWnd &&
      m_ctlCompleteFunctionButton.m_hWnd &&
      m_ctlGoToLineButton.m_hWnd &&
      m_ctlOK)
    {
    // move OK and Cancel buttons
    WINDOWPLACEMENT wndpl;
    int iHeight;
    int iWidth;
    int iBorder = 10;

    const int iButtonCount = 5; // how many buttons

    // -----------------------
    // where is OK button?
    GetButtonSize (m_ctlOK, iHeight, iWidth);

    int iTopOfRow = cy - iHeight - 10;

    // ------------------------

    // calculate gaps for middle buttons - I will assume all buttons are the same size here

    // gap (between OK and cancel buttons) will be the width of the dialog
    // less the gaps on the side of those buttons, less the width of the iButtonCount buttons themselves

    int iGap = cx - (iBorder * 2) - (iWidth * iButtonCount);

    // we need (iButtonCount - 1) gaps:  OK --1-- Functions --2-- Complete --3-- GoToLine --4-- Cancel
    iGap /= iButtonCount - 1;

    // -----------------------

    // OK button (1)
    ADJUST_BUTTON (m_ctlOK, 1);

    // Function list button (2)
    ADJUST_BUTTON (m_ctlFunctionListButton, 2);

    // Complete function name button (3)
    ADJUST_BUTTON (m_ctlCompleteFunctionButton, 3);

    // Go to Line button (4)
    ADJUST_BUTTON (m_ctlGoToLineButton, 4);

    // Cancel Button (5)
    ADJUST_BUTTON (m_ctlCancel, 5);

    // -----------------------
    // where is Cancel button now?
    m_ctlCancel.GetWindowPlacement (&wndpl);

    // move text to just above it
	  m_ctlText.MoveWindow(0, 0, cx, wndpl.rcNormalPosition.top - 10);
    }

  }
예제 #10
0
void CMuleToolbarCtrl::SetAllButtonsWidth()
{
	if (GetButtonCount() == 0)
		return;

	if (m_eLabelType == LabelsBelow)
	{
		CDC *pDC = GetDC();
		CFont *pFnt = GetFont();
		CFont *pOldFnt = pDC->SelectObject(pFnt);
		CRect r(0,0,0,0);

		// calculate the max. possible button-size
		int iCalcSize = 0;
		for (int i = 0; i < m_buttoncount ; i++)
		{
			if (!IsButtonHidden(IDC_TOOLBARBUTTON + i))
			{
				pDC->DrawText(TBStrings[i], -1, r, DT_SINGLELINE | DT_CALCRECT);
 				if (r.Width() > iCalcSize)
					iCalcSize = r.Width();
			}
		}
		iCalcSize += 10;

		pDC->SelectObject(pOldFnt);
		ReleaseDC(pDC);

		if (!thePrefs.GetUseReBarToolbar())
		{
			GetClientRect(&r);
			int bc = GetButtonCount();
			if (bc == 0)
				bc = 1;
			int iMaxPossible = r.Width() / bc;

			// if the buttons are to big, reduze their size
			if (iCalcSize > iMaxPossible)
				iCalcSize = iMaxPossible;
		}
		else
		{
			if (iCalcSize < 56)
				iCalcSize = 56;
			else if (iCalcSize > 72)
				iCalcSize = 72;
		}
		SetButtonWidth(iCalcSize, iCalcSize);
	}
	else
	{
		int iSmallIconsButtonHeight;
		if (theApp.m_ullComCtrlVer < MAKEDLLVERULL(6, 0, 0, 0)) {
			// Win98,WinME,Win2000: Comtrl32 prior to 6.0 cannot make a toolbar smaller than 22 pixels
			// in height and if it gets larger than 22 pixels the icons do not get centered vertically.
			iSmallIconsButtonHeight = 22;
		}
		else
			iSmallIconsButtonHeight = GetSystemMetrics(SM_CYSCREEN) <= 600 ? 16 : 28;

		if (m_eLabelType == NoLabels)
		{
			DWORD dwSize = GetButtonSize();
			int iFixedButtonWidth;
			int iFixedButtonHeight = HIWORD(dwSize);
			if (m_sizBtnBmp.cx == 16)
			{
				iFixedButtonWidth = 28;
				iFixedButtonHeight = iSmallIconsButtonHeight;
			}
			else
			{
				iFixedButtonWidth = 56;
			}

			// it seems that the control updates itself more properly, if 'SetButtonWidth' id called *before* 'SetButtonSize'
			SetButtonWidth(iFixedButtonWidth, iFixedButtonWidth);
			SetButtonSize(CSize(iFixedButtonWidth, iFixedButtonHeight));
		}
		else
		{
			int iFixedButtonHeight = 0;
			if (m_sizBtnBmp.cx == 16)
				iFixedButtonHeight = iSmallIconsButtonHeight;

			// it seems that the control updates itself more properly, if 'SetButtonWidth' id called *before* 'SetButtonSize'
			SetButtonWidth(0, 0);
			SetButtonSize(CSize(0, iFixedButtonHeight));
		}
	}
}
예제 #11
0
void CMuleToolbarCtrl::Dump()
{
	TRACE("---\n");
	CRect rcWnd;
	GetWindowRect(&rcWnd);
	TRACE("Wnd =%4d,%4d-%4d,%4d (%4d x %4d)\n", rcWnd.left, rcWnd.top, rcWnd.right, rcWnd.bottom, rcWnd.Width(), rcWnd.Height());

	CRect rcClnt;
	GetClientRect(&rcClnt);
	TRACE("Clnt=%4d,%4d-%4d,%4d (%4d x %4d)\n", rcClnt.left, rcClnt.top, rcClnt.right, rcClnt.bottom, rcClnt.Width(), rcClnt.Height());

	// Total size of all of the visible buttons and separators in the toolbar.
	CSize siz;
	GetMaxSize(&siz);
	TRACE("MaxSize=                  %4d x %4d\n", siz.cx, siz.cy);

	int iButtons = GetButtonCount();	// Count of the buttons currently in the toolbar.
	int iRows = GetRows();				// Number of rows of buttons in a toolbar with the TBSTYLE_WRAPABLE style
	int iMaxTextRows = GetMaxTextRows();// Maximum number of text rows that can be displayed on a toolbar button.
	TRACE("ButtonCount=%d  Rows=%d  MaxTextRows=%d\n", iButtons, iRows, iMaxTextRows);

	// Current width and height of toolbar buttons, in pixels.
	DWORD dwButtonSize = GetButtonSize();
	TRACE("ButtonSize=%dx%d\n", LOWORD(dwButtonSize), HIWORD(dwButtonSize));

	// Padding for a toolbar control.
	DWORD dwPadding = SendMessage(TB_GETPADDING);
	TRACE("Padding=%dx%d\n", LOWORD(dwPadding), HIWORD(dwPadding));

	DWORD dwBitmapFlags = GetBitmapFlags(); // TBBF_LARGE=0x0001
	TRACE("BitmapFlags=%u\n", dwBitmapFlags);

	// Bounding rectangle of a button in a toolbar.
	TRACE("ItemRects:");
	for (int i = 0; i < iButtons; i++)
	{
		CRect rcButton(0,0,0,0);
		GetItemRect(i, &rcButton);
		TRACE(" %2dx%2d", rcButton.Width(), rcButton.Height());
	}
	TRACE("\n");

	// Bounding rectangle for a specified toolbar button.
	TRACE("Rects    :");
	for (int i = 0; i < iButtons; i++)
	{
		CRect rcButton(0,0,0,0);
		GetRect(IDC_TOOLBARBUTTON + i, &rcButton);
		TRACE(" %2dx%2d", rcButton.Width(), rcButton.Height());
	}
	TRACE("\n");

	TRACE("Info     :");
	for (int i = 0; i < iButtons; i++)
	{
		TCHAR szLabel[256];
		TBBUTTONINFO tbi = {0};
		tbi.cbSize = sizeof(tbi);
		tbi.dwMask |= TBIF_BYINDEX | TBIF_COMMAND | TBIF_IMAGE | TBIF_LPARAM | TBIF_SIZE | TBIF_STATE | TBIF_STYLE | TBIF_TEXT;
		tbi.cchText = _countof(szLabel);
		tbi.pszText = szLabel;
		GetButtonInfo(i, &tbi);
		szLabel[_countof(szLabel) - 1] = _T('\0');
		TRACE(" %2d ", tbi.cx);
	}
	TRACE("\n");
}