本文整理汇总了C++中wxDC::SetDeviceOrigin方法的典型用法代码示例。如果您正苦于以下问题:C++ wxDC::SetDeviceOrigin方法的具体用法?C++ wxDC::SetDeviceOrigin怎么用?C++ wxDC::SetDeviceOrigin使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类wxDC
的用法示例。
在下文中一共展示了wxDC::SetDeviceOrigin方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SetUpDC
void SetUpDC(wxDC &dc){
int w,h;
dc.SetAxisOrientation(true, true);
dc.GetSize(&w, &h);
dc.SetDeviceOrigin(0,h);
}
示例2: InitialStateWithTransformedDC
void ClippingBoxTestCaseBase::InitialStateWithTransformedDC()
{
// Initial clipping box with transformed DC.
m_dc->SetDeviceOrigin(10, 15);
m_dc->SetUserScale(0.5, 1.5);
m_dc->SetLogicalScale(4.0, 2.0);
m_dc->SetLogicalOrigin(-15, -20);
m_dc->SetBackground(wxBrush(s_fgColour, wxBRUSHSTYLE_SOLID));
m_dc->Clear();
CheckBox(-20, -25, 50, 40);
}
示例3: OneRegionWithTransformedDC
void ClippingBoxTestCaseBase::OneRegionWithTransformedDC()
{
// Setting one clipping box inside DC area
// with applied some transformations.
m_dc->SetDeviceOrigin(10, 15);
m_dc->SetUserScale(0.5, 1.5);
m_dc->SetLogicalScale(4.0, 2.0);
m_dc->SetLogicalOrigin(-15, -20);
m_dc->SetClippingRegion(-10, -20, 80, 75);
m_dc->SetBackground(wxBrush(s_fgColour, wxBRUSHSTYLE_SOLID));
m_dc->Clear();
CheckBox(-10, -20, 40, 35);
}
示例4: PrepareDC
// In case we're using the generic tree control.
void wxRemotelyScrolledTreeCtrl::PrepareDC(wxDC& dc)
{
if (IsKindOf(CLASSINFO(wxGenericTreeCtrl)))
{
ecScrolledWindow* scrolledWindow = GetScrolledWindow();
wxGenericTreeCtrl* win = (wxGenericTreeCtrl*) this;
int startX, startY;
GetViewStart(& startX, & startY);
int xppu1, yppu1, xppu2, yppu2;
win->wxGenericTreeCtrl::GetScrollPixelsPerUnit(& xppu1, & yppu1);
scrolledWindow->GetScrollPixelsPerUnit(& xppu2, & yppu2);
dc.SetDeviceOrigin( -startX * xppu1, -startY * yppu2 );
// dc.SetUserScale( win->GetScaleX(), win->GetScaleY() );
}
}
示例5: PrepareDC
void CScrolledTreeCtrl::PrepareDC(wxDC & dc)
{
#if !defined(__WXMSW__)
if (IsKindOf(CLASSINFO(wxTreeCtrl))) {
wxScrolledWindow *scrolledWindow = GetScrolledWindow();
wxGenericTreeCtrl *win = (wxGenericTreeCtrl *) this;
int startX, startY;
GetViewStart(&startX, &startY);
int xppu1, yppu1, xppu2, yppu2;
win->wxGenericTreeCtrl::GetScrollPixelsPerUnit(&xppu1, &yppu1);
scrolledWindow->GetScrollPixelsPerUnit(&xppu2, &yppu2);
dc.SetDeviceOrigin(-startX * xppu1, -startY * yppu2);
}
#endif
}
示例6: DoPrepareDC
// Override this function if you don't want to have wxScrolledWindow
// automatically change the origin according to the scroll position.
void wxScrolledWindow::DoPrepareDC(wxDC& dc)
{
dc.SetDeviceOrigin( -m_xScrollPosition * m_xScrollPixelsPerLine,
-m_yScrollPosition * m_yScrollPixelsPerLine );
}
示例7: paint
void WSortView::paint(wxDC& dc, const wxSize& dcsize)
{
dc.SetBackground(*wxBLACK_BRUSH);
dc.Clear();
if (size() == 0) return;
size_t fwidth = dcsize.GetWidth();
size_t fheight = dcsize.GetHeight();
size_t width = fwidth - 20;
size_t height = fheight - 20;
dc.SetDeviceOrigin(10,10);
// *** draw array element bars
// draw | | | | bars: each bar is width w, separation is w/2
// thus n bars need n * w + (n-1) * w/2 width
// 1st variant: space is 0.5 of bar size
//double wbar = width / (size() + (size()-1) / 2.0);
//double bstep = 1.5 * wbar;
// 2nd variant: one pixel between bars
double wbar = (width - (size()-1)) / (double)size();
if (width <= (size()-1)) wbar = 0.0;
double bstep = wbar + 1.0;
// special case for bstep = 2 pixel -> draw 2 pixel bars instead of 1px
// bar/1px gaps.
if ( fabs(wbar - 1.0) < 0.1 && fabs(bstep - 2.0) < 0.1 ) wbar = 2, bstep = 2;
static const wxPen pens[] = {
*wxWHITE_PEN,
*wxRED_PEN,
*wxGREEN_PEN,
*wxCYAN_PEN,
wxPen(wxColour(255,255,0)), // 4 yellow
wxPen(wxColour(255,0,255)), // 5 magenta
wxPen(wxColour(255,192,128)), // 6 orange
wxPen(wxColour(255,128,192)), // 7 pink
wxPen(wxColour(128,192,255)), // 8 darker cyan
wxPen(wxColour(192,255,128)), // 9 darker green
wxPen(wxColour(192,128,255)), // 10 purple
wxPen(wxColour(128,255,192)), // 11 light green
wxPen(wxColour(128,128,255)), // 12 blue
wxPen(wxColour(192,128,192)), // 13 dark purple
wxPen(wxColour(128,192,192)), // 14 dark cyan
wxPen(wxColour(192,192,128)), // 15 dark yellow
wxPen(wxColour(0,128,255)), // 16 blue/cyan mix
};
static const wxBrush brushes[] = {
*wxWHITE_BRUSH,
*wxRED_BRUSH,
*wxGREEN_BRUSH,
*wxCYAN_BRUSH,
wxBrush(wxColour(255,255,0)), // 4 yellow
wxBrush(wxColour(255,0,255)), // 5 magenta
wxBrush(wxColour(255,192,128)), // 6 orange
wxBrush(wxColour(255,128,192)), // 7 pink
wxBrush(wxColour(128,192,255)), // 8 darker cyan
wxBrush(wxColour(192,255,128)), // 9 darker green
wxBrush(wxColour(192,128,255)), // 10 purple
wxBrush(wxColour(128,255,192)), // 11 light green
wxBrush(wxColour(128,128,255)), // 12 blue
wxBrush(wxColour(192,128,192)), // 13 dark purple
wxBrush(wxColour(128,192,192)), // 14 dark cyan
wxBrush(wxColour(192,192,128)), // 15 dark yellow
wxBrush(wxColour(0,128,255)), // 16 blue/cyan mix
};
wxMutexLocker lock(m_mutex);
ASSERT(lock.IsOk());
for (size_t i = 0; i < size(); ++i)
{
int clr;
// select color
if (i == m_access1.index)
{
clr = m_access1.color;
}
else if (i == m_access2.index)
{
clr = m_access2.color;
}
else if ( (clr = InWatchList(i)) != 0 )
{
// clr already set
}
else if (m_mark[i] != 0)
{
clr = m_mark[i];
}
else if ( (clr = InAccessList(i)) >= 0 )
{
//.........这里部分代码省略.........
示例8: OnDraw
// Define the repainting behaviour
void MyCanvas::OnDraw(wxDC& dc)
{
// vars to use ...
#if wxUSE_STATUSBAR
wxString s;
#endif // wxUSE_STATUSBAR
wxPen wP;
wxBrush wB;
wxPoint points[6];
wxColour wC;
wxFont wF;
dc.SetFont(*wxSWISS_FONT);
dc.SetPen(*wxGREEN_PEN);
switch (m_index)
{
default:
case 0:
// draw lines to make a cross
dc.DrawLine(0, 0, 200, 200);
dc.DrawLine(200, 0, 0, 200);
// draw point colored line and spline
wP = *wxCYAN_PEN;
wP.SetWidth(3);
dc.SetPen(wP);
dc.DrawPoint (25,15);
dc.DrawLine(50, 30, 200, 30);
dc.DrawSpline(50, 200, 50, 100, 200, 10);
#if wxUSE_STATUSBAR
s = wxT("Green Cross, Cyan Line and spline");
#endif // wxUSE_STATUSBAR
break;
case 1:
// draw standard shapes
dc.SetBrush(*wxCYAN_BRUSH);
dc.SetPen(*wxRED_PEN);
dc.DrawRectangle(10, 10, 100, 70);
wB = wxBrush (wxT("DARK ORCHID"), wxBRUSHSTYLE_TRANSPARENT);
dc.SetBrush (wB);
dc.DrawRoundedRectangle(50, 50, 100, 70, 20);
dc.SetBrush (wxBrush(wxT("GOLDENROD")) );
dc.DrawEllipse(100, 100, 100, 50);
points[0].x = 100; points[0].y = 200;
points[1].x = 70; points[1].y = 260;
points[2].x = 160; points[2].y = 230;
points[3].x = 40; points[3].y = 230;
points[4].x = 130; points[4].y = 260;
points[5].x = 100; points[5].y = 200;
dc.DrawPolygon(5, points);
dc.DrawLines (6, points, 160);
#if wxUSE_STATUSBAR
s = wxT("Blue rectangle, red edge, clear rounded rectangle, gold ellipse, gold and clear stars");
#endif // wxUSE_STATUSBAR
break;
case 2:
// draw text in Arial or similar font
dc.DrawLine(50,25,50,35);
dc.DrawLine(45,30,55,30);
dc.DrawText(wxT("This is a Swiss-style string"), 50, 30);
wC = dc.GetTextForeground();
dc.SetTextForeground (wxT("FIREBRICK"));
// no effect in msw ??
dc.SetTextBackground (wxT("WHEAT"));
dc.DrawText(wxT("This is a Red string"), 50, 200);
dc.DrawRotatedText(wxT("This is a 45 deg string"), 50, 200, 45);
dc.DrawRotatedText(wxT("This is a 90 deg string"), 50, 200, 90);
wF = wxFont ( 18, wxROMAN, wxITALIC, wxBOLD, false, wxT("Times New Roman"));
dc.SetFont(wF);
dc.SetTextForeground (wC);
dc.DrawText(wxT("This is a Times-style string"), 50, 60);
#if wxUSE_STATUSBAR
s = wxT("Swiss, Times text; red text, rotated and colored orange");
#endif // wxUSE_STATUSBAR
break;
case 3 :
// four arcs start and end points, center
dc.SetBrush(*wxGREEN_BRUSH);
dc.DrawArc ( 200,300, 370,230, 300,300 );
dc.SetBrush(*wxBLUE_BRUSH);
dc.DrawArc ( 270-50, 270-86, 270-86, 270-50, 270,270 );
dc.SetDeviceOrigin(-10,-10);
dc.DrawArc ( 270-50, 270-86, 270-86, 270-50, 270,270 );
dc.SetDeviceOrigin(0,0);
wP.SetColour (wxT("CADET BLUE"));
dc.SetPen(wP);
dc.DrawArc ( 75,125, 110, 40, 75, 75 );
wP.SetColour (wxT("SALMON"));
dc.SetPen(wP);
dc.SetBrush(*wxRED_BRUSH);
//.........这里部分代码省略.........
示例9: FullRefresh
void GraphPane::FullRefresh(wxDC& dc)
{
// Erase Background
wxCoord width, height;
this->GetSize(&width, &height);
dc.SetPen((BlackBG ? *wxBLACK_PEN : *wxWHITE_PEN));
dc.SetBrush(BlackBG ? *wxBLACK_BRUSH : *wxWHITE_BRUSH);
dc.DrawRectangle(0, 0, width, height);
// Set the origin at the centre
dc.SetDeviceOrigin(wxCoord(width/2), wxCoord(height/2));
wxPen pen((BlackBG ? *wxWHITE : *wxBLACK), 1);
wxBrush brush((BlackBG ? *wxBLACK_BRUSH : *wxWHITE_BRUSH));
dc.SetPen(pen);
if (GraphInfoVector != NULL && !(GraphInfoVector->empty())) {
// Declare iterators for each set of coordinates --> Loop through all trails/sets of coordinates
std::vector<GraphInfo*>::const_iterator CoordSetIt;
// Declare iterators for each trail
std::deque<double>::const_iterator XCoordIt;
std::deque<double>::const_iterator YCoordIt;
//Begin iterating
CoordSetIt = GraphInfoVector->begin();
while (CoordSetIt != GraphInfoVector->end()) {
// Set Colour
if ((*CoordSetIt)->TrailColour == *wxBLACK && BlackBG) {
pen = wxPen(*wxWHITE, 1);
} else {
pen = wxPen((*CoordSetIt)->TrailColour, 1);
}
dc.SetPen(pen);
// Iterate through all coordinates
if ((*CoordSetIt)->XCoordinate.size() > unsigned(NewPoints)) {
XCoordIt = (*CoordSetIt)->XCoordinate.begin() + NewPoints - 1;
YCoordIt = (*CoordSetIt)->YCoordinate.begin() + NewPoints - 1;
}
else {
XCoordIt = (*CoordSetIt)->XCoordinate.begin();
YCoordIt = (*CoordSetIt)->YCoordinate.begin();
}
while (XCoordIt != (*CoordSetIt)->XCoordinate.end()) {
dc.DrawPoint(wxCoord((*XCoordIt) * ScalingFactor), wxCoord((*YCoordIt) * ScalingFactor* (-1)));
XCoordIt++;
YCoordIt++;
}
// If terminator size > 0, draw circle terminator at last coordinate.
if ((*CoordSetIt)->TermSize > 0) {
XCoordIt--;
YCoordIt--;
if ((*CoordSetIt)->TrailColour == *wxBLACK && BlackBG) {
brush.SetColour(*wxWHITE);
} else {
brush.SetColour((*CoordSetIt)->TrailColour);
}
dc.SetBrush(brush);
dc.DrawEllipse(wxCoord((*XCoordIt) * ScalingFactor - (*CoordSetIt)->TermSize),
wxCoord((*YCoordIt) * ScalingFactor* (-1) - (*CoordSetIt)->TermSize),
(*CoordSetIt)->TermSize * 2, (*CoordSetIt)->TermSize * 2);
}
++CoordSetIt;
}
}
}
示例10: VdkDcDeviceOriginAdder
void VdkDcDeviceOriginAdder(wxDC &dc, int dX, int dY) {
int x, y;
dc.GetDeviceOrigin(&x, &y);
dc.SetDeviceOrigin(x + dX, y + dY);
}
示例11: DrawForPrintingHelper
void DrawForPrintingHelper(wxDC& dc, const CalChartConfiguration& config, const CalChartDoc& show, const CC_sheet& sheet, unsigned ref, bool landscape)
{
// set up everything to be restored after we print
SaveAndRestore_DeviceOrigin orig_dev(dc);
SaveAndRestore_UserScale orig_scale(dc);
SaveAndRestore_Font orig_font(dc);
// get the page dimensions
int pageW, pageH;
dc.GetSize(&pageW, &pageH);
dc.Clear();
dc.SetLogicalFunction(wxCOPY);
// Print the field:
// create a field for drawing:
const auto pts = sheet.GetPoints();
auto boundingBox = GetMarcherBoundingBox(pts);
auto mode = CreateFieldForPrinting(Coord2Int(boundingBox.first.x), Coord2Int(boundingBox.second.x), landscape);
// set the origin and scaling for drawing the field
dc.SetDeviceOrigin(kFieldBorderOffset*pageW, kFieldTop*pageH);
auto scale = (pageW-2*kFieldBorderOffset*pageW)/(double)mode->Size().x;
dc.SetUserScale(scale, scale);
// draw the field.
DrawMode(dc, config, *mode, ShowMode_kPrinting);
wxFont *pointLabelFont = wxTheFontList->FindOrCreateFont((int)Float2Coord(config.Get_DotRatio() * config.Get_NumRatio()), wxSWISS, wxNORMAL, wxNORMAL);
dc.SetFont(*pointLabelFont);
for (auto i = 0u; i < pts.size(); i++)
{
const auto point = pts.at(i);
const auto pos = point.GetPos(ref) + mode->Offset();
dc.SetBrush(*wxBLACK_BRUSH);
DrawPointHelper(dc, config, pos, point, show.GetPointLabel(i));
}
// now reset everything to draw the rest of the text
dc.SetDeviceOrigin(Int2Coord(0), Int2Coord(0));
dc.SetBrush(*wxTRANSPARENT_BRUSH);
// set the page for drawing:
dc.GetSize(&pageW, &pageH);
if (landscape)
{
dc.SetUserScale(pageW/kSizeXLandscape, pageH/kSizeYLandscape);
pageW = kSizeXLandscape;
pageH = kSizeYLandscape;
}
else
{
dc.SetUserScale(pageW/kSizeX, pageH/kSizeY);
pageW = kSizeX;
pageH = kSizeY;
}
// draw the header
dc.SetFont(*wxTheFontList->FindOrCreateFont(16, wxROMAN, wxNORMAL, wxBOLD));
dc.SetPen(*wxThePenList->FindOrCreatePen(*wxBLACK, 1, wxSOLID));
DrawCenteredText(dc, kHeader, wxPoint(pageW*kHeaderLocation[landscape][0], pageH*kHeaderLocation[landscape][1]));
DrawCenteredText(dc, sheet.GetNumber(), wxPoint(pageW*kUpperNumberPosition[landscape][0], pageH*kUpperNumberPosition[landscape][1]));
DrawCenteredText(dc, sheet.GetNumber(), wxPoint(pageW*kLowerNumberPosition[landscape][0], pageH*kLowerNumberPosition[landscape][1]));
dc.DrawRectangle(pageW*kLowerNumberBox[landscape][0], pageH*kLowerNumberBox[landscape][1], pageW*kLowerNumberBox[landscape][2], pageH*kLowerNumberBox[landscape][3]);
dc.SetFont(*wxTheFontList->FindOrCreateFont(8, wxSWISS, wxNORMAL, wxNORMAL));
DrawLineOverText(dc, kMusicLabel, wxPoint(pageW*kMusicLabelPosition[landscape][0], pageH*kMusicLabelPosition[landscape][1]), pageW*kMusicLabelPosition[landscape][2]);
DrawLineOverText(dc, kFormationLabel, wxPoint(pageW*kFormationLabelPosition[landscape][0], pageH*kFormationLabelPosition[landscape][1]), pageW*kFormationLabelPosition[landscape][2]);
DrawLineOverText(dc, kGameLabel, wxPoint(pageW*kGameLabelPosition[landscape][0], pageH*kGameLabelPosition[landscape][1]), pageW*kGameLabelPosition[landscape][2]);
DrawLineOverText(dc, kPageLabel, wxPoint(pageW*kPageLabelPosition[landscape][0], pageH*kPageLabelPosition[landscape][1]), pageW*kPageLabelPosition[landscape][2]);
DrawCenteredText(dc, kSideLabel, wxPoint(pageW*kSideLabelPosition[landscape][0], pageH*kSideLabelPosition[landscape][1]));
// draw arrows
DrawCenteredText(dc, kUpperSouthLabel, wxPoint(pageW*kUpperSouthPosition[landscape][0], pageH*kUpperSouthPosition[landscape][1]));
DrawArrow(dc, wxPoint(pageW*kUpperSouthArrow[landscape][0], pageH*kUpperSouthArrow[landscape][1]), pageW*kUpperSouthArrow[landscape][2], false);
DrawCenteredText(dc, kUpperNorthLabel, wxPoint(pageW*kUpperNorthPosition[landscape][0], pageH*kUpperNorthPosition[landscape][1]));
DrawArrow(dc, wxPoint(pageW*kUpperNorthArrow[landscape][0], pageH*kUpperNorthArrow[landscape][1]), pageW*kUpperNorthArrow[landscape][2], true);
DrawCenteredText(dc, kLowerSouthLabel, wxPoint(pageW*kLowerSouthPosition[landscape][0], pageH*kLowerSouthPosition[landscape][1]));
DrawArrow(dc, wxPoint(pageW*kLowerSouthArrow[landscape][0], pageH*kLowerSouthArrow[landscape][1]), pageW*kLowerSouthArrow[landscape][2], false);
DrawCenteredText(dc, kLowerNorthLabel, wxPoint(pageW*kLowerNorthPosition[landscape][0], pageH*kLowerNorthPosition[landscape][1]));
DrawArrow(dc, wxPoint(pageW*kLowerNorthArrow[landscape][0], pageH*kLowerNorthArrow[landscape][1]), pageW*kLowerNorthArrow[landscape][2], true);
DrawCont(dc, sheet.GetPrintableContinuity(), wxRect(wxPoint(10, pageH*kContinuityStart[landscape]), wxSize(pageW-20, pageH-pageH*kContinuityStart[landscape])), landscape);
}
示例12: OnDraw
// Define the repainting behaviour
void MyCanvas::OnDraw(wxDC& dc)
{
// vars to use ...
#if wxUSE_STATUSBAR
wxString s ;
#endif // wxUSE_STATUSBAR
wxPen wP ;
wxBrush wB ;
wxPoint points[6];
wxColour wC;
wxFont wF ;
dc.SetFont(*wxSWISS_FONT);
dc.SetPen(*wxGREEN_PEN);
switch (m_index)
{
default:
case 0:
// draw lines to make a cross
dc.DrawLine(0, 0, 200, 200);
dc.DrawLine(200, 0, 0, 200);
// draw point colored line and spline
wP = *wxCYAN_PEN ;
wP.SetWidth(3);
dc.SetPen(wP);
dc.DrawPoint (25,15) ;
dc.DrawLine(50, 30, 200, 30);
dc.DrawSpline(50, 200, 50, 100, 200, 10);
#if wxUSE_STATUSBAR
s = wxT("Green Cross, Cyan Line and spline");
#endif // wxUSE_STATUSBAR
break ;
case 1:
// draw standard shapes
dc.SetBrush(*wxCYAN_BRUSH);
dc.SetPen(*wxRED_PEN);
dc.DrawRectangle(10, 10, 100, 70);
wB = wxBrush (_T("DARK ORCHID"), wxTRANSPARENT);
dc.SetBrush (wB);
dc.DrawRoundedRectangle(50, 50, 100, 70, 20);
dc.SetBrush (wxBrush(_T("GOLDENROD"), wxSOLID) );
dc.DrawEllipse(100, 100, 100, 50);
points[0].x = 100; points[0].y = 200;
points[1].x = 70; points[1].y = 260;
points[2].x = 160; points[2].y = 230;
points[3].x = 40; points[3].y = 230;
points[4].x = 130; points[4].y = 260;
points[5].x = 100; points[5].y = 200;
dc.DrawPolygon(5, points);
dc.DrawLines (6, points, 160);
#if wxUSE_STATUSBAR
s = wxT("Blue rectangle, red edge, clear rounded rectangle, gold ellipse, gold and clear stars");
#endif // wxUSE_STATUSBAR
break ;
case 2:
// draw text in Arial or similar font
dc.DrawLine(50,25,50,35);
dc.DrawLine(45,30,55,30);
dc.DrawText(wxT("This is a Swiss-style string"), 50, 30);
wC = dc.GetTextForeground() ;
dc.SetTextForeground (_T("FIREBRICK"));
// no effect in msw ??
dc.SetTextBackground (_T("WHEAT"));
dc.DrawText(wxT("This is a Red string"), 50, 200);
dc.DrawRotatedText(wxT("This is a 45 deg string"), 50, 200, 45);
dc.DrawRotatedText(wxT("This is a 90 deg string"), 50, 200, 90);
wF = wxFont ( 18, wxROMAN, wxITALIC, wxBOLD, false, wxT("Times New Roman"));
dc.SetFont(wF);
dc.SetTextForeground (wC) ;
dc.DrawText(wxT("This is a Times-style string"), 50, 60);
#if wxUSE_STATUSBAR
s = wxT("Swiss, Times text; red text, rotated and colored orange");
#endif // wxUSE_STATUSBAR
break ;
case 3 :
// four arcs start and end points, center
dc.SetBrush(*wxGREEN_BRUSH);
dc.DrawArc ( 200,300, 370,230, 300,300 );
dc.SetBrush(*wxBLUE_BRUSH);
dc.DrawArc ( 270-50, 270-86, 270-86, 270-50, 270,270 );
dc.SetDeviceOrigin(-10,-10);
dc.DrawArc ( 270-50, 270-86, 270-86, 270-50, 270,270 );
dc.SetDeviceOrigin(0,0);
wP.SetColour (_T("CADET BLUE"));
dc.SetPen(wP);
dc.DrawArc ( 75,125, 110, 40, 75, 75 );
wP.SetColour (_T("SALMON"));
dc.SetPen(wP);
//.........这里部分代码省略.........
示例13: rc
VdkCusdrawReturnFlag OOPLyric::DoDrawCellText
(const VdkLcCell *cell,
int col_index,
int index0,
wxDC &dc,
VdkLcHilightState state) {
wxASSERT(m_parser);
// 注意:index 是不计算加入的空行的
int index = (int) (cell->GetClientData()) - 1;
if (index == -1) { // 此时 ClientData == NULL,是我们添加的空行
return VCCDRF_DODEFAULT;
}
dc.SetTextForeground(m_TextColor);
// 暂停时高亮当前行,情景见于用户正在拖动歌词。
// 另外先暂停,然后拖动歌词完毕,此时假如歌词秀是以卡拉OK
// 方式进行显示时,那么不会保持半高亮的状态,而是全高亮。
if (TestState(OLST_PAUSED)) {
int yStart;
GetViewStartCoord(NULL, &yStart);
int rowHeight = GetRowHeight();
int dragRegion = yStart + rowHeight * m_blankLinesTop;
int index2 = index + m_blankLinesTop;
// 检测拖动歌词时中间线下面的一行
if (rowHeight * index2 <= dragRegion &&
rowHeight * (index2 + 1) > dragRegion) {
m_draggHit = m_parser->GetLine(index);
dc.SetTextForeground(m_HilightColor);
}
return VCCDRF_DODEFAULT;
}
LineInfo *currLine = *m_currLine;
// TODO: 是否考虑优化?
size_t currLineIndex = m_parser->IndexOf(m_currLine);
int lineHasGone = m_stopWatch->Time() - currLine->GetStartTime();
if ((index == currLineIndex - 1) && !cell->GetLabel().empty()) {
// 使用渐变色还原上一句歌词
if (lineHasGone < ALPHA_SHOW_LAST_LINE_MS) {
unsigned char r, g, b;
double alpha2 = double(lineHasGone) / ALPHA_SHOW_LAST_LINE_MS;
double alpha1 = 1 - alpha2;
r = m_HilightColor.Red() * alpha1 + m_TextColor.Red() * alpha2;
g = m_HilightColor.Green() * alpha1 + m_TextColor.Green() * alpha2;
b = m_HilightColor.Blue() * alpha1 + m_TextColor.Blue() * alpha2;
dc.SetTextForeground(wxColour(r, g, b));
}
} else if (index == currLineIndex) { // 高亮当前文本行
// 尽管这是一种很罕见的情况,但一旦出现了就会导致下面 (*) 表达式
// 的除数为 0
if (currLine->GetMilSeconds() == 0) {
return VCCDRF_DODEFAULT;
}
if (!cell->IsEmpty()) {
/* 经验教训:
1. SetClippingRegiion 有叠加效应,因此在执行新的
SetClippingRegiion 前别忘了销毁原来的 ClippingRegiion 。
2. 关于表达式中整数与浮点数混用:注意中间运算结果会
被强制转换成 int 然后参加下一步的运算,并不是对
最终结果进行转换,使之成为一个浮点数。
*/
const int rowHeight = GetRowHeight();
int y = (currLineIndex + m_blankLinesTop) * rowHeight;
cell->DrawLabel(dc, 0, y);
// (*)
double lineProgress = double(lineHasGone) / currLine->GetMilSeconds();
// 要实现 KALA-OK 效果的文本宽度
int w = (m_Rect.width - cell->GetX_Padding() * 2) * lineProgress;
wxRect rc(GetAbsoluteRect());
const int bottom = rc.y + rc.height;
int yStart;
VdkScrolledWindow::GetViewStartCoord(NULL, &yStart);
rc.y += y - yStart;
rc.width = cell->GetX_Padding() + w;
rc.height = rowHeight;
// 不能使 KALA-OK 效果的 ClippingRegion 超出列表窗口
if ((rc.y + rc.height) > bottom) {
rc.height = bottom - rc.y;
}
VdkDcDeviceOriginSaver saver(dc);
dc.SetDeviceOrigin(0, 0);
VdkDcClippingRegionDestroyer destroyer(dc, rc);
//.........这里部分代码省略.........