void clTabRendererClassic::FinaliseBackground(wxWindow* parent, wxDC& dc, const wxRect& clientRect,
                                              const clTabColours& colours, size_t style)
{
    wxUnusedVar(parent);
    clTabColours c = colours;
    if(DrawingUtils::IsDark(c.activeTabBgColour)) {
        InitDarkColours(c, c.activeTabBgColour);
    } else {
        InitLightColours(c, c.activeTabBgColour);
    }

    dc.SetPen(c.activeTabPenColour);
    if(style & kNotebook_BottomTabs) {
        dc.DrawLine(clientRect.GetTopLeft(), clientRect.GetTopRight());
    } else {
        dc.DrawLine(clientRect.GetBottomLeft(), clientRect.GetBottomRight());
    }
}
void wxGD::Draw::GlossyGradient( wxDC &dc, wxRect &rect, wxColour &topStart,
                                 wxColour &bottomStart,  wxColour &bottomEnd,
                                 wxColour &colour, bool hover )
{
    wxColour topEnd = colour;

    int r = colour.Red()   + 45;
    if( r > 255 ) r = 225;
    int g = colour.Green() + 45;
    if( g > 255 ) g = 225;
    int b = colour.Blue()  + 45;
    if( b > 255)  b = 225;

    topStart = wxColour( (unsigned char)r, (unsigned char)g, (unsigned char)b );

    r = colour.Red()   - 75;
    if( r < 0 ) r = 15;
    g = colour.Green() - 75;
    if( g < 0 ) g = 15;
    b = colour.Blue()  - 75;
    if( b < 0 ) b = 15;

    bottomStart = wxColour( (unsigned char)r, (unsigned char)g, (unsigned char)b );

    r = colour.Red()   - 15;
    if( r < 0 ) r = 30;
    g = colour.Green() - 15;
    if( g < 0 ) g = 30;
    b = colour.Blue()  - 15;
    if( b < 0 ) b = 30;

    bottomEnd =  wxColour( (unsigned char)r, (unsigned char)g, (unsigned char)b );

    rect.SetHeight( rect.GetHeight() / 2 );

    dc.GradientFillLinear( rect, topStart, topEnd, wxSOUTH );

    rect.Offset( 0, rect.GetHeight() );

    if( hover )
        dc.GradientFillLinear( rect, bottomStart, topStart, wxSOUTH );
    else
        dc.GradientFillLinear( rect, bottomStart, topEnd, wxSOUTH );
}
Exemple #3
0
void CViewHeader::OnSize(wxSizeEvent& event)
{
	const wxRect client_rect = GetClientRect();

	wxRect rect = client_rect;
	rect.SetWidth(rect.GetWidth() - m_cbOffset + 2);
	rect.SetX(m_cbOffset);
	rect.Deflate(0, border_offset / 2);
	rect.SetWidth(rect.GetWidth() - border_offset / 2);
	m_pComboBox->SetSize(rect);

	rect.SetX(5);
	rect.SetWidth(m_cbOffset - 5);
	rect.SetY((client_rect.GetHeight() - m_labelHeight) / 2 - 1);
	rect.SetHeight(m_labelHeight);
	m_pLabel->SetSize(rect);

	Refresh();
}
void MainGLCanvas::OnPaint(wxPaintEvent& WXUNUSED(event))
{
    // This is required even though dc is not used otherwise.
    wxPaintDC dc(this);

    // Set the OpenGL viewport according to the client size of this canvas.
    // This is done here rather than in a wxSizeEvent handler because our
    // OpenGL rendering context (and thus viewport setting) is used with
    // multiple canvases: If we updated the viewport in the wxSizeEvent
    // handler, changing the size of one canvas causes a viewport setting that
    // is wrong when next another canvas is repainted.
    const wxRect rect = GetRect();

    wxGetApp().GetContext(this).RedrawScene(rect.GetWidth(), rect.GetHeight());

    wxString viewport;
    viewport << _("(") << rect.GetWidth() << _(",") << rect.GetHeight() << _(")");
    wxLogStatus(viewport);
}
// Calculate the area that contains both rectangles
static wxRect CombineRectangles(const wxRect & rect1, const wxRect & rect2)
{
    wxRect rect;

    int right1 = rect1.GetRight();
    int bottom1 = rect1.GetBottom();
    int right2 = rect2.GetRight();
    int bottom2 = rect2.GetBottom();

    wxPoint topLeft = wxPoint(wxMin(rect1.x, rect2.x), wxMin(rect1.y, rect2.y));
    wxPoint bottomRight = wxPoint(wxMax(right1, right2), wxMax(bottom1, bottom2));

    rect.x = topLeft.x;
    rect.y = topLeft.y;
    rect.SetRight(bottomRight.x);
    rect.SetBottom(bottomRight.y);

    return rect;
}
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();
}
wxJigsawInputParameter::wxJigsawInputParameterHitTest wxJigsawInputParameter::HitTest(
	const wxPoint & pos, const wxRect & paramRect, bool bDebug)
{
	do
	{
		if(!paramRect.Contains(pos)) break;
		if(pos.x - paramRect.GetLeft() < m_LabelSize.GetWidth())
		{
			return wxJSP_HITETST_LABEL;
		}
		if(m_Shape)
		{
			return wxJSP_HITTEST_SHAPE;
		}
		return wxJSP_HITTEST_SLOT;
	}
	while(false);
	return wxJSP_HITTEST_NONE;
}
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();
}
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;
}
Exemple #10
0
    wxToolInfo(HWND hwndOwner, unsigned int id, const wxRect& rc)
    {
        // initialize all members
        ::ZeroMemory(this, sizeof(TOOLINFO));

        // the structure TOOLINFO has been extended with a 4 byte field in
        // version 4.70 of comctl32.dll and another one in 5.01 but we don't
        // use these extended fields so use the old struct size to ensure that
        // the tooltips work on old (Windows 95) systems too
        cbSize = TTTOOLINFO_V1_SIZE;

        hwnd = hwndOwner;

        if (rc.IsEmpty())
        {
            uFlags = TTF_IDISHWND;
            uId = (UINT_PTR)hwndOwner;
        }
        else
        {
            // this tooltip must be shown only if the mouse hovers a specific rect
            // of the hwnd parameter!
            rect.left = rc.GetLeft();
            rect.right = rc.GetRight();
            rect.top = rc.GetTop();
            rect.bottom = rc.GetBottom();

            // note that not setting TTF_IDISHWND from the uFlags member means that the
            // ti.uId field should not contain the HWND but rather as MSDN says an
            // "Application-defined identifier of the tool"; this is used internally by
            // Windows to distinguish the different tooltips attached to the same window
            uId = id;
        }

        // we use TTF_TRANSPARENT to fix a problem which arises at least with
        // the text controls but may presumably happen with other controls
        // which display the tooltip at mouse position: it can start flashing
        // then as the control gets "focus lost" events and dismisses the
        // tooltip which then reappears because mouse remains hovering over the
        // control, see SF patch 1821229
        uFlags |= TTF_TRANSPARENT;
    }
