void GUIComboBox::Init(const xhn::static_string configName) { GUIListEntry::Init(configName); SpriteRect rect; GetBackgroundRect(rect); m_dropDownMenu = static_cast<GUIList *>(m_dropDownMenuFactory->MakeSprite()); m_dropDownMenu->SetCoord(0.0f, rect.size.height); AddChild(m_dropDownMenu); }
///**********************************************************************/// /// class implement begin /// ///**********************************************************************/// const FourBorders& GUIComboBox::GetFourBorders() { SpriteRect mainRect; SpriteRect menuRect; GetBackgroundRect(mainRect); GetDropDownMenuRect(menuRect); mainRect.Merge(menuRect); mainRect.GetFourBorders(m_renderer, m_fourBorders); matrix4x4 mat; Matrix4x4_set_one(&mat); GetMatrix(&mat); m_fourBorders.ApplyTranform(&mat); return m_fourBorders; }
bool SUIComponentComposite::PreDraw() { // Create render target to be rendered by children. childTarget = SPTextureManager::GetSingleton(). CreateRenderTarget(GetWidth(), GetHeight(), properties.backgroundColor); // A card problem ? //childTarget->Fill(0x00000000); SPRectangle destRect = properties.rectangle; destRect.X = 0; destRect.Y = 0; // Render background color and image. SPTexturePtr backgroundColorTex = SPTextureManager::GetSingleton().GetBlankWhiteTexture(); SPSpriteManager::GetSingleton().RenderOnScreen(backgroundColorTex, NULL, destRect, properties.backgroundColor, 1, childTarget); if (properties.backgroundImage) { SPSpriteManager::GetSingleton().RenderOnScreen(properties.backgroundImage, NULL, GetBackgroundRect(), SPColor::White, 1, childTarget); } SPComposite::ChildIterator iter = children.begin(); while(iter != children.end()) { if (*iter) { (*iter)->SetRenderTarget(childTarget); iter++; } else { iter = children.erase(iter); } } return true; }
void ScreenshotCommand::Capture(wxString filename, wxWindow *window, int x, int y, int width, int height, bool bg) { if (window) { if (window->IsTopLevel()) { window->Raise(); } else { wxGetTopLevelParent(window)->Raise(); } } Yield(); int screenW, screenH; wxDisplaySize(&screenW, &screenH); wxBitmap full(screenW, screenH); wxScreenDC screenDC; wxMemoryDC fullDC; // We grab the whole screen image since there seems to be a problem with // using non-zero source coordinates on OSX. (as of wx2.8.9) fullDC.SelectObject(full); fullDC.Blit(0, 0, screenW, screenH, &screenDC, 0, 0); fullDC.SelectObject(wxNullBitmap); wxRect r(x, y, width, height); // Ensure within bounds (x/y are negative on Windows when maximized) r.Intersect(wxRect(0, 0, screenW, screenH)); // Convert to screen coordinates if needed if (window && window->GetParent() && !window->IsTopLevel()) { r.SetPosition(window->GetParent()->ClientToScreen(r.GetPosition())); } // Extract the actual image wxBitmap part = full.GetSubBitmap(r); // Add a background if (bg && mBackground) { wxRect b = GetBackgroundRect(); wxBitmap back(width + b.width, height + b.height); fullDC.SelectObject(back); fullDC.SetBackground(wxBrush(mBackColor, wxSOLID)); fullDC.Clear(); fullDC.DrawBitmap(part, b.x, b.y); fullDC.SelectObject(wxNullBitmap); part = back; } // Save the final image wxImage image = part.ConvertToImage(); if (image.SaveFile(filename)) { mOutput->Status(_("Saved ") + filename); } else { mOutput->Error(_("Error trying to save file: ") + filename); } ::wxBell(); }
bool ScreenshotCommand::Apply(CommandExecutionContext context) { // Read the parameters that were passed in wxString filePath = GetString(wxT("FilePath")); wxString captureMode = GetString(wxT("CaptureMode")); wxString background = GetString(wxT("Background")); // Build a suitable filename wxString fileName = MakeFileName(filePath, captureMode); if (background.IsSameAs(wxT("Blue"))) { mBackground = true; mBackColor = wxColour(51, 102, 153); } else if (background.IsSameAs(wxT("White"))) { mBackground = true; mBackColor = wxColour(255, 255, 255); } else { mBackground = false; } // Reset the toolbars to a known state context.proj->mToolManager->Reset(); wxTopLevelWindow *w = GetFrontWindow(context.proj); if (!w) { return false; } if (captureMode.IsSameAs(wxT("window"))) { int x = 0, y = 0; int width, height; w->ClientToScreen(&x, &y); w->GetClientSize(&width, &height); if (w != context.proj && w->GetTitle() != wxT("")) { fileName = MakeFileName(filePath, captureMode + (wxT("-") + w->GetTitle() + wxT("-"))); } Capture(fileName, w, x, y, width, height); } else if (captureMode.IsSameAs(wxT("fullwindow")) || captureMode.IsSameAs(wxT("windowplus"))) { wxRect r = w->GetRect(); r.SetPosition(w->GetScreenPosition()); r = w->GetScreenRect(); if (w != context.proj && w->GetTitle() != wxT("")) { fileName = MakeFileName(filePath, captureMode + (wxT("-") + w->GetTitle() + wxT("-"))); } #if defined(__WXGTK__) // In wxGTK, we need to include decoration sizes r.width += (wxSystemSettings::GetMetric(wxSYS_BORDER_X, w) * 2); r.height += wxSystemSettings::GetMetric(wxSYS_CAPTION_Y, w) + wxSystemSettings::GetMetric(wxSYS_BORDER_Y, w); #endif if (!mBackground && captureMode.IsSameAs(wxT("windowplus"))) { // background colour not selected but we want a background wxRect b = GetBackgroundRect(); r.x = (r.x - b.x) >= 0 ? (r.x - b.x): 0; r.y = (r.y - b.y) >= 0 ? (r.y - b.y): 0; r.width += b.width; r.height += b.height; } Capture(fileName, w, r.x, r.y, r.width, r.height, true); } else if (captureMode.IsSameAs(wxT("fullscreen"))) { int width, height; wxDisplaySize(&width, &height); Capture(fileName, w, 0, 0, width, height); } else if (captureMode.IsSameAs(wxT("toolbars"))) { CaptureDock(context.proj->mToolManager->GetTopDock(), fileName); } else if (captureMode.IsSameAs(wxT("selectionbar"))) { CaptureDock(context.proj->mToolManager->GetBotDock(), fileName); } else if (captureMode.IsSameAs(wxT("tools"))) { CaptureToolbar(context.proj->mToolManager, ToolsBarID, fileName); } else if (captureMode.IsSameAs(wxT("control"))) { CaptureToolbar(context.proj->mToolManager, ControlBarID, fileName); } else if (captureMode.IsSameAs(wxT("mixer"))) { CaptureToolbar(context.proj->mToolManager, MixerBarID, fileName); } else if (captureMode.IsSameAs(wxT("meter"))) { CaptureToolbar(context.proj->mToolManager, MeterBarID, fileName); } else if (captureMode.IsSameAs(wxT("edit"))) { CaptureToolbar(context.proj->mToolManager, EditBarID, fileName); } else if (captureMode.IsSameAs(wxT("device"))) { CaptureToolbar(context.proj->mToolManager, DeviceBarID, fileName); } else if (captureMode.IsSameAs(wxT("transcription"))) { CaptureToolbar(context.proj->mToolManager, TranscriptionBarID, fileName); } else if (captureMode.IsSameAs(wxT("trackpanel"))) { TrackPanel *panel = context.proj->mTrackPanel; AdornedRulerPanel *ruler = panel->mRuler; int h = ruler->GetRulerHeight(); int x = 0, y = -h; int width, height; panel->ClientToScreen(&x, &y); panel->GetParent()->ScreenToClient(&x, &y); panel->GetClientSize(&width, &height); Capture(fileName, panel, x, y, width, height + h); } else if (captureMode.IsSameAs(wxT("ruler"))) { TrackPanel *panel = context.proj->mTrackPanel; AdornedRulerPanel *ruler = panel->mRuler; int x = 0, y = 0; int width, height; ruler->ClientToScreen(&x, &y); ruler->GetParent()->ScreenToClient(&x, &y); ruler->GetClientSize(&width, &height); height = ruler->GetRulerHeight(); Capture(fileName, ruler, x, y, width, height); } else if (captureMode.IsSameAs(wxT("tracks"))) { TrackPanel *panel = context.proj->mTrackPanel; int x = 0, y = 0; int width, height; panel->ClientToScreen(&x, &y); panel->GetParent()->ScreenToClient(&x, &y); panel->GetClientSize(&width, &height); Capture(fileName, panel, x, y, width, height); } else if (captureMode.IsSameAs(wxT("firsttrack"))) { TrackPanel *panel = context.proj->mTrackPanel; TrackListIterator iter(context.proj->GetTracks()); Track * t = iter.First(); if (!t) { return false; } wxRect r = panel->FindTrackRect(t, true); int x = 0, y = r.y - 3; int width, height; panel->ClientToScreen(&x, &y); panel->GetParent()->ScreenToClient(&x, &y); panel->GetClientSize(&width, &height); Capture(fileName, panel, x, y, width, r.height + 6); } else if (captureMode.IsSameAs(wxT("secondtrack"))) { TrackPanel *panel = context.proj->mTrackPanel; TrackListIterator iter(context.proj->GetTracks()); Track * t = iter.First(); if (!t) { return false; } if (t->GetLinked()) { t = iter.Next(); } t = iter.Next(); if (!t) { return false; } wxRect r = panel->FindTrackRect(t, true); int x = 0, y = r.y - 3; int width, height; panel->ClientToScreen(&x, &y); panel->GetParent()->ScreenToClient(&x, &y); panel->GetClientSize(&width, &height); Capture(fileName, panel, x, y, width, r.height + 6); } else { // Invalid capture mode! return false; } return true; }
void GUIComboBox::GetScope(SpriteRect& result) { GetBackgroundRect(result); }