当前位置: 首页>>代码示例>>C++>>正文


C++ wxPen函数代码示例

本文整理汇总了C++中wxPen函数的典型用法代码示例。如果您正苦于以下问题:C++ wxPen函数的具体用法?C++ wxPen怎么用?C++ wxPen使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了wxPen函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: _

/**
 * Render the event in the bitmap
 */
void GroupEvent::Render(wxDC & dc, int x, int y, unsigned int width, gd::EventsEditorItemsAreas & areas, gd::EventsEditorSelection & selection, const gd::Platform & platform)
{
#if !defined(GD_NO_WX_GUI)
    wxString groupTitle = name.empty() ? _("Untitled group") : wxString(name);
    wxColour backgroundColor = wxColour(colorR, colorG, colorB);
    wxColour textColor = colorR + colorG + colorB > 200*3 ? *wxBLACK : *wxWHITE;
    if (IsDisabled())
    {
        backgroundColor.MakeDisabled();
        textColor = wxColour(160, 160, 160);
    }

    dc.SetBrush(wxBrush(backgroundColor));
    dc.SetPen(wxPen(backgroundColor.ChangeLightness(70)));
    wxRect rect(x+1, y, width-2, GetRenderedHeight(width, platform)-2);
    dc.DrawRectangle(rect);

    dc.SetTextBackground(backgroundColor);
    dc.SetTextForeground(textColor);
    dc.SetFont( wxFont( 12, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD ) );
    dc.DrawText( groupTitle, x+5, y + 5 );
#endif
}
开发者ID:alcemirfernandes,项目名称:GD,代码行数:26,代码来源:GroupEvent.cpp

示例2: DigitX

void kwxLCDDisplay::DrawTwoDots( wxDC *dc, int digit )
{
	int sl = mSegmentLen;
	int sw = mSegmentWidth;
//	int sp = mSpace;

	int x = DigitX( digit );
	int y = DigitY( digit );

	wxBrush brushOn( mLightColour, wxSOLID );

	x += ( sl / 2 ) - sw;
	y += ( sl / 2 ) - sw;

	dc->SetBrush( brushOn );
	dc->SetPen( wxPen( GetBackgroundColour(), 1, wxSOLID ) );

	dc->DrawEllipse( x, y, 2 * sw, 2 * sw );

	y += sl;

	dc->DrawEllipse( x, y, 2 * sw, 2 * sw );
}
开发者ID:BlueAndi,项目名称:vscp_software,代码行数:23,代码来源:LCDWindow.cpp

示例3: DrawHighlightedShapes

void ConditionalHistogramCanvas::DrawHighlightedShapes(wxMemoryDC &dc)
{
	dc.SetPen(wxPen(highlight_color));
	dc.SetBrush(wxBrush(highlight_color, wxBRUSHSTYLE_CROSSDIAG_HATCH));
	int t = var_info[HIST_VAR].time;
	int i=0;
	double s;
	for (int r=0; r<vert_num_cats; r++) {
		for (int c=0; c<horiz_num_cats; c++) {
			for (int ival=0; ival<cur_intervals; ival++) {
				if (cell_data[t][r][c].ival_obs_sel_cnt[ival] != 0) {
					s = (((double) cell_data[t][r][c].ival_obs_sel_cnt[ival]) /
						 ((double) cell_data[t][r][c].ival_obs_cnt[ival]));
					GdaRectangle* rec = (GdaRectangle*) selectable_shps[i];
					dc.DrawRectangle(rec->lower_left.x, rec->lower_left.y,
									 rec->upper_right.x - rec->lower_left.x,
									 (rec->upper_right.y-rec->lower_left.y)*s);
				}
				i++;
			}
		}
	}
}
开发者ID:GeoDaCenter,项目名称:geoda,代码行数:23,代码来源:ConditionalHistogramView.cpp

示例4: WXUNUSED