Exemple #11
0
bool SCH_JUNCTION::IsSelectStateChanged( const wxRect& aRect )
{
    bool previousState = IsSelected();

    if( aRect.Contains( m_pos ) )
        m_Flags |= SELECTED;
    else
        m_Flags &= ~SELECTED;

    return previousState != IsSelected();
}
Exemple #12
0
bool SCH_NO_CONNECT::IsSelectStateChanged( const wxRect& aRect )
{
    bool previousState = IsSelected();

    if( aRect.Contains( m_pos ) )
        SetFlags( SELECTED );
    else
        ClearFlags( SELECTED );

    return previousState != IsSelected();
}
Exemple #13
0
void wxTreeCompanionWindow::DrawItem(wxDC& dc, wxTreeItemId id, const wxRect& rect)
{
	// TEST CODE
#if 1
	if (m_treeCtrl)
	{
		wxString text = m_treeCtrl->GetItemText(id);
		dc.SetTextForeground(* wxBLACK);
		dc.SetBackgroundMode(wxTRANSPARENT);

		int textW, textH;
		dc.GetTextExtent(text, & textW, & textH);

		int x = 5;
		int y = rect.GetY() + wxMax(0, (rect.GetHeight() - textH) / 2);

		dc.DrawText(text, x, y);
	}
#endif
}
Exemple #14
0
bool SCH_TEXT::IsSelectStateChanged( const wxRect& aRect )
{
    bool previousState = IsSelected();

    if( aRect.Contains( GetTextPos() ) )
        SetFlags( SELECTED );
    else
        ClearFlags( SELECTED );

    return previousState != IsSelected();
}
Exemple #15
0
void DrawingUtils::PaintStraightGradientBox(wxDC& dc,
        const wxRect& rect,
        const wxColour& startColor,
        const wxColour& endColor,
        bool  vertical)
{
    int rd, gd, bd, high = 0;
    rd = endColor.Red() - startColor.Red();
    gd = endColor.Green() - startColor.Green();
    bd = endColor.Blue() - startColor.Blue();

    /// Save the current pen and brush
    wxPen savedPen = dc.GetPen();
    wxBrush savedBrush = dc.GetBrush();

    if ( vertical )
        high = rect.GetHeight()-1;
    else
        high = rect.GetWidth()-1;

    if ( high < 1 )
        return;

    for (int i = 0; i <= high; ++i) {
        int r = startColor.Red() +  ((i*rd*100)/high)/100;
        int g = startColor.Green() + ((i*gd*100)/high)/100;
        int b = startColor.Blue() + ((i*bd*100)/high)/100;

        wxPen p(wxColor(r, g, b));
        dc.SetPen(p);

        if ( vertical )
            dc.DrawLine(rect.x, rect.y+i, rect.x+rect.width, rect.y+i);
        else
            dc.DrawLine(rect.x+i, rect.y, rect.x+i, rect.y+rect.height);
    }

    /// Restore the pen and brush
    dc.SetPen( savedPen );
    dc.SetBrush( savedBrush );
}
Exemple #16
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.

    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;
}
void DefaultTabArt::DrawBackground(wxDC& dc,
                                        wxWindow* WXUNUSED(wnd),
                                        const wxRect& rect)
{
    // draw background
m_baseColour = wxColour(75,75,75);
    wxColor top_color       = m_baseColour.ChangeLightness(90);
    wxColor bottom_color   = m_baseColour.ChangeLightness(110);
    wxRect r;

   if (m_flags &wxAUI_NB_BOTTOM)
       r = wxRect(rect.x, rect.y, rect.width+2, rect.height);
   // TODO: else if (m_flags &wxAUI_NB_LEFT) {}
   // TODO: else if (m_flags &wxAUI_NB_RIGHT) {}
   else //for wxAUI_NB_TOP
       r = wxRect(rect.x, rect.y, rect.width+2, rect.height-3);

    dc.GradientFillLinear(r, top_color, bottom_color, wxSOUTH);


   // draw base lines
m_borderPen = top_color;
   dc.SetPen(m_borderPen);
   int y = rect.GetHeight();
   int w = rect.GetWidth();

   if (m_flags &wxAUI_NB_BOTTOM)
   {
       dc.SetBrush(wxBrush(bottom_color));
       dc.DrawRectangle(-1, 0, w+2, 4);
   }
   // TODO: else if (m_flags &wxAUI_NB_LEFT) {}
   // TODO: else if (m_flags &wxAUI_NB_RIGHT) {}
   else //for wxAUI_NB_TOP
   {
       dc.SetBrush(m_baseColourBrush);
       dc.SetBrush(m_baseColour);
       
       dc.DrawRectangle(-1, y-4, w+2, 4);
   }
}
Exemple #18
0
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));
}
void wxCustomStatusBarFieldText::Render(wxDC& dc, const wxRect& rect, wxCustomStatusBarArt::Ptr_t art)
{
    m_rect = rect;
    wxSize textSize = dc.GetTextExtent(m_text);

    // Center text
    wxCoord textY = (rect.GetHeight() - textSize.GetHeight()) / 2 + rect.y;
    wxCoord textX;
    if(m_textAlign == wxALIGN_CENTER) {
        textX = (rect.GetWidth() - textSize.GetWidth()) / 2 + rect.x;
    } else {
        // left
        textX = rect.x + 5;
    }

    // draw border line
    art->DrawFieldSeparator(dc, rect);

    // Draw the text
    art->DrawText(dc, textX, textY + 1, m_text);
}
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/\""));
        }
    }
}
Exemple #21
0
// ----------------------------------------------------------------------------
// DrawToDCClipped - play back the op list to the DC but clip any objects
//                   known to be not in rect.  This is a coarse level of 
//                   clipping to speed things up when lots of objects are off 
//                   screen and doesn't affect the dc level clipping
// ----------------------------------------------------------------------------
void wxPseudoDC::DrawToDCClipped(wxDC *dc, const wxRect& rect)
{
    pdcObjectList::Node *pt = m_objectlist.GetFirst();
    pdcObject *obj;
    while (pt) 
    {
        obj = pt->GetData();
        if (!obj->IsBounded() || rect.Intersects(obj->GetBounds()))
            obj->DrawToDC(dc);
        pt = pt->GetNext();
    }
}
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 clAuiMainNotebookTabArt::DrawBackground(wxDC& dc, wxWindow* wnd, const wxRect& rect)
{
    wxUnusedVar(wnd);
#ifdef __WXGTK__
    wxDC& gdc = dc;
#else
    wxGCDC gdc;
    if(!DrawingUtils::GetGCDC(dc, gdc)) return;
#endif

    DoSetColours();
    gdc.SetPen(m_activeTabPenColour);
    wxBrush brush = DrawingUtils::GetStippleBrush();
    brush.SetColour(m_bgColour);
    gdc.SetBrush(brush);
    gdc.GradientFillLinear(rect, m_bgColour, m_bgColour, wxSOUTH);

    wxPoint ptBottomLeft = rect.GetBottomLeft();
    wxPoint ptBottomRight = rect.GetBottomRight();
    gdc.DrawLine(ptBottomLeft, ptBottomRight);
}
Exemple #24
0
void Canvas::zoom_to( wxRect rect )
{
    wxSize window_size = wxWindow::GetClientSize();
    float ratio =
        std::max( float(rect.GetWidth()) / window_size.GetWidth(),
                    float(rect.GetHeight()) / window_size.GetHeight() );

    int zoom;
    if ( ratio < 1 ) {
        /* Zoom in. */
        zoom = round( 1 / ratio ) - 1;
    } else {
        /* Zoom out. */
        zoom = - round( ratio );
    }
    zoom = std::max( -16, std::min( zoom, 16 ) );

    wxPoint sumPoint = (rect.GetTopLeft() + rect.GetBottomRight());
    wxPoint centerPoint( sumPoint.x/2, sumPoint.y/2);
    set_zoom( zoom, centerPoint );
}
 virtual bool Render(wxRect cell, wxDC* dc, int state)
 {
     wxVariant v;
     GetValue(v);
     wxString str = v.GetString();
     str.Trim();
     wxPoint pt = cell.GetTopLeft();
     wxFont f = m_font;
     dc->SetFont(f);
     dc->DrawText(str, pt);
     return true;
 }
