void CFreqDial::drawDial() { wxMemoryDC dc; dc.SelectObject(*m_bitmap); #if defined(__WXMSW__) int major, minor; ::wxGetOsVersion(&major, &minor); wxColour bgColour; if (major >= 6) bgColour = wxColour(0xF0, 0xF0, 0xF0); // Windows Vista and newer else if (major == 5 && minor >= 1) bgColour = wxColour(0xEC, 0xE9, 0xD8); // Windows XP else bgColour = wxColour(0xD4, 0xD0, 0xC8); // Windows 2000 and earlier #elif defined(__WXGTK__) wxColour bgColour(0xF0, 0xF1, 0xF2); // wxColour bgColour(0xED, 0xE9, 0xE3); #elif defined(__WXMAC__) wxColour bgColour(0xF0, 0xF0, 0xF0); #else #error "Unknown platform" #endif wxBrush brush0(bgColour); wxPen pen0(bgColour); dc.SetPen(pen0); dc.SetBrush(brush0); dc.DrawRectangle(0, 0, m_width, m_height); int middleX = m_width / 2; int middleY = m_height / 2; dc.SetBrush(*wxLIGHT_GREY_BRUSH); wxPen pen1(*wxBLACK, 2, wxSOLID); dc.SetPen(pen1); dc.DrawCircle(middleX, middleY, (m_width - 2) / 2); int x = m_width / 2 - int(double(m_width / 2 - 25) * ::sin(m_angle * (M_PI / 180.0)) + 0.5); int y = m_height / 2 + int(double(m_height / 2 - 25) * ::cos(m_angle * (M_PI / 180.0)) + 0.5); dc.SetBrush(*wxBLACK_BRUSH); wxPen pen2(*wxWHITE, 2, wxSOLID); dc.SetPen(pen2); dc.DrawCircle(x, y, 20); dc.SelectObject(wxNullBitmap); wxClientDC clientDC(this); show(clientDC); }
TaskBarBaloon::TaskBarBaloon(wxString sTitle, wxString sMessage, std::string new_ident) : wxFrame(NULL,-1,wxT("no title"),wxDefaultPosition,wxDefaultSize,wxNO_BORDER | wxSTAY_ON_TOP | wxFRAME_SHAPED | wxFRAME_NO_TASKBAR), new_ident(new_ident) { wxColour bgColour(255,255,231); // yellow BG this->SetBackgroundColour(bgColour); wxBoxSizer * mainSizer = new wxBoxSizer(wxVERTICAL); wxStaticText * title = new wxStaticText(this, -1, sTitle); wxFont titleFont = this->GetFont(); titleFont.SetWeight(wxFONTWEIGHT_BOLD); title->SetFont(titleFont); mainSizer->Add(title,0,wxEXPAND | wxTOP | wxLEFT | wxRIGHT, 5); title->Connect(wxEVT_LEFT_DOWN, wxMouseEventHandler(TaskBarBaloon::OnClick), NULL, this ); title->Connect(wxEVT_KEY_DOWN, wxKeyEventHandler(TaskBarBaloon::OnEscape), NULL, this ); wxStaticText * text = new wxStaticText(this, -1, sMessage); mainSizer->Add(text,1,wxEXPAND | wxBOTTOM | wxLEFT | wxRIGHT, 5); text->Connect(wxEVT_LEFT_DOWN, wxMouseEventHandler(TaskBarBaloon::OnClick), NULL, this ); text->Connect(wxEVT_KEY_DOWN, wxKeyEventHandler(TaskBarBaloon::OnEscape), NULL, this ); this->SetSizer(mainSizer); mainSizer->SetSizeHints( this ); this->timer = new wxTimer(this,TIMER_BALOON); // here, we try to align the frame to the right bottom corner this->Center(); int iX = 0, iY = 0; this->GetPosition( &iX, &iY ); iX = (iX * 2) - 2; iY = (iY * 2) - 2; this->Move( iX, iY ); }
void Button::Draw(const Point& screenPos) { if(!drawn) { TextPosition(); drawn = true; } Graphics * g = ui::Engine::Ref().g; Point Position = screenPos; ui::Colour bgColour(0, 0, 0); ui::Colour textColour = Appearance.TextInactive; ui::Colour borderColour = Appearance.BorderInactive; ui::Colour backgroundColour = Appearance.BackgroundInactive; if(Enabled) { if(isButtonDown || (isTogglable && toggle)) { textColour = Appearance.TextActive; borderColour = Appearance.BorderActive; backgroundColour = Appearance.BackgroundActive; } else if (isMouseInside) { textColour = Appearance.TextHover; borderColour = Appearance.BorderHover; backgroundColour = Appearance.BackgroundHover; } else { textColour = Appearance.TextInactive; borderColour = Appearance.BorderInactive; backgroundColour = Appearance.BackgroundInactive; } } else { textColour = Appearance.TextDisabled; borderColour = Appearance.BorderDisabled; backgroundColour = Appearance.BackgroundDisabled; } bgColour = Appearance.BackgroundInactive; g->fillrect(Position.X+1, Position.Y+1, Size.X-2, Size.Y-2, backgroundColour.Red, backgroundColour.Green, backgroundColour.Blue, backgroundColour.Alpha); if(Appearance.Border == 1) g->drawrect(Position.X, Position.Y, Size.X, Size.Y, borderColour.Red, borderColour.Green, borderColour.Blue, borderColour.Alpha); else { if(Appearance.Border.Top) g->draw_line(Position.X, Position.Y, Position.X+Size.X-1, Position.Y, borderColour.Red, borderColour.Green, borderColour.Blue, borderColour.Alpha); if(Appearance.Border.Bottom) g->draw_line(Position.X, Position.Y+Size.Y-1, Position.X+Size.X-1, Position.Y+Size.Y-1, borderColour.Red, borderColour.Green, borderColour.Blue, borderColour.Alpha); if(Appearance.Border.Left) g->draw_line(Position.X, Position.Y, Position.X, Position.Y+Size.Y-1, borderColour.Red, borderColour.Green, borderColour.Blue, borderColour.Alpha); if(Appearance.Border.Right) g->draw_line(Position.X+Size.X-1, Position.Y, Position.X+Size.X-1, Position.Y+Size.Y-1, borderColour.Red, borderColour.Green, borderColour.Blue, borderColour.Alpha); } g->drawtext(Position.X+textPosition.X, Position.Y+textPosition.Y, buttonDisplayText, textColour.Red, textColour.Green, textColour.Blue, textColour.Alpha); bool iconInvert = (backgroundColour.Blue + (3*backgroundColour.Green) + (2*backgroundColour.Red))>544?true:false; if(Appearance.icon) { if(Enabled) if(isButtonDown || (isTogglable && toggle)) { g->draw_icon(Position.X+iconPosition.X, Position.Y+iconPosition.Y, Appearance.icon, 255, iconInvert); } else { g->draw_icon(Position.X+iconPosition.X, Position.Y+iconPosition.Y, Appearance.icon, 255, iconInvert); } else g->draw_icon(Position.X+iconPosition.X, Position.Y+iconPosition.Y, Appearance.icon, 180, iconInvert); } }
int main() { bool moveUp = false; bool moveDown = false; bool moveLeft = false; bool moveRight = false; bool boost = false; float speed; sf::Color bgColour(64,64,64); sf::RenderWindow window(sf::VideoMode(1024, 600), "GameWindow"); window.setFramerateLimit(60); sf::Texture texture; texture.loadFromFile("assets/theguy.png"); sf::Sprite sprite(texture); sprite.setOrigin(texture.getSize().x/2, texture.getSize().y/2); sprite.setPosition(window.getSize().x/2, window.getSize().y/2); sprite.setScale(.75f, .75f); while (window.isOpen()) { sf::Event event; while (window.pollEvent(event)) { switch (event.type) { case sf::Event::KeyPressed: if (event.key.code == sf::Keyboard::A) moveLeft = true; else if (event.key.code == sf::Keyboard::W) moveUp = true; else if (event.key.code == sf::Keyboard::D) moveRight = true; else if (event.key.code == sf::Keyboard::S) moveDown = true; else if (event.key.code == sf::Keyboard::LShift) boost = true; else if (event.key.code == sf::Keyboard::RShift) boost = true; break; case sf::Event::KeyReleased: if (event.key.code == sf::Keyboard::A) moveLeft = false; else if (event.key.code == sf::Keyboard::W) moveUp = false; else if (event.key.code == sf::Keyboard::D) moveRight = false; else if (event.key.code == sf::Keyboard::S) moveDown = false; else if (event.key.code == sf::Keyboard::LShift || event.key.code == sf::Keyboard::RShift) boost = false; break; case sf::Event::Closed: window.close(); break; default: break; } } speed = (boost) ? 4.f : 2.f; if (moveUp && moveRight) { sprite.move(speed,-speed); sprite.setRotation(45); } else if (moveDown && moveRight) { sprite.move(speed,speed); sprite.setRotation(135); } else if (moveDown && moveLeft) { sprite.move(-speed,speed); sprite.setRotation(225); } else if (moveUp && moveLeft) { sprite.move(-speed,-speed); sprite.setRotation(-45); } else if (moveLeft) { sprite.move(-speed,0); sprite.setRotation(-90); } else if (moveDown) { sprite.move(0,speed); sprite.setRotation(180); } else if (moveRight) { sprite.move(speed,0); sprite.setRotation(90); } else if (moveUp) { sprite.move(0,-speed); sprite.setRotation(0); } window.clear(bgColour); window.draw(sprite); window.display(); } return 0; }
void CVolumeDial::drawDial() { wxMemoryDC dc; dc.SelectObject(*m_bitmap); #if defined(__WXMSW__) int major, minor; ::wxGetOsVersion(&major, &minor); wxColour bgColour; if (major >= 6) bgColour = wxColour(0xF0, 0xF0, 0xF0); // Windows Vista and newer else if (major == 5 && minor >= 1) bgColour = wxColour(0xEC, 0xE9, 0xD8); // Windows XP else bgColour = wxColour(0xD4, 0xD0, 0xC8); // Windows 2000 and earlier #elif defined(__WXGTK__) wxColour bgColour(0xF0, 0xF1, 0xF2); // wxColour bgColour(0xED, 0xE9, 0xE3); #elif defined(__WXMAC__) wxColour bgColour(0xE8, 0xE8, 0xE8); #else #error "Unknown platform" #endif wxBrush brush0(bgColour); wxPen pen0(bgColour); dc.SetPen(pen0); dc.SetBrush(brush0); dc.DrawRectangle(0, 0, m_width, m_height); if (IsEnabled()) { dc.SetBrush(*wxLIGHT_GREY_BRUSH); dc.SetPen(wxPen(*wxBLACK, 2, wxSOLID)); } else { dc.SetBrush(brush0); dc.SetPen(wxPen(*wxLIGHT_GREY, 2, wxSOLID)); } dc.DrawEllipse(1, 1, m_width - 2, m_height - 2); double incr = 270.0 / double(m_max - m_min); double angle = (double(m_value - m_min) * incr + 45.0) * (M_PI / 180.0); double xFrac = ::sin(angle); double yFrac = ::cos(angle); int startX = m_width / 2 - int(double(m_width / 2 - 10) * xFrac + 0.5); int startY = m_height / 2 + int(double(m_height / 2 - 10) * yFrac + 0.5); int endX = m_width / 2 - int(double(m_width / 2 - 20) * xFrac + 0.5); int endY = m_height / 2 + int(double(m_height / 2 - 20) * yFrac + 0.5); if (IsEnabled()) dc.SetPen(wxPen(*wxBLACK, 5, wxSOLID)); else dc.SetPen(wxPen(*wxLIGHT_GREY, 2, wxSOLID)); dc.DrawLine(startX, startY, endX, endY); dc.SelectObject(wxNullBitmap); wxClientDC clientDC(this); show(clientDC); }
void clTabRendererCurved::Draw(wxDC& dc, const clTabInfo& tabInfo, const clTabColours& colours, size_t style) { const int TOP_SMALL_HEIGHT = 0; wxColour bgColour(tabInfo.IsActive() ? colours.activeTabBgColour : colours.inactiveTabBgColour); wxColour penColour(tabInfo.IsActive() ? colours.activeTabPenColour : colours.inactiveTabPenColour); wxFont font = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT); dc.SetTextForeground(tabInfo.IsActive() ? colours.activeTabTextColour : colours.inactiveTabTextColour); dc.SetFont(font); if(style & kNotebook_BottomTabs) { // Bottom tabs { wxPoint points[6]; points[0] = tabInfo.m_rect.GetTopLeft(); points[1].x = points[0].x + majorCurveWidth; points[1].y = tabInfo.m_rect.GetBottomLeft().y - TOP_SMALL_HEIGHT; points[2].x = points[1].x + smallCurveWidth; points[2].y = points[1].y + TOP_SMALL_HEIGHT; points[3].x = points[0].x + (tabInfo.m_rect.GetWidth() - (majorCurveWidth + smallCurveWidth)); points[3].y = points[2].y; points[4].x = points[3].x + smallCurveWidth; points[4].y = points[1].y; points[5] = tabInfo.m_rect.GetTopRight(); dc.SetPen(penColour); dc.SetBrush(bgColour); dc.DrawPolygon(6, points); } { wxPoint points[6]; points[0] = tabInfo.m_rect.GetTopLeft(); points[0].x += 1; points[1].x = points[0].x + majorCurveWidth; points[1].y = tabInfo.m_rect.GetBottomLeft().y - TOP_SMALL_HEIGHT - 1; points[2].x = points[1].x + smallCurveWidth; points[2].y = points[1].y + TOP_SMALL_HEIGHT; points[3].x = points[0].x + (tabInfo.m_rect.GetWidth() - 2 - (majorCurveWidth + smallCurveWidth)); points[3].y = points[2].y; points[4].x = points[3].x + smallCurveWidth; points[4].y = points[1].y; points[5] = tabInfo.m_rect.GetTopRight(); points[5].x -= 2; dc.SetPen(tabInfo.IsActive() ? colours.activeTabInnerPenColour : colours.inactiveTabInnerPenColour); dc.SetBrush(bgColour); dc.DrawPolygon(6, points); } } else if(IS_VERTICAL_TABS(style)) { // Left side tabs wxRect rotatedRect(0, 0, tabInfo.m_rect.GetHeight(), tabInfo.m_rect.GetWidth()); wxBitmap b(rotatedRect.GetSize()); wxMemoryDC tmpDC(b); tmpDC.SetPen(colours.tabAreaColour); tmpDC.SetBrush(colours.tabAreaColour); tmpDC.DrawRectangle(rotatedRect); tmpDC.SetFont(font); tmpDC.SetTextForeground(tabInfo.IsActive() ? colours.activeTabTextColour : colours.inactiveTabTextColour); tmpDC.SetPen(penColour); tmpDC.SetBrush(bgColour); if(tabInfo.IsActive()) { { wxPoint points[6]; points[0] = rotatedRect.GetBottomLeft(); points[1].x = points[0].x + majorCurveWidth; points[1].y = rotatedRect.GetLeftTop().y + TOP_SMALL_HEIGHT; points[2].x = points[1].x + smallCurveWidth; points[2].y = points[1].y - TOP_SMALL_HEIGHT; points[3].x = points[0].x + (rotatedRect.GetWidth() - (majorCurveWidth + smallCurveWidth)); points[3].y = points[2].y; points[4].x = points[3].x + smallCurveWidth; points[4].y = points[3].y + TOP_SMALL_HEIGHT; points[5] = rotatedRect.GetBottomRight(); tmpDC.SetPen(penColour); tmpDC.SetBrush(bgColour); tmpDC.DrawPolygon(6, points); } { wxPoint points[6]; points[0] = rotatedRect.GetBottomLeft(); points[0].x += 1; points[1].x = points[0].x + majorCurveWidth; points[1].y = rotatedRect.GetLeftTop().y + TOP_SMALL_HEIGHT + 1; points[2].x = points[1].x + smallCurveWidth; points[2].y = points[1].y - TOP_SMALL_HEIGHT; points[3].x = points[0].x + (rotatedRect.GetWidth() - 2 - (majorCurveWidth + smallCurveWidth)); points[3].y = points[2].y; points[4].x = points[3].x + smallCurveWidth; points[4].y = points[3].y + TOP_SMALL_HEIGHT; points[5] = rotatedRect.GetBottomRight(); points[5].x -= 2; tmpDC.SetPen(tabInfo.IsActive() ? colours.activeTabInnerPenColour : colours.inactiveTabInnerPenColour); tmpDC.SetBrush(bgColour); tmpDC.DrawPolygon(6, points); } } else { // Inactive tabs wxDirection direction = wxNORTH; wxPoint basePoint = ((style & kNotebook_LeftTabs) ? rotatedRect.GetLeftTop() : rotatedRect.GetRightTop()); { wxPoint pt = basePoint; pt.x -= 1; wxRect gr(pt, wxSize(1, rotatedRect.GetHeight())); tmpDC.SetPen(*wxTRANSPARENT_PEN); tmpDC.GradientFillLinear(gr, colours.inactiveTabPenColour, bgColour, direction); } { wxPoint pt = basePoint; wxRect gr(pt, wxSize(1, rotatedRect.GetHeight())); tmpDC.SetPen(*wxTRANSPARENT_PEN); tmpDC.GradientFillLinear(gr, colours.inactiveTabInnerPenColour, bgColour, direction); } { wxPoint pt = basePoint; pt.x += 1; wxRect gr(pt, wxSize(1, rotatedRect.GetHeight())); tmpDC.SetPen(*wxTRANSPARENT_PEN); tmpDC.GradientFillLinear(gr, colours.inactiveTabPenColour, bgColour, direction); } } // Vertical tabs // Draw bitmap if(tabInfo.GetBitmap().IsOk()) { tmpDC.DrawBitmap(tabInfo.GetBitmap(), tabInfo.m_bmpY, tabInfo.m_bmpX); } tmpDC.DrawText(tabInfo.m_label, tabInfo.m_textY, tabInfo.m_textX); if(tabInfo.IsActive() && (style & kNotebook_CloseButtonOnActiveTab)) { tmpDC.DrawBitmap(colours.closeButton, tabInfo.m_bmpCloseY, tabInfo.m_bmpCloseX); } tmpDC.SelectObject(wxNullBitmap); wxImage img = b.ConvertToImage(); img = img.Rotate90((style & kNotebook_RightTabs)); b = wxBitmap(img); dc.DrawBitmap(b, tabInfo.m_rect.GetTopLeft()); } else { // Default tabs (placed at the top) { wxPoint points[6]; points[0] = tabInfo.m_rect.GetBottomLeft(); points[1].x = points[0].x + majorCurveWidth; points[1].y = tabInfo.m_rect.GetLeftTop().y + TOP_SMALL_HEIGHT; points[2].x = points[1].x + smallCurveWidth; points[2].y = points[1].y - TOP_SMALL_HEIGHT; points[3].x = points[0].x + (tabInfo.m_rect.GetWidth() - (majorCurveWidth + smallCurveWidth)); points[3].y = points[2].y; points[4].x = points[3].x + smallCurveWidth; points[4].y = points[3].y + TOP_SMALL_HEIGHT; points[5] = tabInfo.m_rect.GetBottomRight(); dc.SetPen(penColour); dc.SetBrush(bgColour); dc.DrawPolygon(6, points); } { wxPoint points[6]; points[0] = tabInfo.m_rect.GetBottomLeft(); points[0].x += 1; points[1].x = points[0].x + majorCurveWidth; points[1].y = tabInfo.m_rect.GetLeftTop().y + TOP_SMALL_HEIGHT + 1; points[2].x = points[1].x + smallCurveWidth; points[2].y = points[1].y - TOP_SMALL_HEIGHT; points[3].x = points[0].x + (tabInfo.m_rect.GetWidth() - 2 - (majorCurveWidth + smallCurveWidth)); points[3].y = points[2].y; points[4].x = points[3].x + smallCurveWidth; points[4].y = points[3].y + TOP_SMALL_HEIGHT; points[5] = tabInfo.m_rect.GetBottomRight(); points[5].x -= 2; dc.SetPen(tabInfo.IsActive() ? colours.activeTabInnerPenColour : colours.inactiveTabInnerPenColour); dc.SetBrush(bgColour); dc.DrawPolygon(6, points); } } if(!IS_VERTICAL_TABS(style)) { // Draw bitmap if(tabInfo.GetBitmap().IsOk()) { dc.DrawBitmap(tabInfo.GetBitmap(), tabInfo.m_bmpX + tabInfo.m_rect.GetX(), tabInfo.m_bmpY); } dc.DrawText(tabInfo.m_label, tabInfo.m_textX + tabInfo.m_rect.GetX(), tabInfo.m_textY); if(tabInfo.IsActive() && (style & kNotebook_CloseButtonOnActiveTab)) { dc.DrawBitmap(colours.closeButton, tabInfo.m_bmpCloseX + tabInfo.m_rect.GetX(), tabInfo.m_bmpCloseY); } } }
void clTabRendererClassic::Draw(wxWindow* parent, wxDC& dc, wxDC& fontDC, const clTabInfo& tabInfo, const clTabColours& colors, size_t style, eButtonState buttonState) { const int tabRaius = 1.5; clTabColours colours = colors; if(DrawingUtils::IsDark(colours.activeTabBgColour)) { InitDarkColours(colours, colours.activeTabBgColour); } else { InitLightColours(colours, colours.activeTabBgColour); } wxColour bgColour(tabInfo.IsActive() ? colours.activeTabBgColour : colours.inactiveTabBgColour); wxColour penColour(tabInfo.IsActive() ? colours.activeTabPenColour : colours.inactiveTabPenColour); wxFont font = GetTabFont(false); fontDC.SetTextForeground(tabInfo.IsActive() ? colours.activeTabTextColour : colours.inactiveTabTextColour); fontDC.SetFont(font); if(style & kNotebook_BottomTabs) { // Bottom tabs wxRect tabRect = tabInfo.GetRect(); tabRect.SetHeight(tabRect.GetHeight() + tabRaius); tabRect.SetY(tabRect.GetY() - tabRaius); { dc.SetPen(penColour); dc.SetBrush(bgColour); dc.DrawRoundedRectangle(tabRect, tabRaius); } { tabRect.Deflate(1); // The inner border dc.SetPen(tabInfo.IsActive() ? colours.activeTabInnerPenColour : colours.inactiveTabInnerPenColour); dc.SetBrush(bgColour); dc.DrawRoundedRectangle(tabRect, tabRaius); } } else { // Default tabs (placed at the top) wxRect tabRect = tabInfo.GetRect(); tabRect.SetHeight(tabRect.GetHeight() + tabRaius); { dc.SetPen(penColour); dc.SetBrush(bgColour); dc.DrawRoundedRectangle(tabRect, tabRaius); } { tabRect.Deflate(1); // The inner border dc.SetPen(tabInfo.IsActive() ? colours.activeTabInnerPenColour : colours.inactiveTabInnerPenColour); dc.SetBrush(bgColour); dc.DrawRoundedRectangle(tabRect, tabRaius); } } // Draw bitmap if(tabInfo.GetBitmap().IsOk()) { const wxBitmap& bmp = (!tabInfo.IsActive() && tabInfo.GetDisabledBitmp().IsOk()) ? tabInfo.GetDisabledBitmp() : tabInfo.GetBitmap(); dc.DrawBitmap(bmp, tabInfo.m_bmpX + tabInfo.m_rect.GetX(), tabInfo.m_bmpY); } fontDC.DrawText(tabInfo.m_label, tabInfo.m_textX + tabInfo.m_rect.GetX(), tabInfo.m_textY); if(tabInfo.IsActive() && (style & kNotebook_CloseButtonOnActiveTab)) { DrawButton(parent, dc, tabInfo, colours, buttonState); } }