FTetrisField::FTetrisField(int rows, int cols, FColor *color, FVertex *position, float width, float height, float scale, bool d3, float xrot, float yrot, float zrot):FGLDrawObject(color, new FVertex(position->GetX() * scale, position->GetY() * scale, position->GetZ()), xrot, yrot, zrot, true, false, 0, 0, 0) { this->rows = rows; this->cols = cols; this->height = height; this->width = width; this->scale = scale; this->border = .015; this->startx = -GetTotalWidth() / 2; this->starty = GetTotalHeight() / 2; delete position; this->d3 = d3; }
int COXMultiComboBox::AdjustToFitSize() { int nResult; if(m_bFitToSize) { int nTotalWidth=GetTotalWidth()+2*GetSystemMetrics(SM_CXBORDER); int nTotalHeight=GetTotalHeight(); int nBorderHeight=GetSystemMetrics(SM_CYBORDER); int nScrollbarHeight=GetSystemMetrics(SM_CYHSCROLL); CRect rcDrop; GetDroppedControlRect(&rcDrop); if((nTotalHeight > rcDrop.Height()-2*nBorderHeight) || ((nTotalWidth > rcDrop.Width()) && (nTotalHeight > rcDrop.Height()-nScrollbarHeight-2*nBorderHeight))) { nTotalWidth+=::GetSystemMetrics(SM_CXVSCROLL); } int nScreenWidth=::GetSystemMetrics(SM_CXSCREEN); nTotalWidth=nTotalWidth>nScreenWidth ? nScreenWidth : nTotalWidth; nResult=SetDroppedWidth(nTotalWidth); } else nResult=SetDroppedWidth(1); if(nResult!=CB_ERR) { // ... To indicate that the scrollbars has to be re-adjusted m_fSizeChanged = TRUE; // Redraws the listbox if(::IsWindow(m_ComboLBox.m_hWnd)) { m_ComboLBox.RedrawWindow(NULL,NULL, RDW_ERASE|RDW_INVALIDATE|RDW_ERASENOW|RDW_UPDATENOW|RDW_FRAME); } } return nResult; }
// This message is handle to get the HWND of the listbox of the combobox // as there is no otherway to get it(refer to Q65881, Q131845 in Knowledge Base) // The listbox handle is needed to set the scrollbar to it if needed, and to // handle its WM_HSCROLL message. HBRUSH COXMultiComboBox::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) // --- In : pDC : device context (See standard help for detaled info) // pWnd : Pointer Cwnd obejct of the window whose background // has to be painted. // nCtlColor : Type of the control // --- Out : // --- Returns : Brush to supply to paint the background // --- Effect : The listbox's HWND is got and sunclassed to COXComboLBox // window object. The listbox style is modified to // have WS_HSCROLL. The horizontal extent of the listbox is // set and scrollbars are shown are hided depending on the // width and height. Scroll range for horizantal scrollbar // is set and also m_NumCharsPerPage is set. { HBRUSH hbr = CComboBox::OnCtlColor(pDC, pWnd, nCtlColor); // Handle only if the type of control is Listbox only if ((nCtlColor == CTLCOLOR_LISTBOX) && m_fSizeChanged) { // ... To stop this code run unneccessorily m_fSizeChanged = FALSE; if(m_ComboLBox.GetSafeHwnd()==NULL) { m_ComboLBox.SubclassWindow(pWnd->GetSafeHwnd()); m_ComboLBox.ModifyStyle(0,WS_HSCROLL); TEXTMETRIC tm; GetTextMetrics(pDC->m_hDC,&tm); m_nLineWidth = tm.tmAveCharWidth; } int nTotalWidth = GetTotalWidth(); // ... Sets horizontal extent to total width m_ComboLBox.SetHorizontalExtent(nTotalWidth); CRect rcDrop; GetDroppedControlRect(&rcDrop); int iTotalItemHeight = 0; for (int i = 0; i < m_ComboLBox.GetCount(); i++) iTotalItemHeight += m_ComboLBox.GetItemHeight(i); if (rcDrop.Height() < iTotalItemHeight || m_bFitToSize) m_ComboLBox.AdjustHScroll(); if(GetStyle()&CBS_DROPDOWN) { CRect rcWnd; m_ComboLBox.GetWindowRect(&rcWnd); m_ComboLBox.MoveWindow(&rcWnd,TRUE); } if(m_ComboLBox.m_fHorzScrollVisible) { CRect rcClient; m_ComboLBox.GetClientRect(&rcClient); m_nPageWidth = rcClient.Width(); // setting sroll info SCROLLINFO si; si.cbSize = sizeof(si); si.nPos = 0; si.nMin = 0; si.nMax = nTotalWidth; si.nPage = m_nPageWidth; si.fMask = SIF_PAGE | SIF_RANGE | SIF_POS ; m_ComboLBox.SetScrollInfo(SB_HORZ,&si,TRUE); m_ComboLBox.SendMessage(WM_HSCROLL,SB_TOP,0L); } m_ComboLBox.RedrawWindow(NULL,NULL,RDW_INVALIDATE|RDW_FRAME); } return hbr; }
void FTetrisField::InternDraw(bool standalone){ glPushMatrix(); glTranslatef(startx, starty, 0); DrawCubes(); float depth = this->GetBoxWidth()<this->GetBoxHeight()?-this->GetBoxWidth():-this->GetBoxHeight(); if(color) glColor4f(this->color->GetR() * 1.5, this->color->GetG() * 1.5,/* this->color->GetB() * 1.5*/1, this->color->GetA()); else MessageBox(0, "no color in ftetrisfield", "", 0); glPushMatrix(); /*if(d3){ glBegin(GL_QUADS); }else{ glBegin(GL_LINES); }*/ glBegin(GL_QUADS); for(int i = 1; i < rows; i ++){ glVertex3f(0, (float)i / (float)rows * -GetTotalHeight() + GetBorder() / 2, 0);//FRONT glVertex3f(GetTotalWidth(), (float)i / (float)rows * -GetTotalHeight() + GetBorder() / 2, 0); glVertex3f(GetTotalWidth(), (float)i / (float)rows * -GetTotalHeight() - GetBorder() / 2, 0); glVertex3f(0, (float)i / (float)rows * -GetTotalHeight() - GetBorder() / 2, 0); if(d3){ glVertex3f(GetTotalWidth(), (float)i / (float)rows * -GetTotalHeight() + GetBorder() / 2, depth);//BACK glVertex3f(0, (float)i / (float)rows * -GetTotalHeight() + GetBorder() / 2, depth); glVertex3f(0, (float)i / (float)rows * -GetTotalHeight() - GetBorder() / 2, depth); glVertex3f(GetTotalWidth(), (float)i / (float)rows * -GetTotalHeight() - GetBorder() / 2, depth); glVertex3f(0, (float)i / (float)rows * -GetTotalHeight() + GetBorder() / 2, depth);//LEFT glVertex3f(0, (float)i / (float)rows * -GetTotalHeight() + GetBorder() / 2, 0); glVertex3f(0, (float)i / (float)rows * -GetTotalHeight() - GetBorder() / 2, 0); glVertex3f(0, (float)i / (float)rows * -GetTotalHeight() - GetBorder() / 2, depth); glVertex3f(GetTotalWidth(), (float)i / (float)rows * -GetTotalHeight() + GetBorder() / 2, 0);//RIGHT glVertex3f(GetTotalWidth(), (float)i / (float)rows * -GetTotalHeight() + GetBorder() / 2, depth); glVertex3f(GetTotalWidth(), (float)i / (float)rows * -GetTotalHeight() - GetBorder() / 2, depth); glVertex3f(GetTotalWidth(), (float)i / (float)rows * -GetTotalHeight() - GetBorder() / 2, 0); glVertex3f(0, (float)i / (float)rows * -GetTotalHeight() + GetBorder() / 2, depth);//TOP glVertex3f(GetTotalWidth(), (float)i / (float)rows * -GetTotalHeight() + GetBorder() / 2, depth); glVertex3f(GetTotalWidth(), (float)i / (float)rows * -GetTotalHeight() + GetBorder() / 2, 0); glVertex3f(0, (float)i / (float)rows * -GetTotalHeight() + GetBorder() / 2, 0); glVertex3f(0, (float)i / (float)rows * -GetTotalHeight() - GetBorder() / 2, 0);//BOTTOM glVertex3f(GetTotalWidth(), (float)i / (float)rows * -GetTotalHeight() - GetBorder() / 2, 0); glVertex3f(GetTotalWidth(), (float)i / (float)rows * -GetTotalHeight() - GetBorder() / 2, depth); glVertex3f(0, (float)i / (float)rows * -GetTotalHeight() - GetBorder() / 2, depth); } /*glVertex3f(0, (float)i / (float)rows * -GetTotalHeight(), 0); glVertex3f(GetTotalWidth(), (float)i / (float)rows * -GetTotalHeight(), 0); if(d3){ glVertex3f(GetTotalWidth(), (float)i / (float)rows * -GetTotalHeight(), depth); glVertex3f(0, (float)i / (float)rows * -GetTotalHeight(), depth); }*/ } for(int i = 1; i < cols; i ++){ glVertex3f((float)i / (float)cols * GetTotalWidth() - GetBorder() / 2, 0, 0);//FRONT glVertex3f((float)i / (float)cols * GetTotalWidth() + GetBorder() / 2, 0, 0); glVertex3f((float)i / (float)cols * GetTotalWidth() + GetBorder() / 2, -GetTotalHeight(), 0); glVertex3f((float)i / (float)cols * GetTotalWidth() - GetBorder() / 2, -GetTotalHeight(), 0); if(d3){ glVertex3f((float)i / (float)cols * GetTotalWidth() + GetBorder() / 2, 0, depth);//BACK glVertex3f((float)i / (float)cols * GetTotalWidth() - GetBorder() / 2, 0, depth); glVertex3f((float)i / (float)cols * GetTotalWidth() - GetBorder() / 2, -GetTotalHeight(), depth); glVertex3f((float)i / (float)cols * GetTotalWidth() + GetBorder() / 2, -GetTotalHeight(), depth); glVertex3f((float)i / (float)cols * GetTotalWidth() - GetBorder() / 2, 0, depth);//LEFT glVertex3f((float)i / (float)cols * GetTotalWidth() - GetBorder() / 2, 0, 0); glVertex3f((float)i / (float)cols * GetTotalWidth() - GetBorder() / 2, -GetTotalHeight(), 0); glVertex3f((float)i / (float)cols * GetTotalWidth() - GetBorder() / 2, -GetTotalHeight(), depth); glVertex3f((float)i / (float)cols * GetTotalWidth() + GetBorder() / 2, 0, 0);//RIGHT glVertex3f((float)i / (float)cols * GetTotalWidth() + GetBorder() / 2, 0, depth); glVertex3f((float)i / (float)cols * GetTotalWidth() + GetBorder() / 2, -GetTotalHeight(), depth); glVertex3f((float)i / (float)cols * GetTotalWidth() + GetBorder() / 2, -GetTotalHeight(), 0); glVertex3f((float)i / (float)cols * GetTotalWidth() - GetBorder() / 2, 0, depth);//TOP glVertex3f((float)i / (float)cols * GetTotalWidth() + GetBorder() / 2, 0, depth); glVertex3f((float)i / (float)cols * GetTotalWidth() + GetBorder() / 2, 0, 0); glVertex3f((float)i / (float)cols * GetTotalWidth() - GetBorder() / 2, 0, 0); glVertex3f((float)i / (float)cols * GetTotalWidth() - GetBorder() / 2, -GetTotalHeight(), 0); glVertex3f((float)i / (float)cols * GetTotalWidth() + GetBorder() / 2, -GetTotalHeight(), 0); glVertex3f((float)i / (float)cols * GetTotalWidth() + GetBorder() / 2, -GetTotalHeight(), depth); glVertex3f((float)i / (float)cols * GetTotalWidth() - GetBorder() / 2, -GetTotalHeight(), depth); } /*glVertex3f((float)i / (float)cols * width * scale, 0, 0); glVertex3f((float)i / (float)cols * width * scale, - height * scale, 0); if(d3){ glVertex3f((float)i / (float)cols * width * scale, - height * scale, depth); glVertex3f((float)i / (float)cols * width * scale, 0, depth); }*/ } glEnd(); glPopMatrix(); if(color) glColor4f(this->color->GetR(), this->color->GetG(), this->color->GetB(), this->color->GetA()); glBegin(GL_QUADS); glVertex3f(-GetBorder() / 2, GetBorder() / 2, 0);//LEFTFRONT glVertex3f(GetBorder() / 2, GetBorder() / 2, 0); glVertex3f(GetBorder() / 2, -GetTotalHeight() - GetBorder() / 2, 0); glVertex3f(-GetBorder() / 2, -GetTotalHeight() - GetBorder() / 2, 0); glVertex3f(-GetBorder() / 2, GetBorder() / 2, 0);//TOPFRONT glVertex3f(GetTotalWidth() + GetBorder() / 2, GetBorder() / 2, 0); glVertex3f(GetTotalWidth() + GetBorder() / 2, -GetBorder() / 2, 0); glVertex3f(-GetBorder() / 2, -GetBorder() / 2, 0); glVertex3f(GetTotalWidth() - GetBorder() / 2, GetBorder() / 2, 0);//RIGHTFRONT glVertex3f(GetTotalWidth() + GetBorder() / 2, GetBorder() / 2, 0); glVertex3f(GetTotalWidth() + GetBorder() / 2, -GetTotalHeight() - GetBorder() / 2, 0); glVertex3f(GetTotalWidth() - GetBorder() / 2, -GetTotalHeight() - GetBorder() / 2, 0); glVertex3f(-GetBorder() / 2, -GetTotalHeight() + GetBorder() / 2, 0);//BOTTOM glVertex3f(GetTotalWidth() + GetBorder() / 2, -GetTotalHeight() + GetBorder() / 2, 0); glVertex3f(GetTotalWidth() + GetBorder() / 2, -GetTotalHeight() - GetBorder() / 2, 0); glVertex3f(-GetBorder() / 2, -GetTotalHeight() - GetBorder() / 2, 0); if(d3){ glVertex3f(-GetBorder() / 2, GetBorder() / 2, depth);//LEFTLEFT glVertex3f(-GetBorder() / 2, GetBorder() / 2, 0); glVertex3f(-GetBorder() / 2, -GetTotalHeight() - GetBorder() / 2, 0); glVertex3f(-GetBorder() / 2, -GetTotalHeight() - GetBorder() / 2, depth); glVertex3f(GetBorder() / 2, GetBorder() / 2, 0);//LEFTRIGHT glVertex3f(GetBorder() / 2, GetBorder() / 2, depth); glVertex3f(GetBorder() / 2, -GetTotalHeight() - GetBorder() / 2, depth); glVertex3f(GetBorder() / 2, -GetTotalHeight() - GetBorder() / 2, 0); glVertex3f(GetBorder() / 2, GetBorder() / 2, depth);//LEFTBACK glVertex3f(-GetBorder() / 2, GetBorder() / 2, depth); glVertex3f(-GetBorder() / 2, -GetTotalHeight() - GetBorder() / 2, depth); glVertex3f(GetBorder() / 2, -GetTotalHeight() - GetBorder() / 2, depth); glVertex3f(-GetBorder() / 2, GetBorder() / 2, depth);//TOPTOP glVertex3f(GetTotalWidth() + GetBorder() / 2, GetBorder() / 2, depth); glVertex3f(GetTotalWidth() + GetBorder() / 2, GetBorder() / 2, 0); glVertex3f(-GetBorder() / 2, GetBorder() / 2, 0); glVertex3f(-GetBorder() / 2, -GetBorder() / 2, 0);//TOPBOTTOM glVertex3f(GetTotalWidth() + GetBorder() / 2, -GetBorder() / 2, 0); glVertex3f(GetTotalWidth() + GetBorder() / 2, -GetBorder() / 2, depth); glVertex3f(-GetBorder() / 2, -GetBorder() / 2, depth); glVertex3f(GetTotalWidth() + GetBorder() / 2, GetBorder() / 2, depth);//TOPBACK glVertex3f(-GetBorder() / 2, GetBorder() / 2, depth); glVertex3f(-GetBorder() / 2, -GetBorder() / 2, depth); glVertex3f(GetTotalWidth() + GetBorder() / 2, - GetBorder() / 2, depth); glVertex3f(GetTotalWidth() + GetBorder() / 2, GetBorder() / 2, 0);//RIGHTRIGHT glVertex3f(GetTotalWidth() + GetBorder() / 2, GetBorder() / 2, depth); glVertex3f(GetTotalWidth() + GetBorder() / 2, -GetTotalHeight() - GetBorder() / 2, depth); glVertex3f(GetTotalWidth() + GetBorder() / 2, -GetTotalHeight() - GetBorder() / 2, 0); glVertex3f(GetTotalWidth() - GetBorder() / 2, GetBorder() / 2, depth);//RIGHTLEFT glVertex3f(GetTotalWidth() - GetBorder() / 2, GetBorder() / 2, 0); glVertex3f(GetTotalWidth() - GetBorder() / 2, -GetTotalHeight() - GetBorder() / 2, 0); glVertex3f(GetTotalWidth() - GetBorder() / 2, -GetTotalHeight() - GetBorder() / 2, depth); glVertex3f(GetTotalWidth() + GetBorder() / 2, GetBorder() / 2, depth);//RIGHTBACK glVertex3f(GetTotalWidth() - GetBorder() / 2, GetBorder() / 2, depth); glVertex3f(GetTotalWidth() - GetBorder() / 2, -GetTotalHeight() - GetBorder() / 2, depth); glVertex3f(GetTotalWidth() + GetBorder() / 2, -GetTotalHeight() - GetBorder() / 2, depth); glVertex3f(-GetBorder() / 2, -GetTotalHeight() + GetBorder() / 2, depth);//BOTTOMTOP glVertex3f(GetTotalWidth() + GetBorder() / 2, -GetTotalHeight() + GetBorder() / 2, depth); glVertex3f(GetTotalWidth() + GetBorder() / 2, -GetTotalHeight() + GetBorder() / 2, 0); glVertex3f(-GetBorder() / 2, -GetTotalHeight() + GetBorder() / 2, 0); glVertex3f(-GetBorder() / 2, -GetTotalHeight() - GetBorder() / 2, 0);//BOTTOMBOTTOM glVertex3f(GetTotalWidth() + GetBorder() / 2, -GetTotalHeight() - GetBorder() / 2, 0); glVertex3f(GetTotalWidth() + GetBorder() / 2, -GetTotalHeight() - GetBorder() / 2, depth); glVertex3f(-GetBorder() / 2, -GetTotalHeight() - GetBorder() / 2, depth); glVertex3f(GetTotalWidth() + GetBorder() / 2, -GetTotalHeight() + GetBorder() / 2, depth);//BOTTOMBACK glVertex3f(-GetBorder() / 2, -GetTotalHeight() + GetBorder() / 2, depth); glVertex3f(-GetBorder() / 2, -GetTotalHeight() - GetBorder() / 2, depth); glVertex3f(GetTotalWidth() + GetBorder() / 2, -GetTotalHeight() - GetBorder() / 2, depth); } glEnd(); /*if(d3){ glBegin(GL_QUADS); glVertex3f(0, 0, 0); glVertex3f(0, 0, depth); glVertex3f(GetTotalWidth(), 0, depth); glVertex3f(GetTotalWidth(), 0, 0); glVertex3f(0, 0, 0); glVertex3f(0, -GetTotalHeight(), 0); glVertex3f(0, -GetTotalHeight(), depth); glVertex3f(0, 0, depth); glVertex3f(0, -GetTotalHeight(), 0); glVertex3f(GetTotalWidth(), -GetTotalHeight(), 0); glVertex3f(GetTotalWidth(), -GetTotalHeight(), depth); glVertex3f(0, -GetTotalHeight(), depth); glVertex3f(GetTotalWidth(), 0, 0); glVertex3f(GetTotalWidth(), 0, depth); glVertex3f(GetTotalWidth(), -GetTotalHeight(), depth); glVertex3f(GetTotalWidth(), -GetTotalHeight(), 0); }else{ glBegin(GL_LINE_LOOP); glVertex3f(0, 0, 0); glVertex3f(width * scale, 0, 0); glVertex3f(width * scale, - height * scale, 0); glVertex3f(0, - height * scale, 0); }*/ //glEnd(); glPopMatrix(); }