CStatusLineCtrl::CStatusLineCtrl(CQueueView* pParent, const t_EngineData* const pEngineData, const wxRect& initialPosition) : m_pEngineData(pEngineData) { m_mdc = 0; m_pPreviousStatusText = 0; m_last_elapsed_seconds = 0; m_last_left = 0; m_last_bar_split = -1; m_last_permill = -1; wxASSERT(pEngineData); #ifdef __WXMSW__ Create(pParent, wxID_ANY, initialPosition.GetPosition(), initialPosition.GetSize()); #else Create(pParent->GetMainWindow(), wxID_ANY, initialPosition.GetPosition(), initialPosition.GetSize()); #endif SetOwnFont(pParent->GetFont()); SetForegroundColour(pParent->GetForegroundColour()); SetBackgroundStyle(wxBG_STYLE_CUSTOM); SetBackgroundColour(pParent->GetBackgroundColour()); m_transferStatusTimer.SetOwner(this); m_pParent = pParent; m_pStatus = 0; m_lastOffset = -1; m_gcLastTimeStamp = wxDateTime::Now(); m_gcLastOffset = -1; m_gcLastSpeed = -1; SetTransferStatus(0); // Calculate field widths so that the contents fit under every language. if (!m_initialized) { m_initialized = true; wxClientDC dc(this); dc.SetFont(GetFont()); wxCoord w, h; wxTimeSpan elapsed(100, 0, 0); dc.GetTextExtent(elapsed.Format(_("%H:%M:%S elapsed")), &w, &h); m_textHeight = h; m_fieldOffsets[0] = 50 + w; dc.GetTextExtent(elapsed.Format(_("%H:%M:%S left")), &w, &h); m_fieldOffsets[1] = m_fieldOffsets[0] + 20 + w; m_fieldOffsets[2] = m_fieldOffsets[1] + 20; m_fieldOffsets[3] = m_fieldOffsets[2] + PROGRESSBAR_WIDTH + 20; } #ifdef __WXGTK__ ResetCursor(this); #endif }
bool MyApp::OnInit() { Aux::logsStr("", wxT("Wherbarium [" + wxDateTime::Now().Format(wxT("%Y-%m-%d %H:%M:%S")) + "] - IN"), logPut); try { // setting divers wxInitAllImageHandlers(); // évite les problèmes de handlers d'images SetExitOnFrameDelete(false); // évite la fermeture de l'application sur un close quelconque !!! // variables de dimensionnement ecranRectGbl.SetPosition(wxPoint(0, 0)); ecranRectGbl.SetSize(wxSize(wxSystemSettings::GetMetric(wxSYS_SCREEN_X), wxSystemSettings::GetMetric(wxSYS_SCREEN_Y))); wxDisplay *display = new wxDisplay(); clientRectGbl = display->GetClientArea(); gapGbl = 16; winRectGbl.SetPosition(wxPoint(clientRectGbl.GetX()+gapGbl, clientRectGbl.GetY()+gapGbl)); winRectGbl.SetSize(wxSize(clientRectGbl.width-2*gapGbl, clientRectGbl.height-2*gapGbl)); win3RectGbl = winRectGbl; win3RectGbl.SetWidth(winRectGbl.GetWidth()/3); wxSystemSettings sysSet; dimScrollXGbl = sysSet.GetMetric(wxSYS_VSCROLL_X, NULL); dimScrollYGbl = sysSet.GetMetric(wxSYS_HSCROLL_Y, NULL); Aux::logsPoint("MyApp::OnInit::ecranRectGbl", ecranRectGbl.GetPosition(), logNop); Aux::logsSize("MyApp::OnInit::ecranRectGbl", ecranRectGbl.GetSize(), logNop); Aux::logsPoint("MyApp::OnInit::clientRectGbl", clientRectGbl.GetPosition(), logNop); Aux::logsSize("MyApp::OnInit::clientRectGbl", clientRectGbl.GetSize(), logNop); Aux::logsPoint("MyApp::OnInit::winRectGbl", winRectGbl.GetPosition(), logNop); Aux::logsSize("MyApp::OnInit::winRectGbl", winRectGbl.GetSize(), logNop); Aux::logsPoint("MyApp::OnInit::win3RectGbl", win3RectGbl.GetPosition(), logNop); Aux::logsSize("MyApp::OnInit::win3RectGbl", win3RectGbl.GetSize(), logNop); wxString dbDir = "/Users/" + wxGetUserId() + "/Pictures/Wherbarium/Connect/"; if (! wxDir::Exists(dbDir)) { wxDir::Make(dbDir); } wxArrayString *files = new wxArrayString(); wxDir::GetAllFiles(dbDir, files); wxString dbFile = dbDir + "Wherbarium.db"; wxFile *fileConnect; if (files->size() == 0) { fileConnect = new wxFile(); fileConnect->Create(dbFile, false, wxS_DEFAULT); } else if (files->size() != 1) { Exit(); } string tableName = "tblConnParams"; sqlite = new SQLite(string(dbFile), tableName); sqliteStatement = sqlite->ptrTableConnParams(); // début des opérations de l'application InitApp *initApp = new InitApp(); initApp->nop(); } catch (const exception &e) { Aux::logsStr("", e.what(), logPut); } return true; }
GestionCarnet::GestionCarnet() { Aux::logsInOut("GestionCarnet::GestionCarnet", logIn, logNop); try { Create(NULL, wxID_ANY, _("Chargement des photos"), winRectGbl.GetPosition(), winRectGbl.GetSize(), wxDEFAULT_FRAME_STYLE, className); this->Show(false); // !!! hum ... AppMenuBar &appMenuBar = AppMenuBar::Instance(); appMenuBar.disableAllMenus(); ObjPlante *objPlante = new ObjPlante(); tableOfPhotosOfCarnet = new TableOfPhotos(this, winRectGbl.GetSize(), objPlante, this->getClassName()); } catch (const exception &e) { Aux::logsStr("", e.what(), logPut); } Aux::logsInOut("GestionCarnet::GestionCarnet", logOut, logNop); }
bool LfnTech::Copy( void* destBase, const void* srcBase, const wxRect& destBounds, const wxRect& srcBounds, const wxPoint& destPoint, const wxRect& srcRect, int destStride, int srcStride, int bytesPerPixel) { bool result = false; if (!destBounds.IsEmpty() && !srcBounds.IsEmpty()) { wxPoint destPointClipped(destPoint); wxPoint srcPointClipped(srcRect.GetPosition()); wxSize sizeClipped(srcRect.GetSize()); // Clip against src bounds, then against dest bounds, then once again // against src bounds in case the dest clip translation moved it significantly. Clip(srcBounds, srcPointClipped, sizeClipped, destPointClipped); Clip(destBounds, destPointClipped, sizeClipped, srcPointClipped); Clip(srcBounds, srcPointClipped, sizeClipped, destPointClipped); result = Copy(destBase, srcBase, destPointClipped, wxRect(srcPointClipped, sizeClipped), destStride, srcStride, bytesPerPixel); } return result; }
FenetreZoom::FenetreZoom(FenetrePrincipale *f,wxRect &r) : wxFrame(NULL, wxID_ANY, _T("Zoom") , r.GetLeftTop(),r.GetSize()) { fMere = f; facteurZoom=2; zoomInactif=false; }
MovieElement::MovieElement(Stage *inStage, const wxString &inName, Halyard::TCallbackPtr inDispatcher, const wxRect &inBounds, const wxString &inLocation, long inWindowStyle, MovieWindowStyle inMovieWindowStyle, float inVolume) : Widget(inStage, inName, inDispatcher), mLocationInfo(inLocation), mMovieWindow(NULL), mHaveSentMediaErrorEvent(false), mHaveSentMediaTimeoutEvent(false) { mMovieWindow = new MovieWindowNative(inStage, -1, inBounds.GetPosition(), inBounds.GetSize(), inWindowStyle, inMovieWindowStyle); mMovieWindow->SetVolume("all", inVolume); try { mMovieWindow->SetMovie(inLocation); } catch (std::exception &e) { // Log this exception. We'll report it in our Idle() method, // because many movie errors occur after playback has started, so // it's more consistent to handle this one that way. std::string location(inLocation.mb_str()); gLog.Info("halyard", "Movie error: %s for %s", e.what(), location.c_str()); } InitializeWidgetWindow(mMovieWindow); }
CustomWxHtmlWindow::CustomWxHtmlWindow(wxWindow *inParent, const wxRect &inBounds, BrowserElementWx *inElement) : wxHtmlWindow(inParent, -1, inBounds.GetPosition(), inBounds.GetSize(), wxHW_SCROLLBAR_AUTO | wxBORDER), mElement(inElement) { }
/********************************************************************************************* > virtual BOOL CRenderWnd::Create(const wxRect& rect, wxWindow* parent, UINT32 id) Author: Justin_Flude (Xara Group Ltd) <*****@*****.**> Created: ages ago Inputs: Windows instance-style flags; a rectangle describing the position of the scroller; a pointer to its parent window; a child window numeric identifier Outputs: - Returns: TRUE if the window is successfully created. Purpose: Registers a new window class with the operating system, which accepts double clicks, is byte-aligned in video RAM and is responsible for drawing is own backgrounds. Errors: - Scope: Public SeeAlso: CCamView::OnCreate() **********************************************************************************************/ BOOL CRenderWnd::Create(const wxRect& rect, wxWindow *pParent, UINT32 id) { BOOL ok=wxWindow::Create(pParent, id, rect.GetTopLeft(), rect.GetSize(), wxNO_FULL_REPAINT_ON_RESIZE); SetExtraStyle(wxWS_EX_PROCESS_IDLE); #if defined(__WXGTK__) ::SetDoubleBuffer(this, m_DoubleBuffer); #endif return ok; }
void wxPDFViewPage::DrawThumbnail(wxPDFViewPagesClient* client, wxDC& dc, const wxRect& rect) { dc.SetBackground(*wxTRANSPARENT_BRUSH); dc.SetPen(*wxLIGHT_GREY_PEN); dc.DrawRectangle(rect.Inflate(1, 1)); wxBitmap bmp = client->GetCachedBitmap(m_index, rect.GetSize()); if (bmp.Ok()) { dc.DrawBitmap(bmp, rect.GetPosition()); } }
void CLMainAuiTBArt::DrawPlainBackground(wxDC& dc, wxWindow* wnd, const wxRect& rect) { wxUnusedVar(wnd); wxBitmap bmp(rect.GetSize()); wxMemoryDC dcMem; dcMem.SelectObject(bmp); dcMem.SetPen(DrawingUtils::GetPanelBgColour()); dcMem.SetBrush(DrawingUtils::GetPanelBgColour()); dcMem.DrawRectangle(rect); dcMem.SelectObject(wxNullBitmap); dc.DrawBitmap(bmp, wxPoint(0, 0)); }
wxPoint ClampPosition( const wxRect& viewport, const wxRect& extent ) { const wxSize delta( viewport.GetSize() - extent.GetSize() ); wxPoint newTopLeft( viewport.GetPosition() ); if( delta.x < 0 ) { // viewport smaller than extent int minX = extent.GetPosition().x; int maxX = ( extent.GetPosition().x + extent.GetSize().x ) - viewport.GetSize().x; newTopLeft.x = clamp( newTopLeft.x, minX, maxX ); } else { // viewport larger than extent newTopLeft.x = extent.GetPosition().x - ( delta.x / 2 ); } if( delta.y < 0 ) { // viewport smaller than extent int minY = extent.GetPosition().y; int maxY = ( extent.GetPosition().y + extent.GetSize().y ) - viewport.GetSize().y; newTopLeft.y = clamp( newTopLeft.y, minY, maxY ); } else { // viewport larger than extent newTopLeft.y = extent.GetPosition().y - ( delta.y / 2 ); } return newTopLeft; }
void tcButtonConsole::AddButton(wxRect bounds, long command, std::string caption) { wxSize buttonSize = bounds.GetSize(); wxPoint buttonPosition = bounds.GetPosition(); #if 0 tcButton *buttonToAdd = new tcButton(this, buttonPosition, buttonSize); buttonToAdd->SetCaption(caption); buttonToAdd->SetCommand(command); buttonToAdd->SetSendRedraw(true); buttons.push_back(buttonToAdd); #endif }
void wxDialog::ResizeGripper() { wxASSERT_MSG( m_hGripper, wxT("shouldn't be called if we have no gripper") ); HWND hwndGripper = (HWND)m_hGripper; const wxRect rectGripper = wxRectFromRECT(wxGetWindowRect(hwndGripper)); const wxSize size = GetClientSize() - rectGripper.GetSize(); ::SetWindowPos(hwndGripper, HWND_BOTTOM, size.x, size.y, rectGripper.width, rectGripper.height, SWP_NOACTIVATE); }
void wxPDFViewPage::DrawPrint(wxDC& dc, const wxRect& rect, bool forceBitmap) { FPDF_PAGE page = GetPage(); int renderFlags = FPDF_ANNOT | FPDF_PRINTING; #ifdef wxPDFVIEW_USE_RENDER_TO_DC if (!forceBitmap) { FPDF_RenderPage(dc.GetHDC(), page, rect.x, rect.y, rect.width, rect.height, 0, renderFlags); } else #endif { wxBitmap bmp = CreateBitmap(page, m_pages->form(), rect.GetSize(), renderFlags); dc.DrawBitmap(bmp, wxPoint(0, 0)); } }
bool wxSpinCtrl::Reparent(wxWindowBase *newParent) { // Reparenting both the updown control and its buddy does not seem to work: // they continue to be connected somehow, but visually there is no feedback // on the buddy edit control. To avoid this problem, we reparent the buddy // window normally, but we recreate the updown control and reassign its // buddy. // Get the position before changing the parent as it would be offset after // changing it. const wxRect rect = GetRect(); if ( !wxWindowBase::Reparent(newParent) ) return false; newParent->GetChildren().DeleteObject(this); // destroy the old spin button after detaching it from this wxWindow object // (notice that m_hWnd will be reset by UnsubclassWin() so save it first) const HWND hwndOld = GetHwnd(); UnsubclassWin(); if ( !::DestroyWindow(hwndOld) ) { wxLogLastError(wxT("DestroyWindow")); } // create and initialize the new one if ( !wxSpinButton::Create(GetParent(), GetId(), rect.GetPosition(), rect.GetSize(), GetWindowStyle(), GetName()) ) return false; // reapply our values to wxSpinButton wxSpinButton::SetValue(GetValue()); SetRange(m_min, m_max); // also set the size again with wxSIZE_ALLOW_MINUS_ONE flag: this is // necessary if our original position used -1 for either x or y SetSize(rect, wxSIZE_ALLOW_MINUS_ONE); // associate it with the buddy control again ::SetParent(GetBuddyHwnd(), GetHwndOf(GetParent())); (void)::SendMessage(GetHwnd(), UDM_SETBUDDY, (WPARAM)GetBuddyHwnd(), 0); return true; }
BOOL CScrollerCorner::Create(LPCTSTR, LPCTSTR, DWORD style, const wxRect& rect, wxWindow* pParent, UINT32 id) { return wxWindow::Create( pParent, id, rect.GetTopLeft(), rect.GetSize(), style ); /* return CWnd::Create(AfxRegisterWndClass( CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS, 0, HBRUSH(COLOR_SCROLLBAR + 1), 0), "", style | WS_CHILD | WS_CLIPSIBLINGS | WS_VISIBLE, rect, parent, id, ctxt); */ }
CStatusLineCtrl::CStatusLineCtrl(CQueueView* pParent, const t_EngineData* const pEngineData, const wxRect& initialPosition) : m_pParent(pParent) , m_pEngineData(pEngineData) { wxASSERT(pEngineData); Create(pParent->GetMainWindow(), wxID_ANY, initialPosition.GetPosition(), initialPosition.GetSize()); SetOwnFont(pParent->GetFont()); SetForegroundColour(pParent->GetForegroundColour()); SetBackgroundStyle(wxBG_STYLE_CUSTOM); SetBackgroundColour(pParent->GetBackgroundColour()); m_transferStatusTimer.SetOwner(this); InitFieldOffsets(); ClearTransferStatus(); }
AssocPhotosToPlante::AssocPhotosToPlante(wxWindow *parent, vector<ObjMicroPhoto *> &listeOfObjMicrosPhotos, wxString topClass) { Create(parent, wxID_ANY, winRectGbl.GetPosition(), winRectGbl.GetSize(), wxDEFAULT_FRAME_STYLE & ~(wxRESIZE_BORDER | wxMAXIMIZE_BOX)); // Aux::logsThis(wxT("AssocPhotosToPlante::AssocPhotosToPlante"), this, logPut); // Aux::logsThis(wxT("AssocPhotosToPlante::AssocPhotosToPlante::parent"), parent, logPut); parent0 = parent; listeOfObjMicrosPhotos0 = &listeOfObjMicrosPhotos; this->Show(false); SelectPlanteNameFrame *selectPlanteNameFrame = new SelectPlanteNameFrame(this, classTitle, wxEmptyString, wxT("ModelTPL"), topClass); selectPlanteNameFrame->SetPosition(this->GetPosition()); selectPlanteNameFrame->SetBackgroundColour(Couleurs::backgColor); selectPlanteNameFrame->Show(true); selectPlanteNameFrame->SetFocus(); selectPlanteNameFrame->getObjPlante(); }
bool wxNativeWindow::Create(wxWindow* parent, wxWindowID winid, wxNativeWindowHandle hwnd) { wxCHECK_MSG( hwnd, false, wxS("Invalid null HWND") ); wxCHECK_MSG( parent, false, wxS("Must have a valid parent") ); wxASSERT_MSG( ::GetParent(hwnd) == GetHwndOf(parent), wxS("The native window has incorrect parent") ); const wxRect r = wxRectFromRECT(wxGetWindowRect(hwnd)); // Skip wxWindow::Create() which would try to create a new HWND, we don't // want this as we already have one. if ( !CreateBase(parent, winid, r.GetPosition(), r.GetSize(), 0, wxDefaultValidator, wxS("nativewindow")) ) return false; parent->AddChild(this); SubclassWin(hwnd); if ( winid == wxID_ANY ) { // We allocated a new ID to the control, use it at Windows level as // well because we assume that our and MSW IDs are the same in many // places and it seems prudent to avoid breaking this assumption. SetId(GetId()); } else // We used a fixed ID. { // For the same reason as above, check that it's the same as the one // used by the native HWND. wxASSERT_MSG( ::GetWindowLong(hwnd, GWL_ID) == winid, wxS("Mismatch between wx and native IDs") ); } InheritAttributes(); return true; }
bool wxSpinCtrl::Reparent(wxWindowBase *newParent) { // Reparenting both the updown control and its buddy does not seem to work: // they continue to be connected somehow, but visually there is no feedback // on the buddy edit control. To avoid this problem, we reparent the buddy // window normally, but we recreate the updown control and reassign its // buddy. if ( !wxWindowBase::Reparent(newParent) ) return false; newParent->GetChildren().DeleteObject(this); // preserve the old values const wxSize size = GetSize(); int value = GetValue(); const wxRect btnRect = wxRectFromRECT(wxGetWindowRect(GetHwnd())); // destroy the old spin button UnsubclassWin(); if ( !::DestroyWindow(GetHwnd()) ) { wxLogLastError(wxT("DestroyWindow")); } // create and initialize the new one if ( !wxSpinButton::Create(GetParent(), GetId(), btnRect.GetPosition(), btnRect.GetSize(), GetWindowStyle(), GetName()) ) return false; SetValue(value); SetRange(m_min, m_max); SetInitialSize(size); // associate it with the buddy control again ::SetParent(GetBuddyHwnd(), GetHwndOf(GetParent())); (void)::SendMessage(GetHwnd(), UDM_SETBUDDY, (WPARAM)GetBuddyHwnd(), 0); return true; }
GestionPhotosOfPlante::GestionPhotosOfPlante( ) { Aux::logsInOut("GestionPhotosOfPlante", 0, logNop); try { Create(NULL, wxID_ANY, classTitle, winRectGbl.GetPosition(), winRectGbl.GetSize(), wxDEFAULT_FRAME_STYLE & ~(wxRESIZE_BORDER | wxMAXIMIZE_BOX), className); // Model *model = new Model(); if (model->existAnyPlanteAssociated()) { AppMenuBar &appMenuBar = AppMenuBar::Instance(); appMenuBar.disableAllMenus(); SelectPlanteNameFrame *selectPlanteNameFrame = new SelectPlanteNameFrame(this, classTitle, wxEmptyString, wxT("Model"), className); selectPlanteNameFrame->Show(true); } else { wxMessageBox(_("Voir le menu Gestion des photos orphelines"), _("Aucune photo n'est associée à une plante"), wxOK); return; } } catch (const exception &e) { Aux::logsStr("", e.what(), logPut); } Aux::logsInOut("GestionPhotosOfPlante", 1, logNop); }
void wxPDFViewPage::Draw(wxPDFViewPagesClient* client, wxDC& dc, wxGraphicsContext& gc, const wxRect& rect) { // Calculate the required bitmap size wxSize bmpSize = rect.GetSize(); double scaleX, scaleY; dc.GetUserScale(&scaleX, &scaleY); bmpSize.x *= scaleX; bmpSize.y *= scaleY; double screenScale = dc.GetContentScaleFactor(); bmpSize.x *= screenScale; bmpSize.y *= screenScale; wxBitmap bmp = client->GetCachedBitmap(m_index, bmpSize); if (bmp.IsOk()) { gc.DrawBitmap(bmp, rect.x, rect.y, rect.width, rect.height); } else { // Draw empty page gc.SetBrush(*wxWHITE_BRUSH); gc.SetPen(wxNullPen); gc.DrawRectangle(rect.x, rect.y, rect.width, rect.height); } }
FichiersToUpload::FichiersToUpload() { Model *model = new Model(); if (model->isUserDemo()) { wxMessageBox(_("L'utilisateur \"demo\" ne peut pas ajouter de photos")); return; } else { AppMenuBar &appMenuBar = AppMenuBar::Instance(); appMenuBar.disableAllMenus(); wxString toUploadPath = model->getCurBaseDir() + wxT("PhotosToUpload/"); wxDir dir(toUploadPath); if ( !dir.IsOpened() ) { wxMessageBox(_("Répertoire \"") + toUploadPath + _("\" ne peut être ouvert"), _("Erreur fatale")); return; } AfficheFileTransfer *afficheFileTransfer = new AfficheFileTransfer(this, win3RectGbl.GetPosition(), win3RectGbl.GetSize(), _T("Téléchargement d'une liste de fichiers photos"), className, true); wxArrayString fileNames; wxDir::GetAllFiles(toUploadPath, &fileNames, wxT("*.jpg"), wxDIR_DEFAULT); wxDir::GetAllFiles(toUploadPath, &fileNames, wxT("*.JPG"), wxDIR_DEFAULT); wxDir::GetAllFiles(toUploadPath, &fileNames, wxT("*.jpeg"), wxDIR_DEFAULT); wxDir::GetAllFiles(toUploadPath, &fileNames, wxT("*.JPEG"), wxDIR_DEFAULT); if (fileNames.size() == 0) { afficheFileTransfer->addItem(_("Aucun fichier au format JPEG dans le répertoire :")); afficheFileTransfer->addLine(wxT("\"") + model->getCurBaseDir()); afficheFileTransfer->addLine(wxT("PhotosToUpload/\"")); wxMessageBox(_("Seuls les fichiers au format JPEG (extensions .JPEG | .JPG | .jpeg | .jpg) sont acceptés"), _("Rappel")); return; } else { afficheFileTransfer->addItem(_("Nombre de fichiers à télecharger : ")+to_string(fileNames.size())); afficheFileTransfer->wait(); afficheFileTransfer->temps(_("Début : ")); for (int ijk=0; ijk<fileNames.size(); ijk++) { wxString flnIn = wxFileNameFromPath(fileNames[ijk]); afficheFileTransfer->addLine(_("Fichier[") + to_string(ijk) + wxT("] : \"") + flnIn + wxT("\"")); // Aux::logsNumber("ijk", ijk, logPut); int sts = model->addFichierToTblFichiers(toUploadPath, flnIn); if (sts == 0) { afficheFileTransfer->addLine(_("Le fichier existe déjà")); } model->moveFichierAfterLoaded(toUploadPath+flnIn, toUploadPath + "../PhotosUploaded/" + flnIn); } afficheFileTransfer->temps(_("Fin : ")); afficheFileTransfer->addDummy(); afficheFileTransfer->addLine(_("Les fichiers téléchargés sont maintenant dans le répertoire : ")); afficheFileTransfer->addLine(wxT("\"") + model->getCurBaseDir()); afficheFileTransfer->addLine(wxT("PhotosUploaded/\"")); } } }
// Converts a wxRect into a comma-delimited string! // Example: 32,64,128,5 wxString ToString( const wxRect& src, const wxString& separator ) { return ToString( src.GetLeftTop(), separator ) << separator << ToString( src.GetSize(), separator ); }
void wxPopupWindowBase::Position(const wxPoint& ptOrigin, const wxSize& size) { // determine the position and size of the screen we clamp the popup to wxPoint posScreen; wxSize sizeScreen; const int displayNum = wxDisplay::GetFromPoint(ptOrigin); if ( displayNum != wxNOT_FOUND ) { const wxRect rectScreen = wxDisplay(displayNum).GetGeometry(); posScreen = rectScreen.GetPosition(); sizeScreen = rectScreen.GetSize(); } else // outside of any display? { // just use the primary one then posScreen = wxPoint(0, 0); sizeScreen = wxGetDisplaySize(); } const wxSize sizeSelf = GetSize(); // is there enough space to put the popup below the window (where we put it // by default)? wxCoord y = ptOrigin.y + size.y; if ( y + sizeSelf.y > posScreen.y + sizeScreen.y ) { // check if there is enough space above if ( ptOrigin.y > sizeSelf.y ) { // do position the control above the window y -= size.y + sizeSelf.y; } //else: not enough space below nor above, leave below } // now check left/right too wxCoord x = ptOrigin.x; if ( wxTheApp->GetLayoutDirection() == wxLayout_RightToLeft ) { // shift the window to the left instead of the right. x -= size.x; x -= sizeSelf.x; // also shift it by window width. } else x += size.x; if ( x + sizeSelf.x > posScreen.x + sizeScreen.x ) { // check if there is enough space to the left if ( ptOrigin.x > sizeSelf.x ) { // do position the control to the left x -= size.x + sizeSelf.x; } //else: not enough space there neither, leave in default position } Move(x, y, wxSIZE_NO_ADJUSTMENTS); }
void clAuiDockArt::DrawCaption(wxDC& dc, wxWindow* window, const wxString& text, const wxRect& rect, wxAuiPaneInfo& pane) { wxRect tmpRect(wxPoint(0, 0), rect.GetSize()); // Hackishly prevent assertions on linux if(tmpRect.GetHeight() == 0) tmpRect.SetHeight(1); if(tmpRect.GetWidth() == 0) tmpRect.SetWidth(1); #ifdef __WXOSX__ tmpRect = rect; window->PrepareDC(dc); // Prepare the colours wxColour bgColour, penColour, textColour; textColour = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT); bgColour = DrawingUtils::DarkColour(wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE), 2.0); ; // Same as the notebook background colour penColour = wxSystemSettings::GetColour(wxSYS_COLOUR_3DSHADOW); penColour = bgColour; wxFont f = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT); dc.SetFont(f); dc.SetPen(penColour); dc.SetBrush(bgColour); dc.DrawRectangle(tmpRect); // Fill the caption to look like OSX caption wxColour topColour("#d3d2d3"); wxColour bottomColour("#e8e8e8"); dc.GradientFillLinear(tmpRect, topColour, bottomColour, wxNORTH); dc.SetPen(penColour); dc.SetBrush(*wxTRANSPARENT_BRUSH); dc.DrawRectangle(tmpRect); int caption_offset = 0; if(pane.icon.IsOk()) { DrawIcon(dc, tmpRect, pane); caption_offset += pane.icon.GetWidth() + 3; } else { caption_offset = 3; } dc.SetTextForeground(textColour); wxCoord w, h; dc.GetTextExtent(wxT("ABCDEFHXfgkj"), &w, &h); wxRect clip_rect = tmpRect; clip_rect.width -= 3; // text offset clip_rect.width -= 2; // button padding if(pane.HasCloseButton()) clip_rect.width -= m_buttonSize; if(pane.HasPinButton()) clip_rect.width -= m_buttonSize; if(pane.HasMaximizeButton()) clip_rect.width -= m_buttonSize; wxString draw_text = wxAuiChopText(dc, text, clip_rect.width); wxSize textSize = dc.GetTextExtent(draw_text); dc.SetTextForeground(textColour); dc.DrawText(draw_text, tmpRect.x + 3 + caption_offset, tmpRect.y + ((tmpRect.height - textSize.y) / 2)); #else wxBitmap bmp(tmpRect.GetSize()); { wxMemoryDC memDc; memDc.SelectObject(bmp); wxGCDC gdc; wxDC* pDC = NULL; if(!DrawingUtils::GetGCDC(memDc, gdc)) { pDC = &memDc; } else { pDC = &gdc; } // Prepare the colours wxColour bgColour, penColour, textColour; textColour = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT); bgColour = DrawingUtils::DarkColour(wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE), 2.0); ; // Same as the notebook background colour penColour = wxSystemSettings::GetColour(wxSYS_COLOUR_3DSHADOW); penColour = bgColour; wxFont f = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT); pDC->SetFont(f); pDC->SetPen(penColour); pDC->SetBrush(bgColour); pDC->DrawRectangle(tmpRect); pDC->SetPen(penColour); pDC->SetBrush(*wxTRANSPARENT_BRUSH); pDC->DrawRectangle(tmpRect); int caption_offset = 0; if(pane.icon.IsOk()) { DrawIcon(gdc, tmpRect, pane); caption_offset += pane.icon.GetWidth() + 3; } else { caption_offset = 3; } pDC->SetTextForeground(textColour); wxCoord w, h; pDC->GetTextExtent(wxT("ABCDEFHXfgkj"), &w, &h); wxRect clip_rect = tmpRect; clip_rect.width -= 3; // text offset clip_rect.width -= 2; // button padding if(pane.HasCloseButton()) clip_rect.width -= m_buttonSize; if(pane.HasPinButton()) clip_rect.width -= m_buttonSize; if(pane.HasMaximizeButton()) clip_rect.width -= m_buttonSize; wxString draw_text = wxAuiChopText(gdc, text, clip_rect.width); wxSize textSize = pDC->GetTextExtent(draw_text); pDC->SetTextForeground(textColour); pDC->DrawText(draw_text, tmpRect.x + 3 + caption_offset, tmpRect.y + ((tmpRect.height - textSize.y) / 2)); memDc.SelectObject(wxNullBitmap); } dc.DrawBitmap(bmp, rect.x, rect.y, true); #endif }
wxImage ScaleImage(wxImage image, double source_scale_factor, double content_scale_factor, wxSize output_size, wxRect usable_rect, LSIFlags flags, const wxColour& fill_color) { if (!image.IsOk()) { wxFAIL_MSG("WxUtils::ScaleImage expects a valid image."); return image; } if (content_scale_factor != 1.0) { output_size *= content_scale_factor; usable_rect.SetPosition(usable_rect.GetPosition() * content_scale_factor); usable_rect.SetSize(usable_rect.GetSize() * content_scale_factor); } // Fix the output size if it's unset. wxSize img_size = image.GetSize(); if (output_size.GetWidth() < 1) output_size.SetWidth( static_cast<int>(img_size.GetWidth() * (content_scale_factor / source_scale_factor))); if (output_size.GetHeight() < 1) output_size.SetHeight( static_cast<int>(img_size.GetHeight() * (content_scale_factor / source_scale_factor))); // Fix the usable rect. If it's empty then the whole canvas is usable. if (usable_rect.IsEmpty()) { // Constructs a temp wxRect 0,0->output_size then move assigns it. usable_rect = output_size; } else if (!usable_rect.Intersects(output_size)) { wxFAIL_MSG("Usable Zone Rectangle is not inside the canvas. Check the output size is correct."); image.Create(1, 1, false); image.SetRGB(0, 0, fill_color.Red(), fill_color.Green(), fill_color.Blue()); if (fill_color.Alpha() == wxALPHA_TRANSPARENT) image.SetMaskColour(fill_color.Red(), fill_color.Green(), fill_color.Blue()); usable_rect = output_size; } // Step 1: Scale the image if ((flags & LSI_SCALE) != LSI_SCALE_NONE) { if (flags & LSI_SCALE_NO_ASPECT) { // Stretch scale without preserving the aspect ratio. bool scale_width = (img_size.GetWidth() > usable_rect.GetWidth() && flags & LSI_SCALE_DOWN) || (img_size.GetWidth() < usable_rect.GetWidth() && flags & LSI_SCALE_UP); bool scale_height = (img_size.GetHeight() > usable_rect.GetHeight() && flags & LSI_SCALE_DOWN) || (img_size.GetHeight() < usable_rect.GetHeight() && flags & LSI_SCALE_UP); if (scale_width || scale_height) { // NOTE: Using BICUBIC instead of HIGH because it's the same internally // except that downscaling uses a box filter with awful obvious aliasing // for non-integral scale factors. image.Rescale(scale_width ? usable_rect.GetWidth() : img_size.GetWidth(), scale_height ? usable_rect.GetHeight() : img_size.GetHeight(), wxIMAGE_QUALITY_BICUBIC); } } else { // Scale while preserving the aspect ratio. double scale = std::min(static_cast<double>(usable_rect.GetWidth()) / img_size.GetWidth(), static_cast<double>(usable_rect.GetHeight()) / img_size.GetHeight()); int target_width = static_cast<int>(img_size.GetWidth() * scale); int target_height = static_cast<int>(img_size.GetHeight() * scale); // Bilinear produces sharper images when upscaling, bicubic tends to smear/blur sharp edges. if (scale > 1.0 && flags & LSI_SCALE_UP) image.Rescale(target_width, target_height, wxIMAGE_QUALITY_BILINEAR); else if (scale < 1.0 && flags & LSI_SCALE_DOWN) image.Rescale(target_width, target_height, wxIMAGE_QUALITY_BICUBIC); } img_size = image.GetSize(); } // Step 2: Resize the canvas to match the output size. // NOTE: If NOT using LSI_SCALE_DOWN then this will implicitly crop the image if (img_size != output_size || usable_rect.GetPosition() != wxPoint()) { wxPoint base = usable_rect.GetPosition(); if (flags & LSI_ALIGN_HCENTER) base.x += (usable_rect.GetWidth() - img_size.GetWidth()) / 2; else if (flags & LSI_ALIGN_RIGHT) base.x += usable_rect.GetWidth() - img_size.GetWidth(); if (flags & LSI_ALIGN_VCENTER) base.y += (usable_rect.GetHeight() - img_size.GetHeight()) / 2; else if (flags & LSI_ALIGN_BOTTOM) base.y += usable_rect.GetHeight() - img_size.GetHeight(); int r = -1, g = -1, b = -1; if (fill_color.Alpha() != wxALPHA_TRANSPARENT) { r = fill_color.Red(); g = fill_color.Green(); b = fill_color.Blue(); } image.Resize(output_size, base, r, g, b); } return image; }
void BaseEditor::DrawRectangle(wxDC& dc, const wxRect& rect) { DrawRectangle(dc, rect.GetPosition(), rect.GetSize()); }
NotePanel::NotePanel(wxWindow *parent, int numeroNote) { try { Create(parent, wxID_ANY, winRectGbl.GetPosition(), wxDefaultSize, wxBORDER_NONE); this->SetBackgroundColour(Couleurs::lightBackgColor); // Aux::logsThis("NotePanel::NotePanel", this, "put"); notePanel = this; numeroNote0 = numeroNote; parent0 = (TableOfNotes *)parent->GetGrandParent(); // Aux::logsThis("NotePanel::NotePanel::parent0", parent0, "put"); int gap16 = 16; int marge4 = 4; int marge8 = 8; wxSize dimText(parent->GetSize().x - 2*scrollW - 32, heightTexte); wxBoxSizer *verticalSizers = new wxBoxSizer(wxVERTICAL); wxBoxSizer *horizontalSizers0 = new wxBoxSizer(wxHORIZONTAL); selButton = new wxButton(this, ID_PhAssAuxNotePanelSelButton, "Sélectionner cette note", wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT); selButton->Enable(true); horizontalSizers0->Add(selButton, 0, wxALL, marge4); horizontalSizers0->AddSpacer(4*gap16); OKButton = new wxButton(this, ID_PhAssAuxNotePanelOKButton, "OK pour cette note", wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT); OKButton->Enable(false); horizontalSizers0->Add(OKButton, 0, wxALL, marge4); verticalSizers->Add(horizontalSizers0, 0); wxBoxSizer *horizontalSizers1 = new wxBoxSizer(wxHORIZONTAL); horizontalSizers1->AddSpacer(gap16); delButton = new wxButton(this, ID_PhAssAuxNotePanelDelButton, "Supprimer", wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT); delButton->Enable(false); horizontalSizers1->Add(delButton, 0, wxALL, marge4); horizontalSizers1->AddSpacer(gap16); editButton = new wxButton(this, ID_PhAssAuxNotePanelEditButton, "Editer", wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT); editButton->Enable(false); horizontalSizers1->Add(editButton, 0, wxALL, marge4); horizontalSizers1->AddSpacer(gap16); editOKButton = new wxButton(this, ID_PhAssAuxNotePanelEditOKButton, "Edition OK", wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT); editOKButton->Enable(false); horizontalSizers1->Add(editOKButton, 0, wxALL, marge4); horizontalSizers1->AddSpacer(gap16); zoneButton = new wxButton(this, ID_PhAssAuxNotePanelZoneButton, "Zone", wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT); zoneButton->Enable(false); horizontalSizers1->Add(zoneButton, 0, wxALL, marge4); horizontalSizers1->AddSpacer(gap16); zoneOKButton = new wxButton(this, ID_PhAssAuxNotePanelZoneOKButton, "Zone OK", wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT); zoneOKButton->Enable(false); horizontalSizers1->Add(zoneOKButton, 0, wxALL, marge4); verticalSizers->Add(horizontalSizers1, 0); wxBoxSizer *horizontalSizers2 = new wxBoxSizer(wxHORIZONTAL); horizontalSizers2->AddSpacer(marge8); noteText = new wxTextCtrl(this, ID_PhAssAuxNotePanelNoteText, wxEmptyString, wxDefaultPosition, dimText, wxTE_MULTILINE); noteText->Enable(false); horizontalSizers2->Add(noteText, 0, wxALL, marge8); horizontalSizers2->AddSpacer(marge8); verticalSizers->Add(horizontalSizers2, 0); // SetSizerAndFit(verticalSizers); SetSizer(verticalSizers); heightNotePanelZ = verticalSizers->GetSize().y; // this->SetSize(parent->GetSize().x-scrollW, heightNotePanelZ); this->SetSize(winRectGbl.GetSize()); this->Show(true); objNote0 = new ObjNote(); objNote0->setNumero(numeroNote); } catch (const exception &e) { Aux::logsStr("", e.what(), logPut); } }
AddPageToCarnet::AddPageToCarnet(wxWindow *parent, TableOfImagesPanelDyn *tableOfImagePanelDyn,/*vector<ObjMicroPhoto *> listeOfObjMicrosPhotos,*/ wxString topClass) { // Aux::logsStr("AddPageToCarnet::topClass", topClass, logPut); Create(parent, wxID_ANY, _("Attributs de terrain d'un groupe de photos"), winRectGbl.GetPosition(), winRectGbl.GetSize(), wxDEFAULT_FRAME_STYLE & ~(wxRESIZE_BORDER | wxMAXIMIZE_BOX | wxMINIMIZE_BOX | wxCLOSE_BOX), wxEmptyString); // Aux::logsThis(wxT("AddPageToCarnet"), this, logPut); // Aux::logsThis(wxT("AddPageToCarnet::parent"), parent, logPut); parent0 = parent; topClass0 = topClass; tableOfImagePanelDyn0 = tableOfImagePanelDyn; // Aux::logsNumber("AddPageToCarnet::size", (int)listeOfObjMicrosPhotos0.size(), logPut); // for (int ijk; ijk<listeOfObjMicrosPhotos0.size(); ijk++) { // Aux::logsStr("AddPageToCarnet::[" + to_string(ijk) + "]", listeOfObjMicrosPhotos0.at(ijk)->getNomPhoto(), logPut); // model->assocPhotoToCarnetPages(listeOfObjMicrosPhotos0.at(ijk), objPageOfCarnet); // Aux::logsThis("AddPageToCarnet::", listeOfObjMicrosPhotos0.at(ijk), logPut); // } panel0 = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL, wxEmptyString); panel0->SetBackgroundColour(Couleurs::backgColor); int curDelta = deltaGbl; EntetePanel *entetePanel = new EntetePanel(panel0, _("Entrer les attributs qui seront affectés à chacune des photos sélectionnées"), wxDefaultPosition, wxDefaultSize, Couleurs::planteColor); entetePanel->SetSize(winSizeX, entetePanel->GetSize().y); curDelta = entetePanel->GetSize().y; wxStaticText *paysLabel = new wxStaticText(panel0, wxID_ANY, _("Pays : "), wxPoint(X0, curDelta), wxSize(size0, heightGbl),wxALIGN_RIGHT); paysLabel->Show(true); paysNom = new wxTextCtrl(panel0, wxID_ANY, wxEmptyString, wxPoint(X1, curDelta), wxSize(size1,heightGbl)); paysNom->SetHint(_("Pays")); paysNom->SetValue(wxT("France")); paysNom->SetFocus(); paysNom->Show(true); curDelta = curDelta + heightGbl + deltaGbl; int XX0 = deltaGbl, sizeX0 = 96; int XX1 = XX0 + sizeX0 + deltaGbl, sizeX1 = 48; wxStaticText *cpLabel = new wxStaticText(panel0, wxID_ANY, _("Code postal : "), wxPoint(XX0, curDelta), wxSize(sizeX0, heightGbl),wxALIGN_RIGHT); cpLabel->Show(true); cpNom = new wxTextCtrl(panel0, wxID_ANY, wxEmptyString, wxPoint(XX1, curDelta), wxSize(sizeX1, heightGbl)); cpNom->SetHint(wxT("CP")); cpNom->SetValue(wxT("00000")); cpNom->SetFocus(); cpNom->Show(true); int XX2 = 172, sizeX2 = 96; int XX3 = XX2 + sizeX2 + deltaGbl, sizeX3 = 340; wxStaticText *communeLabel = new wxStaticText(panel0,wxID_ANY, _("Commune : "), wxPoint(XX2, curDelta), wxSize(sizeX2 ,heightGbl),wxALIGN_RIGHT); communeLabel->Show(true); communeNom = new wxTextCtrl(panel0, wxID_ANY, wxEmptyString, wxPoint(XX3, curDelta), wxSize(sizeX3,heightGbl)); communeNom->SetHint(_("Commune")); communeNom->SetValue(wxT("- nop -")); communeNom->SetFocus(); communeNom->Show(true); curDelta = curDelta + heightGbl + deltaGbl; wxStaticText *lieuDitLabel = new wxStaticText(panel0,wxID_ANY, _("Lieu-dit : "), wxPoint(X0, curDelta), wxSize(size0 ,heightGbl),wxALIGN_RIGHT); lieuDitLabel->Show(true); lieuDitNom = new wxTextCtrl(panel0, wxID_ANY, wxEmptyString, wxPoint(X1, curDelta), wxSize(size1,heightGbl)); lieuDitNom->SetHint(_("Lieu-dit")); lieuDitNom->SetValue(wxT("- nop -")); lieuDitNom->SetFocus(); lieuDitNom->Show(true); curDelta = curDelta + heightGbl + deltaGbl; wxStaticText *auteurNomLabel = new wxStaticText(panel0,wxID_ANY, _("Nom de l'auteur : "), wxPoint(X0, curDelta), wxSize(size0 ,3*heightGbl),wxALIGN_RIGHT); auteurNomLabel->Show(true); auteurNom = new wxTextCtrl(panel0, wxID_ANY, wxEmptyString, wxPoint(X1, curDelta), wxSize(size1,heightGbl) ); auteurNom->SetValue(wxT("Nadot")); auteurNom->Show(true); curDelta = curDelta + heightGbl + deltaGbl; wxStaticText *auteurPrenomLabel = new wxStaticText(panel0,wxID_ANY, _("Prénom de l'auteur : "), wxPoint(X0, curDelta), wxSize(size0 ,3*heightGbl),wxALIGN_RIGHT); auteurPrenomLabel->Show(true); auteurPrenom = new wxTextCtrl(panel0, wxID_ANY, wxEmptyString, wxPoint(X1, curDelta), wxSize(size1,heightGbl) ); auteurPrenom->SetValue(wxT("Sophie")); auteurPrenom->Show(true); curDelta = curDelta + heightGbl + deltaGbl; wxStaticText *commentLabel = new wxStaticText(panel0,wxID_ANY, _("Commentaire : "), wxPoint(X0, curDelta), wxSize(size0 ,3*heightGbl),wxALIGN_RIGHT); commentLabel->Show(true); commentNom = new wxTextCtrl(panel0, wxID_ANY, wxEmptyString, wxPoint(X1, curDelta), wxSize(size1,3*heightGbl), wxTE_MULTILINE); commentNom->SetValue(wxT("- nop -")); commentNom->Show(true); curDelta = curDelta + (maxFields-4)*(heightGbl + deltaGbl); cancelButton = new wxButton(panel0, ID_PhInitAuxCarnetPagesPhotosCancel, _("Annuler"), wxPoint(X2Button,curDelta), wxSize(sizeButton,heightGbl)); cancelButton->Enable(true); cancelButton->Show(); OKButton = new wxButton(panel0, ID_PhInitAuxCarnetPagesPhotosOK, _("Terminer"), wxPoint(X1Button,curDelta), wxSize(sizeButton,heightGbl)); OKButton->Enable(true); this->SetSize(winRectGbl.GetSize()); // panel0->Show(); this->Show(true); }