void SAuiTabArt::DrawBackground(wxDC& dc,
	wxWindow* WXUNUSED(wnd),
	const wxRect& rect)
{
	// draw background
	wxColor top_color = (m_mainTabs && Global::win_version_major >= 10) ? col_w10_bg : m_baseColour;
	wxColor bottom_color = (m_mainTabs && Global::win_version_major >= 10) ? col_w10_bg : m_baseColour;
	wxRect r;

	if (m_flags &wxAUI_NB_BOTTOM)
		r = wxRect(rect.x, rect.y, rect.width + 2, rect.height);
	else
		r = wxRect(rect.x, rect.y, rect.width + 2, rect.height);

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

	// draw base lines
	dc.SetPen(wxPen(m_baseColour));
	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);
	}
	else
	{
		//dc.SetPen(*wxTRANSPARENT_PEN);
		//dc.SetBrush(wxBrush(m_activeColour));
		//dc.SetBrush(wxBrush(wxColor(224, 238, 255)));
		//dc.DrawRectangle(-1, y - 4, w + 2, 4);

		dc.SetPen(m_borderPen);
		dc.DrawLine(-2, y - 1, w + 2, y - 1);
	}
}
开发者ID:SanyaWaffles,项目名称:SLADE,代码行数:37,代码来源:SAuiTabArt.cpp

示例5: dc

void TileSelector::OnPaint(wxPaintEvent &event) {
	wxPaintDC dc(this);

	if(tiles == 0 || tiles_per_line == 0)
		return;

	wxBitmap tile;
	wxRect rect;

	wxPoint p;

	for(int i = 0; i < tiles_max; i++) {
		rect.x = i * TILE_W;
		rect.y = 0;
		rect.width = TILE_W;
		rect.height = TILE_H;

		p.x = BORDER + (i % tiles_per_line) * (TILE_W + (TILE_SPACING * 2));
		p.y = BORDER + (i / tiles_per_line) * (TILE_H + (TILE_SPACING * 2));

		if(selected == i) {
			wxSize size;
			size.x = TILE_W + (TILE_SPACING * 2);
			size.y = TILE_H + (TILE_SPACING * 2);
			dc.SetPen(wxPen(wxColor(0x88, 0x88, 0xff), 2));
			dc.SetBrush(*wxTRANSPARENT_BRUSH);
			dc.DrawRectangle(p, size);
		}

		p.x += TILE_SPACING;
		p.y += TILE_SPACING;

		tile = tiles->GetSubBitmap(rect);
		dc.DrawBitmap(tile, p, true);
	}
}
开发者ID:DemonTPx,项目名称:smashbattle-leveleditor,代码行数:36,代码来源:TileSelector.cpp

示例6: wxWindow

SjOscWindow::SjOscWindow(SjOscModule* oscModule, wxWindow* parent)
	: wxWindow( parent, -1, /*oscModule->m_name,*/
	            wxPoint(-1000,-1000), wxSize(100,100),
	            (wxNO_BORDER /*| wxFRAME_NO_TASKBAR | wxFRAME_FLOAT_ON_PARENT*/) ),
	m_offscreenBitmap(16,16)
{
	m_oscModule = oscModule;

	// get the number of samples wanted
	// (currently we exactly 576 for the spcectrum analyzer)
	m_sampleCount = SjMs2Bytes(SLEEP_MS) / (SJ_WW_CH*SJ_WW_BYTERES);
	if( m_sampleCount < 576*2 )
	{
		m_sampleCount = 576*2;
	}

	m_bufferStart = (unsigned char*)malloc(m_sampleCount*SJ_WW_CH*SJ_WW_BYTERES);

	// set colors
	m_textColour = wxColour(0x2F, 0x60, 0xA3);
	m_fgColour = wxColour(0x3D, 0x80, 0xDF);
	m_fgPen = wxPen(m_fgColour, 1, wxSOLID);

	// create the drawing objects
	m_spectrum = new SjOscSpectrum(m_sampleCount);
	m_oscilloscope = new SjOscOscilloscope(m_sampleCount);
	m_title = new SjOscTitle();
	m_rotor = new SjOscRotor();
	m_hands = new SjOscHands();
	m_firework = new SjOscFirework();
	m_starfield = new SjOscStarfield();

	// finally, start the timer
	m_timer.SetOwner(this, IDC_TIMER);
	m_timer.Start(SLEEP_MS);
}
开发者ID:antonivich,项目名称:Silverjuke,代码行数:36,代码来源:vis_oscilloscope.cpp

