void CFT_Area::ConstructL() { // TRACE ("WARNING !! Test\n"); CAE_Object::ConstructL(); iBeaconC = CAE_TState<TInt>::NewL(KAreaBeaconCName, this, TTransInfo()); iBeaconX = CAE_TState<TInt>::NewL(KAreaBeaconXName, this, TTransInfo()); iLbDown = CAE_TState<TInt>::NewL("LbDown", this, TTransInfo(), CAE_StateBase::EType_Input); iMcPos = CAE_TState<CF_TdPoint>::NewL("McPos", this, TTransInfo(), CAE_StateBase::EType_Input); iRect = CAE_TState<CF_Rect>::NewL(KAreaRectName, this, TTransInfo(), CAE_StateBase::EType_Input); *iRect = iInitRect; // Create borders CF_Rect rt = iInitRect; float midx, midy; midx = (rt.iRightLower.iX - rt.iLeftUpper.iX)/2.0; midy = (rt.iRightLower.iY - rt.iLeftUpper.iY)/2.0; printf("area_constr: lx= %d, ly= %d, rx= %d, ry= %d\n", rt.iLeftUpper.iX, rt.iLeftUpper.iY, rt.iRightLower.iX, rt.iRightLower.iY); CreateBorder(rt.iLeftUpper.iX-KBorderRadius, midy, KObjBorderLeftName, CAE_TRANS(UpdateBordHookLeft)); CreateBorder(rt.iRightLower.iX + KBorderRadius, midy, KObjBorderRightName, CAE_TRANS(UpdateBordHookRight)); CreateBorder(midx, rt.iLeftUpper.iY - KBorderRadius, KObjBorderTopName, CAE_TRANS(UpdateBordHookTop)); CreateBorder(midx, rt.iRightLower.iY + KBorderRadius, KObjBorderBottomName, CAE_TRANS(UpdateBordHookBottom)); // Create balls CreateBall(40, 40, 2000, 20, "Ball1"); CreateBall(300, 300, 2000, 30, "Ball2"); CreateBall(200, 400, 3000, 40, "Ball3"); #if 0 CreateBall(300, 300, 200, 40, "Ball2"); CreateBall(400, 300, 300, 60, "Ball3"); #endif }
//=========================================================================== void DrawActiveWindow(HDC buf, RECT r) { COLORREF bColor; Settings const & s = getSettings(); // Checks for windows just showing on the edges of the screen if (r.bottom - r.top < 2) { if (!_stricmp(s.m_focusedWindow.styleType, "border")) bColor = s.m_focusedWindow.borderColor; else bColor = s.m_window.borderColor; HPEN borderPen = CreatePen(PS_SOLID, 1, bColor); HPEN oldPen = (HPEN) SelectObject(buf, borderPen); MoveToEx(buf, r.left, r.top, NULL); LineTo(buf, r.right, r.top); SelectObject(buf,oldPen); DeleteObject(borderPen); //MessageBox(0, "Warning sir!\n\nCan't draw this window as a RECT dude!", "DrawActiveWindow", MB_OK | MB_TOPMOST | MB_SETFOREGROUND); return; } if (r.right - r.left < 2) { if (!_stricmp(s.m_focusedWindow.styleType, "border")) bColor = s.m_focusedWindow.borderColor; else bColor = s.m_window.borderColor; HPEN borderPen = CreatePen(PS_SOLID, 1, bColor); HPEN oldPen = (HPEN) SelectObject(buf, borderPen); MoveToEx(buf, r.left, r.top, NULL); LineTo(buf, r.left, r.bottom); SelectObject(buf,oldPen); DeleteObject(borderPen); return; } if (!_stricmp(s.m_focusedWindow.styleType, "texture")) { MakeStyleGradient(buf, &r, s.m_focusedWindow.ownStyle ? s.m_focusedWindow.style : &s.m_focusedWindow.Style, false); CreateBorder(buf, &r, s.m_focusedWindow.borderColor, 1); } else if (!_stricmp(s.m_focusedWindow.styleType, "border")) { MakeStyleGradient(buf, &r, s.m_window.ownStyle ? s.m_window.style : &s.m_window.Style, false); CreateBorder(buf, &r, s.m_focusedWindow.borderColor, 1); } else MakeStyleGradient(buf, &r, s.m_window.style, true); }
void DrawInactiveWindow(HDC buf, RECT r) { Settings const & s = getSettings(); if (r.bottom - r.top < 2) { HPEN borderPen = CreatePen(PS_SOLID, 1, getSettings().m_window.borderColor); HPEN oldPen = (HPEN) SelectObject(buf, borderPen); MoveToEx(buf, r.left, r.top, NULL); LineTo(buf, r.right, r.top); SelectObject(buf,oldPen); DeleteObject(borderPen); return; } if (r.right - r.left < 2) { HPEN borderPen = CreatePen(PS_SOLID, 1, getSettings().m_window.borderColor); HPEN oldPen = (HPEN) SelectObject(buf, borderPen); MoveToEx(buf, r.left, r.top, NULL); LineTo(buf, r.left, r.bottom); SelectObject(buf,oldPen); DeleteObject(borderPen); return; } MakeStyleGradient(buf, &r, s.m_window.ownStyle ? s.m_window.style : &s.m_window.Style, false); CreateBorder(buf, &r, s.m_window.borderColor, 1); }
World::World(const int &ROWS, const int &COLS, const int &SMOOTH_LEVEL, const int &GRASS_CHANCE) : Map(ROWS, COLS), SMOOTH_LEVEL(SMOOTH_LEVEL), GRASS_CHANCE(GRASS_CHANCE) { for(int y = 0; y < ROWS; y++) { for(int x = 0; x < COLS; x++) { Tile::TileType type = GetRandomTileType(); At(x, y) = Tile(x, y, type); } } for(int i = 0; i < SMOOTH_LEVEL; i++) { if(i == SMOOTH_LEVEL - 1) { CreateBorder(); } CellularAutomata(); } int numDungeonsToCreate = GameMath::Random(ROWS/2, ROWS/3); for (int i = 0; i < numDungeonsToCreate; i++) { Vector2 newDungeonCoords; bool otherDungeonNear = true; while(otherDungeonNear) { otherDungeonNear = false; newDungeonCoords = *GetFreeTileCoords(COLS, ROWS); const int DUNGEON_PADDING = 3; int x = newDungeonCoords.x - DUNGEON_PADDING; int y = newDungeonCoords.y - DUNGEON_PADDING; int xMax = newDungeonCoords.x + DUNGEON_PADDING; int yMax = newDungeonCoords.y + DUNGEON_PADDING; for (; y < yMax; y++) { for (; x < xMax; x++) { if(!IsOutOfBounds(x, y) && At(x, y).type == Tile::DOOR && (x != newDungeonCoords.x && y != newDungeonCoords.y)) { otherDungeonNear = true; break; } } } } At(newDungeonCoords).type = Tile::DOOR; } entryCoords = GetFreeTileCoords(COLS, ROWS); spawnCoords = entryCoords; }
//=========================================================================== void DrawActiveDesktop(HDC buf, RECT r, int i) { Settings const & s = getSettings(); if (!_stricmp(s.m_activeDesktop.styleType, "border3")) { r.right = r.right + 2; r.bottom = r.bottom + 2; if (s.m_activeDesktop.Style.parentRelative) CreateBorder(buf, &r, s.m_activeDesktop.borderColor, 1); else { MakeStyleGradient(buf, &r, s.m_activeDesktop.ownStyle ? s.m_activeDesktop.style : &s.m_activeDesktop.Style, false); CreateBorder(buf, &r, s.m_activeDesktop.borderColor, 1); } } else if (!_stricmp(s.m_activeDesktop.styleType, "border2")) { r.left = r.left - 1; r.top = r.top - 1; r.right = r.right + 1; r.bottom = r.bottom + 1; if (!s.m_activeDesktop.ownStyle && s.m_activeDesktop.Style.parentRelative) CreateBorder(buf, &r, s.m_activeDesktop.borderColor, 1); else { MakeStyleGradient(buf, &r, s.m_activeDesktop.ownStyle ? s.m_activeDesktop.style : &s.m_activeDesktop.Style, false); CreateBorder(buf, &r, s.m_desktop.Style.borderColor, 1); } } else if (!_stricmp(s.m_activeDesktop.styleType, "border")) { if (!s.m_activeDesktop.ownStyle && s.m_activeDesktop.Style.parentRelative) CreateBorder(buf, &r, s.m_activeDesktop.borderColor, 1); else { MakeStyleGradient(buf, &r, s.m_activeDesktop.ownStyle ? s.m_activeDesktop.style : &s.m_activeDesktop.Style, false); CreateBorder(buf, &r, s.m_desktop.Style.borderColor, 1); } } else if (!_stricmp(s.m_activeDesktop.styleType, "texture")) { if (!s.m_activeDesktop.ownStyle && !s.m_activeDesktop.Style.parentRelative) MakeStyleGradient(buf, &r, s.m_activeDesktop.ownStyle ? s.m_activeDesktop.style : &s.m_activeDesktop.Style, false); CreateBorder(buf, &r, s.m_activeDesktop.borderColor, 1); } else if (!s.m_desktop.Style.parentRelative) // "none" MakeStyleGradient(buf, &r, s.m_desktop.ownStyle ? s.m_desktop.style : &s.m_desktop.Style, false); //desktopRect[i] = r; desktopRect.insert(desktopRect.begin() + i, r); }
void PutGradient (WinInfo * WI, HDC hdc, RECT * rc, StyleItem * pG) { if (pG->parentRelative) { if (pG->borderWidth) CreateBorder(hdc, rc, pG->borderColor, pG->borderWidth); return; } int width = rc->right - rc->left; int height = rc->bottom - rc->top; int i = pG >= &mSkin.F.Title ? pG - &mSkin.F.Title + 6 : pG - &mSkin.U.Title; GdiInfo *pGdi = WI->gdiobjs + i; HBITMAP bmp = (HBITMAP)pGdi->hObj; HGDIOBJ other; if (bmp && width == pGdi->cx && height == pGdi->cy) { other = SelectObject(WI->buf, bmp); } else { RECT r; r.left = r.top = 0; r.right = width, r.bottom = height; if (bmp) DeleteObject(bmp); pGdi->cx = width; pGdi->cx = height; pGdi->hObj = bmp = CreateCompatibleBitmap(hdc, width, height); if (NULL == bmp) return; other = SelectObject(WI->buf, bmp); StyleItem si; si = *pG; // makes a copy of StyleItem into si MakeStyleGradient(WI->buf, &r, &si, true); } BitBlt(hdc, rc->left, rc->top, width, height, WI->buf, 0, 0, SRCCOPY); SelectObject(WI->buf, other); }
IBorderPtr IBorder::CreateBorderFromStream(SYSTEM::IArchive &ar) { unsigned long lPos = ar.GetCurrentPos(); int type; ar & type; ar.GetCurrentPos() = lPos; IBorderPtr pBorder = CreateBorder((Border_Type)type); if (pBorder != NULL) pBorder->serialization(ar); return pBorder; }
void Scene2Controller::Setup() { // Box2D CreateBorder(); CreateCourt(); CreateNet(); scene_begin_time = ofGetElapsedTimef(); const ofPoint left(256-64, 200); const ofPoint right(768-64, 200); const float pause = 0.5; model_.dialogue .Speed(20.0) .Foreground(ofColor::white) .Background(ofColor(0, 0, 0, 0)) .Position("left", left) .Position("right", right) .Message("You know why you're here, right?", "right").Pause(pause) .Message("No.", "left").Pause(pause) .Message("Because you're bad at tennis.\nI'm gonna make you good.", "right").Pause(2.0) .Clear(); }
void Scene3Controller::Setup() { // Box2D CreateBorder(); CreateCourt(); CreateEight(); CreateNet(); model_.world.SetContactListener(this); const ofPoint right(768-256, 50); const float pause = 2.0; model_.dialogue .Speed(25.0) .PunctuationDelay(0.0) .FontSize(16.0) .Foreground(ofColor::black) .Position("court", ofPoint(768, 600)) .Position("right", right) .Position("below", right + ofVec2f(0, 100)).Then([this] () { std::vector<float> volume_targets; volume_targets.push_back(0.1); //bass sound volume_targets.push_back(0.5); //high arpeg v1 volume_targets.push_back(0.0); //high arpeg v2 volume_targets.push_back(0.0); //low arpeg v1 volume_targets.push_back(0.0); //low arpeg v2 volume_targets.push_back(0.0); //words 1 volume_targets.push_back(0.0); //words 2 volume_targets.push_back(0.0); //words 3 scene_manager.GetMusic().GetSoundEffect<LoopSet>("opponents")->SetVolumeTargets(volume_targets); }).Message("I don't believe in gravity, \nI will surely win this match!", "right").Then([this] () { model_.served = false; model_.ball_in_play = true; model_.opponent_index = 0; }) .Barrier("point").Then([this] () { std::vector<float> volume_targets; volume_targets.push_back(0.2); //bass sound volume_targets.push_back(0.5); //high arpeg v1 volume_targets.push_back(0.0); //high arpeg v2 volume_targets.push_back(1.0); //low arpeg v1 volume_targets.push_back(0.0); //low arpeg v2 volume_targets.push_back(0.0); //words 1 volume_targets.push_back(0.0); //words 2 volume_targets.push_back(0.0); //words 3 scene_manager.GetMusic().GetSoundEffect<LoopSet>("opponents")->SetVolumeTargets(volume_targets); }).Clear().Pause(pause) .Message("I have time, \nI will surely win this match!", "right").Then([this] () { model_.served = false; model_.ball_in_play = true; model_.opponent_index = 1; }) .Barrier("point").Then([this] () { std::vector<float> volume_targets; volume_targets.push_back(0.5); //bass sound volume_targets.push_back(0.3); //high arpeg v1 volume_targets.push_back(0.0); //high arpeg v2 volume_targets.push_back(1.0); //low arpeg v1 volume_targets.push_back(0.0); //low arpeg v2 volume_targets.push_back(0.0); //words 1 volume_targets.push_back(0.0); //words 2 volume_targets.push_back(0.0); //words 3 scene_manager.GetMusic().GetSoundEffect<LoopSet>("opponents")->SetVolumeTargets(volume_targets); }).Clear().Pause(pause) .Message("I have many racquets, \nI will surely win this match!", "right").Then([this] () { model_.served = false; model_.ball_in_play = true; model_.opponent_index = 2; }) .Barrier("point").Then([this] () { std::vector<float> volume_targets; volume_targets.push_back(0.5); //bass sound volume_targets.push_back(0.2); //high arpeg v1 volume_targets.push_back(0.0); //high arpeg v2 volume_targets.push_back(1.0); //low arpeg v1 volume_targets.push_back(0.0); //low arpeg v2 volume_targets.push_back(0.0); //words 1 volume_targets.push_back(0.0); //words 2 volume_targets.push_back(0.0); //words 3 scene_manager.GetMusic().GetSoundEffect<LoopSet>("opponents")->SetVolumeTargets(volume_targets); }).Clear().Pause(pause) .Message("We're playing a whole different game,\nwe will surely win this match!", "right").Then([this] () { model_.served = true; model_.ball_in_play = true; model_.opponent_index = 3; }) .Barrier("point").Then([this] () { std::vector<float> volume_targets; volume_targets.push_back(0.5); //bass sound volume_targets.push_back(0.2); //high arpeg v1 volume_targets.push_back(0.0); //high arpeg v2 volume_targets.push_back(0.9); //low arpeg v1 volume_targets.push_back(0.0); //low arpeg v2 volume_targets.push_back(0.0); //words 1 volume_targets.push_back(0.3); //words 2 volume_targets.push_back(0.0); //words 3 scene_manager.GetMusic().GetSoundEffect<LoopSet>("opponents")->SetVolumeTargets(volume_targets); }).Clear().Pause(pause) .Message("I'm made of glass, \nI will surely win this match!", "right").Then([this] () { model_.served = false; model_.ball_in_play = true; model_.opponent_index = 4; }) .Barrier("point").Then([this] () { std::vector<float> volume_targets; volume_targets.push_back(0.5); //bass sound volume_targets.push_back(0.0); //high arpeg v1 volume_targets.push_back(0.5); //high arpeg v2 volume_targets.push_back(0.0); //low arpeg v1 volume_targets.push_back(1.0); //low arpeg v2 volume_targets.push_back(0.0); //words 1 volume_targets.push_back(0.3); //words 2 volume_targets.push_back(0.0); //words 3 scene_manager.GetMusic().GetSoundEffect<LoopSet>("opponents")->SetVolumeTargets(volume_targets); }).Clear().Pause(pause).Then([this] () { model_.served = true; model_.ball_in_play = true; model_.opponent_index = 5; }) .Barrier("point").Then([this] () { std::vector<float> volume_targets; volume_targets.push_back(0.5); //bass sound volume_targets.push_back(0.0); //high arpeg v1 volume_targets.push_back(0.5); //high arpeg v2 volume_targets.push_back(1.0); //low arpeg v1 volume_targets.push_back(0.0); //low arpeg v2 volume_targets.push_back(0.6); //words 1 volume_targets.push_back(0.0); //words 2 volume_targets.push_back(0.0); //words 3 scene_manager.GetMusic().GetSoundEffect<LoopSet>("opponents")->SetVolumeTargets(volume_targets); }) .Message("I'm late, I will...", "court").Pause(0.5).Clear().Pause(0.5) .Message("I'm a blank slate,\nI will surely win this match!", "right").Then([this] () { model_.served = false; model_.ball_in_play = true; model_.opponent_index = 6; }) .Barrier("point").Then([this] () { std::vector<float> volume_targets; volume_targets.push_back(0.7); //bass sound volume_targets.push_back(0.0); //high arpeg v1 volume_targets.push_back(0.5); //high arpeg v2 volume_targets.push_back(1.0); //low arpeg v1 volume_targets.push_back(0.0); //low arpeg v2 volume_targets.push_back(0.4); //words 1 volume_targets.push_back(0.0); //words 2 volume_targets.push_back(0.4); //words 3 scene_manager.GetMusic().GetSoundEffect<LoopSet>("opponents")->SetVolumeTargets(volume_targets); }).Clear().Pause(pause) .Message("I've spent my life studying this game,\nI will surely win this match!", "right").Then([this] () { model_.served = false; model_.ball_in_play = true; model_.opponent_index = 7; }) .Barrier("point").Then([this] () { std::vector<float> volume_targets; volume_targets.push_back(0.7); //bass sound volume_targets.push_back(0.0); //high arpeg v1 volume_targets.push_back(0.3); //high arpeg v2 volume_targets.push_back(0.5); //low arpeg v1 volume_targets.push_back(0.0); //low arpeg v2 volume_targets.push_back(0.4); //words 1 volume_targets.push_back(0.0); //words 2 volume_targets.push_back(0.4); //words 3 scene_manager.GetMusic().GetSoundEffect<LoopSet>("opponents")->SetVolumeTargets(volume_targets); }).Clear().Pause(pause).Foreground(ofColor::white) .Message("I'm the score itself, \nI will surely win this match!", "right").Then([this] () { model_.eight_body->SetActive(true); model_.served = false; model_.ball_in_play = true; model_.opponent_index = 8; }) .Barrier("point").Then([this] () { std::vector<float> volume_targets; volume_targets.push_back(0.9); //bass sound volume_targets.push_back(0.0); //high arpeg v1 volume_targets.push_back(0.2); //high arpeg v2 volume_targets.push_back(0.0); //low arpeg v1 volume_targets.push_back(1.0); //low arpeg v2 volume_targets.push_back(0.5); //words 1 volume_targets.push_back(0.0); //words 2 volume_targets.push_back(0.5); //words 3 scene_manager.GetMusic().GetSoundEffect<LoopSet>("opponents")->SetVolumeTargets(volume_targets); }).Clear().Pause(pause).Foreground(ofColor::black) .Message("I'm you, \nI will surely win this match!", "right").Then([this] () { model_.eight_body->SetActive(false); model_.served = false; model_.ball_in_play = true; model_.opponent_index = 9; }) .Barrier("score").Then([this] () { model_.served = false; model_.ball_in_play = true; }).Barrier("score").Then([this] () { model_.served = false; model_.ball_in_play = true; }).Barrier("point").Clear(); }
//=========================================================================== void PaintToolbar(HDC hdc, RECT *rcPaint) { RECT r; int i; const TCHAR *label = Toolbar_CurrentWindow; StyleItem *pSI; #ifdef BBOPT_MEMCHECK // Display some statistics. #pragma message("\n"__FILE__ "(397) : warning 0: MEMCHECK enabled.\n") /* if (NULL==Toolbar_hFont) { LOGFONT logFont; SystemParametersInfo(SPI_GETICONTITLELOGFONT, 0, &logFont, 0); Toolbar_hFont = CreateFontIndirect(&logFont); } */ extern int g_menu_count; extern int g_menu_item_count; TCHAR temp[256]; if (alloc_size && false == Toolbar_ShowingExternalLabel) { _stprintf(temp,_T("Menus %d MenuItems %d Memory %d"), g_menu_count, g_menu_item_count, alloc_size); label = temp; } #endif int tbW = TBInfo.width; int tbH = TBInfo.height; HDC buf = CreateCompatibleDC(NULL); HGDIOBJ bufother = SelectObject(buf, CreateCompatibleBitmap(hdc, tbW, tbH)); if (NULL==Toolbar_hFont) Toolbar_hFont = CreateStyleFont(&mStyle.Toolbar); HGDIOBJ other_font = SelectObject(buf, Toolbar_hFont); // Get width of clock... SIZE size; GetTextExtentPoint32(buf, Toolbar_CurrentTime, (int)_tcsnlen(Toolbar_CurrentTime,0x7FFFFFFFUL), &size); size.cx += 6; if (tbClockW < size.cx) tbClockW = size.cx + 6; GetTextExtentPoint32(buf, Toolbar_WorkspaceName, (int)_tcsnlen(Toolbar_WorkspaceName,0x7FFFFFFFUL), &size); int tbLabelW = size.cx + 6; // The widest sets the width! tbLabelW = tbClockW = (int)imax(tbH * 2, imax(tbLabelW, tbClockW)); int margin = tbMargin; int border = mStyle.Toolbar.borderWidth; int border_margin = margin + border; int button_padding = (tbH - tbButtonWH) / 2 - border; int tbLabelX = border_margin; int tbClockX = tbW - tbClockW - border_margin; int two_buttons = 2*tbButtonWH + 3*button_padding; int tbWinLabelX = tbLabelX + tbLabelW + two_buttons; int tbWinLabelW = tbClockX - tbWinLabelX - two_buttons; if (tbWinLabelW < 0) tbWinLabelW = 0; Toolbar_Button[0].r.left = tbLabelX + tbLabelW + button_padding; Toolbar_Button[1].r.left = Toolbar_Button[0].r.left + tbButtonWH + button_padding; Toolbar_Button[2].r.left = tbClockX - 2*tbButtonWH - 2*button_padding; Toolbar_Button[3].r.left = Toolbar_Button[2].r.left + tbButtonWH + button_padding; Toolbar_Button[4].r.left = tbClockX; for (i = 0; i<5; i++) { Toolbar_Button[i].r.top = (tbH - tbButtonWH) / 2; Toolbar_Button[i].r.bottom = Toolbar_Button[i].r.top + tbButtonWH; Toolbar_Button[i].r.right = Toolbar_Button[i].r.left + tbButtonWH; } Toolbar_Button[4].r.right = tbClockX + tbClockW; //==================== // Paint toolbar Style _SetRect(&r, 0, 0, tbW, tbH); pSI = &mStyle.Toolbar; MakeStyleGradient(buf, &r, pSI, true); //==================== // Paint unpressed workspace/task buttons... r.left = r.top = 0; r.right = r.bottom = tbButtonWH; { HPEN activePen = CreatePen(PS_SOLID, 1, mStyle.ToolbarButtonPressed.picColor); HPEN inactivePen = CreatePen(PS_SOLID, 1, mStyle.ToolbarButton.picColor); HDC src = CreateCompatibleDC(NULL); HGDIOBJ srcother = SelectObject(src, CreateCompatibleBitmap(hdc, tbButtonWH, tbButtonWH)); int yOffset = tbH / 2; int xOffset; int f1 = -1; for (i=0; i<4; i++) { int f2 = Toolbar_Button[i].pressed || (Toolbar_force_button_pressed && i&1); pSI = f2 ? &mStyle.ToolbarButtonPressed : &mStyle.ToolbarButton; if (pSI->parentRelative) { CreateBorder(buf, &r, pSI->borderColor, pSI->borderWidth); } else { if (f1 != f2) MakeStyleGradient(src, &r, pSI, pSI->bordered), f1 = f2; BitBlt(buf, Toolbar_Button[i].r.left, Toolbar_Button[i].r.top, tbButtonWH, tbButtonWH, src, 0, 0, SRCCOPY ); } xOffset = Toolbar_Button[i].r.left + (tbButtonWH / 2); HGDIOBJ penother = SelectObject(buf, f2 ? activePen : inactivePen); arrow_bullet(buf, xOffset, yOffset, (i&1)*2-1); SelectObject(buf, penother); } DeleteObject(SelectObject(src, srcother)); DeleteDC(src); DeleteObject(inactivePen); DeleteObject(activePen); } //==================== r.top = (tbH - tbLabelH)/2; r.bottom = r.top + tbLabelH; SetBkMode(buf, TRANSPARENT); int justify = mStyle.Toolbar.Justify | (DT_VCENTER|DT_SINGLELINE|DT_WORD_ELLIPSIS|DT_NOPREFIX); // Paint workspaces background... r.right = (r.left = tbLabelX) + tbLabelW; pSI = &mStyle.ToolbarLabel; MakeStyleGradient(buf, &r, pSI, pSI->bordered); _InflateRect(&r, -3, 0); BBDrawText(buf, Toolbar_WorkspaceName, -1, &r, justify, pSI); // Paint window label background... r.right = (r.left = tbWinLabelX) + tbWinLabelW; pSI = &mStyle.ToolbarWindowLabel; MakeStyleGradient(buf, &r, pSI, pSI->bordered); _InflateRect(&r, -3, 0); BBDrawText(buf, label, -1, &r, justify, pSI); // Paint clock background... r.right = (r.left = tbClockX) + tbClockW; pSI = &mStyle.ToolbarClock; MakeStyleGradient(buf, &r, pSI, pSI->bordered); _InflateRect(&r, -3, 0); BBDrawText(buf, Toolbar_CurrentTime, -1, &r, justify, pSI); //==================== BitBltRect(hdc, buf, rcPaint); SelectObject(buf, other_font); DeleteObject(SelectObject(buf, bufother)); DeleteDC(buf); }
void Tab::CreateTab() { CreateBorder(this->ti.x0 , this->ti.y0, this->ti.width, this->ti.height, 0); // writes bytes in the graphic_array Print8pxHighString( &(this->ti.tabName), this->ti.x0 + this->ti.margin_x, this->ti.y0 + this->ti.margin_y, 0, string_buffer, descend_buffer); // writes bytes in the string_buffer }
Border::Border() { CreateBorder(); }
//=========================================================================== void DrawBBPager(HWND hwnd) { Settings const & s = getSettings(); // Create buffer hdc's, bitmaps etc. PAINTSTRUCT ps; HDC hdc = BeginPaint(hwnd, &ps); HDC buf = CreateCompatibleDC(NULL); HBITMAP bufbmp = CreateCompatibleBitmap(hdc, s.m_frame.width, s.m_frame.height); HGDIOBJ oldbmp = SelectObject(buf, bufbmp); RECT r; char toolText[256]; GetClientRect(hwnd, &r); // Paint background and border according to the current style... MakeStyleGradient(buf, &r, s.m_frame.ownStyle ? s.m_frame.style : &s.m_frame.Style, true); HFONT font = CreateStyleFont((StyleItem *)GetSettingPtr(SN_TOOLBARLABEL)); HGDIOBJ oldfont = SelectObject(buf, font); SetBkMode(buf, TRANSPARENT); SetTextColor(buf, s.m_desktop.fontColor); UINT flags = DT_CENTER|DT_VCENTER|DT_SINGLELINE|DT_WORD_ELLIPSIS|DT_NOPREFIX; desktopRect.clear(); // Paint desktops :D if (s.m_position.horizontal) { // Do loop to draw desktops other than current selected desktop int i = 0; do { col = i / s.m_frame.rows; row = i % s.m_frame.rows + 1; if (getRuntimeState().m_currentDesktop == i) { currentCol = col; currentRow = row; } else { r.left = s.m_frame.borderWidth + s.m_frame.bevelWidth + ((col) * (s.m_desktop.width + s.m_frame.bevelWidth)); r.right = r.left + s.m_desktop.width; r.top = s.m_frame.borderWidth + s.m_frame.bevelWidth + ((row - 1) * (s.m_desktop.height + s.m_frame.bevelWidth)); r.bottom = r.top + s.m_desktop.height; //desktopRect[i] = r; // set RECT item for this desktop //desktopRect.insert(desktopRect.begin() + i - 1, r); desktopRect.push_back(r); if (s.m_desktop.ownStyle) CreateBorder(buf, &r, s.m_activeDesktop.borderColor, 1); else { r.left += 1; r.top += 1; r.right -= 1; r.bottom -= 1; MakeStyleGradient(buf, &r, &s.m_activeDesktop.Style, false); } if (s.m_desktop.numbers) { char desktopNumber[4]; sprintf(desktopNumber, "%d", (i + 1)); DrawText(buf, desktopNumber, -1, &r, flags); } } i++; } while (i < getRuntimeState().m_desktops); // Do this now so bordered desktop is drawn last i = getRuntimeState().m_currentDesktop; r.left = s.m_frame.borderWidth + s.m_frame.bevelWidth + ((currentCol) * (s.m_desktop.width + s.m_frame.bevelWidth)); r.right = r.left + s.m_desktop.width; r.top = s.m_frame.borderWidth + s.m_frame.bevelWidth + ((currentRow - 1) * (s.m_desktop.height + s.m_frame.bevelWidth)); r.bottom = r.top + s.m_desktop.height; //desktopRect[i] = r; // set RECT item for this desktop DrawActiveDesktop(buf, r, i); if (s.m_desktop.numbers) { char desktopNumber[4]; sprintf(desktopNumber, "%d", (i + 1)); DrawText(buf, desktopNumber, -1, &r, flags); } } else if (s.m_position.vertical) { // Do loop to draw desktops other than current selected desktop int i = 0; do { row = i / s.m_frame.columns; col = i % s.m_frame.columns + 1; if (getRuntimeState().m_currentDesktop == i) { currentCol = col; currentRow = row; } else { r.left = s.m_frame.borderWidth + s.m_frame.bevelWidth + ((col - 1) * (s.m_desktop.width + s.m_frame.bevelWidth)); r.right = r.left + s.m_desktop.width; r.top = s.m_frame.borderWidth + s.m_frame.bevelWidth + ((row) * (s.m_desktop.height + s.m_frame.bevelWidth)); r.bottom = r.top + s.m_desktop.height; //desktopRect[i] = r; // set RECT item for this desktop //desktopRect.insert(desktopRect.begin() + i - 1, r); desktopRect.push_back(r); MakeStyleGradient(buf, &r, s.m_desktop.ownStyle ? s.m_desktop.style : &s.m_desktop.Style, false); if (s.m_desktop.ownStyle) CreateBorder(buf, &r, s.m_activeDesktop.borderColor, 1); else { r.left += 1; r.top += 1; r.right -= 1; r.bottom -= 1; MakeStyleGradient(buf, &r, &s.m_activeDesktop.Style, false); } if (s.m_desktop.numbers) { char desktopNumber[4]; sprintf(desktopNumber, "%d", (i + 1)); DrawText(buf, desktopNumber, -1, &r, flags); } } i++; } while (i < getRuntimeState().m_desktops); // Do this now so bordered desktop is drawn last i = getRuntimeState().m_currentDesktop; r.left = s.m_frame.borderWidth + s.m_frame.bevelWidth + ((currentCol - 1) * (s.m_desktop.width + s.m_frame.bevelWidth)); r.right = r.left + s.m_desktop.width; r.top = s.m_frame.borderWidth + s.m_frame.bevelWidth + ((currentRow) * (s.m_desktop.height + s.m_frame.bevelWidth)); r.bottom = r.top + s.m_desktop.height; //desktopRect[i] = r; // set RECT item for this desktop DrawActiveDesktop(buf, r, i); if (s.m_desktop.numbers) { char desktopNumber[4]; sprintf(desktopNumber, "%d", (i + 1)); SetTextColor(buf, s.m_activeDesktop.borderColor); DrawText(buf, desktopNumber, -1, &r, DT_CENTER | DT_VCENTER | DT_SINGLELINE | DT_WORD_ELLIPSIS | DT_NOPREFIX); //DrawText(buf, desktopNumber, strlen(desktopNumber), &r, DT_CALCRECT|DT_NOPREFIX); //SetTextColor(buf, s.m_desktop.fontColor); } } //DeleteObject(font); DeleteObject(SelectObject(buf, oldfont)); // Draw windows on workspaces if wanted if (s.m_desktop.windows) { getRuntimeState().m_winCount = 0; // Reset number of windows to 0 on each paint to be counted by... getRuntimeState().m_winList.clear(); // ... this function which passes HWNDs to CheckTaskEnumProc callback procedure if (!getRuntimeState().m_is_xoblite && getRuntimeState().m_usingAltMethod) EnumWindows(CheckTaskEnumProc_AltMethod, 0); else EnumWindows(CheckTaskEnumProc, 0); //struct tasklist *tlist; /*tl = GetTaskListPtr(); while (tl) { AddBBWindow(tl); tl = tl->next; }*/ // Only paint windows if there are any! if (getRuntimeState().m_winCount > 0) { // Start at end of list (bottom of zorder) for (int i = (getRuntimeState().m_winCount - 1); i > -1; i--) { RECT win = getRuntimeState().m_winList[i].r; RECT desk = desktopRect[getRuntimeState().m_winList[i].desk]; if (win.right - win.left <= 1 && win.bottom - win.top <= 1) continue; // This is done so that windows only show within the applicable desktop RECT if (win.top < desk.top) win.top = desk.top; // + 1; if (win.right > desk.right) win.right = desk.right; // - 1; if (win.bottom > desk.bottom) win.bottom = desk.bottom; // - 1; if (win.left < desk.left) win.left = desk.left; // + 1; if (getRuntimeState().m_winList[i].sticky) { RECT sWin; RECT sDesk; win.bottom = win.bottom - desk.top; win.top = win.top - desk.top; win.left = win.left - desk.left; win.right = win.right - desk.left; for (int j = 0; j < getRuntimeState().m_desktops; j++) { sDesk = desktopRect[j]; sWin.bottom = sDesk.top + win.bottom; sWin.top = sDesk.top + win.top; sWin.left = sDesk.left + win.left; sWin.right = sDesk.left + win.right; if (getRuntimeState().m_winList[i].active) // draw active window style { DrawActiveWindow(buf, sWin); RemoveFlash(getRuntimeState().m_winList[i].window, true); } else if (IsFlashOn(getRuntimeState().m_winList[i].window)) { DrawActiveWindow(buf, sWin); } else // draw inactive window style { DrawInactiveWindow(buf, sWin); RemoveFlash(getRuntimeState().m_winList[i].window, true); } // Create a tooltip... if (s.m_desktop.tooltips) { GetWindowText(getRuntimeState().m_winList[i].window, toolText, 255); SetToolTip(&sWin, toolText); } } } else { if (getRuntimeState().m_winList[i].active) // draw active window style { DrawActiveWindow(buf, win); RemoveFlash(getRuntimeState().m_winList[i].window, true); } else if (IsFlashOn(getRuntimeState().m_winList[i].window)) { DrawActiveWindow(buf, win); } else // draw inactive window style { DrawInactiveWindow(buf, win); RemoveFlash(getRuntimeState().m_winList[i].window, true); } // Create a tooltip... if (s.m_desktop.tooltips) { GetWindowText(getRuntimeState().m_winList[i].window, toolText, 255); SetToolTip(&win, toolText); } } } } if (getRuntimeState().m_winMoving) { RECT win = getRuntimeState().m_moveWin.r; RECT client; GetClientRect(getRuntimeState().m_hwndBBPager, &client); // This is done so that the window only shows within the pager if (win.top < client.top) win.top = client.top; // + 1; if (win.right > client.right) win.right = client.right; // - 1; if (win.bottom > client.bottom) win.bottom = client.bottom; // - 1; if (win.left < client.left) win.left = client.left; // + 1; if (getRuntimeState().m_moveWin.active) // draw active window style DrawActiveWindow(buf, win); else // draw inactive window style DrawInactiveWindow(buf, win); } } ClearToolTips(); // Finally, copy from the paint buffer to the window... BitBlt(hdc, 0, 0, s.m_frame.width, s.m_frame.height, buf, 0, 0, SRCCOPY); //restore the first previous whatever to the dc, //get in exchange back our bitmap, and delete it. DeleteObject(SelectObject(buf, oldbmp)); //delete the memory - 'device context' DeleteDC(buf); //done EndPaint(hwnd, &ps); }
bool tomEdit::Init() { WLDC dc(this) ; s_XPixelPerInch = dc.GetDeviceCaps(LOGPIXELSX) ; s_YPixelPerInch = dc.GetDeviceCaps(LOGPIXELSY) ; m_ref_count = 1 ; m_show_vert_scroll_bar = false ; m_show_horz_scroll_bar = false ; m_background_transparent = true ; m_use_system_background_color = true ; m_use_system_highlight_text_color = true ; m_use_system_highlight_text_background_color = true ; m_word_wrap = !(GetStyle() & (WS_HSCROLL | ES_AUTOHSCROLL)) ; HRESULT hr ; IUnknown * pUnknown ; // 由于CreateTextServices会触发TxGetCharFormat和TxGetParaFormat, // 所以要在此之前初始化CharFormat和ParaFormat // 初始化CharFormat InitDefaultCharFormat() ; // 初始化ParaFormat InitDefaultParaFormat() ; RECT bound_in_host ; GetRectInHost(&bound_in_host) ; if (FAILED(CreateBorder(IID_IRectangleBorder, (IUnknown**)&m_border))) return FALSE ; m_border->SetPos(bound_in_host.left, bound_in_host.top) ; m_border->SetSize(bound_in_host.right - bound_in_host.left, bound_in_host.bottom - bound_in_host.top) ; m_border->SetInset(m_border_inset.left, m_border_inset.top, m_border_inset.right, m_border_inset.bottom) ; if (FAILED(CreateTextServices(NULL, this, &pUnknown))) return false ; hr = pUnknown->QueryInterface(IID_ITextServices, (void**)&m_services) ; pUnknown->Release() ; if (FAILED(hr)) return false ; // 输入的客户区矩形范围似乎无用,总是会调用ITextHost::TxGetClientRect来获取区域 if (FAILED(m_services->OnTxInPlaceActivate(&bound_in_host))) return false ; LRESULT mask ; m_services->TxSendMessage(EM_GETEVENTMASK, 0, 0, &mask) ; mask |= ENM_SELCHANGE ; m_services->TxSendMessage(EM_SETEVENTMASK, 0, mask, NULL) ; m_call_back = new tomEditCallback(this) ; SetOLECallback(m_call_back) ; // 注册拖拽 IDropTarget * dt = NULL ; if (S_OK == m_services->TxGetDropTarget(&dt)) { RegisterDragDrop(dt) ; dt->Release() ; } return true ; }
//=========================================================================== static void PaintToolbar(HDC hdc, RECT *rcPaint) { RECT r; StyleItem *pSI; struct button *btn; HDC buf; HGDIOBJ bufother, other_font; int size; int margin, border, border_margin, button_padding, middle_padding, two_buttons; int tbW, tbH, tbLabelW, tbLabelX, tbClockX, tbWinLabelX, tbWinLabelW; int i, justify; tbW = TBInfo.width; tbH = TBInfo.height; buf = CreateCompatibleDC(NULL); bufother = SelectObject(buf, CreateCompatibleBitmap(hdc, tbW, tbH)); if (NULL==Toolbar_hFont) Toolbar_hFont = CreateStyleFont(&mStyle.Toolbar); other_font = SelectObject(buf, Toolbar_hFont); size = 6 + get_text_extend(buf, Toolbar_CurrentTime); if (tbClockW < size) tbClockW = size + 2*tbLabelIndent; size = get_text_extend(buf, Toolbar_WorkspaceName); tbLabelW = size + 2*tbLabelIndent; // The widest sets the width! tbLabelW = tbClockW = imax(tbH * 2, imax(tbLabelW, tbClockW)); margin = tbMargin; border = mStyle.Toolbar.borderWidth; border_margin = margin + border; button_padding = (tbH - tbButtonWH) / 2 - border; middle_padding = button_padding; if (0 == button_padding) middle_padding -= mStyle.ToolbarButton.borderWidth; tbLabelX = border_margin; tbClockX = tbW - tbClockW - border_margin; two_buttons = 2*tbButtonWH + 2*button_padding + middle_padding; tbWinLabelX = tbLabelX + tbLabelW + two_buttons; tbWinLabelW = tbClockX - tbWinLabelX - two_buttons; if (tbWinLabelW < 0) tbWinLabelW = 0; btn = Toolbar_Button; btn[0].r.left = tbLabelX + tbLabelW + button_padding; btn[1].r.left = btn[0].r.left + tbButtonWH + middle_padding; btn[2].r.left = tbClockX - 2*tbButtonWH - button_padding - middle_padding; btn[3].r.left = btn[2].r.left + tbButtonWH + middle_padding; btn[4].r.left = tbClockX; for (i = 0; i<5; i++) { btn[i].r.top = (tbH - tbButtonWH) / 2; btn[i].r.bottom = btn[i].r.top + tbButtonWH; btn[i].r.right = btn[i].r.left + tbButtonWH; } btn[4].r.right = tbClockX + tbClockW; //==================== // Paint toolbar Style r.left = r.top = 0; r.right = tbW; r.bottom = tbH; pSI = &mStyle.Toolbar; MakeStyleGradient(buf, &r, pSI, pSI->bordered); //==================== // Paint unpressed workspace/task buttons... r.left = r.top = 0; r.right = r.bottom = tbButtonWH; { HDC src; HGDIOBJ srcother; int x, y, f2, f1 = -1; src = CreateCompatibleDC(NULL); srcother = SelectObject(src, CreateCompatibleBitmap(hdc, tbButtonWH, tbButtonWH)); for (i = 0; i < 4; i++) { btn = Toolbar_Button + i; f2 = btn->pressed || (Toolbar_force_button_pressed && (i&1)); x = btn->r.left, y = btn->r.top; pSI = f2 ? &mStyle.ToolbarButtonPressed : &mStyle.ToolbarButton; if (pSI->parentRelative) { RECT b; b.left = x, b.top = y, b.right = x+r.right, b.bottom = y+r.bottom; CreateBorder(buf, &b, pSI->borderColor, pSI->borderWidth); } else { if (f1 != f2) { MakeStyleGradient(src, &r, pSI, pSI->bordered); f1 = f2; } BitBlt(buf, x, y, tbButtonWH, tbButtonWH, src, 0, 0, SRCCOPY); } bbDrawPix(buf, &btn->r, pSI->picColor, (i&1) ? BS_TRIANGLE : -BS_TRIANGLE); } DeleteObject(SelectObject(src, srcother)); DeleteDC(src); } //==================== r.top = (tbH - tbLabelH)/2; r.bottom = r.top + tbLabelH; SetBkMode(buf, TRANSPARENT); justify = mStyle.Toolbar.Justify | (DT_VCENTER|DT_SINGLELINE|DT_WORD_ELLIPSIS|DT_NOPREFIX); // Paint workspaces background... r.right = (r.left = tbLabelX) + tbLabelW; pSI = &mStyle.ToolbarLabel; MakeStyleGradient(buf, &r, pSI, pSI->bordered); r.left += tbLabelIndent; r.right -= tbLabelIndent; bbDrawText(buf, Toolbar_WorkspaceName, &r, justify, pSI->TextColor); // Paint window label background... r.right = (r.left = tbWinLabelX) + tbWinLabelW; pSI = &mStyle.ToolbarWindowLabel; MakeStyleGradient(buf, &r, pSI, pSI->bordered); r.left += tbLabelIndent; r.right -= tbLabelIndent; bbDrawText(buf, Toolbar_CurrentWindow, &r, justify, pSI->TextColor); // Paint clock background... r.right = (r.left = tbClockX) + tbClockW; pSI = &mStyle.ToolbarClock; MakeStyleGradient(buf, &r, pSI, pSI->bordered); r.left += tbLabelIndent; r.right -= tbLabelIndent; bbDrawText(buf, Toolbar_CurrentTime, &r, justify, pSI->TextColor); //==================== BitBltRect(hdc, buf, rcPaint); SelectObject(buf, other_font); DeleteObject(SelectObject(buf, bufother)); DeleteDC(buf); }