void CHoverButton::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) { // TODO: Add your code to draw the specified item CDC *pDC=CDC::FromHandle(lpDrawItemStruct->hDC); CPoint point(0,0); CGumpPtr pDib = m_pDib[NORMAL]; UINT state = lpDrawItemStruct->itemState; if (!IsCheckbox()) { if (state & ODS_DISABLED) pDib = m_pDib[NORMAL]; else if (state & ODS_SELECTED) pDib = m_pDib[PRESSED]; else if (m_bHover) pDib = m_pDib[HOVER]; } else { if (m_bClick) pDib = m_pDib[PRESSED]; } if (pDib) pDib->DrawTransparent(pDC, CPoint(0,0), RGB(255,255,255)); CString strText; GetWindowText(strText); CRect rcItem(lpDrawItemStruct->rcItem); if (lpDrawItemStruct->itemState & ODS_SELECTED) rcItem += CPoint(2,2); SetTextColor(lpDrawItemStruct->hDC, m_bHover ? RGB(255,255,0) : RGB(255,255,255)); DrawText(lpDrawItemStruct->hDC, strText, strText.GetLength(), &rcItem, DT_CENTER | DT_VCENTER | DT_SINGLELINE); }
int CHoverButton::GetGumpID(STATE state) { CGumpPtr pDib = GetGump(state); if (pDib) return pDib->GetGumpID(); return -1; }
void CGumpBorder::SetGump(CGumpPtr pGump, bool bUpdateRect) { // ASSERT(pGump); for (int i = 0; i < NUM_PART; i++) { m_pGumpB[i] = NULL; m_sizeGumpB[i].SetSize(0,0); } if (!pGump) return; int iGumpID = pGump->GetGumpID(); int iWidth = 0, iHeight = 0; CGumpEditorDoc* pDoc = GfxGetGumpDocument(); m_pGumpB[LT] = pGump; m_sizeGumpB[LT] = pGump->GetDimensions(); for (int i = 1; i < NUM_PART; i++) { m_pGumpB[i] = pDoc->LoadGump(iGumpID+i); if (!m_pGumpB[i]) continue; m_sizeGumpB[i] = m_pGumpB[i]->GetDimensions(); if (i < LC) iWidth += m_sizeGumpB[i].cx; if (i % LC == 0) iHeight += m_sizeGumpB[i].cy; } if (!bUpdateRect) return; CRect rect = GetRect(); SetRect(rect.left,rect.top,rect.left+iWidth,rect.top+iHeight); }
long CGumpEditorView::AddControl(WPARAM wParam, LPARAM lParam) { // Creates a new control on the screen, caught from the // drop event from the toolbar control UINT nType = wParam; CPoint point(lParam>>16,lParam&0xffff); CGumpPtr pGump = GetDocument()->GetSelectedGump(); if (!pGump) return 0; CGumpControlTypeDlg dlg; if (IDOK != dlg.DoModal()) return 0; int controlType = dlg.GetControlType(); CDiagramEntity* obj=NULL; if (controlType==dlg.PICTURE) { obj = new CGumpPicture(pGump); } else if (controlType==dlg.BORDER) { obj = new CGumpBorder(pGump); } else if (controlType==dlg.PAPERDOLL) { obj = new CGumpPaperdoll(pGump); } else if (controlType==dlg.BUTTON) { CGumpPtr pGump2 = GetDocument()->FindGump(pGump->GetGumpID()+1,pGump->GetWidth(),pGump->GetHeight()); obj = new CGumpButton(pGump,pGump,pGump2 ? pGump2 : pGump); } else if (controlType==dlg.CHECKBOX) { CGumpPtr pGump2 = GetDocument()->FindGump(pGump->GetGumpID()+1,pGump->GetWidth(),pGump->GetHeight()); obj = new CGumpCheckbox(pGump, pGump2); } else if (controlType==dlg.RADIO) { CGumpPtr pGump2 = GetDocument()->FindGump(pGump->GetGumpID()+1,pGump->GetWidth(),pGump->GetHeight()); obj = new CGumpRadio(pGump, pGump2); } if (!obj) return 0; CSize size = obj->GetRect().Size(); CRect rect(point,point+size); m_editor.AdjustRect(rect); obj->SetRect(rect); m_editor.UnselectAll(); m_editor.SelectObject( obj, TRUE); m_editor.AddObject( obj ); return 0; }
void CGumpButton::SetGump(STATE state, CGumpPtr pGump) { //ASSERT(pGump); m_pGump[state] = pGump; if (NORMAL==state && pGump) { CRect rect = GetRect(); CSize size = pGump->GetDimensions(); SetConstraints(size,size); SetRect(rect.left,rect.top,rect.left+size.cx,rect.top+size.cy); } }
CGumpPicture::CGumpPicture(CGumpPtr pGump) { SetGump(pGump); SetTitle("Picture"); SetType("picture"); CString strName; strName.Format("picture_%x", pGump ? pGump->GetGumpID() : 0); SetName(strName); AddPropertyPage( &m_page ); }
CGumpBorder::CGumpBorder(CGumpPtr pGump) : CGumpPicture(NULL) { SetGump(pGump); SetTitle("border"); SetType("border"); CString strName; strName.Format("border_%x", pGump ? pGump->GetGumpID() : 0); SetName(strName); //AddPropertyPage( &m_page ); }
CGumpButton::CGumpButton(CGumpPtr pNormal, CGumpPtr pHover, CGumpPtr pPressed) { //ASSERT(pNormal); SetGump(pNormal, pHover, pPressed); SetTitle("button"); SetType("button"); CString strName; strName.Format("button_%x", pNormal ? pNormal->GetGumpID() : 0); SetName(strName); AddPropertyPage( &m_page ); }
CGumpRadio::CGumpRadio(CGumpPtr pNormal, CGumpPtr pChecked, int iGroupID, bool bCheck) : CGumpCheckbox(pNormal,pChecked,bCheck) { // SetGump(pNormal, pChecked); SetTitle("radio"); SetType("radio"); CString strName; strName.Format("radio_%x", pNormal ? pNormal->GetGumpID() : 0); SetName(strName); SetGroupID(iGroupID); AddPropertyPage( &m_page ); }
CGumpPicture::CGumpPicture(CGumpPtr pGump, TYPE eType, DWORD hueId) { SetGump(pGump); SetTitle("Picture"); SetType("picture"); CString strName; strName.Format("picture_%x", pGump ? pGump->GetGumpID() : 0); SetName(strName); SetPictureType(eType); SetHueId(hueId); AddPropertyPage( &m_page ); }