示例7: dc

/* SToolBar::onPaint
 * Called when the toolbar needs to be drawn
 *******************************************************************/
void SToolBar::onPaint(wxPaintEvent& e)
{
	wxPaintDC dc(this);

	// Get system colours needed
	wxColour col_background = Drawing::getPanelBGColour();
	wxColour col_light = Drawing::lightColour(col_background, 1.5f);
	wxColour col_dark = Drawing::darkColour(col_background, 1.5f);
	
	// Draw background
	dc.SetBackground(wxBrush(col_background));
	dc.Clear();

	if (draw_border)
	{
		// Draw top
		//dc.SetPen(wxPen(col_dark));// col_light));
		//dc.DrawLine(wxPoint(0, 0), wxPoint(GetSize().x+1, 0));

		// Draw bottom
		dc.SetPen(wxPen(col_dark));
		dc.DrawLine(wxPoint(0, GetSize().y-1), wxPoint(GetSize().x+1, GetSize().y-1));
	}
}
开发者ID:jonrimmer,项目名称:SLADE,代码行数:27,代码来源:SToolBar.cpp

示例8: defined

// Initialize colours
void wxStatusBarGeneric::InitColours()
{
    // Shadow colours
#if defined(__WIN95__) || defined(__WXMAC__)
    wxColour mediumShadowColour(wxSystemSettings::GetColour(wxSYS_COLOUR_3DSHADOW));
    m_mediumShadowPen = wxPen(mediumShadowColour, 1, wxSOLID);

    wxColour hilightColour(wxSystemSettings::GetColour(wxSYS_COLOUR_3DHILIGHT));
    m_hilightPen = wxPen(hilightColour, 1, wxSOLID);
#elif defined(__WXPM__)
    m_mediumShadowPen = wxPen(wxColour(127, 127, 127), 1, wxSOLID);
    m_hilightPen = wxPen(_T("WHITE"), 1, wxSOLID);

    wxColour                        vColour;

    vColour.Set(wxString(_T("LIGHT GREY")));
    SetBackgroundColour(vColour);
    vColour.Set(wxString(_T("BLACK")));
    SetForegroundColour(vColour);
#else
    m_mediumShadowPen = wxPen("GREY", 1, wxSOLID);
    m_hilightPen = wxPen("WHITE", 1, wxSOLID);
#endif
}
开发者ID:gitrider,项目名称:wxsj2,代码行数:25,代码来源:statusbr.cpp

示例9: wxBrush

void wxAuiSimpleTabArt::SetActiveColour(const wxColour& colour)
{
    m_selectedBkBrush = wxBrush(colour);
    m_selectedBkPen = wxPen(colour);
}
开发者ID:futurepr0n,项目名称:wxWidgets,代码行数:5,代码来源:tabart.cpp

示例10: wxT


