//////////////////////// // Draw the column header void CListviewColumn::Draw(SDL_Surface *bmpDest, int x, int y, int w, int h) { CColumnStyle *style = getCurrentStyle(); // Background style->cBackground.Draw(bmpDest, x, y, w, h); // Text SDL_Rect r = {x + style->cBorder.getLeftW(), y + style->cBorder.getTopW(), w - ((style->bmpSortArrow.get().get() && iSortDirection != sort_None) ? style->bmpSortArrow->w : 0) - style->cBorder.getLeftW() - style->cBorder.getRightW(), h - style->cBorder.getTopW() - style->cBorder.getBottomW()}; style->cText.tFontRect = &r; DrawGameText(bmpDest, sText, style->cFont, style->cText); // Sort arrow SDL_Rect r1(MakeRect(x + w - 3 - style->bmpSortArrow->w, y, w, h)); SDL_Rect r2(MakeRect(0, 0, style->bmpSortArrow->w, style->bmpSortArrow->h)); if (style->bmpSortArrow.get().get() && iSortDirection != sort_None) DrawImageAdv(bmpDest, style->bmpSortArrow.get(), r1, r2); // Border style->cBorder.Draw(bmpDest, x, y, w, h); }
/** * @fn PlayerModelView *PlayerModelView::init(PlayerModelView *self) * * @memberof PlayerModelView */ static PlayerModelView *initWithFrame(PlayerModelView *self, const SDL_Rect *frame) { self = (PlayerModelView *) super(View, self, initWithFrame, frame); if (self) { self->view.backgroundColor = Colors.Charcoal; self->view.backgroundColor.a = 64; self->animation1.animation = ANIM_TORSO_STAND1; self->animation2.animation = ANIM_LEGS_RUN; const SDL_Rect iconFrame = MakeRect(0, 0, 64, 64); self->iconView = $(alloc(ImageView), initWithFrame, &iconFrame); assert(self->iconView); self->iconView->view.alignment = ViewAlignmentTopRight; $((View *) self, addSubview, (View *) self->iconView); self->view.padding.top = 4; self->view.padding.right = 4; self->view.padding.bottom = 4; self->view.padding.left = 4; } return self; }
void SlideShowLayerAnim::LoadImage() { Texture2D *tex = new Texture2D(mImageFileNames[mCurImage]); Vec2 zoomSize = GetZoomSize(ZoomModeFit,MakeVec2(800,600),tex->GetSize()); Rect rect; rect.mMin[0] = (800 - zoomSize[0]) / 2; rect.mMin[1] = (600 - zoomSize[1]) / 2; rect.mMax = rect.mMin + zoomSize; ImageLayer *layer = new ImageLayer(rect,tex); ConstLayerAnim *imageLayerAnim = new ConstLayerAnim(layer); layer->Unref(); tex->Unref(); if(mLayerAnim) { const LayerAnim *prevLayerAnim = mLayerAnim; mLayerAnim = new SlideLayerAnim(prevLayerAnim, imageLayerAnim, MakeRect(0,0,800,600), SlideTransition::SlideOffToBottom, AnimCurve::EaseIn, .5f); imageLayerAnim->Unref(); prevLayerAnim->Unref(); } else { mLayerAnim = imageLayerAnim; } }
int sgl_attach_window(CameraSgl *camera, HWND attached, int left, int top, int width, int height, EventCallback callback) { camera->display_win = imaqGetSystemWindowHandle (camera->display_win_num); camera->attached_win = attached; camera->rect_show = MakeRect (top, left, height, width); //SetWindowLong( camera->display_win, GWL_STYLE, WS_CHILDWINDOW ); SetParent( camera->display_win, camera->attached_win); SetWindowLong( camera->display_win, GWL_STYLE, WS_CLIPSIBLINGS ); imaqSetWindowSize( camera->display_win_num, width, height ); // 显示工具条窗口 ToolWindowOptions twoptions; Point pos; int img_width, img_height; memset(&twoptions, 1, sizeof(twoptions)); twoptions.showZoomTool = TRUE; twoptions.showRectangleTool = TRUE; imaqSetupToolWindow (TRUE, 4, &twoptions); imaqGetWindowPos (camera->display_win_num, &pos); imaqGetWindowSize (camera->display_win_num, &img_width, &img_height); pos.x = pos.x + width; imaqMoveToolWindow (pos); imaqShowToolWindow (TRUE); // 注册工具条的回调处理 imaqSetEventCallback (callback, TRUE); return 0; }
//////////////////// // Draw the item void CListviewItem::Draw(SDL_Surface *bmpDest, const SDL_Rect &r) { // Save the clipping rect ScopedSurfaceClip clip(bmpDest, r); CItemStyle *style = getCurrentStyle(); // Background style->cBackground.Draw(bmpDest, r.x, r.y, r.w, r.h); // Draw the subitems std::list<CListviewSubitem *>::iterator subit = tSubitems.begin(); std::vector<CListviewColumn *>::const_iterator colit = cParent->getColumns().begin(); int cur_x = r.x + style->cBorder.getLeftW(); for ( ; subit != tSubitems.end() && colit != cParent->getColumns().end(); colit++, subit++) { (*subit)->Draw(bmpDest, MakeRect(cur_x, r.y + style->cBorder.getTopW(), (*colit)->getWidth(), r.h - style->cBorder.getTopW() - style->cBorder.getBottomW())); cur_x += (*colit)->getWidth(); } // If no subitems, draw the text if (tSubitems.size() == 0) { DrawItemText(bmpDest, r); } // Border style->cBorder.Draw(bmpDest, r.x, r.y, r.w, r.h); }
/***************************************************************************** . . Función C: CAN_InfoControl . Responsable: César Armando Cruz Mendoza . Descripcion: Dibuja la marca solicitada en el canvas del panel . Parámetro de entrada: int x | coordenada x de la marca . int y | coordenada y de la marca . Parámetro de salida: cero . Fecha de creación: 18 de Febrero de 2011 . *****************************************************************************/ int CAN_DibujarMarca(int x, int y, int color) { SetCtrlAttribute (iPanelCanvas, iControlCanvas, ATTR_PEN_FILL_COLOR, color); CanvasDrawOval (iPanelCanvas, iControlCanvas, MakeRect (y, x, 30, 30), VAL_DRAW_INTERIOR); /* VAL_LT_GRAY VAL_DK_YELLOW VAL_OFFWHITE VAL_DK_MAGENTA VAL_DK_CYAN VAL_DK_GREEN VAL_DK_RED VAL_MAGENTA VAL_GREEN VAL_BLUE VAL_CYAN VAL_RED VAL_YELLOW VAL_DK_BLUE VAL_BLACK VAL_GRAY VAL_TRANSPARENT VAL_PANEL_GRAY VAL_DK_GRAY VAL_WHITE */ return 0; }
ImageWidget::ImageWidget(const char *fileName,ZoomMode zoomMode) { Image img(fileName); mZoomMode = zoomMode; mImgSize = MakeVec2(img.GetWidth(),img.GetHeight()); mActor = new AtlasActor(MakeRect(0,0,0,0),img); }
/////////////////// // Draw the list view void CListview::DoRepaint() { CHECK_BUFFER; CContainerWidget::DoRepaint(); int cur_y = cBorder.getTopW(); // Repaint all the subwidgets that need it // TODO: some list of widgets so we don't have to iterate through everything? for (std::list<CListviewItem *>::iterator it = tItems.begin(); it != tItems.end(); it++) for (std::list<CListviewSubitem *>::iterator sub = (*it)->getSubitems().begin(); sub != (*it)->getSubitems().end(); sub++) if ((*sub)->getType() == sub_Widget) if (((CWidgetSubitem *)(*sub))->getWidget()->needsRepaint()) ((CWidgetSubitem *)(*sub))->getWidget()->DoRepaint(); // Background cBackground.Draw(bmpBuffer, 0, 0, getWidth(), getHeight()); // Columns if (bShowColumnHeaders) { int cur_x = cBorder.getLeftW(); for (std::vector<CListviewColumn *>::iterator it = tColumns.begin(); it != tColumns.end(); it++) { (*it)->Draw(bmpBuffer.get(), cur_x, cur_y, (*it)->getWidth(), iColumnHeight); cur_x += (*it)->getWidth(); } cur_y += iColumnHeight; } // Items int i = 0; int scroll_w = ((cScrollbar->getVisible() || bAlwaysVisibleScrollbar) ? cScrollbar->getWidth() : 0); for (std::list<CListviewItem *>::iterator it = tItems.begin(); it != tItems.end(); it++, i++) { // Item above the displayed area if (i < cScrollbar->getValue()) continue; // Draw the item (*it)->Draw(bmpBuffer.get(), MakeRect(cBorder.getLeftW(), cur_y, getWidth() - cBorder.getLeftW() - cBorder.getRightW() - scroll_w, (*it)->getHeight())); cur_y += (*it)->getHeight(); if (cur_y >= getHeight() - cBorder.getBottomW()) break; } // Scrollbar if (cScrollbar->getVisible()) { if (cScrollbar->needsRepaint()) cScrollbar->DoRepaint(); cScrollbar->Draw(bmpBuffer.get(), cScrollbar->getX(), cScrollbar->getY()); } // Border cBorder.Draw(bmpBuffer, 0, 0, getWidth(), getHeight()); }
void WINAPI duStatic::OnMouseIn(POINT pt) { duCtrlManager *pCtrlManager = GetCtrlManager(m_hWnd); if (pCtrlManager == NULL) return; if (m_fShowToolTip) { pCtrlManager->AddToolTip((LPTSTR)GetText()); } else { LPCTSTR lpszText = GetText(); if (lpszText && *lpszText) { duStyleGroup *pStyleGroup = (duStyleGroup *)GetResObj(GetStyle(), DU_RES_STYLEGROUP); if (pStyleGroup == NULL) return; int i; int nStyleCount = pStyleGroup->GetStyleCount(); for (i = 0;i < nStyleCount; i++) { duStyleBase *pStyleBase = pStyleGroup->GetStyle(i); if (pStyleBase->GetType() == STYLE_TEXT) { duTextStyle *pTextStyle = (duTextStyle *)pStyleBase; duSize size(0, 0); pTextStyle->CalcTextRect(lpszText, &size); duRect rcStyle; rcStyle.SetRectEmpty(); duRect rcStatic; Plugin_GetRect(this, &rcStatic); rcStatic.OffsetRect(-rcStatic.left, -rcStatic.top); MakeRect(pTextStyle->GetLeft(), pTextStyle->GetTop(), pTextStyle->GetRight(), pTextStyle->GetBottom(), pTextStyle->GetWidth(), pTextStyle->GetHeight(), &rcStatic, &rcStyle); POINT point; point.x = size.cx; point.y = size.cy; if (!rcStyle.PtInRect(point)) { pCtrlManager->AddToolTip((LPTSTR)lpszText); } break; } } } } }
FlatLayer* matterFlatLayerNew(float minX,float minY,float maxX,float maxY,float r,float g,float b,float a) { try { return new FlatLayer(MakeRect(minX,minY,maxX,maxY),MakeVec4(r,g,b,a)); } catch(const std::exception &err) { matterSetLastError(err.what()); return 0; } }
static void CheckNeedExtScroll(ExtScrollScreenParm& scrl, const SMALL_RECT *lpScrollRectangle, const SMALL_RECT *lpClipRectangle, COORD dwDestinationOrigin) { // TODO: ... _ASSERTE(lpClipRectangle == NULL); _ASSERTE(dwDestinationOrigin.X == 0); // Full console contents is to be scrolled if (!lpScrollRectangle) return; scrl.Flags |= essf_Region|essf_Global; scrl.Region = MakeRect(lpScrollRectangle->Left, lpScrollRectangle->Top, lpScrollRectangle->Right, lpScrollRectangle->Bottom); }
void CTabPanelWin::RePaintInt() { if (!mh_Rebar) return; RECT client, self; client = gpConEmu->GetGuiClientRect(); GetWindowRect(mh_Rebar, &self); MapWindowPoints(NULL, ghWnd, (LPPOINT)&self, 2); int nNewY; if (gpSet->nTabsLocation == 1) { int nStatusHeight = gpSet->isStatusBarShow ? gpSet->StatusBarHeight() : 0; nNewY = client.bottom-nStatusHeight-(self.bottom-self.top); } else { nNewY = 0; } if ((client.right != (self.right - self.left)) || (nNewY != self.top)) { RepositionInt(); #if 0 MoveWindow(mh_Rebar, 0, nNewY, client.right, self.bottom-self.top, 1); if (gpSet->nTabsLocation == 1) m_Margins = MakeRect(0,0,0,mn_TabHeight); else m_Margins = MakeRect(0,mn_TabHeight,0,0); gpSet->UpdateMargins(m_Margins); #endif } UpdateWindow(mh_Rebar); }
RECT CTabBarClass::GetMargins() { RECT rcNewMargins = {0,0}; if (!this) { _ASSERTE(this); return rcNewMargins; } if (_active || (gpSet->isTabs == 1)) { if (!_tabHeight) { // Вычислить высоту GetTabbarHeight(); } if (_tabHeight /*&& IsTabsShown()*/) { _ASSERTE(_tabHeight!=0 && "Height must be evaluated already!"); if (gpSet->nTabsLocation == 1) rcNewMargins = MakeRect(0,0,0,_tabHeight); else rcNewMargins = MakeRect(0,_tabHeight,0,0); //if (memcmp(&rcNewMargins, &m_Margins, sizeof(m_Margins)) != 0) //{ // m_Margins = rcNewMargins; // gpSet->UpdateMargins(m_Margins); //} } } //return m_Margins; return rcNewMargins; }
/***************************************************************************** . . Función C: CAN_DibujarEtiqueta . Responsable: César Armando Cruz Mendoza . Descripcion: Dibuja la leyenda en la posicion indicada . Parámetro de entrada: int x | coordenada x de la marca . int y | coordenada y de la marca . char *pcCadena | cadena que se desea dibujar . Parámetro de salida: cero . Fecha de creación: 18 de Febrero de 2011 . *****************************************************************************/ int CAN_DibujarEtiqueta(int x, int y, char *pcCadena, int color) { SetCtrlAttribute (iPanelCanvas, iControlCanvas, ATTR_PEN_COLOR, color); SetCtrlAttribute (iPanelCanvas, iControlCanvas, ATTR_PEN_FILL_COLOR, VAL_TRANSPARENT); CreateMetaFont ("Sincros01", VAL_APP_META_FONT, 14, 1, 0, 0, 0); CanvasDrawText (iPanelCanvas, iControlCanvas, pcCadena, "Sincros01", MakeRect (y+5, x+5, 20, 20), VAL_CENTER); return 0; }
bool TextWidget::on_expose_event(GdkEventExpose* event) { Rect drw_rct = Planed::DevToRel(trans, MakeRect(event->area)); CairoStateSave save(caiCont); CR::RectClip(caiCont, drw_rct); ClearCanvas(caiCont); // собственно отрисовка RenderByRegion(drw_rct); PaintRegion(drw_rct); return false; }
void CTestGame::Render() { //draw background SDL_Rect* rect = MakeRect(0,0,GetScreenWidth(),GetScreenHeight()); int col = SDL_MapRGB(Display_Surface->GetSDLSurface()->format,255,255,255); Display_Surface->FillRect(rect,col); delete rect; //draw game space space->Draw(Display_Surface); //draw fps and other stats CGame::GameStats->Draw(Display_Surface); CGame::GameOutput->Draw(Display_Surface); }
void App::Render() { AutoUnrefPool pool; glClearColor(0,1,0,1); glClearDepthf(1); glClearStencil(0); glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT|GL_STENCIL_BUFFER_BIT); RenderCtx renderCtx(mWidth,mHeight); mRootWidget->ComputeSizeRequest(); mRootWidget->Layout(MakeRect(0,0,mWidth,mHeight)); Layer *exerciseViewLayer = mRootWidget->GetLayer(); exerciseViewLayer->Render(renderCtx); eglSwapBuffers(mDisplay, mSurface); }
GradientLayer* matterGradientLayerNew(float minX,float minY,float maxX,float maxY, float axisStartX,float axisStartY, float axisEndX,float axisEndY, const Gradient *gradient) { try { return new GradientLayer(MakeRect(minX,minY,maxX,maxY), MakeVec2(axisStartX,axisStartY), MakeVec2(axisEndX,axisEndY), gradient); } catch(const std::exception &err) { matterSetLastError(err.what()); return 0; } }
static void Init(void) { static const char *fragShaderText = "uniform ivec2 WinSize; \n" "void main() {\n" " vec2 d = dFdy(gl_TexCoord[0].xy) * vec2(WinSize); \n" " gl_FragColor = vec4(d.x, d.y, 0.0, 1.0);\n" " // gl_FragColor = gl_TexCoord[0];\n" "}\n"; static const char *vertShaderText = "void main() {\n" " gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;\n" " gl_TexCoord[0] = gl_MultiTexCoord0;\n" "}\n"; if (!ShadersSupported()) exit(1); vertShader = CompileShaderText(GL_VERTEX_SHADER, vertShaderText); fragShader = CompileShaderText(GL_FRAGMENT_SHADER, fragShaderText); program = LinkShaders(vertShader, fragShader); glUseProgram(program); WinSizeUniform = glGetUniformLocation(program, "WinSize"); /*assert(glGetError() == 0);*/ glClearColor(0.3f, 0.3f, 0.3f, 0.0f); glEnable(GL_DEPTH_TEST); MakeSphere(); MakeRect(); CurList = SphereList; printf("GL_RENDERER = %s\n",(const char *) glGetString(GL_RENDERER)); assert(glIsProgram(program)); assert(glIsShader(fragShader)); assert(glIsShader(vertShader)); glColor3f(1, 0, 0); }
int CTabPanelWin::QueryTabbarHeight() { if (!this) return 0; // Нужно пересчитать высоту таба //bool bDummyCreate = (hTabs == NULL); // //if (bDummyCreate) //{ // hTabs = CreateTabbar(true); //} if (mh_Tabbar) { // нас интересует смещение клиентской области. Т.е. начало - из 0. Остальное не важно RECT rcClient = MakeRect(600, 400); //rcClient = gpConEmu->GetGuiClientRect(); TabCtrl_AdjustRect(mh_Tabbar, FALSE, &rcClient); mn_TabHeight = rcClient.top - mn_ThemeHeightDiff - (gpSet->FontUseUnits ? 1 : 0); } else { // Не будем создавать TabBar. Все равно вне окно ConEmu оценка получается неточной //_ASSERTE((hTabs!=NULL) && "Creating of a dummy tab control failed"); int lfHeight = gpSetCls->EvalSize(gpSet->nTabFontHeight, esf_Vertical|esf_CanUseDpi|esf_CanUseUnits); mn_TabHeight = gpSetCls->EvalFontHeight(gpSet->sTabFontFace, lfHeight, gpSet->nTabFontCharSet) + gpSetCls->EvalSize((lfHeight < 0) ? 8 : 9, esf_Vertical); } //if (bDummyCreate && hTabs) //{ // DestroyWindow(hTabs); // mh_Tabbar = NULL; //} return mn_TabHeight; }
/** * @see ViewController::loadView(ViewController *) */ static void loadView(ViewController *self) { super(ViewController, self, loadView); cgi.GetServers(); MenuViewController *this = (MenuViewController *) self; ServersTableView *servers; { Box *box = $(alloc(Box), initWithFrame, NULL); $(box->label, setText, "JOIN GAME"); box->view.autoresizingMask |= ViewAutoresizingFill; const SDL_Rect frame = MakeRect(0, 0, 0, 320); servers = $(alloc(ServersTableView), initWithFrame, &frame, ControlStyleDefault); servers->tableView.control.view.autoresizingMask = ViewAutoresizingWidth; $((Control *) servers, addActionForEventType, SDL_MOUSEBUTTONUP, connectAction, self, servers); $((View *) box, addSubview, (View *) servers); release(servers); $((View *) this->panel->contentView, addSubview, (View *) box); release(box); } { this->panel->accessoryView->view.hidden = false; Cg_Button((View *) this->panel->accessoryView, "Create..", createAction, self, NULL); Cg_Button((View *) this->panel->accessoryView, "Refresh", refreshAction, self, NULL); Cg_Button((View *) this->panel->accessoryView, "Connect", connectAction, self, servers); } }
bool CBackground::CreateField(int anWidth, int anHeight) { if (!hBgDc || !hBgBitmap || anWidth != bgSize.X || anHeight != bgSize.Y) { Destroy(); } else { return true; // уже создано } bool lbRc = false; // Создать MemoryDC const HDC hScreenDC = GetDC(ghWnd); hBgDc = CreateCompatibleDC(hScreenDC); if (hBgDc) { bgSize.X = klMin(32767,anWidth); bgSize.Y = klMin(32767,anHeight); hBgBitmap = CreateCompatibleBitmap(hScreenDC, bgSize.X, bgSize.Y); if (hBgBitmap) { // Выбрать в MemoryDC созданный Bitmap для установки его размера hOldBitmap = (HBITMAP)SelectObject(hBgDc, hBgBitmap); // И залить черным фоном RECT rcFull = MakeRect(bgSize.X, bgSize.Y); FillRect(hBgDc, &rcFull, (HBRUSH)GetStockObject(BLACK_BRUSH)); // теперь - OK lbRc = true; } } ReleaseDC(ghWnd, hScreenDC); return lbRc; }
LRESULT CFrameHolder::OnNcCalcSize(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { RecalculateFrameSizes(); LRESULT lRc = 0, lRcDef = 0; // В Aero (Glass) важно, чтобы клиенская область начиналась с верхнего края окна, // иначе не получится "рисовать по стеклу" FrameDrawStyle fdt = gpConEmu->DrawType(); // Если nCaption == 0, то при fdt_Aero текст в заголовке окна не отрисовывается DEBUGTEST(int nCaption = GetCaptionHeight()); bool bCallDefProc = true; #if defined(CONEMU_TABBAR_EX) // В режиме Aero/Glass (хоть он и почти выпилен в Win8) // мы расширяем клиентскую область на заголовок if (gpSet->isTabsInCaption && (fdt == fdt_Aero || fdt == fdt_Win8)) { nCaption = 0; bCallDefProc = false; // Must be "glassed" or "themed", otherwise system will not draw window caption _ASSERTE(gpConEmu->IsGlass() || gpConEmu->IsThemed()); } #endif if (wParam) { // lParam points to an NCCALCSIZE_PARAMS structure that contains information // an application can use to calculate the new size and position of the client rectangle. // The application should indicate which part of the client area contains valid information! NCCALCSIZE_PARAMS* pParm = wParam ? ((NCCALCSIZE_PARAMS*)lParam) : NULL; // r[0] contains the new coordinates of a window that has been moved or resized, // that is, it is the proposed new window coordinates // r[1] contains the coordinates of the window before it was moved or resized // r[2] contains the coordinates of the window's client area before the window was moved or resized RECT r[3] = {pParm->rgrc[0], pParm->rgrc[1], pParm->rgrc[2]}; bool bAllowPreserveClient = mb_AllowPreserveClient && (memcmp(r, r+1, sizeof(*r)) == 0); // We need to call this, otherwise some parts of window may be broken // If don't - system will not draw window caption when theming is off if (bCallDefProc) { lRcDef = ::DefWindowProc(hWnd, uMsg, wParam, lParam); } //RECT rcWnd = {0,0, r[0].right-r[0].left, r[0].bottom-r[0].top}; RECT rcClient; // = gpConEmu->CalcRect(CER_MAINCLIENT, rcWnd, CER_MAIN); //_ASSERTE(rcClient.left==0 && rcClient.top==0); RECT rcMargins = gpConEmu->CalcMargins(CEM_FRAMECAPTION); #if defined(CONEMU_TABBAR_EX) if (gpSet->isTabsInCaption) { _ASSERTE(nCaption==0); rcClient = MakeRect(r[0].left+rcMargins.left, r[0].top, r[0].right-rcMargins.right, r[0].bottom-rcMargins.bottom); } else #endif { // Need screen coordinates! rcClient = MakeRect(r[0].left+rcMargins.left, r[0].top+rcMargins.top, r[0].right-rcMargins.right, r[0].bottom-rcMargins.bottom); //int nDX = ((rcWnd.right - rcClient.right) >> 1); //int nDY = ((rcWnd.bottom - rcClient.bottom - nCaption) >> 1); //// Need screen coordinates! //OffsetRect(&rcClient, r[0].left + nDX, r[0].top + nDY + nCaption); } // pParm->rgrc[0] contains the coordinates of the new client rectangle resulting from the move or resize // pParm->rgrc[1] rectangle contains the valid destination rectangle // pParm->rgrc[2] rectangle contains the valid source rectangle pParm->rgrc[0] = rcClient; //TODO: #if 0 if (!bAllowPreserveClient) { pParm->rgrc[1] = MakeRect(rcClient.left, rcClient.top, rcClient.left, rcClient.top); pParm->rgrc[2] = MakeRect(r[2].left, r[2].top, r[2].left, r[2].top); } else #endif { pParm->rgrc[1] = rcClient; // Mark as valid - only client area. Let system to redraw the frame and caption. pParm->rgrc[2] = r[2]; } if (bAllowPreserveClient) { lRc = WVR_VALIDRECTS; } // При смене режимов (особенно при смене HideCaption/NotHideCaption) // требовать полную перерисовку клиентской области else if (mb_DontPreserveClient || (gpConEmu->GetChangeFromWindowMode() != wmNotChanging)) { lRc = WVR_REDRAW; } } else { // lParam points to a RECT structure. On entry, the structure contains the proposed window // rectangle for the window. On exit, the structure should contain the screen coordinates // of the corresponding window client area. LPRECT nccr = (LPRECT)lParam; RECT rc = *nccr; //RECT rcWnd = {0,0, rc.right-rc.left, rc.bottom-rc.top}; RECT rcClient; // = gpConEmu->CalcRect(CER_MAINCLIENT, rcWnd, CER_MAIN); //_ASSERTE(rcClient.left==0 && rcClient.top==0); RECT rcMargins = gpConEmu->CalcMargins(CEM_FRAMECAPTION); if (bCallDefProc) { // Call default function JIC lRcDef = ::DefWindowProc(hWnd, uMsg, wParam, lParam); } #if defined(CONEMU_TABBAR_EX) if (gpSet->isTabsInCaption) { _ASSERTE(nCaption==0); rcClient = MakeRect(rc.left+rcMargins.left, rc.top, rc.right-rcMargins.right, rc.bottom-rcMargins.bottom); //int nDX = ((rcWnd.right - rcClient.right) >> 1); //int nDY = ((rcWnd.bottom - rcClient.bottom /*- nCaption*/) >> 1); //*nccr = MakeRect(rc.left+nDX, rc.top+nDY, rc.right-nDX, rc.bottom-nDY); } else #endif { // Need screen coordinates! rcClient = MakeRect(rc.left+rcMargins.left, rc.top+rcMargins.top, rc.right-rcMargins.right, rc.bottom-rcMargins.bottom); //int nDX = ((rcWnd.right - rcClient.right) >> 1); //int nDY = ((rcWnd.bottom - rcClient.bottom - nCaption) >> 1); //OffsetRect(&rcClient, rc.left + nDX, rc.top + nDY + nCaption); } *nccr = rcClient; } //if (!gpSet->isTabsInCaption) //{ // lRc = DefWindowProc(hWnd, uMsg, wParam, lParam); //} //else //{ // if (!gpSet->isTabs || !gpSet->isTabsInCaption) // { // lRc = DefWindowProc(hWnd, uMsg, wParam, lParam); // } // else // { // RECT r[3]; // r[0] = *nccr; // if (wParam) // { // r[1] = pParm->rgrc[1]; // r[2] = pParm->rgrc[2]; // } // // if (fdt == fdt_Aero) // { // // В Aero (Glass) важно, чтобы клиенская область начиналась с верхнего края окна, // // иначе не получится "рисовать по стеклу" // nccr->top = r->top; // нада !!! // nccr->left = r->left + GetFrameWidth(); // nccr->right = r->right - GetFrameWidth(); // nccr->bottom = r->bottom - GetFrameHeight(); // } // else // { // //TODO: Темы!!! В XP ширина/высота рамки может быть больше // nccr->top = r->top + GetFrameHeight() + GetCaptionHeight(); // nccr->left = r->left + GetFrameWidth(); // nccr->right = r->right - GetFrameWidth(); // nccr->bottom = r->bottom - GetFrameHeight(); // } // } // // Наверное имеет смысл сбрасывать всегда, чтобы Win не пыталась // // отрисовать невалидное содержимое консоли (она же размер меняет) // if (wParam) // { // //pParm->rgrc[1] = *nccr; // //pParm->rgrc[2] = r[2]; // memset(pParm->rgrc+1, 0, sizeof(RECT)*2); // } //} UNREFERENCED_PARAMETER(lRcDef); UNREFERENCED_PARAMETER(fdt); return lRc; }
bool CBackground::FillBackground( const BITMAPFILEHEADER* apBkImgData, // Содержимое *.bmp файла LONG X, LONG Y, LONG Width, LONG Height, // Куда нужно положить картинку BackgroundOp Operation, // {eUpLeft = 0, eStretch = 1, eTile = 2, eUpRight = 4, ...} bool abFade) // затемнение картинки, когда ConEmu НЕ в фокусе { if (!hBgDc) return false; // Залить черным фоном RECT rcFull = MakeRect(X,Y,Width,Height); FillRect(hBgDc, &rcFull, (HBRUSH)GetStockObject(BLACK_BRUSH)); if (apBkImgData == NULL || apBkImgData->bfType != 0x4D42/*BM*/ || IsBadReadPtr(apBkImgData, apBkImgData->bfSize)) { return false; } bool lbRc = false; HDC hLoadDC = NULL; HBITMAP hLoadBmp = NULL; BITMAPINFO* pBmp = (BITMAPINFO*)(apBkImgData+1); LPBYTE pBits = ((LPBYTE)apBkImgData) + apBkImgData->bfOffBits; LPVOID pDstBits = NULL; BITMAPINFOHEADER* pHdr = &pBmp->bmiHeader; if (pHdr->biPlanes != 1 || pHdr->biCompression != BI_RGB) // BI_JPEG|BI_PNG { return false; } DWORD nBitSize = apBkImgData->bfSize - apBkImgData->bfOffBits; TODO("Stride?"); DWORD nCalcSize = (pHdr->biWidth * pHdr->biHeight * pHdr->biBitCount) >> 3; if (nBitSize > nCalcSize) nBitSize = nCalcSize; if (!gpSet->isFadeInactive) abFade = false; // Создать MemoryDC const HDC hScreenDC = GetDC(ghWnd); if (hScreenDC) { hLoadDC = CreateCompatibleDC(hScreenDC); ReleaseDC(ghWnd, hScreenDC); if (hLoadDC) { hLoadBmp = CreateDIBSection(hLoadDC, pBmp, DIB_RGB_COLORS, &pDstBits, NULL, 0); if (hLoadBmp && pDstBits) { // Поместить биты из apBkImgData в hLoadDC HBITMAP hOldLoadBmp = (HBITMAP)SelectObject(hLoadDC, hLoadBmp); memmove(pDstBits, pBits, nBitSize); GdiFlush(); // Гарантировать commit битов // Теперь - скопировать биты из hLoadDC в hBgDc с учетом положения и Operation BLENDFUNCTION bf = {AC_SRC_OVER, 0, gpSet->bgImageDarker, 0}; if (abFade) { // GetFadeColor возвращает ColorRef, поэтому при вызове для (0..255) // он должен вернуть "коэффициент" затемнения или осветления DWORD nHigh = (gpSet->GetFadeColor(255) & 0xFF); if (nHigh < 255) { // Затемнение фона bf.SourceConstantAlpha = LOBYTE(nHigh * bf.SourceConstantAlpha / 255); } //// "коэффициент" вернется в виде RGB (R==G==B) //DWORD nLow = gpSet->GetFadeColor(0); //if (nLow > 0 && ((nLow & 0xFF) < nHigh)) //{ // // Осветление фона // RECT r = {X,Y,X+Width,Y+Height}; // HBRUSH h = CreateSolidBrush(nLow); // FillRect(hBgDc, &r, h); // DeleteObject(h); // // еще нужно убедиться, что сама картинка будет немного прозрачной, // // чтобы это осветление было заметно // if ((nLow & 0xFF) < 200) // bf.SourceConstantAlpha = klMin((int)bf.SourceConstantAlpha, (int)(255 - (nLow & 0xFF))); // else if (bf.SourceConstantAlpha >= 240) // bf.SourceConstantAlpha = 240; //} } if ((Operation == eUpLeft) || (Operation == eUpRight) || (Operation == eDownLeft) || (Operation == eDownRight) || (Operation == eCenter)) { int W = klMin(Width,pHdr->biWidth); int H = klMin(Height,pHdr->biHeight); if (GdiAlphaBlend(hBgDc, X, Y, W, H, hLoadDC, 0, 0, W, H, bf)) lbRc = true; } else if (Operation == eStretch || Operation == eFit) { if (GdiAlphaBlend(hBgDc, X, Y, Width, Height, hLoadDC, 0, 0, pHdr->biWidth, pHdr->biHeight, bf)) lbRc = true; } else if (Operation == eFill) { int srcX = 0, srcY = 0, srcW = pHdr->biWidth, srcH = pHdr->biHeight; if (Width && Width > Height) { srcH = klMin((srcW * Height / Width), _abs(pHdr->biHeight)); srcY = (pHdr->biHeight - srcH) / 2; } else if (Height) { srcW = klMin((srcH * Width / Height), pHdr->biWidth); srcX = (pHdr->biWidth - srcW) / 2; } if (GdiAlphaBlend(hBgDc, X, Y, Width, Height, hLoadDC, srcX, srcY, srcW, srcH, bf)) lbRc = true; } else if (Operation == eTile) { for (int DY = Y; DY < (Y+Height); DY += pHdr->biHeight) { for (int DX = X; DX < (X+Width); DX += pHdr->biWidth) { int W = klMin((Width-DX),pHdr->biWidth); int H = klMin((Height-DY),pHdr->biHeight); if (GdiAlphaBlend(hBgDc, DX, DY, W, H, hLoadDC, 0, 0, W, H, bf)) lbRc = true; } } } _ASSERTE(lbRc && "GdiAlphaBlend failed in background creation?"); TODO("Осветление картинки в Fade, когда gpSet->mn_FadeLow>0"); //if (abFade) //{ // // "коэффициент" вернется в виде RGB (R==G==B) // DWORD nLow = gpSet->GetFadeColor(0); // if (nLow) // { // // Осветление фона // RECT r = {X,Y,X+Width,Y+Height}; // HBRUSH h = CreateSolidBrush(nLow); // // Осветлить картинку // //FillRect(hBgDc, &r, h); // DeleteObject(h); // } //} SelectObject(hLoadDC, hOldLoadBmp); } if (hLoadBmp) { DeleteObject(hLoadBmp); hLoadBmp = NULL; } DeleteDC(hLoadDC); hLoadDC = NULL; } } return lbRc; }
HWND CTabPanelWin::CreateTabbar() { gpSetCls->CheckTheming(); if (!mh_Rebar) return NULL; // Табы создаются только как Band в ReBar if (mh_Tabbar) return mh_Tabbar; // Уже создали //if (!m_TabIcons.IsInitialized()) //{ // InitIconList(); //} // Важно проверку делать после создания главного окна, иначе IsAppThemed будет возвращать FALSE BOOL bAppThemed = FALSE, bThemeActive = FALSE; FAppThemed pfnThemed = NULL; HMODULE hUxTheme = LoadLibrary(L"UxTheme.dll"); if (hUxTheme) { pfnThemed = (FAppThemed)GetProcAddress(hUxTheme, "IsAppThemed"); if (pfnThemed) bAppThemed = pfnThemed(); pfnThemed = (FAppThemed)GetProcAddress(hUxTheme, "IsThemeActive"); if (pfnThemed) bThemeActive = pfnThemed(); FreeLibrary(hUxTheme); hUxTheme = NULL; } if (!bAppThemed || !bThemeActive) mn_ThemeHeightDiff = 2; /*mh_TabbarP = CreateWindow(_T("VirtualConsoleClassBar"), _T(""), WS_VISIBLE|WS_CHILD, 0,0,340,22, ghWnd, 0, 0, 0); if (!mh_TabbarP) return NULL;*/ RECT rcClient = {-32000, -32000, -32000+300, -32000+100}; if (ghWnd) { rcClient = gpConEmu->GetGuiClientRect(); } else { _ASSERTE(ghWnd!=NULL && "ConEmu main window must be created already!"); } DWORD nPlacement = TCS_SINGLELINE|WS_VISIBLE|WS_CHILD/*|TCS_BUTTONS*//*|TCS_TOOLTIPS*/; //|((gpSet->nTabsLocation == 1) ? TCS_BOTTOM : 0); mh_Tabbar = CreateWindow(WC_TABCONTROL, NULL, nPlacement | WS_CLIPSIBLINGS | TCS_FOCUSNEVER, 0, 0, rcClient.right, 0, mh_Rebar, NULL, g_hInstance, NULL); if (mh_Tabbar == NULL) { return NULL; } //#if !defined(__GNUC__) //#pragma warning (disable : 4312) //#endif // Надо TabPanelWinMap map = {this}; //{ CTabPanelWin* object; HWND hWnd; WNDPROC defaultProc; }; map.defaultProc = (WNDPROC)SetWindowLongPtr(mh_Tabbar, GWLP_WNDPROC, (LONG_PTR)_TabProc); map.hWnd = mh_Tabbar; gp_TabPanelWinMap->Set(mh_Tabbar, map); SendMessage(mh_Tabbar, TCM_SETIMAGELIST, 0, (LPARAM)mp_Owner->GetTabIcons()); if (!mh_TabTip || !IsWindow(mh_TabTip)) InitTooltips(mh_Tabbar); TabCtrl_SetToolTips(mh_Tabbar, mh_TabTip); UpdateTabFontInt(); //HFONT hFont = CreateFont(gpSet->nTabFontHeight, 0, 0, 0, FW_DONTCARE, FALSE, FALSE, FALSE, gpSet->nTabFontCharSet, OUT_DEFAULT_PRECIS, // CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_SWISS, gpSet->sTabFontFace); //SendMessage(mh_Tabbar, WM_SETFONT, WPARAM(hFont), TRUE); if (!mh_Balloon || !IsWindow(mh_Balloon)) { InitTooltips(mh_Tabbar); } // Добавляет закладку, или меняет (при необходимости) заголовок существующей //AddTab(gpConEmu->isFar() ? gpSet->szTabPanels : gpSet->pszTabConsole, 0); AddTabInt(gpConEmu->GetDefaultTabLabel(), 0, gpConEmu->mb_IsUacAdmin, -1); // нас интересует смещение клиентской области. Т.е. начало - из 0. Остальное не важно rcClient = MakeRect(600, 400); //rcClient = gpConEmu->GetGuiClientRect(); TabCtrl_AdjustRect(mh_Tabbar, FALSE, &rcClient); mn_TabHeight = rcClient.top - mn_ThemeHeightDiff; return mh_Tabbar; }
inline void MakeRectBottomRight(RECT &rect, int x, int y, int cx, int cy) { MakeRect(rect, x - cx, y - cy, cx, cy); }
bool CRConData::FindPanels(bool& bLeftPanel, RECT& rLeftPanel, RECT& rLeftPanelFull, bool& bRightPanel, RECT& rRightPanel, RECT& rRightPanelFull) { rLeftPanel = rLeftPanelFull = rRightPanel = rRightPanelFull = MakeRect(-1,-1); bLeftPanel = bRightPanel = false; if (!isValid(true, nWidth*nHeight)) return false; uint nY = 0; BOOL lbIsMenu = FALSE; if (pConChar[0] == L' ') { lbIsMenu = TRUE; for (UINT i=0; i<nWidth; i++) { if (pConChar[i]==ucBoxDblHorz || pConChar[i]==ucBoxDblDownRight || pConChar[i]==ucBoxDblDownLeft) { lbIsMenu = FALSE; break; } } if (lbIsMenu) nY ++; // скорее всего, первая строка - меню } else if ((((pConChar[0] == L'R') && ((pConAttr[0] & 0xFF) == 0x4F)) || ((pConChar[0] == L'P') && ((pConAttr[0] & 0xFF) == 0x2F))) && pConChar[1] == L' ') { for (UINT i=1; i<nWidth; i++) { if (pConChar[i]==ucBoxDblHorz || pConChar[i]==ucBoxDblDownRight || pConChar[i]==ucBoxDblDownLeft) { lbIsMenu = FALSE; break; } } if (lbIsMenu) nY ++; // скорее всего, первая строка - меню, при включенной записи макроса } uint nIdx = nY*nWidth; // Левая панель BOOL bFirstCharOk = (nY == 0) && ( (pConChar[0] == L'R' && (pConAttr[0] & 0xFF) == 0x4F) // символ записи макроса || (pConChar[0] == L'P' && (pConAttr[0] & 0xFF) == 0x2F) // символ воспроизведения макроса ); bool bFarShowColNames = true; bool bFarShowSortLetter = true; bool bFarShowStatus = true; const CEFAR_INFO_MAPPING *pFar = NULL; if (mp_RCon->m_FarInfo.cbSize) { pFar = &mp_RCon->m_FarInfo; if (pFar) { if ((pFar->FarPanelSettings.ShowColumnTitles) == 0) //-V112 bFarShowColNames = false; if ((pFar->FarPanelSettings.ShowSortModeLetter) == 0) bFarShowSortLetter = false; if ((pFar->FarPanelSettings.ShowStatusLine) == 0) bFarShowStatus = false; } } // Проверяем левую панель bool bContinue = false; if (pConChar[nIdx+nWidth] == ucBoxDblVert) // двойная рамка продолжается вниз { if ((bFirstCharOk || pConChar[nIdx] != ucBoxDblDownRight) && (pConChar[nIdx+1]>=L'0' && pConChar[nIdx+1]<=L'9')) // открыто несколько редакторов/вьюверов bContinue = true; else if (((bFirstCharOk || pConChar[nIdx] == ucBoxDblDownRight) && (((pConChar[nIdx+1] == ucBoxDblHorz || pConChar[nIdx+1] == L' ') && (bFarShowColNames || !bFarShowSortLetter)) || pConChar[nIdx+1] == ucBoxSinglDownDblHorz // доп.окон нет, только рамка || pConChar[nIdx+1] == ucBoxDblDownDblHorz || (pConChar[nIdx+1] == L'[' && pConChar[nIdx+2] == ucLeftScroll) // ScreenGadgets, default || (!bFarShowColNames && !(pConChar[nIdx+1] == ucBoxDblHorz || pConChar[nIdx+1] == L' ') && pConChar[nIdx+1] != ucBoxSinglDownDblHorz && pConChar[nIdx+1] != ucBoxDblDownDblHorz) ))) bContinue = true; } if (bContinue) { for (UINT i=2; !bLeftPanel && i<nWidth; i++) { // Найти правый край левой панели if (pConChar[nIdx+i] == ucBoxDblDownLeft && ((pConChar[nIdx+i-1] == ucBoxDblHorz || pConChar[nIdx+i-1] == L' ') || pConChar[nIdx+i-1] == ucBoxSinglDownDblHorz // правый угол панели || pConChar[nIdx+i-1] == ucBoxDblDownDblHorz || (pConChar[nIdx+i-1] == L']' && pConChar[nIdx+i-2] == L'\\') // ScreenGadgets, default ) // МОЖЕТ быть закрыто AltHistory /*&& pConChar[nIdx+i+nWidth] == ucBoxDblVert*/) { uint nBottom = nHeight - 1; while(nBottom > 4) //-V112 { if (pConChar[nWidth*nBottom] == ucBoxDblUpRight /*&& pConChar[nWidth*nBottom+i] == ucBoxDblUpLeft*/) { rLeftPanel.left = 1; rLeftPanel.top = nY + (bFarShowColNames ? 2 : 1); rLeftPanel.right = i-1; if (bFarShowStatus) { rLeftPanel.bottom = nBottom - 3; for (int j = (nBottom - 3); j > (int)(nBottom - 13) && j > rLeftPanel.top; j--) { if (pConChar[nWidth*j] == ucBoxDblVertSinglRight) { rLeftPanel.bottom = j - 1; break; } } } else { rLeftPanel.bottom = nBottom - 1; } rLeftPanelFull.left = 0; rLeftPanelFull.top = nY; rLeftPanelFull.right = i; rLeftPanelFull.bottom = nBottom; bLeftPanel = TRUE; break; } nBottom --; } } } } // (Если есть левая панель и она не FullScreen) или левой панели нет вообще if ((bLeftPanel && rLeftPanelFull.right < (int)nWidth) || !bLeftPanel) { if (bLeftPanel) { // Положение известно, нужно только проверить наличие if (pConChar[nIdx+rLeftPanelFull.right+1] == ucBoxDblDownRight /*&& pConChar[nIdx+rLeftPanelFull.right+1+nWidth] == ucBoxDblVert*/ /*&& pConChar[nIdx+nWidth*2] == ucBoxDblVert*/ /*&& pConChar[(rLeftPanelFull.bottom+3)*nWidth+rLeftPanelFull.right+1] == ucBoxDblUpRight*/ && pConChar[(rLeftPanelFull.bottom+1)*nWidth-1] == ucBoxDblUpLeft ) { rRightPanel = rLeftPanel; // bottom & top берем из rLeftPanel rRightPanel.left = rLeftPanelFull.right+2; rRightPanel.right = nWidth-2; rRightPanelFull = rLeftPanelFull; rRightPanelFull.left = rLeftPanelFull.right+1; rRightPanelFull.right = nWidth-1; bRightPanel = TRUE; } } // Начиная с FAR2 build 1295 панели могут быть разной высоты // или левой панели нет // или активная панель в FullScreen режиме if (!bRightPanel) { // нужно определить положение панели if (((pConChar[nIdx+nWidth-1]>=L'0' && pConChar[nIdx+nWidth-1]<=L'9') // справа часы || pConChar[nIdx+nWidth-1] == ucBoxDblDownLeft) // или рамка && (pConChar[nIdx+nWidth*2-1] == ucBoxDblVert // ну и правая граница панели || pConChar[nIdx+nWidth*2-1] == ucUpScroll) // или стрелка скроллбара ) { int iMinFindX = bLeftPanel ? (rLeftPanelFull.right+1) : 0; for(int i=nWidth-3; !bRightPanel && i>=iMinFindX; i--) { // ищем левую границу правой панели if (pConChar[nIdx+i] == ucBoxDblDownRight && (((pConChar[nIdx+i+1] == ucBoxDblHorz || pConChar[nIdx+i+1] == L' ') && bFarShowColNames) || pConChar[nIdx+i+1] == ucBoxSinglDownDblHorz // правый угол панели || pConChar[nIdx+i+1] == ucBoxDblDownDblHorz || (pConChar[nIdx+i-1] == L']' && pConChar[nIdx+i-2] == L'\\') // ScreenGadgets, default || (!bFarShowColNames && !(pConChar[nIdx+i+1] == ucBoxDblHorz || pConChar[nIdx+i+1] == L' ') && pConChar[nIdx+i+1] != ucBoxSinglDownDblHorz && pConChar[nIdx+i+1] != ucBoxDblDownDblHorz) ) // МОЖЕТ быть закрыто AltHistory /*&& pConChar[nIdx+i+nWidth] == ucBoxDblVert*/) { uint nBottom = nHeight - 1; while(nBottom > 4) //-V112 { if (/*pConChar[nWidth*nBottom+i] == ucBoxDblUpRight &&*/ pConChar[nWidth*(nBottom+1)-1] == ucBoxDblUpLeft) { rRightPanel.left = i+1; rRightPanel.top = nY + (bFarShowColNames ? 2 : 1); rRightPanel.right = nWidth-2; //rRightPanel.bottom = nBottom - 3; if (bFarShowStatus) { rRightPanel.bottom = nBottom - 3; for (int j = (nBottom - 3); j > (int)(nBottom - 13) && j > rRightPanel.top; j--) { if (pConChar[nWidth*j+i] == ucBoxDblVertSinglRight) { rRightPanel.bottom = j - 1; break; } } } else { rRightPanel.bottom = nBottom - 1; } rRightPanelFull.left = i; rRightPanelFull.top = nY; rRightPanelFull.right = nWidth-1; rRightPanelFull.bottom = nBottom; bRightPanel = TRUE; break; } nBottom --; } } } } } } return (bLeftPanel || bRightPanel); }
HWND CTabPanelWin::CreateTabbar() { gpSetCls->CheckTheming(); if (!mh_Rebar) return NULL; // создаётся только как Band в ReBar if (mh_Tabbar) return mh_Tabbar; // Уже создали // Важно проверку делать после создания главного окна, иначе IsAppThemed будет возвращать FALSE BOOL bAppThemed = FALSE, bThemeActive = FALSE; FAppThemed pfnThemed = NULL; HMODULE hUxTheme = LoadLibrary(L"UxTheme.dll"); if (hUxTheme) { pfnThemed = (FAppThemed)GetProcAddress(hUxTheme, "IsAppThemed"); if (pfnThemed) bAppThemed = pfnThemed(); pfnThemed = (FAppThemed)GetProcAddress(hUxTheme, "IsThemeActive"); if (pfnThemed) bThemeActive = pfnThemed(); FreeLibrary(hUxTheme); hUxTheme = NULL; } if (!bAppThemed || !bThemeActive) mn_ThemeHeightDiff = 2; RECT rcClient = {-32000, -32000, -32000+300, -32000+100}; if (ghWnd) { rcClient = gpConEmu->GetGuiClientRect(); } else { _ASSERTE(ghWnd!=NULL && "ConEmu main window must be created already!"); } DWORD nPlacement = TCS_SINGLELINE|WS_VISIBLE|WS_CHILD; mh_Tabbar = CreateWindow(WC_TABCONTROL, NULL, nPlacement | WS_CLIPSIBLINGS | TCS_FOCUSNEVER, 0, 0, rcClient.right, 0, mh_Rebar, NULL, g_hInstance, NULL); if (mh_Tabbar == NULL) { return NULL; } // Надо TabPanelWinMap map = {this}; //{ CTabPanelWin* object; HWND hWnd; WNDPROC defaultProc; }; map.defaultProc = (WNDPROC)SetWindowLongPtr(mh_Tabbar, GWLP_WNDPROC, (LONG_PTR)_TabProc); map.hWnd = mh_Tabbar; gp_TabPanelWinMap->Set(mh_Tabbar, map); SendMessage(mh_Tabbar, TCM_SETIMAGELIST, 0, (LPARAM)mp_Owner->GetTabIcons()); if (!mh_TabTip || !IsWindow(mh_TabTip)) InitTooltips(mh_Tabbar); TabCtrl_SetToolTips(mh_Tabbar, mh_TabTip); UpdateTabFontInt(); if (!mh_Balloon || !IsWindow(mh_Balloon)) { InitTooltips(mh_Tabbar); } // Добавляет закладку, или меняет (при необходимости) заголовок существующей AddTabInt(gpConEmu->GetDefaultTabLabel(), 0, gpConEmu->mb_IsUacAdmin, -1); // нас интересует смещение клиентской области. Т.е. начало - из 0. Остальное не важно rcClient = MakeRect(600, 400); QueryTabbarHeight(); return mh_Tabbar; }
bool CConEmuInside::GetInsideRect(RECT* prWnd) { RECT rcWnd = {}; if (m_InsideIntegration == ii_None) { _ASSERTE(m_InsideIntegration != ii_None); return false; } RECT rcParent = {}, rcRelative = {}; GetClientRect(mh_InsideParentWND, &rcParent); if (m_InsideIntegration == ii_Simple) { mrc_InsideParent = rcParent; ZeroStruct(mrc_InsideParentRel); rcWnd = rcParent; } else { RECT rcChild = {}; GetWindowRect(mh_InsideParentRel, &rcChild); MapWindowPoints(NULL, mh_InsideParentWND, (LPPOINT)&rcChild, 2); mrc_InsideParent = rcParent; mrc_InsideParentRel = rcChild; IntersectRect(&rcRelative, &rcParent, &rcChild); // WinXP & Win2k3 if (gnOsVer < 0x600) { rcWnd = rcRelative; } // Windows 7 else if ((rcParent.bottom - rcRelative.bottom) >= 100) { // Предпочтительно // Далее - ветвимся по OS if (gnOsVer < 0x600) { rcWnd = MakeRect(rcRelative.left, rcRelative.bottom + 4, rcParent.right, rcParent.bottom); } else { rcWnd = MakeRect(rcParent.left, rcRelative.bottom + 4, rcParent.right, rcParent.bottom); } } else if ((rcParent.right - rcRelative.right) >= 200) { rcWnd = MakeRect(rcRelative.right + 4, rcRelative.top, rcParent.right, rcRelative.bottom); } else { TODO("Другие системы и проверки на валидность"); rcWnd = MakeRect(rcParent.left, rcParent.bottom - 100, rcParent.right, rcParent.bottom); } } if (prWnd) *prWnd = rcWnd; return true; }
static void Init(void) { static const char *fragShaderText = "uniform vec4 diffuse;\n" "uniform vec4 specular;\n" "varying vec3 normal;\n" "void main() {\n" " // Compute dot product of light direction and normal vector\n" " float dotProd = max(dot(gl_LightSource[0].position.xyz, \n" " normalize(normal)), 0.0);\n" " // Compute diffuse and specular contributions\n" " gl_FragColor = diffuse * dotProd + specular * pow(dotProd, 20.0);\n" "}\n"; static const char *vertShaderText = "varying vec3 normal;\n" "void main() {\n" " gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;\n" " normal = gl_NormalMatrix * gl_Normal;\n" "}\n"; const char *version; version = (const char *) glGetString(GL_VERSION); if (version[0] != '2' || version[1] != '.') { printf("This program requires OpenGL 2.x, found %s\n", version); exit(1); } GetExtensionFuncs(); fragShader = glCreateShader_func(GL_FRAGMENT_SHADER); if (FragProgFile) ReadShader(fragShader, FragProgFile); else LoadAndCompileShader(fragShader, fragShaderText); vertShader = glCreateShader_func(GL_VERTEX_SHADER); if (VertProgFile) ReadShader(vertShader, VertProgFile); else LoadAndCompileShader(vertShader, vertShaderText); program = glCreateProgram_func(); glAttachShader_func(program, fragShader); glAttachShader_func(program, vertShader); glLinkProgram_func(program); CheckLink(program); glUseProgram_func(program); uDiffuse = glGetUniformLocation_func(program, "diffuse"); uSpecular = glGetUniformLocation_func(program, "specular"); uTexture = glGetUniformLocation_func(program, "texture"); printf("DiffusePos %d SpecularPos %d TexturePos %d\n", uDiffuse, uSpecular, uTexture); glUniform4fv_func(uDiffuse, 1, diffuse); glUniform4fv_func(uSpecular, 1, specular); /* assert(glGetError() == 0);*/ glUniform1i_func(uTexture, 2); /* use texture unit 2 */ /*assert(glGetError() == 0);*/ if (CoordAttrib) { int i; glBindAttribLocation_func(program, CoordAttrib, "coord"); i = glGetAttribLocation_func(program, "coord"); assert(i >= 0); if (i != CoordAttrib) { printf("Hmmm, NVIDIA bug?\n"); CoordAttrib = i; } else { printf("Mesa bind attrib: coord = %d\n", i); } } /*assert(glGetError() == 0);*/ glClearColor(0.3f, 0.3f, 0.3f, 0.0f); glEnable(GL_DEPTH_TEST); glEnable(GL_LIGHT0); glEnable(GL_LIGHTING); glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, diffuse); glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, specular); glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, 20.0f); MakeSphere(); MakeRect(); CurList = SphereList; #if TEXTURE MakeTexture(); #endif printf("GL_RENDERER = %s\n",(const char *) glGetString(GL_RENDERER)); printf("Press p to toggle between per-pixel and per-vertex lighting\n"); /* test glGetShaderSource() */ if (0) { GLsizei len = strlen(fragShaderText) + 1; GLsizei lenOut; GLchar *src =(GLchar *) malloc(len * sizeof(GLchar)); glGetShaderSource_func(fragShader, 0, NULL, src); glGetShaderSource_func(fragShader, len, &lenOut, src); assert(len == lenOut + 1); assert(strcmp(src, fragShaderText) == 0); free(src); } assert(glIsProgram_func(program)); assert(glIsShader_func(fragShader)); assert(glIsShader_func(vertShader)); glColor3f(1, 0, 0); /* for testing state vars */ { static GLfloat fc[4] = { 1, 1, 0, 0 }; static GLfloat amb[4] = { 1, 0, 1, 0 }; glFogfv(GL_FOG_COLOR, fc); glLightfv(GL_LIGHT1, GL_AMBIENT, amb); } #if 0 TestFunctions(); #else (void) TestFunctions; #endif }