コード例 #1
0
ファイル: menu.c プロジェクト: TheCodeJanitor/collisionWM
void MenuButtonRelease(XEvent *event)
{
  StampTime(event->xbutton.time);
  if(ButtonCount(event->xbutton.state)>1) {
    if(SpecialProc != NULL) SpecialProc(event, selectedMenuItem);
  } else if(!(keepIt & KeepNonTransMenu)) keepIt &= ~KeepMenuActive;
}
コード例 #2
0
ファイル: HYButtonBar.cpp プロジェクト: mdsmith/OCLHYPHY
//__________________________________________________________________
 _HYRect	_HYButtonBar::_SuggestDimensions (void)
 {
  	_HYRect res = {10,10,10,10,HY_COMPONENT_NO_SCROLL};
 	int w = ButtonCount(), 
 		h=1;
 	
 	if (w>BarWidth())
 	{
 		w = BarWidth();
 		h = ButtonCount()/w+(ButtonCount()%w>0);
 	}
 	
 	res.right =  w*(buttonDim+2*HY_BUTTONBAR_BORDER);
  	res.bottom = h*(buttonDim+2*HY_BUTTONBAR_BORDER);
	return res;
 }
コード例 #3
0
CMessageBox::~CMessageBox()
{
	for(unsigned int i=0;i<ButtonCount();i++){
		deleteZ(m_arBInfo[i].m_pWnd);
	}
	deleteZ(m_pStaticText);
	deleteZ(m_pStaticIcon);
}
コード例 #4
0
int CMessageBox::IndexOf(UINT id)
{
	for(unsigned int i=0;i<ButtonCount();i++){
		if(m_arBInfo[i].m_id==id){
			return (signed)i;
		}
	}
	return -1;
}
コード例 #5
0
void CMessageBox::AddButton(const CString & strCaption, UINT id, bool bEnabled/*=true*/)
{
#ifdef _DEBUG
	ASSERT(-1==IndexOf(id));
	for(unsigned int i=0;i<ButtonCount();i++){
		if(0==m_arBInfo[i].m_strCaption.Compare(strCaption)){
			ASSERT(FALSE);
		}
	}
#endif
	if(bEnabled){
		if(IDCANCEL==id || (IDOK==id && -1==m_nEscapeButton)){
			m_nEscapeButton=ButtonCount();
		} 
	}
	CButtonInfo info(id,bEnabled,strCaption);
	m_arBInfo.Add(info);
}
コード例 #6
0
void CMessageBox::OnFontChange() 
{
	CDialog::OnFontChange();
	
	m_pFont=CFont::FromHandle(HFONT(GetStockObject(DEFAULT_GUI_FONT)));	
	for(unsigned int i=0;i<ButtonCount();i++){
		Button(i).SetFont(m_pFont);
	}
	m_pStaticText->SetFont(m_pFont);
}
コード例 #7
0
ファイル: menu.c プロジェクト: TheCodeJanitor/collisionWM
void SelectItem(MenuItem *item, unsigned int state)
{
  if(selectedMenuItem){
    DrawBevel(selectedMenuItem->win, 0, 0,
              selectedMenuItem->menu->width - 2 * MENUBORDERW - 1,
              selectedMenuItem->menu->ItemHeight - 1, MENUBORDERW,
              TheScreen.MenuBackGC, TheScreen.MenuBackGC);
  }
  selectedMenuItem=item;
  if(selectedMenuItem){
    if((selectedMenuItem->y+selectedMenuItem->menu->y
        + selectedMenuItem->menu->ItemHeight) >= TheScreen.height){
      XWarpPointer(disp,None,None,0,0,0,0,0,-MENUSCROLLHEIGHT*\
                           selectedMenuItem->menu->ItemHeight);
      selectedMenuItem->menu->y -= MENUSCROLLHEIGHT 
	                           * selectedMenuItem->menu->ItemHeight;
      XMoveWindow(disp, selectedMenuItem->menu->win, selectedMenuItem->menu->x,
		  selectedMenuItem->menu->y);
    }
    if((selectedMenuItem->y+selectedMenuItem->menu->y)<=0){
      XWarpPointer(disp,None,None,0,0,0,0,0,MENUSCROLLHEIGHT*\
                                  selectedMenuItem->menu->ItemHeight);
      selectedMenuItem->menu->y += MENUSCROLLHEIGHT
	                           * selectedMenuItem->menu->ItemHeight;
      XMoveWindow(disp, selectedMenuItem->menu->win, selectedMenuItem->menu->x,
		  selectedMenuItem->menu->y);
    }
    if(ButtonCount(state)>0) MenuDontKeepItAnymore();
    if(selectedMenuItem->menu != activemen){
      DeleteSubMenus(selectedMenuItem->menu);
      activemen = selectedMenuItem->menu;
    }
    if(selectedMenuItem->type == I_SUBMENU) {
      long int x,y;
      Menu *men;
      men=selectedMenuItem->data;
      men->parent=selectedMenuItem->menu;
      x=selectedMenuItem->menu->x+selectedMenuItem->menu->width*0.8;
      if((x+men->width)>TheScreen.width) x=selectedMenuItem->menu->x-men->width;
      if(x<30) x=30;
      y=selectedMenuItem->menu->y+selectedMenuItem->y;
      if(y>(((signed long int)TheScreen.height)-((signed long int)men->height-\
                                         1))) y=TheScreen.height-men->height-1;
      if(y<0) y=0;
      MapMenu(men, x, y);
    }
    DrawBevel(item->win, 0, 0, item->menu->width - 2 * MENUBORDERW - 1,
              item->menu->ItemHeight - 1, MENUBORDERW,
              TheScreen.MenuShadowGC, TheScreen.MenuLightGC);
  }
}
コード例 #8
0
ファイル: winmenu.c プロジェクト: TheCodeJanitor/collisionWM
void WinMenuButtonRelease(XEvent *event)
{
  StampTime(event->xbutton.time);
  if(ButtonCount(event->xbutton.state)>1) {
    switch(event->xbutton.button){
      case Button1: ButtonAction(0); break;
      case Button2: ButtonAction(1); break;
      case Button3: ButtonAction(2); break;
      case Button4: break;
      case Button5: break;
    }
  } else {
    StopWinMenu(selectedHex, event);
  }
  
}
コード例 #9
0
void CMessageBox::SetDefaultButton(UINT nIndex)
{
	ASSERT(nIndex<ButtonCount());
	m_nDefaultButton=nIndex; 
}
コード例 #10
0
BOOL CMessageBox::OnInitDialog() 
{
	// Create buttons as required
	ASSERT(ButtonCount()>0);

	SetWindowText(m_strCaption);

	if(-1==m_nEscapeButton||IDCANCEL!=m_arBInfo[m_nEscapeButton].m_id){
		// No cancel button
		CMenu *pMenu=GetSystemMenu(FALSE);
		pMenu->RemoveMenu(SC_CLOSE,MF_BYCOMMAND);
	}

	CDialog::OnInitDialog();
	CDC *pDC=GetDC();
	CFont *pOldFont=pDC->SelectObject(m_pFont);
	TEXTMETRIC tm;
	pDC->GetTextMetrics(&tm);
	
	int cxDLU=tm.tmAveCharWidth;
	int cyDLU=tm.tmHeight;
	int nButtonWidth= (60*cxDLU)/4;		// width of a button
	int nButtonHeight=(14*cyDLU)/8;		// height of a button
	int cxButtonSep=   (4*cxDLU)/4;		// horizontal button separation
	int cxTextButtonSep=(10*cxDLU)/4;	// horizontal separation between text and icon
	int cyTextButtonSep=(10*cyDLU)/8;	// vertical separation between text and buttons
	int cxBorder=   (7*cxDLU)/4;		// horizontal separation between buttons and border
	int cyBorder=   (7*cyDLU)/8;		// vertical separation between buttons and border
	int cxIcon=GetSystemMetrics(SM_CXICON); // width of an icon
	int cyIcon=GetSystemMetrics(SM_CYICON); // height of an icon
	int nTotalButtonWidth=(ButtonCount()*nButtonWidth)+(ButtonCount()-1)*cxButtonSep;
	int cxText=max(50,nTotalButtonWidth-(m_hIcon?(cxIcon+cxTextButtonSep):0));
	int cyText=0;

	// Size the text control according to the maximum line length
	LPCTSTR c=m_strText;
	while(*c){
		PTCHAR d=_tcsstr(c,_T("\r\n"));
		int nCount;
		if(d){
			*d=_TCHAR('\0');
			nCount=d-c;
		} else {\
			nCount=_tcslen(c);
		}
		cxText=max(cxText,pDC->GetTextExtent(c,nCount).cx);
		cyText+=tm.tmHeight;
		if(d){
			*d=_TCHAR('\r');
			c=d+2;
		} else {
			break;
		}
	}
	
	// If vertical extent of text is less than that of the icon, difference between the two
	int cyTextExtra= (m_hIcon && cyText<cyIcon)?cyIcon-cyText:0;

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

	// Set dialog box size
	{
		int cx=(2*cxBorder)+cxText+cxButtonSep+2*GetSystemMetrics(SM_CXDLGFRAME);
		if(m_hIcon){
			cx+=cxIcon+cxTextButtonSep;
		}
		int cy=(2*cyBorder)+cyText+cyTextExtra+cyTextButtonSep+nButtonHeight+
   			GetSystemMetrics(SM_CYCAPTION)+2*GetSystemMetrics(SM_CYDLGFRAME);
		UINT flags=SWP_NOMOVE;
		if(!m_bTopMost){
			flags|=SWP_NOZORDER;
		}
		SetWindowPos(&wndTopMost,0,0,cx,cy,flags);
	}

	// Create a static control for the icon
	if(m_hIcon){
		m_pStaticIcon=new CStatic;
		m_pStaticIcon->Create(NULL,WS_CHILD|WS_VISIBLE|SS_ICON,
			CRect(cxBorder,cyBorder,cxBorder+cxIcon,cyBorder+cyIcon), this);
		m_pStaticIcon->SetIcon(m_hIcon);
	}

	// Create a static control for the text
	{
		int cx=m_hIcon?cxIcon+cxTextButtonSep:0;
		m_pStaticText=new CStatic;
		m_pStaticText->Create(m_strText,WS_CHILD|WS_VISIBLE|m_nJustify|SS_NOPREFIX,
			CRect(cxBorder+cx,cyBorder+cyTextExtra/2,cxBorder+cx+cxText,cyBorder+cyText+cyTextExtra/2), this);
		m_pStaticText->SetFont(m_pFont);
	}

	// Create the buttons
	CRect rcClient;
	GetClientRect(rcClient);
	CRect rect;
	rect.left=(rcClient.Width()-nTotalButtonWidth)/2;
	rect.right=rect.left+nButtonWidth;
	rect.bottom=rcClient.bottom-cyBorder;
	rect.top=rect.bottom-nButtonHeight;

	ASSERT(m_nDefaultButton<ButtonCount());

	for(unsigned i=0;i<ButtonCount();i++){
		CButton *pWnd=new CButton;
		m_arBInfo[i].m_pWnd=pWnd;
		UINT id=m_arBInfo[i].m_id;
		UINT style=WS_CHILD|WS_VISIBLE|WS_TABSTOP;
		if(!m_arBInfo[i].m_bEnabled){
			style|=WS_DISABLED;
		}
		if(0==i){
			style|=WS_GROUP;
		}
		style|=(m_nDefaultButton==i)?BS_DEFPUSHBUTTON:BS_PUSHBUTTON;
			
		pWnd->Create(m_arBInfo[i].m_strCaption,style,rect,this,id);
		pWnd->SetFont(m_pFont);
		if(m_nDefaultButton==i){
			pWnd->SetFocus();
		}
		rect.left+=nButtonWidth+cxButtonSep;
		rect.right+=nButtonWidth+cxButtonSep;
	}

	m_nFocusButton=m_nDefaultButton;
	m_bDialogCreated=true;
	return FALSE;
}