Exemple #26
0
        virtual void DrawItem(wxDC& dc, wxTreeItemId id, const wxRect& rect)
        {
	        if (m_treeCtrl)
	        {
                PETreeData *data = (PETreeData*)m_treeCtrl->GetItemData(id);
		        wxString text;
                if (data != NULL) text = data->EditCtrl->GetValueAsText(id);
                dc.SetBrush(wxBrush(GetBackgroundColour(), wxSOLID));
                dc.DrawRectangle(rect);
		        dc.SetTextForeground(* wxBLACK);
		        dc.SetBackgroundMode(wxTRANSPARENT);

		        int textW, textH;
		        dc.GetTextExtent(text, & textW, & textH);

		        int x = 5;
		        int y = rect.GetY() + wxMax(0, (rect.GetHeight() - textH) / 2);

		        dc.DrawText(text, x, y);
	        }
        }
// Returns the rectangle for this object (id = 0) or a child element (id > 0).
wxAccStatus CProjectListCtrlAccessible::GetLocation(wxRect& rect, int elementId)
{
    CProjectListCtrl* pCtrl = wxDynamicCast(GetWindow(), CProjectListCtrl);
    if (pCtrl && (0 == elementId))
    {
        // List control
        rect.SetPosition(pCtrl->GetScreenPosition());
        rect.SetWidth(pCtrl->GetSize().GetWidth());
        rect.SetHeight(pCtrl->GetSize().GetHeight());
        return wxACC_OK;
    }
    else if (pCtrl && (0 != elementId))
    {
        // List item
        wxSize cCtrlSize = pCtrl->GetClientSize();

        // Set the initial control postition to the absolute coords of the upper
        //   left hand position of the control
        rect.SetPosition(pCtrl->GetScreenPosition());
        rect.width = cCtrlSize.GetWidth() - 1;
        rect.height = pCtrl->GetItemHeight(elementId - 1) - 1;

        // Items can have different heights
        int    firstVisibleItem = (int)pCtrl->GetFirstVisibleLine();
        int    yOffset = 0;
        for (int i=firstVisibleItem; i<(elementId - 1); ++i) {
            yOffset += pCtrl->GetItemHeight((size_t)i);
        }
        rect.SetTop(rect.GetTop() + yOffset);
        rect.height -= 1;
        return wxACC_OK;
    }
    // Let the framework handle the other cases.
    return wxACC_FALSE;
}
Exemple #28
0
BOOL FontDropDown::DrawIcon(void * ItemData, wxDC& dc, wxRect& IconRect, BOOL Disabled, INT32 flags)
{
	ResourceID BitmapID = 0;
	FontClass Type;

	if ((ItemData==&TheTopItem) || !ItemData)
		Type = TheTopItem.Type;
	else
		Type = ((FontDropItem *)ItemData)->Type;

	switch(Type)
	{
		case FC_TRUETYPE:
			BitmapID = _R(IDB_TTF_SYMBOL);
			break;

		case FC_ATM:
			BitmapID = _R(IDB_ATM_SYMBOL);
			break;

		case FC_UNDEFINED:
			BitmapID = _R(IDB_UNKNOWNFONT_SYMBOL);
			break;

		default:
			BitmapID = 0;
			break;
	}

	if(BitmapID == 0)
		return FALSE;

	wxBitmap * pBitmap = CamArtProvider::Get()->FindBitmap(BitmapID, (CamArtFlags)(CAF_DEFAULT|(Disabled?CAF_GREYED:0)));
	if (!pBitmap)
		return FALSE;

	dc.DrawBitmap(*pBitmap, IconRect.GetLeft(), IconRect.GetTop(), TRUE);

	return TRUE;
}
bool wxCheckListBoxItem::OnDrawItem(wxDC& dc, const wxRect& rc,
                                    wxODAction act, wxODStatus stat)
{
    // first draw the label
    if ( !wxOwnerDrawn::OnDrawItem(dc, rc, act, stat) )
        return false;

    // now draw the check mark part
    wxMSWDCImpl *impl = (wxMSWDCImpl*) dc.GetImpl();
    HDC hdc = GetHdcOf(*impl);

    wxSize size = wxRendererNative::Get().GetCheckBoxSize(GetParent());

    // first create bitmap in a memory DC
    MemoryHDC hdcMem(hdc);
    CompatibleBitmap hBmpCheck(hdc, size.GetWidth(), size.GetHeight());

    // then draw a check mark into it
    {
        SelectInHDC selBmp(hdcMem, hBmpCheck);

        int flags = wxCONTROL_FLAT;
        if ( IsChecked() )
            flags |= wxCONTROL_CHECKED;

        wxDCTemp dcMem(hdcMem);
        wxRendererNative::Get().DrawCheckBox(GetParent(), dcMem, wxRect(size), flags);
    } // select hBmpCheck out of hdcMem

    // finally draw bitmap to screen

    // position of check mark bitmap
    int x = rc.GetX() + CHECKMARK_EXTRA_SPACE;
    int y = rc.GetY() + (rc.GetHeight() - size.GetHeight()) / 2;

    UINT uState = stat & wxOwnerDrawn::wxODSelected ? wxDSB_SELECTED : wxDSB_NORMAL;
    wxDrawStateBitmap(hdc, hBmpCheck, x, y, uState);

    return true;
}
Exemple #30
0
void CPathItem::DrawFore(wxDC &dc, wxRect &rc)
{
	dc.SetTextForeground(*wxBLACK);

	wxString csName(_T("mixer"));
	if(NULL != m_pInput)
	{
		const char *nname = m_pInput->GetName();
		const char *dname = m_pInput->GetDisplayName();
		csName = (wxChar*)(strlen(nname) > strlen(dname) ? dname : nname);
	}

	int width = rc.GetWidth();
	if(!m_bFirst)
		width -= CORNER_LENGTH;

	wxFont oldFont = dc.GetFont();
	wxFont font(7, wxSWISS, wxNORMAL, wxNORMAL);
	font.SetWeight(IsSelected() ? wxBOLD : wxNORMAL);
	font.SetStyle(IsSelected() ? wxITALIC : wxNORMAL );
	font.SetPointSize( 7 );
	dc.SetFont( font );

	int w=0, h=0;
	dc.GetTextExtent(csName, &w, &h);
	if(h<rc.GetHeight())
	{
		if(w>width)
		{
			csName.Printf(_T("%c"),csName[0]);
			dc.GetTextExtent(csName, &w, &h);
		}
		int x = rc.GetX() + width/2 - w/2 + (m_bFirst ? 0 : CORNER_LENGTH);
		int y = rc.GetY() + rc.GetHeight()/2 - h/2;
		dc.DrawText( csName, x, y );
	}

	dc.SetFont( oldFont );
}