BOOL CSelectBox::SetBitmap(UINT nResourceID, int nIndex, CString strType) { if(nIndex >= 0 && nIndex < (int)m_vecpImage.size()) { Image *&pImage = m_vecpImage[nIndex]; if(pImage != NULL) { delete pImage; pImage = NULL; } if(ImageFromIDResource(nResourceID, strType, pImage)) { m_vecsizeImage[nIndex].SetSize(pImage->GetWidth(), pImage->GetHeight()); UpdateControl(true); return true; } } else if(nIndex == -1 && (int)m_vecpImage.size() < m_nXCount * m_nYCount) { Image *pImage = NULL; if(ImageFromIDResource(nResourceID, strType, pImage)) { CSize sizeImage(pImage->GetWidth(), pImage->GetHeight()); m_vecpImage.push_back(pImage); m_vecsizeImage.push_back(sizeImage); UpdateControl(true); return true; } } return false; }
BOOL CSelectBox::SetBitmap(CString strImage, int nIndex) { if(nIndex >= 0 && nIndex < (int)m_vecpImage.size()) { Image *&pImage = m_vecpImage[nIndex]; if(pImage != NULL) { delete pImage; pImage = NULL; } if(DuiSystem::Instance()->LoadImageFile(strImage, m_bImageUseECM, pImage)) { m_vecsizeImage[nIndex].SetSize(pImage->GetWidth(), pImage->GetHeight()); UpdateControl(true); return true; } } else if(nIndex == -1 && (int)m_vecpImage.size() < m_nXCount * m_nYCount) { Image *pImage = NULL; if(DuiSystem::Instance()->LoadImageFile(strImage, m_bImageUseECM, pImage)) { CSize sizeImage(pImage->GetWidth(), pImage->GetHeight()); m_vecpImage.push_back(pImage); m_vecsizeImage.push_back(sizeImage); UpdateControl(true); return true; } } return false; }
// Hinzufügen einer Bitmap zur Toolbar, liefert Index des ersten Buttons der // Bitmap HRESULT CTRiASToolBar::AddBitmap (HINSTANCE hInst, UINT uiRsc, int nNumButtons, int *piOffset) { AFX_MANAGE_STATE(AfxGetModuleState()); ASSERT_VALID(this); ASSERT(::IsWindow(m_hWnd)); if (NULL != piOffset) *piOffset = -1; // für alle Fälle #if !defined(_USE_SEC_CLASSES) // Größen für das Control ausrechnen HBITMAP hBmp = NULL; if (NULL == hInst) hBmp = (HBITMAP)uiRsc; else { HRSRC hRsrcImageWell = ::FindResource(hInst, (LPCSTR)uiRsc, RT_BITMAP); if (hRsrcImageWell == NULL) return E_FAIL; // Bitmap not found hBmp = AfxLoadSysColorBitmap(hInst, hRsrcImageWell); } if (NULL == hBmp) return E_FAIL; // need complete bitmap size to determine size of images BITMAP bitmap; VERIFY(::GetObject(hBmp, sizeof(BITMAP), &bitmap)); int iWidth = bitmap.bmWidth / nNumButtons; int iHeight = bitmap.bmHeight; CSize sizeImage(iWidth, iHeight+1); CSize sizeButton(iWidth + 7, iHeight + 7); SetSizes(sizeButton, sizeImage); // Bitmap zu Control hinzufügen TBADDBITMAP tbab; tbab.hInst = NULL; tbab.nID = (UINT)hBmp; int iOffset = (int) DefWindowProc(TB_ADDBITMAP, (WPARAM)nNumButtons, (LPARAM)&tbab); if (NULL != piOffset) *piOffset = iOffset; return NOERROR; #else // einfach weiterreichen return m_pMainFrm -> AddBitmap (hInst, uiRsc, nNumButtons, piOffset); #endif // _USE_SEC_CLASSES }
void Slideshow::drawImage (GLuint tex, QImage image, GLfloat opacity) { if (opacity > 0.0) { glColor4f (1.0,1.0,1.0, opacity); glBindTexture (GL_TEXTURE_RECTANGLE, tex); glPushMatrix (); sizeImage (image); trect[1] = trect[3] = image.height(); trect[2] = trect[6] = image.width(); glTexCoordPointer (2, GL_FLOAT, 0, trect); glDrawArrays (GL_TRIANGLE_STRIP, 0, 4); glPopMatrix (); } }
// Support loading a toolbar from a resource BOOL CFlatToolbar::LoadToolBar(LPCTSTR lpszResourceName) { ASSERT_VALID(this); ASSERT(lpszResourceName != NULL); // determine location of the bitmap in resource fork HINSTANCE hInst = AfxFindResourceHandle(lpszResourceName, RT_TOOLBAR); HRSRC hRsrc = ::FindResource(hInst, lpszResourceName, RT_TOOLBAR); if (hRsrc == NULL) return FALSE; HGLOBAL hGlobal = LoadResource(hInst, hRsrc); if (hGlobal == NULL) return FALSE; CToolBarData* pData = (CToolBarData*)LockResource(hGlobal); if (pData == NULL) return FALSE; ASSERT(pData->wVersion == 1); UINT* pItems = new UINT[pData->wItemCount]; for (int i = 0; i < pData->wItemCount; i++) pItems[i] = pData->items()[i]; BOOL bResult = SetButtons(pItems, pData->wItemCount); delete[] pItems; if (bResult) { // set new sizes of the buttons CSize sizeImage(pData->wWidth, pData->wHeight); CSize sizeButton(pData->wWidth + 7, pData->wHeight + 7); SetSizes(sizeButton, sizeImage); // load bitmap now that sizes are known by the toolbar control bResult = LoadBitmap(lpszResourceName); } UnlockResource(hGlobal); FreeResource(hGlobal); return bResult; }
BOOL CSelectBox::SetBitmap(CString strImage, int nIndex) { if(nIndex >= 0 && nIndex < m_vecpImage.size()) { Image *&pImage = m_vecpImage[nIndex]; if(pImage != NULL) { delete pImage; pImage = NULL; } pImage = Image::FromFile(strImage, m_bImageUseECM); if(pImage->GetLastStatus() == Ok) { m_vecsizeImage[nIndex].SetSize(pImage->GetWidth(), pImage->GetHeight()); UpdateControl(true); return true; } } else if(nIndex == -1 && m_vecpImage.size() < m_nXCount * m_nYCount) { Image *pImage = NULL; pImage = Image::FromFile(strImage, m_bImageUseECM); if(pImage->GetLastStatus() == Ok) { CSize sizeImage(pImage->GetWidth(), pImage->GetHeight()); m_vecpImage.push_back(pImage); m_vecsizeImage.push_back(sizeImage); UpdateControl(true); return true; } } return false; }
void CEnListCtrl::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) { CDC* pDC; CRect rText, rItem, rClient, rHeader; COLORREF crOldText, crOldBack; CSize sizeText; LV_COLUMN lvc = { 0 }; // CPen* pOldPen; CImageList* pImageList; CImageList* pStateList; int nImage = -1; BOOL bItemFocused, bListFocused, bSelected, bDropHighlighted, bSelAlways; UINT uStyle, uState; CSize sizeState(0, 0), sizeImage(0, 0); int nIndent = 0; // get and prepare device context pDC = CDC::FromHandle(lpDrawItemStruct->hDC);//GetDC(); pDC->SelectObject(GetFont()); pDC->SetROP2(R2_COPYPEN); // init helper variables int nItem = lpDrawItemStruct->itemID; GetItemRect(nItem, rItem, LVIR_BOUNDS);//lpDrawItemStruct->rcItem; GetClientRect(&rClient); // some problems with drophiliting items during drag and drop // so we need to make sure drawing is clipped to client area // this fixes it admirably! if (GetHeader()) { GetHeader()->GetWindowRect(rHeader); ScreenToClient(rHeader); rClient.top = max(0, rHeader.bottom); pDC->IntersectClipRect(rClient); } rText = rItem; uStyle = GetStyle(); uState = GetItemState(nItem, LVIS_DROPHILITED | LVIS_SELECTED); bDropHighlighted = (uState & LVIS_DROPHILITED); bItemFocused = (GetFocusedItem() == nItem); bListFocused = (GetFocus() == this); bSelected = (uState & LVIS_SELECTED); bSelAlways = ((uStyle & LVS_SHOWSELALWAYS) == LVS_SHOWSELALWAYS); bSelected = bSelected && (bListFocused || bSelAlways); crOldText = pDC->SetTextColor(COLORREF(0)); // this will be overwritten on a per subitem basis crOldBack = pDC->SetBkColor(GetItemBackColor(nItem, bSelected, bDropHighlighted, bListFocused)); // images and indentation pImageList = GetImageList(LVSIL_SMALL); if (pImageList) { nImage = GetImageIndex(nItem, 0); ImageList_GetIconSize(pImageList->m_hImageList, (int*)&sizeImage.cx, (int*)&sizeImage.cy); nIndent = GetItemIndent(nItem) * sizeImage.cx; rText.left += nIndent; rItem.left += nIndent; // if (pImageList == &s_ilIndent) // pImageList = NULL; } // state pStateList = GetImageList(LVSIL_STATE); if (pStateList) ImageList_GetIconSize(pStateList->m_hImageList, (int*)&sizeState.cx, (int*)&sizeState.cy); if (lpDrawItemStruct->itemAction & (ODA_DRAWENTIRE | ODA_SELECT)) { // setup colors and pens int nImageStyle = GetImageStyle(bSelected, bDropHighlighted, bListFocused); // draw item images if required int nImageWidth = 0; // make sure there is enough space lvc.mask = LVCF_WIDTH | LVCF_FMT; int nCol = 0; BOOL bRes = GetColumn(nCol, &lvc); // must paint the background of column 0 before the icons if (bRes && (pStateList || pImageList)) pDC->ExtTextOut(0, rItem.top, ETO_CLIPPED | ETO_OPAQUE, CRect(0, rItem.top, lvc.cx, rItem.bottom), _T(""), NULL); // state if (pStateList && bRes) { int nState = (GetItemState(nItem, LVIS_STATEIMAGEMASK) & LVIS_STATEIMAGEMASK); nState = nState >> 12; if (lvc.cx > sizeState.cx) pStateList->Draw(pDC, nState, CPoint(rText.left + 1, rText.top), ILD_TRANSPARENT); nImageWidth = sizeState.cx + 2; // 1 pixel border either side }
InfoMessageBox::InfoMessageBox(QString message, QString title) { m_dlg_width = 383; m_dlg_height = 212; //this->resize(228, 117); this->resize(m_dlg_width, m_dlg_height); this->setModal(true); this->setWindowFlags(Qt::Dialog| Qt::FramelessWindowHint | Qt::ToolTip); this->setAttribute(Qt::WA_TranslucentBackground); m_dlgtitle_lb_height = 32; m_dlgtitle_lb_spaceitemw = 60; m_frame_lr_margin = 12; m_frame_tb_margin = 11; m_framecontainer_style = QString::fromUtf8("#frame_container{background-image: url(:/images/bg_dialog_L.png);color:rgb(0,0,0);font-size:12px;}"); // m_framecontainer = new QFrame(this); // m_framecontainer->setObjectName(QString("frame_container")); // m_framecontainer->setAutoFillBackground(true); // m_framecontainer->setStyleSheet(m_framecontainer_style); // QVBoxLayout *dlg_layout = new QVBoxLayout(this); // dlg_layout->setContentsMargins(0,0,0,0); // dlg_layout->addWidget(m_framecontainer); // // m_dlgtitle_lb = new QLabel(m_framecontainer); // init_dlgtitle(); // // // QSpacerItem *title_spitem = new QSpacerItem(m_dlgtitle_lb_spaceitemw,0,QSizePolicy::Fixed); // QHBoxLayout *title_layout = new QHBoxLayout(); // title_layout->addItem(title_spitem); // title_layout->addWidget(m_dlgtitle_lb); // // // QVBoxLayout *container_layout = new QVBoxLayout(m_framecontainer); // container_layout->setContentsMargins(m_frame_lr_margin,m_frame_tb_margin,m_frame_lr_margin,m_frame_tb_margin); // container_layout->setSpacing(1); // container_layout->addLayout(title_layout); // //m_inner_widget->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding); // //container_layout->addWidget(m_inner_widget); // // container_layout->setStretch(0,0); // container_layout->setStretch(1,10); // //// resize(m_dlg_width,m_dlg_height); // gridLayout = new QGridLayout(this); // gridLayout->setSpacing(0); // gridLayout->setContentsMargins(0, 0, 0, 0); mFrame = new QFrame(this); mFrame->setObjectName(QString("Input_frame")); mFrame->setFrameShape(QFrame::StyledPanel); mFrame->setFrameShadow(QFrame::Raised); QPixmap pix; pix.load(":/images/bg_dialog_L.png",0,Qt::AvoidDither | Qt::ThresholdDither | Qt::ThresholdAlphaDither); QSize sizeImage(m_dlg_width, m_dlg_height); QPixmap pixmap(pix.scaled(sizeImage)); QPalette mPalette = palette(); mPalette.setBrush(QPalette::Window, QBrush(pixmap)); mFrame->setPalette(mPalette); QVBoxLayout *mGridLayout = new QVBoxLayout(this); //mGridLayout->setSpacing(0); mGridLayout->setContentsMargins(0, 0, 0, 0); titleLabel = new QLabel(mFrame); titleLabel->setObjectName(QString("dlg_title_lb")); titleLabel->setFixedHeight(m_dlgtitle_lb_height); titleLabel->setAlignment(Qt::AlignVCenter); QString stylesheet = QString("titleLabel{color:rgb(255,255,255);%1;font-weight:bold;}"); stylesheet = stylesheet.arg("font-size:14px"); titleLabel->setStyleSheet(stylesheet); titleLabel->setText("Error"); QSpacerItem *title_spitem = new QSpacerItem(m_dlgtitle_lb_spaceitemw,0,QSizePolicy::Fixed); QHBoxLayout *title_layout = new QHBoxLayout(); title_layout->addItem(title_spitem); title_layout->addWidget(titleLabel); mGridLayout->addWidget(mFrame); // gridLayout_2 = new QGridLayout(mFrame); // // horizontalLayout = new QHBoxLayout(); // // label = new QLabel(mFrame); // label->setMinimumSize(QSize(38, 0)); // label->setMaximumSize(QSize(38, 16777215)); // label->setText("Error"); // // horizontalLayout->addWidget(label); // // label_2 = new QLabel(mFrame); // QFont font; // font.setBold(true); // font.setWeight(75); // label_2->setFont(font); // label_2->setText(title); // label_2->setStyleSheet(QString::fromUtf8("color: rgb(255, 255, 255);")); // label_2->setProperty("overstriking",1); // // horizontalLayout->addWidget(label_2); // // gridLayout_2->addLayout(horizontalLayout, 0, 0, 0, 0); // // label_3 = new QLabel(mFrame); // label_3->setWordWrap(true); // label_3->setText(message); // label_3->setAlignment(Qt::AlignVCenter | Qt::AlignHCenter); // // gridLayout_2->addWidget(label_3, 1, 0, 1, 3); // // horizontalSpacer = new QSpacerItem(60, 20, QSizePolicy::Expanding, QSizePolicy::Minimum); // // gridLayout_2->addItem(horizontalSpacer, 2, 0, 1, 1); pushButton = new QPushButton(mFrame); pushButton->setFocusPolicy(Qt::NoFocus); SET_STYLE_PROPERTY(NORMAL_BUTTON ,pushButton); //gridLayout_2->addWidget(pushButton, 2, 1, 1, 1); //horizontalSpacer_2 = new QSpacerItem(60, 20, QSizePolicy::Expanding, QSizePolicy::Minimum); //gridLayout_2->addItem(horizontalSpacer_2, 2, 2, 1, 1); title_layout->addWidget(pushButton); //gridLayout->addWidget(mFrame, 0, 0, 1, 1); //mGridLayout->addLayout(title_layout); uuid ="{f9b01961-e3b2-474c-8521-42371d2cab61}"; connect(pushButton,SIGNAL(clicked()),this,SLOT(ChangePage())); retranslateUi(); }