//.........这里部分代码省略.........

    wxPoint border_points[6];
    if (m_flags &wxAUI_NB_BOTTOM)
    {
        border_points[0] = wxPoint(tab_x,             tab_y);
        border_points[1] = wxPoint(tab_x,             tab_y+tab_height-6);
        border_points[2] = wxPoint(tab_x+2,           tab_y+tab_height-4);
        border_points[3] = wxPoint(tab_x+tab_width-2, tab_y+tab_height-4);
        border_points[4] = wxPoint(tab_x+tab_width,   tab_y+tab_height-6);
        border_points[5] = wxPoint(tab_x+tab_width,   tab_y);
    }
    else //if (m_flags & wxAUI_NB_TOP) {}
    {
        border_points[0] = wxPoint(tab_x,             tab_y+tab_height-4);
        border_points[1] = wxPoint(tab_x,             tab_y+2);
        border_points[2] = wxPoint(tab_x+2,           tab_y);
        border_points[3] = wxPoint(tab_x+tab_width-2, tab_y);
        border_points[4] = wxPoint(tab_x+tab_width,   tab_y+2);
        border_points[5] = wxPoint(tab_x+tab_width,   tab_y+tab_height-4);
    }
    // TODO: else if (m_flags &wxAUI_NB_LEFT) {}
    // TODO: else if (m_flags &wxAUI_NB_RIGHT) {}

    int drawn_tab_yoff = border_points[1].y;
    int drawn_tab_height = border_points[0].y - border_points[1].y;


    if (page.active)
    {
        // draw active tab

        // draw base background color
        wxRect r(tab_x, tab_y, tab_width, tab_height);
        dc.SetPen(wxPen(m_activeColour));
        dc.SetBrush(wxBrush(m_activeColour));
        dc.DrawRectangle(r.x+1, r.y+1, r.width-1, r.height-4);

        // this white helps fill out the gradient at the top of the tab
        dc.SetPen(*wxWHITE_PEN);
        dc.SetBrush(*wxWHITE_BRUSH);
        dc.DrawRectangle(r.x+2, r.y+1, r.width-3, r.height-4);

        // these two points help the rounded corners appear more antialiased
        dc.SetPen(wxPen(m_activeColour));
        dc.DrawPoint(r.x+2, r.y+1);
        dc.DrawPoint(r.x+r.width-2, r.y+1);

        // set rectangle down a bit for gradient drawing
        r.SetHeight(r.GetHeight()/2);
        r.x += 2;
        r.width -= 3;
        r.y += r.height;
        r.y -= 2;

        // draw gradient background
        wxColor top_color = *wxWHITE;
        wxColor bottom_color = m_activeColour;
        dc.GradientFillLinear(r, bottom_color, top_color, wxNORTH);
    }
    else
    {
        // draw inactive tab

        wxRect r(tab_x, tab_y+1, tab_width, tab_height-3);

        // start the gradent up a bit and leave the inside border inset
开发者ID:futurepr0n,项目名称:wxWidgets,代码行数:67,代码来源:tabart.cpp

示例11: GetCanvasPixLL

bool IACSystem::Draw(wxDC *dc, PlugIn_ViewPort *vp, TexFont &numfont, TexFont &sysfont) {
    bool hasDrawn = false;
    if (dc) {
        if (m_positions.GetCount() == 1) {
            GeoPoint &Pos = m_positions[0];
            if (PointInLLBox(vp, Pos.x, Pos.y)) {
                wxPoint p;
                GetCanvasPixLL(vp, &p, Pos.y, Pos.x);
                wxColour colour;
                wxString msg1 = GetShortType(m_type);
                if (!msg1.IsEmpty()) {
                    hasDrawn = true;
                    GetGlobalColor(_T ( "UBLCK" ), &colour);
                    dc->SetTextForeground(colour);
                    wxFont sfont = dc->GetFont();

                    wxFont *font1 = wxTheFontList->FindOrCreateFont(SYSTEMS_FONT_SIZE, wxFONTFAMILY_ROMAN, wxNORMAL,
                                                                    wxFONTWEIGHT_BOLD, FALSE, wxString(_T ( "Arial" )));
                    dc->SetFont(*font1);
                    wxSize s1 = dc->GetTextExtent(msg1);
                    dc->DrawText(msg1, p.x - (s1.GetWidth() / 2), p.y - (s1.GetHeight() / 2));
                    wxFont *font2 = wxTheFontList->FindOrCreateFont(NUMBERS_FONT_SIZE, wxFONTFAMILY_SWISS, wxITALIC,
                                                                    wxFONTWEIGHT_NORMAL, FALSE, wxString(_T ( "Arial" )));
                    dc->SetFont(*font2);
                    wxString msg2 = GetValue();
                    if (!msg2.IsEmpty()) {
                        wxSize s2 = dc->GetTextExtent(msg2);
                        dc->DrawText(msg2, p.x - (s2.GetWidth() / 2), p.y + (s1.GetHeight() / 2) + (s2.GetHeight() / 2));

                        dc->SetFont(sfont);
                    }
                }
            }
        } else {
            wxColour colour;
            wxPen pen;
            pen = dc->GetPen();
            GetGlobalColor(_T ( "GREEN2" ), &colour);
            dc->SetPen(wxPen(colour, m_isoLineWidth));
            DrawPositions(dc, vp);
            dc->SetPen(pen);
        }
    } else {
        if (m_positions.GetCount() == 1) {
            GeoPoint &Pos = m_positions[0];
            if (PointInLLBox(vp, Pos.x, Pos.y)) {
                wxPoint p;
                GetCanvasPixLL(vp, &p, Pos.y, Pos.x);
                wxColour colour;
                wxString msg1 = GetShortType(m_type);
                if (!msg1.IsEmpty()) {
                    hasDrawn = true;
                    glEnable(GL_BLEND);
                    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

                    wxPoint p;
                    GetCanvasPixLL(vp, &p, Pos.y, Pos.x);
                    int w, h;
                    sysfont.GetTextExtent(msg1, &w, &h);

                    int xd = p.x - (w / 2);
                    int yd = p.y - (h / 2);

                    GetGlobalColor(_T ( "UBLCK" ), &colour);
                    glColor3ub(colour.Red(), colour.Green(), colour.Blue());

                    glEnable(GL_TEXTURE_2D);
                    sysfont.RenderString(msg1, xd, yd);
                    wxString msg2 = GetValue();
                    if (!msg2.IsEmpty()) {
                        int w1, h1;
                        numfont.GetTextExtent(msg2, &w1, &h1);
                        numfont.RenderString(msg2, p.x - (w1 / 2), p.y + (h / 2) + (h1 / 2));
                    }
                    glDisable(GL_TEXTURE_2D);
                    glDisable(GL_BLEND);
                }
            }
        } else {
            wxColour colour = m_isoLineColor;
            GetGlobalColor(_T ( "GREEN2" ), &m_isoLineColor);
            DrawPositions(dc, vp);
            m_isoLineColor = colour;
        }
    }
    return hasDrawn;
}
开发者ID:rgleason,项目名称:iacfleet_pi,代码行数:87,代码来源:iacfile.cpp

示例12: dc

void FreqWindow::PlotPaint(wxPaintEvent & evt)
{
   wxPaintDC dc( (wxWindow *) evt.GetEventObject() );

   dc.DrawBitmap( *mBitmap, 0, 0, true );
   if( mProcessed == NULL )
      return;

   int alg = mAlgChoice->GetSelection();

   dc.SetFont(mFreqFont);

   wxRect r = mPlotRect;

   int width = r.width - 2;

   float xMin, xMax, xPos, xRatio, xLast, xStep;

   if (alg == 0) {
      xMin = mRate / mWindowSize;
      xMax = mRate / 2;
      xRatio = xMax / xMin;
      xPos = xMin;
      xLast = xPos / 2.0;
      if (mLogAxis)
         xStep = pow(2.0f, (log(xRatio) / log(2.0f)) / width);
      else
         xStep = (xMax - xMin) / width;
   } else {
      xMin = 0;
      xMax = mProcessedSize / mRate;
      xPos = xMin;
      xLast = xPos / 2.0;
      xStep = (xMax - xMin) / width;
   }

   // Find the peak nearest the cursor and plot it

   float bestpeak = float(0.0);
   if ( r.Contains(mMouseX, mMouseY) & (mMouseX!=0) & (mMouseX!=r.width-1) ) {
      if (mLogAxis)
         xPos = xMin * pow(xStep, mMouseX - (r.x + 1));
      else
         xPos = xMin + xStep * (mMouseX - (r.x + 1));

      bool up = (mProcessed[1] > mProcessed[0]);
      float bestdist = 1000000;
      float bestValue = 0.0;
      for (int bin = 2; bin < mProcessedSize; bin++) {
         bool nowUp = mProcessed[bin] > mProcessed[bin - 1];
         if (!nowUp && up) {
            // Local maximum.  Find actual value by cubic interpolation
            int leftbin = bin - 2;
            if (leftbin < 1)
               leftbin = 1;
            float valueAtMax = 0.0;
            float max = leftbin + CubicMaximize(mProcessed[leftbin],
                                                mProcessed[leftbin + 1],
                                                mProcessed[leftbin + 2],
                                                mProcessed[leftbin + 3], &valueAtMax);

            float thispeak;
            if (alg == 0)
               thispeak = max * mRate / mWindowSize;
            else
               thispeak = max / mRate;

            if (fabs(thispeak - xPos) < bestdist) {
               bestpeak = thispeak;
               bestdist = fabs(thispeak - xPos);
               bestValue = valueAtMax;
               if (thispeak > xPos)
                  break;
            }
         }
         up = nowUp;
      }

      int px;
      if (mLogAxis)
         px = int (log(bestpeak / xMin) / log(xStep));
      else
         px = int ((bestpeak - xMin) * width / (xMax - xMin));

      dc.SetPen(wxPen(wxColour(160,160,160), 1, wxSOLID));
      AColor::Line(dc, r.x + 1 + px, r.y, r.x + 1 + px, r.y + r.height);

       // print out info about the cursor location

      float value;

      if (mLogAxis) {
         xPos = xMin * pow(xStep, mMouseX - (r.x + 1));
         value = GetProcessedValue(xPos, xPos * xStep);
      } else {
         xPos = xMin + xStep * (mMouseX - (r.x + 1));
         value = GetProcessedValue(xPos, xPos + xStep);
      }

      wxString info;
//.........这里部分代码省略.........
开发者ID:ruthmagnus,项目名称:audacity,代码行数:101,代码来源:FreqWindow.cpp

示例13: WXUNUSED

void wxSymbolListCtrl::OnPaint(wxPaintEvent& WXUNUSED(event))
{
    // If size is larger, recalculate double buffer bitmap
    wxSize clientSize = GetClientSize();

    if ( !m_doubleBuffer ||
         clientSize.x > m_doubleBuffer->GetWidth() ||
         clientSize.y > m_doubleBuffer->GetHeight() )
    {
        delete m_doubleBuffer;
        m_doubleBuffer = new wxBitmap(clientSize.x+25,clientSize.y+25);
    }

    wxBufferedPaintDC dc(this,*m_doubleBuffer);

    // the update rectangle
    wxRect rectUpdate = GetUpdateClientRect();

    // fill it with background colour
    dc.SetBackground(GetBackgroundColour());
    dc.Clear();

    // set the font to be displayed
    dc.SetFont(GetFont());

    // the bounding rectangle of the current line
    wxRect rectRow;
    rectRow.width = clientSize.x;

    dc.SetPen(wxPen(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT)));
    dc.SetTextForeground(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT));
    dc.SetBackgroundMode(wxBRUSHSTYLE_TRANSPARENT);

    // iterate over all visible lines
    const size_t lineMax = GetVisibleEnd();
    for ( size_t line = GetVisibleBegin(); line < lineMax; line++ )
    {
        const wxCoord hRow = OnGetRowHeight(line);

        rectRow.height = hRow;

        // and draw the ones which intersect the update rect
        if ( rectRow.Intersects(rectUpdate) )
        {
            // don't allow drawing outside of the lines rectangle
            wxDCClipper clip(dc, rectRow);

            wxRect rect = rectRow;
            rect.Deflate(m_ptMargins.x, m_ptMargins.y);
            OnDrawItem(dc, rect, line);
        }
        else // no intersection
        {
            if ( rectRow.GetTop() > rectUpdate.GetBottom() )
            {
                // we are already below the update rect, no need to continue
                // further
                break;
            }
            //else: the next line may intersect the update rect
        }

        rectRow.y += hRow;
    }
}
开发者ID:Kaoswerk,项目名称:newton-dynamics,代码行数:65,代码来源:richtextsymboldlg.cpp

示例14: wxRect

void CLMainAuiTBArt::DrawDropDownButton(wxDC& dc, wxWindow* wnd, const wxAuiToolBarItem& item, const wxRect& rect)
{
    wxAuiDefaultToolBarArt::DrawDropDownButton(dc, wnd, item, rect);
#if 0
    // Dark theme
    int textWidth = 0, textHeight = 0, textX = 0, textY = 0;
    int bmpX = 0, bmpY = 0, dropBmpX = 0, dropBmpY = 0;

    wxRect buttonRect = wxRect(rect.x, rect.y, rect.width - BUTTON_DROPDOWN_WIDTH, rect.height);
    wxRect dropDownRect =
        wxRect(rect.x + rect.width - BUTTON_DROPDOWN_WIDTH - 1, rect.y, BUTTON_DROPDOWN_WIDTH + 1, rect.height);

    if(m_flags & wxAUI_TB_TEXT) {
        dc.SetFont(m_font);

        int tx, ty;
        if(m_flags & wxAUI_TB_TEXT) {
            dc.GetTextExtent(wxT("ABCDHgj"), &tx, &textHeight);
            textWidth = 0;
        }

        dc.GetTextExtent(item.GetLabel(), &textWidth, &ty);
    }

    dropBmpX = dropDownRect.x + (dropDownRect.width / 2) - (m_buttonDropDownBmp.GetWidth() / 2);
    dropBmpY = dropDownRect.y + (dropDownRect.height / 2) - (m_buttonDropDownBmp.GetHeight() / 2);

    if(m_textOrientation == wxAUI_TBTOOL_TEXT_BOTTOM) {
        bmpX = buttonRect.x + (buttonRect.width / 2) - (item.GetBitmap().GetWidth() / 2);
        bmpY = buttonRect.y + ((buttonRect.height - textHeight) / 2) - (item.GetBitmap().GetHeight() / 2);

        textX = rect.x + (rect.width / 2) - (textWidth / 2) + 1;
        textY = rect.y + rect.height - textHeight - 1;
    } else if(m_textOrientation == wxAUI_TBTOOL_TEXT_RIGHT) {
        bmpX = rect.x + 3;

        bmpY = rect.y + (rect.height / 2) - (item.GetBitmap().GetHeight() / 2);

        textX = bmpX + 3 + item.GetBitmap().GetWidth();
        textY = rect.y + (rect.height / 2) - (textHeight / 2);
    }

    if(item.GetState() & wxAUI_BUTTON_STATE_PRESSED) {
        dc.SetPen(wxPen(m_highlightColour));
        dc.SetBrush(wxBrush(m_highlightColour.ChangeLightness(140)));
        dc.DrawRectangle(buttonRect);

        dc.SetBrush(wxBrush(m_highlightColour.ChangeLightness(170)));
        dc.DrawRectangle(dropDownRect);
    } else if(item.GetState() & wxAUI_BUTTON_STATE_HOVER || item.IsSticky()) {
        dc.SetPen(wxPen(m_highlightColour));
        dc.SetBrush(wxBrush(m_highlightColour.ChangeLightness(170)));
        dc.DrawRectangle(buttonRect);
        dc.DrawRectangle(dropDownRect);
    } else if(item.GetState() & wxAUI_BUTTON_STATE_CHECKED) {
        // Notice that this branch must come after the hover one to ensure the
        // correct appearance when the mouse hovers over a checked item.m_
        dc.SetPen(wxPen(m_highlightColour));
        dc.SetBrush(wxBrush(m_highlightColour.ChangeLightness(170)));
        dc.DrawRectangle(buttonRect);
        dc.DrawRectangle(dropDownRect);
    }

    wxBitmap bmp;
    wxBitmap dropbmp;
    if(item.GetState() & wxAUI_BUTTON_STATE_DISABLED) {
        bmp = CreateDisabledBitmap(item.GetBitmap());
        dropbmp = m_disabledButtonDropDownBmp;
    } else {
        bmp = item.GetBitmap();
        dropbmp = m_buttonDropDownBmp;
    }

    if(!bmp.IsOk()) return;

    dc.DrawBitmap(bmp, bmpX, bmpY, true);
    dc.DrawBitmap(dropbmp, dropBmpX, dropBmpY, true);

    // set the item's text color based on if it is disabled
    dc.SetTextForeground(*wxBLACK);
    if(item.GetState() & wxAUI_BUTTON_STATE_DISABLED) dc.SetTextForeground(DISABLED_TEXT_COLOR);

    if((m_flags & wxAUI_TB_TEXT) && !item.GetLabel().empty()) {
        dc.DrawText(item.GetLabel(), textX, textY);
    }
#endif
}
开发者ID:292388900,项目名称:codelite,代码行数:87,代码来源:cl_aui_tb_are.cpp

示例15: if

void CLMainAuiTBArt::DrawButton(wxDC& dc, wxWindow* wnd, const wxAuiToolBarItem& item, const wxRect& rect)
{
    wxAuiDefaultToolBarArt::DrawButton(dc, wnd, item, rect);
#if 0
    // if(!DrawingUtils::IsThemeDark()) {
    //     wxAuiDefaultToolBarArt::DrawButton(dc, wnd, item, rect);
    //     return;
    // }

    int textWidth = 0, textHeight = 0;

    if(m_flags & wxAUI_TB_TEXT) {
        dc.SetFont(m_font);

        int tx, ty;

        dc.GetTextExtent(wxT("ABCDHgj"), &tx, &textHeight);
        textWidth = 0;
        dc.GetTextExtent(item.GetLabel(), &textWidth, &ty);
    }

    int bmpX = 0, bmpY = 0;
    int textX = 0, textY = 0;

    if(m_textOrientation == wxAUI_TBTOOL_TEXT_BOTTOM) {
        bmpX = rect.x + (rect.width / 2) - (item.GetBitmap().GetWidth() / 2);

        bmpY = rect.y + ((rect.height - textHeight) / 2) - (item.GetBitmap().GetHeight() / 2);

        textX = rect.x + (rect.width / 2) - (textWidth / 2) + 1;
        textY = rect.y + rect.height - textHeight - 1;
    } else if(m_textOrientation == wxAUI_TBTOOL_TEXT_RIGHT) {
        bmpX = rect.x + 3;

        bmpY = rect.y + (rect.height / 2) - (item.GetBitmap().GetHeight() / 2);

        textX = bmpX + 3 + item.GetBitmap().GetWidth();
        textY = rect.y + (rect.height / 2) - (textHeight / 2);
    }

    if(!(item.GetState() & wxAUI_BUTTON_STATE_DISABLED)) {
        if(item.GetState() & wxAUI_BUTTON_STATE_PRESSED) {
            dc.SetPen(wxPen(m_highlightColour));
            dc.SetBrush(wxBrush(m_highlightColour.ChangeLightness(150)));
            dc.DrawRectangle(rect);
        } else if((item.GetState() & wxAUI_BUTTON_STATE_HOVER) || item.IsSticky()) {
            dc.SetPen(wxPen(m_highlightColour));
            dc.SetBrush(wxBrush(m_highlightColour.ChangeLightness(170)));

            // draw an even lighter background for checked item hovers (since
            // the hover background is the same color as the check background)
            if(item.GetState() & wxAUI_BUTTON_STATE_CHECKED)
                dc.SetBrush(wxBrush(m_highlightColour.ChangeLightness(180)));

            dc.DrawRectangle(rect);
        } else if(item.GetState() & wxAUI_BUTTON_STATE_CHECKED) {
            // it's important to put this code in an else statement after the
            // hover, otherwise hovers won't draw properly for checked items
            dc.SetPen(wxPen(m_highlightColour));
            dc.SetBrush(wxBrush(m_highlightColour.ChangeLightness(170)));
            dc.DrawRectangle(rect);
        }
    }

    wxBitmap bmp;
    if(item.GetState() & wxAUI_BUTTON_STATE_DISABLED) {
        bmp = CreateDisabledBitmap(item.GetBitmap());
    } else
        bmp = item.GetBitmap();

    if(bmp.IsOk()) dc.DrawBitmap(bmp, bmpX, bmpY, true);

    // set the item's text color based on if it is disabled
    dc.SetTextForeground(*wxBLACK);
    if(item.GetState() & wxAUI_BUTTON_STATE_DISABLED) dc.SetTextForeground(DISABLED_TEXT_COLOR);

    if((m_flags & wxAUI_TB_TEXT) && !item.GetLabel().empty()) {
        dc.DrawText(item.GetLabel(), textX, textY);
    }
#endif
}
开发者ID:292388900,项目名称:codelite,代码行数:81,代码来源:cl_aui_tb_are.cpp


注:本文中的wxPen函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。