Example #1
0
/*++

Routine Name:

    CDocPropPage::SendNotify

Routine Description:

    Call the OnNotify() method in the relevant control handler in the collection.

Arguments:

    hDlg - Handle of property page.
    pNMhdr - Windows Notify structure that was passed with the windows message WM_NOTIFY.

Return Value:

    HRESULT
    S_OK - On success
    E_*  - On error

--*/
HRESULT
CDocPropPage::SendNotify(
    __in CONST HWND   hDlg,
    __in CONST NMHDR* pNMhdr
    )
{
    //
    // Use the wParam as the index into the control map and
    // inform the control of an activation
    //
    HRESULT hr = S_OK;

    UIControlMap* pComponents = NULL;

    if (SUCCEEDED(hr = GetUIComponents(&pComponents)) &&
        SUCCEEDED(hr = CHECK_POINTER(pComponents, E_POINTER)))
    {
        try
        {
            CUIControl* pControl = (*pComponents)[pNMhdr->idFrom];
            if (SUCCEEDED(hr = CHECK_POINTER(pControl, E_POINTER)))
            {
                hr = pControl->OnNotify(hDlg, pNMhdr);
            }
        }
        catch (exception& DBG_ONLY(e))
        {
            ERR(e.what());
            hr = E_FAIL;
        }
    }

    ERR_ON_HR(hr);
    return hr;
}
Example #2
0
DWORD_PTR CUIComboBox::GetItemData(int nItem)
{
	if( m_items.GetSize() == 0 )
	{
		return NULL;
	}

	if( nItem < 0 || nItem >= (int)m_items.GetSize())
	{
		return NULL;
	}

	CUIControl* pControl = static_cast<CUIControl*>(m_items[nItem]);
	if (pControl == NULL)
	{
		return NULL;
	}
	IListItemUI* pListItem = static_cast<IListItemUI*>(pControl->GetInterface(_T("ListItem")));
	
	if( pListItem == NULL )
	{
		return NULL;
	}

	return pListItem->GetItemData();
}
Example #3
0
/*++

Routine Name:

    CDocPropPage::SendCommand

Routine Description:

    Call the OnCommand() method in the relevant control handler in the collection.

Arguments:

    hDlg - Handle of property page.
    wParam - Windows WPARAM value passed with the windows message WM_COMMAND.

Return Value:

    HRESULT
    S_OK - On success
    E_*  - On error

--*/
HRESULT
CDocPropPage::SendCommand(
    __in CONST HWND   hDlg,
    __in CONST WPARAM wParam
    )
{
    //
    // Use the wParam as the index into the control map and
    // inform the control that generated the command
    //
    HRESULT hr = S_OK;

    UIControlMap* pComponents = NULL;

    if (SUCCEEDED(hr = GetUIComponents(&pComponents)) &&
        SUCCEEDED(hr = CHECK_POINTER(pComponents, E_POINTER)))
    {
        try
        {
            CUIControl* pControl = (*pComponents)[LOWORD(wParam)];
            if (SUCCEEDED(hr = CHECK_POINTER(pControl, E_POINTER)))
            {
                hr = pControl->OnCommand(hDlg, HIWORD(wParam));
            }
        }
        catch (exception& DBG_ONLY(e))
        {
            ERR(e.what());
            hr = E_FAIL;
        }
    }

    ERR_ON_HR(hr);
    return hr;
}
Example #4
0
bool CUIComboBox::Activate()
{
   if( !CUIControl::Activate() ) return false;
   m_uButtonState |= UISTATE_PUSHED | UISTATE_CAPTURED;

   if (m_pWindow) return true;
   m_pWindow = new CUIComboBoxWnd;

   SIZE szAvailable = { 0, 30 };
    m_szDropBox.cy = 0;
   for( int i = 0; i < m_items.GetSize(); i++ )
   {
	   CUIControl* pControl = static_cast<CUIControl*>(m_items[i]);

	   if (pControl)
	   {
		   SIZE size = pControl->EstimateSize(szAvailable);
		   if (m_nItemHeight < size.cy)
		   {
				m_szDropBox.cy += size.cy;
		   }
		   else
		   {
				m_szDropBox.cy += m_nItemHeight;

				CUIListLabelElement* pLabel = dynamic_cast<CUIListLabelElement*>(pControl);
				if (pLabel)
				{
					pLabel->SetHeight(m_nItemHeight);
				}

		   }

	   }
   }
   m_szDropBox.cy += 6;

   if (m_szDropBox.cy > m_nDropBoxHeight)
   {
	   m_szDropBox.cy = m_nDropBoxHeight;

	   m_bIsHasVScroll = true;
   }

   m_pWindow->Init(this);
   if( m_pManager != NULL ) m_pManager->SendNotify(this, UI_NOTIFY_DROPDOWN);
   Invalidate();
   return true;
}
Example #5
0
/*++

Routine Name:

    CDocPropPage::PublishHelpToControls

Routine Description:

    Propagate any useful interfaces used in this class down to the collection of control handlers.
    This allows access to these helper interfaces in the control handlers classes.

Arguments:

    None

Return Value:

    HRESULT
    S_OK - On success
    E_*  - On error

--*/
HRESULT
CDocPropPage::PublishHelpToControls(
    VOID
    )
{
    ASSERTMSG(m_pDriverUIHelp != NULL, "NULL pointer to driver UI help interface.\n");
    ASSERTMSG(m_pOemCUIPParam != NULL, "NULL pointer to OEMCUIPPARAM structure.\n");
    ASSERTMSG(m_pUIProperties != NULL, "NULL pointer to CUIProperties.\n");

    HRESULT hr = S_OK;

    if (SUCCEEDED(hr = CHECK_POINTER(m_pDriverUIHelp, E_PENDING)) &&
        SUCCEEDED(hr = CHECK_POINTER(m_pOemCUIPParam, E_PENDING)) &&
        SUCCEEDED(hr = CHECK_POINTER(m_pUIProperties, E_PENDING)))
    {
        try
        {
            //
            // Iterate over all controls and report the helper interfaces
            //
            if (!m_UIControls.empty())
            {
                UIControlMap::iterator iterUIComponents = m_UIControls.begin();

                while (iterUIComponents != m_UIControls.end())
                {
                    CUIControl* pControl = iterUIComponents->second;

                    if (SUCCEEDED(hr = CHECK_POINTER(pControl, E_POINTER)) &&
                        SUCCEEDED(hr = pControl->SetPrintOemDriverUI(m_pDriverUIHelp)) &&
                        SUCCEEDED(hr = pControl->SetUIProperties(m_pUIProperties)) &&
                        SUCCEEDED(hr = pControl->SetOemCUIPParam(m_pOemCUIPParam)))
                    {
                        iterUIComponents++;
                    }
                }

            }
        }
        catch (exception& DBG_ONLY(e))
        {
            ERR(e.what());
            hr = E_FAIL;
        }
    }

    ERR_ON_HR(hr);
    return hr;
}
Example #6
0
CStdString CUIComboBox::GetSubItemText( UINT auIndex )
{
	if( auIndex < 0 || auIndex >= (int)m_items.GetSize())
	{
		return _T("");
	}

	CUIControl* lpControl = static_cast<CUIControl*>(m_items[auIndex]);
	if (lpControl == NULL)
	{
		lpControl->GetText();
		return _T("");
	}
	return lpControl->GetText();
}
Example #7
0
/*++

Routine Name:

    CDocPropPage::SendSetActive

Routine Description:

    Call the OnActivate() method in all control handlers in the collection.

Arguments:

    hDlg - Handle of property page.

Return Value:

    HRESULT
    S_OK - On success
    E_*  - On error

--*/
HRESULT
CDocPropPage::SendSetActive(
    __in CONST HWND   hDlg
    )
{
    //
    // Use the wParam as the index into the control map and
    // inform the control of an activation
    //
    HRESULT hr = S_OK;

    UIControlMap* pComponents = NULL;

    if (SUCCEEDED(hr = GetUIComponents(&pComponents)) &&
        SUCCEEDED(hr = CHECK_POINTER(pComponents, E_POINTER)))
    {
        try
        {
            UIControlMap::iterator iterUIComponents = pComponents->begin();

            while (iterUIComponents != pComponents->end())
            {
                CUIControl* pControl = iterUIComponents->second;
                if (SUCCEEDED(hr = CHECK_POINTER(pControl, E_POINTER)))
                {
                    if (FAILED(hr = pControl->OnActivate(hDlg)))
                    {
                        break;
                    }
                }

                iterUIComponents++;
            }
        }
        catch (exception& DBG_ONLY(e))
        {
            ERR(e.what());
            hr = E_FAIL;
        }
    }

    ERR_ON_HR(hr);
    return hr;
}
Example #8
0
bool CUIComboBox::SetItemData(int nItem, DWORD_PTR dwData)
{
	if( nItem < 0 || nItem >= (int)m_items.GetSize())
	{
		return false;
	}

	CUIControl* pControl = static_cast<CUIControl*>(m_items[nItem]);
	if (pControl == NULL)
	{
		return false;
	}
	IListItemUI* pListItem = static_cast<IListItemUI*>(pControl->GetInterface(_T("ListItem")));

	if( pListItem == NULL )
	{
		return false;
	}

	return pListItem->SetItemData(dwData);
}
Example #9
0
bool CUIComboBox::SetCurSel(int iIndex)
{
   if( iIndex == m_iCurSel ) return true;
   if( m_iCurSel >= 0 ) {
      CUIControl* pControl = static_cast<CUIControl*>(m_items[m_iCurSel]);
      IListItemUI* pListItem = static_cast<IListItemUI*>(pControl->GetInterface(_T("ListItem")));
      if( pListItem != NULL ) pListItem->Select(false);
      m_iCurSel = -1;
   }
   if( m_items.GetSize() == 0 ) return false;
   if( iIndex < 0 ) iIndex = 0;
   if( iIndex >= m_items.GetSize() ) iIndex = m_items.GetSize() - 1;
   CUIControl* pControl = static_cast<CUIControl*>(m_items[iIndex]);
   if( !pControl->IsVisible() ) return false;
   if( !pControl->IsEnabled() ) return false;
   IListItemUI* pListItem = static_cast<IListItemUI*>(pControl->GetInterface(_T("ListItem")));
   if( pListItem == NULL ) return false;
   m_iCurSel = iIndex;
   pControl->SetFocus();
   pListItem->Select(true);

   CUIContainer* pContainer = dynamic_cast<CUIContainer*>(pListItem->GetOwner());
   if (pContainer)
   {
	   RECT rcItem = pControl->GetPos();
	   RECT rcList = pContainer->GetPos();
	   int iPos = pContainer->GetScrollPos();
	   if( rcItem.top < rcList.top || rcItem.bottom > rcList.bottom )
	   {
		   int dx = 0;
		   if( rcItem.top < rcList.top ) dx = rcItem.top - rcList.top;
		   if( rcItem.bottom > rcList.bottom ) dx = rcItem.bottom - rcList.bottom;
			pContainer->SetScrollPos(pContainer->GetScrollPos() + dx);
	   }

   }

   Invalidate();
   return true;
}
Example #10
0
void CUIComboBox::DoPaint(HDC hDC, const RECT& rcPaint)
{
   // Paint the nice frame
   int cy = m_rcItem.bottom - m_rcItem.top;
   ::SetRect(&m_rcButton, m_rcItem.right - cy, m_rcItem.top, m_rcItem.right, m_rcItem.bottom);
   RECT rcText = { m_rcItem.left + 5, m_rcItem.top, m_rcButton.left + 1, m_rcItem.bottom };

   UINT uState = m_uButtonState;
   if( IsFocused() ) uState |= UISTATE_FOCUSED;
   if( !IsEnabled() ) uState |= UISTATE_DISABLED;


	RECT rcPadding = { 0 };

   // Paint dropdown button
   if (m_pImageOwner != NULL)
   {
	   RECT rcImage = {0};
	   int nWidth = m_pImageOwner->GetWidth() / 4;
	   int nHeight = m_pImageOwner->GetHeight();

	   // Draw frame and body
	   if( (uState & UISTATE_DISABLED) != 0 ) {
		   RECT rcTemp = {nWidth *3, 0, nWidth * 4, nHeight};
		   rcImage = rcTemp;
	   }
	   else if( (uState & UISTATE_PUSHED) != 0 ) {
		   RECT rcTemp ={nWidth *2, 0, nWidth * 3, nHeight};
		   rcImage = rcTemp;
	   }
	   else if( (uState & UISTATE_HOT) != 0 ) {
		   RECT rcTemp ={nWidth *1, 0, nWidth * 2, nHeight};
		   rcImage = rcTemp;
	   }
	   else {
		   RECT rcTemp ={nWidth *0, 0, nWidth * 1, nHeight};
		   rcImage = rcTemp;
	   }

	   CUIBlueRenderEngine::DoFillRect(hDC, m_pManager, m_rcItem, rcImage, m_pImageOwner);

   }
   else
   {
	   CUIBlueRenderEngine::DoPaintButton(hDC, m_pManager, m_rcItem, uState, NULL, 0);
   }


   if (m_sText.GetLength() > 0)
   {
	   UITYPE_COLOR clrText;
	   if( (m_uButtonState & UISTATE_DISABLED) != 0 ) {
		   clrText = UICOLOR_BUTTON_TEXT_DISABLED;  
	   }
	   else if( (m_uButtonState & UISTATE_PUSHED) != 0 ) {
		   clrText = UICOLOR_BUTTON_TEXT_PUSHED;
	   }
	   else {
		   clrText = UICOLOR_BUTTON_TEXT_NORMAL;
	   }

	   RECT rcText = m_rcItem;
	   ::InflateRect(&rcText, -1, -1);
	   rcText.left += rcPadding.left;
	   rcText.top += rcPadding.top;
	   rcText.right -= rcPadding.right;
	   rcText.bottom -= rcPadding.bottom;

	   int nLinks = 0;

	   CUIBlueRenderEngine::DoPaintPrettyText(hDC, m_pManager, rcText, m_sText, clrText, UICOLOR__INVALID, NULL, nLinks, 0);
   }

   // Paint dropdown edit box
   ::InflateRect(&rcText, -1, -1);
   if( m_iCurSel >= 0 ) {
      CUIControl* pControl = static_cast<CUIControl*>(m_items[m_iCurSel]);
      IListItemUI* pElement = static_cast<IListItemUI*>(pControl->GetInterface(_T("ListItem")));
      if( pElement != NULL ) {
         // Render item with specific draw-style
		  int nLinks = 0;
		  CUIBlueRenderEngine::DoPaintPrettyText(hDC, m_pManager, rcText, pControl->GetText(), UICOLOR_CONTROL_TEXT_NORMAL, UICOLOR__INVALID, NULL, nLinks, DT_SINGLELINE | DT_VCENTER);
      }
      else {
         //// Allow non-listitems to render as well.
         RECT rcOldPos = pControl->GetPos();
         pControl->SetPos(rcText);
         pControl->DoPaint(hDC, rcText);
         pControl->SetPos(rcOldPos);
      }
   }
}
Example #11
0
CStdString CUIComboBox::GetText() const
{
   if( m_iCurSel < 0 ) return _T("");
   CUIControl* pControl = static_cast<CUIControl*>(m_items[m_iCurSel]);
   return pControl->GetText();
}
Example #12
0
void CUIVerticalLayout::SetPos(const CUIRect& rc)
{
    CUIRect rcTemp = rc;
	CUIControl::SetPos(rc);
	rcTemp = m_rcItem;

	//
	// 调整内边距
	//

	rcTemp.left += m_rcInset.left;
	rcTemp.top += m_rcInset.top;
	rcTemp.right -= m_rcInset.right;
	rcTemp.bottom -= m_rcInset.bottom;
	
	if( m_items.GetSize() == 0) {
		ProcessScrollBar(rcTemp, 0, 0);
		return;
	}

	//
	// 如果有滚动条,减去滚动条的宽度
	//
	
	if(m_pVerticalScrollBar && m_pVerticalScrollBar->IsVisible()) 
		rcTemp.right -= m_pVerticalScrollBar->GetFixedWidth();

	if(m_pHorizontalScrollBar && m_pHorizontalScrollBar->IsVisible()) 
		rcTemp.bottom -= m_pHorizontalScrollBar->GetFixedHeight();

	//
	// Determine the minimum size
	//

	SIZE szAvailable = { rcTemp.right - rcTemp.left, rcTemp.bottom - rcTemp.top };
	if( m_pHorizontalScrollBar && m_pHorizontalScrollBar->IsVisible() ) 
		szAvailable.cx += m_pHorizontalScrollBar->GetScrollRange();

	int nAdjustables = 0; //要调整控件的个数
	int cyFixed = 0;	  //控件固定的宽度
	int nEstimateNum = 0; //调整控件的个数

	for( int it1 = 0; it1 < m_items.GetSize(); it1++ ) {
		CUIControl* pControl = static_cast<CUIControl*>(m_items[it1]);
		
		//
		// 控件不可见不进行处理
		//
		
		if(!pControl->IsVisible()) 
			continue;
		
		//
		// 控件为float类型的不进行处理
		//
		
		if(pControl->IsFloat()) 
			continue;

		SIZE sz = pControl->EstimateSize(szAvailable);
		if(sz.cy == 0) {
			
			//
			// 高度等于0需要我们来计算
			//
			
			nAdjustables++;
		}else{
			
			//
			// 不能超出控件的设置的最小和最大值
			//
			
			if( sz.cy < pControl->GetMinHeight() ) 
				sz.cy = pControl->GetMinHeight();
			if( sz.cy > pControl->GetMaxHeight() ) 
				sz.cy = pControl->GetMaxHeight();
		}
		
		//
		// 加上下外边距
		//
		
		cyFixed += sz.cy + pControl->GetPadding().top + pControl->GetPadding().bottom;
		nEstimateNum++;
	}
	
	//
	// 加上子控件之间的额外距离
	//
	
	cyFixed += (nEstimateNum - 1) * m_iChildPadding;

	//
	// Place elements
	//

	int cyNeeded = 0;
	int cyExpand = 0;
	
	//
	// 计算要调整的每个控件的平均高度
	//
	
	if( nAdjustables > 0 ) 
		cyExpand = MAX(0, (szAvailable.cy - cyFixed) / nAdjustables);

	//
	// Position the elements
	// 减去滚动条的位置
	//

	SIZE szRemaining = szAvailable;
	int iPosY = rcTemp.top;
	if(m_pVerticalScrollBar && m_pVerticalScrollBar->IsVisible()) {
		iPosY -= m_pVerticalScrollBar->GetScrollPos();
	}

	int iPosX = rcTemp.left;
	if(m_pHorizontalScrollBar && m_pHorizontalScrollBar->IsVisible()) {
		iPosX -= m_pHorizontalScrollBar->GetScrollPos();
	}

	int iAdjustable = 0;
	int cyFixedRemaining = cyFixed;
	for( int it2 = 0; it2 < m_items.GetSize(); it2++ ) {
		CUIControl* pControl = static_cast<CUIControl*>(m_items[it2]);
		if( !pControl->IsVisible() )
			continue;
		if( pControl->IsFloat() ) {
			SetFloatPos(it2);
			continue;
		}

		RECT rcPadding = pControl->GetPadding();
		szRemaining.cy -= rcPadding.top;
		CUISize sz = pControl->EstimateSize(szRemaining);
		if(sz.cy == 0){
			iAdjustable++;
			
			//
			// 赋平均值
			//
			
			sz.cy = cyExpand;
			if( iAdjustable == nAdjustables ) {

				//
				// Distribute remaining to last element (usually round-off left-overs)
				//

				sz.cy = MAX(0, szRemaining.cy - rcPadding.bottom - cyFixedRemaining);
			} 
			
			//
			// 不能超过控件的最大与最小值
			//
			
			if( sz.cy < pControl->GetMinHeight() ) sz.cy = pControl->GetMinHeight();
			if( sz.cy > pControl->GetMaxHeight() ) sz.cy = pControl->GetMaxHeight();
		}else{
			
			//
			// 固定高度的控件
			//
			
			if( sz.cy < pControl->GetMinHeight() ) sz.cy = pControl->GetMinHeight();
			if( sz.cy > pControl->GetMaxHeight() ) sz.cy = pControl->GetMaxHeight();
			cyFixedRemaining -= sz.cy;
		}
		
		//
		// 调整宽度的值
		//
		
		sz.cx = pControl->GetFixedWidth();
		if( sz.cx == 0 ) sz.cx = szAvailable.cx - rcPadding.left - rcPadding.right;
		if( sz.cx < 0 ) sz.cx = 0;
		if( sz.cx < pControl->GetMinWidth() ) sz.cx = pControl->GetMinWidth();
		if( sz.cx > pControl->GetMaxWidth() ) sz.cx = pControl->GetMaxWidth();
		
		//
		// 生成并设置新的POS
		//
		
		CUIRect rcCtrl(iPosX + rcPadding.left, iPosY + rcPadding.top, iPosX + rcPadding.left + sz.cx, 
            iPosY + sz.cy + rcPadding.top + rcPadding.bottom);
		pControl->SetPos(rcCtrl);
		
		//
		// 处理下ChildPadding
		//
		
		iPosY += sz.cy + m_iChildPadding + rcPadding.top + rcPadding.bottom;
		cyNeeded += sz.cy + rcPadding.top + rcPadding.bottom;
		szRemaining.cy -= sz.cy + m_iChildPadding + rcPadding.bottom;
	}
	cyNeeded += (nEstimateNum - 1) * m_iChildPadding;

	//
	// Process the scrollbar
	//

	ProcessScrollBar(rcTemp, 0, cyNeeded);
}
Example #13
0
void CUIListBox::OnFrameRender(const Matrix& mTransform, double fTime, float fElapsedTime)
{
	CUIControl::OnFrameRender(mTransform,fTime,fElapsedTime);

	CONTROL_STATE iState = GetState();

	// Render the text
	if(m_Items.size() > 0)
	{
		CRect<int> rc(0,0,m_rcText.getWidth(),m_nTextHeight);
		rc.bottom = rc.top+m_nTextHeight;

		m_StyleSelected.Blend(iState, fElapsedTime);
		m_StyleItem1.Blend(iState, fElapsedTime);
		m_StyleItem2.Blend(iState, fElapsedTime);
		for(int i = m_ScrollBar.GetTrackPos(); i < (int)m_Items.size(); ++i)
		{
			if(rc.bottom > m_rcText.getHeight())
				break;

			UIListBoxItem *pItem = m_Items[i];

			// Determine if we need to render this item with the
			// selected element.
			bool bSelectedStyle = false;

			if(!(m_dwStyle & MULTISELECTION) && i == m_nSelected)
				bSelectedStyle = true;
			else
				if(m_dwStyle & MULTISELECTION)
				{
					if(IsPressed() &&
						((i >= m_nSelected && i < m_nSelStart) ||
						(i <= m_nSelected && i > m_nSelStart)))
						bSelectedStyle = m_Items[m_nSelStart]->bSelected;
					else
						if(pItem->bSelected)
							bSelectedStyle = true;
				}

				if(bSelectedStyle)
				{
					m_StyleSelected.draw(rc.getRECT(), pItem->wstrText.c_str());
				}
				else
				{
					if (i%2==0)
					{
						m_StyleItem1.draw(rc.getRECT(), pItem->wstrText.c_str());
					}
					else
					{
						m_StyleItem2.draw(rc.getRECT(), pItem->wstrText.c_str());
					}
				}
				rc.offset(0, m_nTextHeight);
		}
	}

	// render controls
	for(size_t i=0;i<m_Controls.size();++i)
	{
		CUIControl* pControl = m_Controls[i];   

		if (pControl->IsFocus())
		{
			continue;
		}
		pControl->OnFrameRender(m_mWorld,fTime,fElapsedTime);
	}
	for(size_t i=0;i<m_Controls.size();++i)
	{
		CUIControl* pControl = m_Controls[i];   

		if (pControl->IsFocus())
		{
			pControl->OnFrameRender(m_mWorld,fTime, fElapsedTime);
		}
	}
}