void gXGrid::paint(gGraph & w,int left,int top, int width, int height) { int x,y; gVertexBuffer * stippled, * lines; EventDataType miny,maxy; if (w.zoomY()==0 && PROFILE.appearance->allowYAxisScaling()) { miny=w.physMinY(); maxy=w.physMaxY(); } else { miny=w.min_y; maxy=w.max_y; if (miny<0) { // even it up if it's starts negative miny=-MAX(fabs(miny),fabs(maxy)); } } w.roundY(miny,maxy); //EventDataType dy=maxy-miny; if (height<0) return; static QString fd="0"; GetTextExtent(fd,x,y); double max_yticks=round(height / (y+14.0)); // plus spacing between lines //double yt=1/max_yticks; double mxy=MAX(fabs(maxy),fabs(miny)); double mny=miny; if (miny<0) { mny=-mxy; } double rxy=mxy-mny; int myt; bool fnd=false; for (myt=max_yticks;myt>=1;myt--) { float v=rxy/float(myt); if (float(v)==int(v)) { fnd=true; break; } } if (fnd) max_yticks=myt; else { max_yticks=2; } double yt=1/max_yticks; double ymult=height/rxy; double min_ytick=rxy*yt; float ty,h; if (min_ytick<=0) { qDebug() << "min_ytick error in gXGrid::paint() in" << w.title(); return; } if (min_ytick>=1000000) { min_ytick=100; } stippled=w.backlines(); lines=w.backlines(); for (double i=miny; i<=maxy+min_ytick-0.00001; i+=min_ytick) { ty=(i - miny) * ymult; h=top+height-ty; if (m_show_major_lines && (i > miny)) { stippled->add(left,h,left+width,h,m_major_color.rgba()); } double z=(min_ytick/4)*ymult; double g=h; for (int i=0;i<3;i++) { g+=z; if (g>top+height) break; //if (vertcnt>=maxverts) { // qWarning() << "vertarray bounds exceeded in gYAxis for " << w.title() << "graph" << "MinY =" <<miny << "MaxY =" << maxy << "min_ytick=" <<min_ytick; // break; // } if (m_show_minor_lines) {// && (i > miny)) { stippled->add(left,g,left+width,g,m_minor_color.rgba()); } if (stippled->full()) { break; } } if (lines->full() || stippled->full()) { qWarning() << "vertarray bounds exceeded in gYAxis for " << w.title() << "graph" << "MinY =" <<miny << "MaxY =" << maxy << "min_ytick=" <<min_ytick; break; } } }
static void DrawCoolBox (HWND hWnd, HDC hdc, PCOOL_INDICATOR_CTRL pdata) { db_msg("DrawCoolBox\n"); COOL_INDICATOR_ITEMDATA* tmpdata; RECT rc; int l,t; WINDOWINFO *info = (WINDOWINFO*)GetWindowInfo (hWnd); DWORD color; DWORD mainc = GetWindowElementAttr (hWnd, WE_MAINC_THREED_BODY); GetClientRect (hWnd, &rc); if (pdata->BackBmp) { FillBoxWithBitmap (hdc, 0, 0, rc.right, rc.bottom, pdata->BackBmp); } // color = info->we_rdr->calc_3dbox_color (mainc, LFRDR_3DBOX_COLOR_DARKEST); // SetPenColor (hdc, RGBA2Pixel (hdc, GetRValue (color), GetGValue (color), GetBValue (color), GetAValue (color))); // MoveTo (hdc, 0, rc.bottom - 2); // color = info->we_rdr->calc_3dbox_color (mainc, LFRDR_3DBOX_COLOR_LIGHTEST); // SetPenColor (hdc, RGBA2Pixel (hdc, GetRValue (color), GetGValue (color), GetBValue (color), GetAValue (color))); // MoveTo (hdc, 0, 3); // LineTo (hdc, rc.right, 3); // MoveTo (hdc, 0, 4); // LineTo (hdc, rc.right, 4); // // MoveTo (hdc, 0, rc.bottom - 1); // LineTo (hdc, rc.right, rc.bottom - 1); tmpdata = pdata->head; while (tmpdata) { l = tmpdata->RcTitle.left; t = tmpdata->RcTitle.top; switch (tmpdata->ItemType) { case TYPE_BARITEM: { WINDOWINFO *info = (WINDOWINFO*)GetWindowInfo (hWnd); RECT rcTmp; rcTmp.left = l + 2; rcTmp.top = 4; rcTmp.right = l + 4; rcTmp.bottom = rc.bottom - 4; info->we_rdr->draw_3dbox (hdc, &rcTmp, GetWindowElementAttr (hWnd, WE_MAINC_THREED_BODY), LFRDR_BTN_STATUS_PRESSED); } break; case TYPE_BMPITEM: { FillBoxWithBitmap (hdc, l + 4, t + 4, pdata->ItemWidth, pdata->ItemHeight, tmpdata->Bmp); } break; case TYPE_TEXTITEM: { SIZE size; int h; WINDOWINFO *info; RECT rc; if (tmpdata->Caption == NULL || tmpdata->Caption [0] == '\0') break; GetTextExtent (hdc, tmpdata->Caption, -1, &size); h = (pdata->ItemHeight - size.cy) / 2; SetBkMode (hdc, BM_TRANSPARENT); if (tmpdata->Disable) { info = (WINDOWINFO*)GetWindowInfo (hWnd); rc.left = l + 2; rc.top = t + h + 2; rc.right = rc.left + size.cx; rc.bottom = rc.top + size.cy; info->we_rdr->disabled_text_out (hWnd, hdc, tmpdata->Caption, &rc, DT_SINGLELINE); } else { SetBkColor (hdc, GetWindowBkColor (hWnd)); SetTextColor (hdc, PIXEL_black); TextOut (hdc, l+2, t + h + 2, tmpdata->Caption); } } break; default: break; } tmpdata = tmpdata->next; } db_msg("xxxxxxxxxxx\n"); draw_hilight_box (hWnd, hdc, GetCurSel(pdata)); //if(enable_hint == TRUE) // ShowCurItemHint (hWnd, pdata); }
void gtab_paintcell(HWND hwnd, HDC hdc, lpTable ptab, int line, int cell) { lpLineData pline; lpCellData cd; lpCellPos ppos; RECT rc, rcbox; int cx, x, y, tabwidth; UINT align; LPSTR chp, tabp; DWORD fcol, bkcol; HFONT hfont; TEXTMETRIC tm; HBRUSH hbr; fcol = 0; bkcol = 0; /* eliminate spurious diagnostic, generate worse code */ hfont = 0; /* eliminate spurious diagnostic, generate worse code */ /* init pointers to cell text and properties */ pline = &ptab->pdata[line]; cd = &pline->pdata[cell]; ppos = &ptab->pcellpos[cell]; /* clip all output to this rectangle */ rc.top = pline->linepos.clipstart; rc.bottom = pline->linepos.clipend; rc.left = ppos->clipstart; rc.right = ppos->clipend; /* check cell properties and colours */ if (cd->props.valid & P_ALIGN) { align = cd->props.alignment; } else { align = P_LEFT; } if (cd->props.valid & P_FONT) { hfont = SelectObject(hdc, cd->props.hFont); GetTextMetrics(hdc, &tm); tabwidth = tm.tmAveCharWidth * ptab->tabchars; } else { tabwidth = ptab->avewidth * ptab->tabchars; } /* set colours if not default */ if (cd->props.valid & P_FCOLOUR) { fcol = SetTextColor(hdc, cd->props.forecolour); } if (cd->props.valid & P_BCOLOUR) { /* there is a non-default background colour. * create a brush and fill the entire cell with it */ hbr = CreateSolidBrush(cd->props.backcolour); FillRect(hdc, &rc, hbr); DeleteObject(hbr); /* also set colour as background colour for the text */ bkcol = SetBkColor(hdc, cd->props.backcolour); } /* calc offset of text within cell for right-align or centering */ if (align == P_LEFT) { cx = ptab->avewidth/2; } else { if (cd->ptext == NULL) { cx = 0; } else { cx = LOWORD(GetTextExtent(hdc, cd->ptext, lstrlen(cd->ptext))); } if (align == P_CENTRE) { cx = (ppos->size - cx) / 2; } else { cx = ppos->size - cx - (ptab->avewidth/2); } } cx += ppos->start; /* expand tabs on output */ x = 0; y = pline->linepos.start; for (chp = cd->ptext; ((chp != NULL) && ((tabp = _fstrchr(chp, '\t')) != NULL)); ) { /* perform output upto tab char */ ExtTextOut(hdc, x+cx, y, ETO_CLIPPED, &rc, chp, tabp-chp, NULL); /* advance past the tab */ x += LOWORD(GetTextExtent(hdc, chp, tabp - chp)); x = ( (x + tabwidth) / tabwidth) * tabwidth; chp = ++tabp; } /*no more tabs - output rest of string */ if (chp != NULL) { ExtTextOut(hdc, x+cx, y, ETO_CLIPPED, &rc, chp, lstrlen(chp), NULL); } /* reset colours to original if not default */ if (cd->props.valid & P_FCOLOUR) { SetTextColor(hdc, fcol); } if (cd->props.valid & P_BCOLOUR) { SetBkColor(hdc, bkcol); } if (cd->props.valid & P_FONT) { SelectObject(hdc, hfont); } /* now box cell if marked */ if (cd->props.valid & P_BOX) { if (cd->props.box != 0) { rcbox.top = pline->linepos.start; rcbox.bottom = rcbox.top + pline->linepos.size; rcbox.left = ppos->start; rcbox.right = ppos->start + ppos->size; gtab_boxcell(hwnd, hdc, &rcbox, &rc, cd->props.box); } } }
TargetWindow::TargetWindow(wxWindow *parent) : wxWindow(parent,wxID_ANY,wxDefaultPosition,wxDefaultSize, 0,_("Target")) { //SetFont(wxFont(8,wxFONTFAMILY_DEFAULT,wxFONTSTYLE_NORMAL,wxFONTWEIGHT_NORMAL)); SetBackgroundColour(*wxBLACK); m_visible = false; m_pClient = new TargetClient(this); wxBoxSizer *pMainSizer = new wxBoxSizer(wxHORIZONTAL); wxBoxSizer *pLeftSizer = new wxBoxSizer(wxVERTICAL); pMainSizer->Add(pLeftSizer); wxString label = wxString::Format("%3d", m_pClient->m_length); m_lengthButton = new OptionsButton(this,BUTTON_GRAPH_LENGTH,label,wxDefaultPosition,wxSize(40/*80*/,-1),wxALIGN_CENTER_HORIZONTAL); m_lengthButton->SetToolTip(_("Select the number of frames of history to display")); wxBoxSizer *pZoomSizer = new wxBoxSizer(wxHORIZONTAL); wxButton *zoomInButton = new wxButton(this, BUTTON_GRAPH_ZOOMIN, _T("+"), wxDefaultPosition, wxSize(40, -1)); zoomInButton->SetToolTip(_("Zoom in")); wxButton *zoomOutButton = new wxButton(this, BUTTON_GRAPH_ZOOMOUT, _T("-"), wxDefaultPosition, wxSize(40, -1)); zoomOutButton->SetToolTip(_("Zoom out")); pZoomSizer->Add(zoomInButton, wxSizerFlags(1).Expand()); pZoomSizer->Add(zoomOutButton, wxSizerFlags(1).Expand()); wxButton *clearButton = new wxButton(this,BUTTON_GRAPH_CLEAR,_("Clear"),wxDefaultPosition,wxSize(80,-1)); clearButton->SetToolTip(_("Clear graph data")); m_enableRefCircle = new wxCheckBox(this, TARGET_ENABLE_REF_CIRCLE, _("Reference Circle")); m_enableRefCircle->SetToolTip(_("Check to display a reference circle")); #if defined(__WXOSX__) // workaround inability to set checkbox foreground color m_enableRefCircle->SetBackgroundColour(wxColor(200, 200, 200)); #else m_enableRefCircle->SetForegroundColour(*wxLIGHT_GREY); #endif wxStaticText *lbl = new wxStaticText(this, wxID_ANY, _("Radius:")); lbl->SetForegroundColour(*wxLIGHT_GREY); lbl->SetBackgroundColour(*wxBLACK); int w, h; GetTextExtent(_T("88.8"), &w, &h); m_refCircleRadius = new wxSpinCtrlDouble(this, TARGET_REF_CIRCLE_RADIUS, wxEmptyString, wxDefaultPosition, wxSize(w + 30, -1)); m_refCircleRadius->SetToolTip(_("Reference circle radius")); m_refCircleRadius->SetRange(0.1, 10.0); m_refCircleRadius->SetIncrement(0.1); m_refCircleRadius->SetDigits(1); wxBoxSizer *sizer1 = new wxBoxSizer(wxHORIZONTAL); sizer1->Add(lbl, wxSizerFlags().Align(wxALIGN_CENTER_VERTICAL).Border(wxRIGHT, 5)); sizer1->Add(m_refCircleRadius, wxSizerFlags(1).Align(wxALIGN_CENTER_VERTICAL).Expand()); pLeftSizer->Add(m_lengthButton, wxSizerFlags().Center().Border(wxTOP | wxRIGHT | wxLEFT, 5).Expand()); pLeftSizer->Add(pZoomSizer, wxSizerFlags().Border(wxRIGHT | wxLEFT, 5).Expand()); pLeftSizer->Add(clearButton, wxSizerFlags().Border(wxRIGHT | wxLEFT,5).Expand()); pLeftSizer->Add(m_enableRefCircle, wxSizerFlags().Center().Border(wxALL, 3).Expand()); pLeftSizer->Add(sizer1, wxSizerFlags().Center().Border(wxRIGHT | wxLEFT, 5).Expand()); pMainSizer->Add(m_pClient, wxSizerFlags().Border(wxALL,3).Expand().Proportion(1)); SetSizer(pMainSizer); pMainSizer->SetSizeHints(this); UpdateControls(); }
void EffectAutoDuckPanel::OnPaint(wxPaintEvent & WXUNUSED(evt)) { int clientWidth, clientHeight; GetSize(&clientWidth, &clientHeight); if (!mBackgroundBitmap || mBackgroundBitmap->GetWidth() != clientWidth || mBackgroundBitmap->GetHeight() != clientHeight) { if (mBackgroundBitmap) delete mBackgroundBitmap; mBackgroundBitmap = new wxBitmap(clientWidth, clientHeight); } wxMemoryDC dc; dc.SelectObject(*mBackgroundBitmap); dc.SetBrush(*wxWHITE_BRUSH); dc.SetPen(*wxBLACK_PEN); dc.DrawRectangle(0, 0, clientWidth, clientHeight); dc.SetFont(wxFont(10, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL)); dc.SetTextForeground(*wxBLACK); dc.SetTextBackground(*wxWHITE); double duckAmountDb = 0; double innerFadeDownLen = 0; double innerFadeUpLen = 0; double outerFadeDownLen = 0; double outerFadeUpLen = 0; mEffect->mDuckAmountDbBox->GetValue().ToDouble(&duckAmountDb); mEffect->mInnerFadeDownLenBox->GetValue().ToDouble(&innerFadeDownLen); mEffect->mInnerFadeUpLenBox->GetValue().ToDouble(&innerFadeUpLen); mEffect->mOuterFadeDownLenBox->GetValue().ToDouble(&outerFadeDownLen); mEffect->mOuterFadeUpLenBox->GetValue().ToDouble(&outerFadeUpLen); if (innerFadeDownLen < MIN_InnerFadeDownLen || innerFadeDownLen > MAX_InnerFadeDownLen || innerFadeUpLen < MIN_InnerFadeUpLen || innerFadeUpLen > MAX_InnerFadeUpLen || outerFadeDownLen < MIN_OuterFadeDownLen || outerFadeDownLen > MAX_OuterFadeDownLen || outerFadeUpLen < MIN_OuterFadeUpLen || outerFadeUpLen > MAX_OuterFadeUpLen || duckAmountDb < MIN_DuckAmountDb || duckAmountDb > MAX_DuckAmountDb) { // values are out of range, no preview available wxString message = wxString::Format(_("Preview not available")); int textWidth = 0, textHeight = 0; dc.GetTextExtent(message, &textWidth, &textHeight); dc.DrawText(message, (clientWidth - textWidth) / 2, (clientHeight - textHeight) / 2); ResetControlPoints(); } else { // draw preview dc.SetBrush(*wxTRANSPARENT_BRUSH); dc.SetPen(wxPen(theTheme.Colour(clrGraphLines), 3, wxSOLID)); wxPoint points[6]; points[0].x = 10; points[0].y = DUCK_AMOUNT_START; points[1].x = FADE_DOWN_START - (int)(outerFadeDownLen * FADE_SCALE); points[1].y = DUCK_AMOUNT_START; points[2].x = FADE_DOWN_START + (int)(innerFadeDownLen * FADE_SCALE); points[2].y = DUCK_AMOUNT_START - (int)(duckAmountDb * DUCK_AMOUNT_SCALE); points[3].x = FADE_UP_START - (int)(innerFadeUpLen * FADE_SCALE); points[3].y = DUCK_AMOUNT_START - (int)(duckAmountDb * DUCK_AMOUNT_SCALE); points[4].x = FADE_UP_START + (int)(outerFadeUpLen * FADE_SCALE); points[4].y = DUCK_AMOUNT_START; points[5].x = clientWidth - 10; points[5].y = DUCK_AMOUNT_START; dc.DrawLines(6, points); dc.SetPen(wxPen(*wxBLACK, 1, wxDOT)); AColor::Line(dc, FADE_DOWN_START, 10, FADE_DOWN_START, clientHeight - 10); AColor::Line(dc, FADE_UP_START, 10, FADE_UP_START, clientHeight - 10); dc.SetPen(AColor::envelopePen); dc.SetBrush(*wxWHITE_BRUSH); mControlPoints[outerFadeDown] = points[1]; mControlPoints[innerFadeDown] = points[2]; mControlPoints[innerFadeUp] = points[3]; mControlPoints[outerFadeUp] = points[4]; mControlPoints[duckAmount] = wxPoint( (points[2].x + points[3].x) / 2, points[2].y); for (int i = 0; i < AUTO_DUCK_PANEL_NUM_CONTROL_POINTS; i++) { EControlPoint cp = (EControlPoint)i; int digits; float value; if (cp == innerFadeDown) { value = innerFadeDownLen; digits = 2; } else if (cp == innerFadeUp) { value = innerFadeUpLen; digits = 2; } else if (cp == outerFadeDown) { value = outerFadeDownLen; digits = 2; } else if (cp == outerFadeUp) { value = outerFadeUpLen; digits = 2; } else { value = duckAmountDb; digits = 1; } wxString valueStr = Internat::ToDisplayString(value, digits); valueStr += wxT(" "); if (cp == duckAmount) /* i18n-hint: short form of 'decibels'.*/ valueStr += _("dB"); else /* i18n-hint: short form of 'seconds'.*/ valueStr += _("s"); int textWidth = 0, textHeight = 0; GetTextExtent(valueStr, &textWidth, &textHeight); int textPosX = mControlPoints[i].x - textWidth / 2; int textPosY = mControlPoints[i].y; if (cp == duckAmount || cp == outerFadeDown || cp == outerFadeUp) textPosY -= TEXT_DISTANCE + textHeight; else textPosY += TEXT_DISTANCE; dc.DrawText(valueStr, textPosX, textPosY); dc.DrawEllipse(mControlPoints[i].x - 3, mControlPoints[i].y - 3, 6, 6); } } // copy background buffer to paint dc wxPaintDC paintDC(this); paintDC.Blit(0, 0, clientWidth, clientHeight, &dc, 0, 0); // clean up: necessary to free resources on Windows dc.SetPen(wxNullPen); dc.SetBrush(wxNullBrush); dc.SetFont(wxNullFont); dc.SelectObject(wxNullBitmap); }
wxSize wxSlider::DoGetBestSize() const { wxSize size; int textwidth, textheight; int mintwidth, mintheight; int maxtwidth, maxtheight; textwidth = textheight = 0; mintwidth = mintheight = 0; maxtwidth = maxtheight = 0; if (GetWindowStyle() & wxSL_LABELS) { wxString text; // Get maximum text label width and height text.Printf( wxT("%d"), ValueInvertOrNot( m_rangeMin ) ); GetTextExtent(text, &mintwidth, &mintheight); text.Printf( wxT("%d"), ValueInvertOrNot( m_rangeMax ) ); GetTextExtent(text, &maxtwidth, &maxtheight); if (maxtheight > mintheight) textheight = maxtheight; else textheight = mintheight; if (maxtwidth > mintwidth) textwidth = maxtwidth; else textwidth = mintwidth; } if (GetWindowStyle() & wxSL_VERTICAL) { size.y = 150; if (GetWindowStyle() & wxSL_AUTOTICKS) size.x = wxSLIDER_DIMENSIONACROSS_WITHTICKMARKS; else size.x = wxSLIDER_DIMENSIONACROSS_ARROW; if (GetWindowStyle() & wxSL_LABELS) size.x += textwidth + wxSLIDER_BORDERTEXT; } else { size.x = 150; if (GetWindowStyle() & wxSL_AUTOTICKS) size.y = wxSLIDER_DIMENSIONACROSS_WITHTICKMARKS; else size.y = wxSLIDER_DIMENSIONACROSS_ARROW; if (GetWindowStyle() & wxSL_LABELS) { size.y += textheight + wxSLIDER_BORDERTEXT; size.x += (mintwidth / 2) + (maxtwidth / 2); } } return size; }
gxSize gxLightweightControl::GetTextSize(gxString &aText) { int w, h; GetTextExtent(aText, &w, &h); return gxSize(w, h); }
static BOOL get_dsp_app (void) { int i; DSPITEM* item; char section [10]; int distance_x = START_X; int distance_y = START_Y; SIZE size; if (GetIntValueFromEtcFile (APP_INFO_FILE, "desktop", "app_nr", &icon_info.nr_apps) != ETC_OK) return FALSE; if (icon_info.nr_apps <= 0) return FALSE; if (GetValueFromEtcFile (APP_INFO_FILE, "desktop", "bg_pic", icon_info.bg_path, PATH_MAX) != ETC_OK) return FALSE; if ((icon_info.app_items = (DSPITEM*)calloc (icon_info.nr_apps, sizeof (DSPITEM))) == NULL) { return FALSE; } item = icon_info.app_items; for (i = 0; i < icon_info.nr_apps; i++, item++) { sprintf (section, "dsp-app%d", i); if (GetValueFromEtcFile (APP_INFO_FILE, section, "path", item->path, PATH_MAX) != ETC_OK) goto error; if (GetValueFromEtcFile (APP_INFO_FILE, section, "name", item->name, NAME_MAX) != ETC_OK) goto error; if (GetValueFromEtcFile (APP_INFO_FILE, section, "layer", item->layer, LEN_LAYER_NAME) != ETC_OK) goto error; if (GetValueFromEtcFile (APP_INFO_FILE, section, "pictrue", item->bmp_path, PATH_MAX + NAME_MAX) != ETC_OK) goto error; if (LoadBitmap (HDC_SCREEN, &item->bmp, item->bmp_path) != ERR_BMP_OK) { fprintf (stderr, "desktop load resource:%s error. \n", item->bmp_path); goto error; } item->cdpath = TRUE; item->hot_spot_rc.left = distance_x; item->hot_spot_rc.right = item->hot_spot_rc.left + DEF_WIDTH; item->hot_spot_rc.top = distance_y; item->hot_spot_rc.bottom = item->hot_spot_rc.top + DEF_HEIGHT; GetTextExtent(HDC_SCREEN, item->name, -1, &size); item->text_rc.top = item->hot_spot_rc.bottom; item->text_rc.left = (item->hot_spot_rc.right + item->hot_spot_rc.left - size.cx)/2; item->text_rc.bottom = item->text_rc.top + size.cy; item->text_rc.right = item->text_rc.left + size.cx; distance_y += SPACE + RECTH(item->hot_spot_rc); if(distance_y + DEF_HEIGHT >= g_rcDesktop.bottom) { distance_y = START_Y; distance_x += SPACE + DEF_WIDTH; } } return TRUE; error: free_dsp_app (); return FALSE; }
void wxRadioBox::DoSetSize(int x, int y, int width, int height, int sizeFlags) { int i; wxRadioButton *current; // define the position int x_current, y_current; int x_offset, y_offset; int widthOld, heightOld; GetSize( &widthOld, &heightOld ); GetPosition( &x_current, &y_current ); x_offset = x; y_offset = y; if (!(sizeFlags & wxSIZE_ALLOW_MINUS_ONE)) { if (x == wxDefaultCoord) x_offset = x_current; if (y == wxDefaultCoord) y_offset = y_current; } // define size int charWidth, charHeight; int maxWidth, maxHeight; int eachWidth[128], eachHeight[128]; int totWidth, totHeight; GetTextExtent( wxT("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), &charWidth, &charHeight ); charWidth /= 52; maxWidth = -1; maxHeight = -1; wxSize bestSizeRadio ; if ( m_radioButtonCycle ) bestSizeRadio = m_radioButtonCycle->GetBestSize(); for (unsigned int i = 0 ; i < m_noItems; i++) { GetTextExtent(GetString(i), &eachWidth[i], &eachHeight[i] ); eachWidth[i] = eachWidth[i] + RADIO_SIZE; eachHeight[i] = wxMax( eachHeight[i], bestSizeRadio.y ); if (maxWidth < eachWidth[i]) maxWidth = eachWidth[i]; if (maxHeight < eachHeight[i]) maxHeight = eachHeight[i]; } // according to HIG (official space - 3 Pixels Diff between Frame and Layout size) int space = 3; if ( GetWindowVariant() == wxWINDOW_VARIANT_MINI ) space = 2; totHeight = GetRowCount() * maxHeight + (GetRowCount() - 1) * space; totWidth = GetColumnCount() * (maxWidth + charWidth); wxSize sz = DoGetSizeFromClientSize( wxSize( totWidth, totHeight ) ) ; // change the width / height only when specified if ( width == wxDefaultCoord ) { if ( sizeFlags & wxSIZE_AUTO_WIDTH ) width = sz.x; else width = widthOld; } if ( height == wxDefaultCoord ) { if ( sizeFlags & wxSIZE_AUTO_HEIGHT ) height = sz.y; else height = heightOld; } wxControl::DoSetSize( x_offset, y_offset, width, height, wxSIZE_AUTO ); // arrange radio buttons int x_start, y_start; x_start = ( width - sz.x ) / 2; y_start = ( height - sz.y ) / 2; x_offset = x_start; y_offset = y_start; current = m_radioButtonCycle; for (i = 0 ; i < (int)m_noItems; i++) { // not to do for the zero button! if ((i > 0) && ((i % GetMajorDim()) == 0)) { if (m_windowStyle & wxRA_SPECIFY_ROWS) { x_offset += maxWidth + charWidth; y_offset = y_start; } else { x_offset = x_start; y_offset += maxHeight + space; } } current->SetSize( x_offset, y_offset, eachWidth[i], eachHeight[i] ); current = current->NextInCycle(); if (m_windowStyle & wxRA_SPECIFY_ROWS) y_offset += maxHeight + space; else x_offset += maxWidth + charWidth; } }
wxSize wxRadioBox::DoGetBestSize() const { int charWidth, charHeight; int maxWidth, maxHeight; int eachWidth, eachHeight; int totWidth, totHeight; wxFont font = GetFont(); // GetParent()->GetFont() GetTextExtent( wxT("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), &charWidth, &charHeight, NULL, NULL, &font ); charWidth /= 52; maxWidth = -1; maxHeight = -1; wxSize bestSizeRadio ; if ( m_radioButtonCycle ) bestSizeRadio = m_radioButtonCycle->GetBestSize(); #if defined(__INTEL_COMPILER) && 1 /* VDM auto patch */ # pragma ivdep # pragma swp # pragma unroll # pragma prefetch # if 0 # pragma simd noassert # endif #endif /* VDM auto patch */ for (unsigned int i = 0 ; i < m_noItems; i++) { GetTextExtent(GetString(i), &eachWidth, &eachHeight, NULL, NULL, &font ); eachWidth = (eachWidth + RADIO_SIZE); eachHeight = wxMax(eachHeight, bestSizeRadio.y ); if (maxWidth < eachWidth) maxWidth = eachWidth; if (maxHeight < eachHeight) maxHeight = eachHeight; } // according to HIG (official space - 3 Pixels Diff between Frame and Layout size) int space = 3; if ( GetWindowVariant() == wxWINDOW_VARIANT_MINI ) space = 2; totHeight = GetRowCount() * maxHeight + (GetRowCount() - 1) * space; totWidth = GetColumnCount() * (maxWidth + charWidth); wxSize sz = DoGetSizeFromClientSize( wxSize( totWidth, totHeight ) ); totWidth = sz.x; totHeight = sz.y; // optimum size is an additional 5 pt border to all sides totWidth += 10; totHeight += 10; // handle radio box title as well GetTextExtent( GetLabel(), &eachWidth, NULL ); eachWidth = (int)(eachWidth + RADIO_SIZE) + 3 * charWidth; if (totWidth < eachWidth) totWidth = eachWidth; return wxSize( totWidth, totHeight ); }
DriftToolWin::DriftToolWin() : wxFrame(pFrame, wxID_ANY, _("Drift Align"), wxDefaultPosition, wxDefaultSize, wxCAPTION|wxCLOSE_BOX|wxMINIMIZE_BOX|wxSYSTEM_MENU|wxTAB_TRAVERSAL|wxFRAME_FLOAT_ON_PARENT|wxFRAME_NO_TASKBAR), m_need_end_dec_drift(false), m_slewing(false) { SetBackgroundColour(wxColor(0xcccccc)); SetSizeHints(wxDefaultSize, wxDefaultSize); // a vertical sizer holding everything wxBoxSizer *topSizer = new wxBoxSizer(wxVERTICAL); // a horizontal box sizer for the bitmap and the instructions wxBoxSizer *instrSizer = new wxBoxSizer(wxHORIZONTAL); # include "icons/AzArrow.xpm" m_azArrowBmp = new wxBitmap(AzArrow); # include "icons/AltArrow.xpm" m_altArrowBmp = new wxBitmap(AltArrow); m_bmp = new wxStaticBitmap(this, wxID_ANY, *m_azArrowBmp, wxDefaultPosition, wxSize(80, 100)); instrSizer->Add(m_bmp, 0, wxALIGN_CENTER_VERTICAL|wxFIXED_MINSIZE, 5); m_instructions = new wxStaticText(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(400,120), wxALIGN_LEFT|wxST_NO_AUTORESIZE); #ifdef __WXOSX__ m_instructions->SetFont(*wxSMALL_FONT); #endif m_instructions->Wrap(-1); instrSizer->Add(m_instructions, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5); topSizer->Add(instrSizer); // static box sizer holding the scope pointing controls wxStaticBoxSizer *sbSizer = new wxStaticBoxSizer(new wxStaticBox(this, wxID_ANY, _("Scope Pointing")), wxVERTICAL); // a grid box sizer for laying out scope pointing the controls wxGridBagSizer *gbSizer = new wxGridBagSizer(0, 0); gbSizer->SetFlexibleDirection(wxBOTH); gbSizer->SetNonFlexibleGrowMode(wxFLEX_GROWMODE_SPECIFIED); wxStaticText *txt; txt = new wxStaticText(this, wxID_ANY, _("Meridian Offset (deg)"), wxDefaultPosition, wxDefaultSize, 0); txt->Wrap(-1); gbSizer->Add(txt, wxGBPosition(0, 1), wxGBSpan(1, 1), wxALL, 5); txt = new wxStaticText(this, wxID_ANY, _("Declination (deg)"), wxDefaultPosition, wxDefaultSize, 0); txt->Wrap(-1); gbSizer->Add(txt, wxGBPosition(0, 2), wxGBSpan(1, 1), wxALL, 5); txt = new wxStaticText(this, wxID_ANY, _("Current"), wxDefaultPosition, wxDefaultSize, 0); txt->Wrap(-1); gbSizer->Add(txt, wxGBPosition(1, 0), wxGBSpan(1, 1), wxALL, 5); m_raCurrent = new wxTextCtrl(this, wxID_ANY, _T("--"), wxDefaultPosition, wxDefaultSize, wxTE_READONLY); gbSizer->Add(m_raCurrent, wxGBPosition(1, 1), wxGBSpan(1, 1), wxEXPAND | wxALL, 5); m_decCurrent = new wxTextCtrl(this, wxID_ANY, _T("--"), wxDefaultPosition, wxDefaultSize, wxTE_READONLY); gbSizer->Add(m_decCurrent, wxGBPosition(1, 2), wxGBSpan(1, 1), wxEXPAND | wxALL, 5); txt = new wxStaticText(this, wxID_ANY, _("Slew To"), wxDefaultPosition, wxDefaultSize, 0); txt->Wrap(-1); gbSizer->Add(txt, wxGBPosition(2, 0), wxGBSpan(1, 1), wxALL, 5); m_raSlew = new wxSpinCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, -90, 90); gbSizer->Add(m_raSlew, wxGBPosition(2, 1), wxGBSpan(1, 1), wxEXPAND | wxALL, 5); m_decSlew = new wxSpinCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, -90, 90); gbSizer->Add(m_decSlew, wxGBPosition(2, 2), wxGBSpan(1, 1), wxEXPAND | wxALL, 5); m_slew = new wxButton(this, ID_SLEW, _("Slew"), wxDefaultPosition, wxDefaultSize, 0); m_slew->SetToolTip(_("Click to slew to given coordinates.")); gbSizer->Add(m_slew, wxGBPosition(2, 3), wxGBSpan(1, 1), wxALL, 5); wxString label = _("Save"); wxSize sz(GetTextExtent(label)); sz.SetHeight(-1); sz.IncBy(16, 0); m_saveCoords = new wxButton(this, ID_SAVE, label, wxDefaultPosition, sz, 0); m_saveCoords->SetToolTip(_("Click to save these coordinates as the default location for this axis adjustment.")); gbSizer->Add(m_saveCoords, wxGBPosition(2, 4), wxGBSpan(1, 1), wxTOP | wxBOTTOM | wxRIGHT, 5); // add grid bag sizer to static sizer sbSizer->Add(gbSizer, 1, wxALIGN_CENTER, 5); // add static sizer to top-level sizer topSizer->Add(sbSizer, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5); // add some padding below the static sizer topSizer->Add(0, 3, 0, wxEXPAND, 3); m_notesLabel = new wxStaticText(this, wxID_ANY, _("Altitude adjustment notes"), wxDefaultPosition, wxDefaultSize, 0); m_notesLabel->Wrap(-1); topSizer->Add(m_notesLabel, 0, wxEXPAND|wxTOP|wxLEFT, 8); m_notes = new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(-1, 54), wxTE_MULTILINE); pFrame->RegisterTextCtrl(m_notes); topSizer->Add(m_notes, 0, wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM, 5); m_notes->Bind(wxEVT_COMMAND_TEXT_UPDATED, &DriftToolWin::OnNotesText, this); // horizontal sizer for the buttons wxBoxSizer *hSizer = new wxBoxSizer(wxHORIZONTAL); // proportional pad on left of Drift button hSizer->Add(0, 0, 2, wxEXPAND, 5); m_drift = new wxButton(this, ID_DRIFT, _("Drift"), wxDefaultPosition, wxDefaultSize, 0); hSizer->Add(m_drift, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); // proportional pad on right of Drift button hSizer->Add(0, 0, 1, wxEXPAND, 5); m_adjust = new wxButton(this, ID_ADJUST, _("Adjust"), wxDefaultPosition, wxDefaultSize, 0); hSizer->Add(m_adjust, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); // proportional pad on right of Align button hSizer->Add(0, 0, 2, wxEXPAND, 5); m_phaseBtn = new wxButton(this, ID_PHASE, wxT("???"), wxDefaultPosition, wxDefaultSize, 0); hSizer->Add(m_phaseBtn, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5); // add button sizer to top level sizer topSizer->Add(hSizer, 1, wxEXPAND|wxALL, 5); SetSizer(topSizer); m_statusBar = CreateStatusBar(1, wxST_SIZEGRIP, wxID_ANY); Layout(); topSizer->Fit(this); int xpos = pConfig->Global.GetInt("/DriftTool/pos.x", -1); int ypos = pConfig->Global.GetInt("/DriftTool/pos.y", -1); MyFrame::PlaceWindowOnScreen(this, xpos, ypos); // can mount slew? m_can_slew = pPointingSource && pPointingSource->CanSlew(); // get site lat/long from scope double lat, lon; m_siteLatLong.Invalidate(); if (pPointingSource && !pPointingSource->GetSiteLatLong(&lat, &lon)) { m_siteLatLong.SetXY(lat, lon); } m_timer = NULL; if (m_can_slew || (pPointingSource && pPointingSource->CanReportPosition())) { enum { SCOPE_POS_POLL_MS = 1500 }; m_timer = new wxTimer(this, ID_TIMER); m_timer->Start(SCOPE_POS_POLL_MS, false /* continuous */); } // make sure graph window is showing if (!pFrame->pGraphLog->IsShown()) { wxCommandEvent evt; evt.SetInt(1); // "Checked" pFrame->OnGraph(evt); } // graph must be showing RA/Dec m_save_graph_mode = pFrame->pGraphLog->SetMode(GraphLogClientWindow::MODE_RADEC); // resize graph scale m_save_graph_length = pFrame->pGraphLog->GetLength(); pFrame->pGraphLog->SetLength(pConfig->Global.GetInt("/DriftTool/GraphLength", GraphLogWindow::DefaultMaxLength)); m_save_graph_height = pFrame->pGraphLog->GetHeight(); pFrame->pGraphLog->SetHeight(pConfig->Global.GetInt("/DriftTool/GraphHeight", GraphLogWindow::DefaultMaxHeight)); pFrame->pGraphLog->Refresh(); // we do not want sticky lock position enabled m_save_lock_pos_is_sticky = pFrame->pGuider->LockPosIsSticky(); pFrame->pGuider->SetLockPosIsSticky(false); pFrame->tools_menu->FindItem(EEGG_STICKY_LOCK)->Check(false); m_save_use_subframes = pCamera->UseSubframes; m_phase = PHASE_ADJUST_AZ; m_mode = MODE_IDLE; UpdatePhaseState(); UpdateModeState(); }
void wxRadioBox::DoSetSize(int x, int y, int width, int height, int sizeFlags) { int i; wxRadioButton *current; // define the position int x_current, y_current; int x_offset, y_offset; int widthOld, heightOld; GetSize( &widthOld, &heightOld ); GetPosition( &x_current, &y_current ); x_offset = x; y_offset = y; if (!(sizeFlags & wxSIZE_ALLOW_MINUS_ONE)) { if (x == wxDefaultCoord) x_offset = x_current; if (y == wxDefaultCoord) y_offset = y_current; } // define size int charWidth, charHeight; int maxWidth, maxHeight; int eachWidth[128], eachHeight[128]; int totWidth, totHeight; GetTextExtent( wxT("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), &charWidth, &charHeight ); charWidth /= 52; maxWidth = -1; maxHeight = -1; wxSize bestSizeRadio ; if ( m_radioButtonCycle ) bestSizeRadio = m_radioButtonCycle->GetBestSize(); #if defined(__INTEL_COMPILER) && 1 /* VDM auto patch */ # pragma ivdep # pragma swp # pragma unroll # pragma prefetch # if 0 # pragma simd noassert # endif #endif /* VDM auto patch */ for (unsigned int i = 0 ; i < m_noItems; i++) { GetTextExtent(GetString(i), &eachWidth[i], &eachHeight[i] ); eachWidth[i] = eachWidth[i] + RADIO_SIZE; eachHeight[i] = wxMax( eachHeight[i], bestSizeRadio.y ); if (maxWidth < eachWidth[i]) maxWidth = eachWidth[i]; if (maxHeight < eachHeight[i]) maxHeight = eachHeight[i]; } // according to HIG (official space - 3 Pixels Diff between Frame and Layout size) int space = 3; if ( GetWindowVariant() == wxWINDOW_VARIANT_MINI ) space = 2; totHeight = GetRowCount() * maxHeight + (GetRowCount() - 1) * space; totWidth = GetColumnCount() * (maxWidth + charWidth); // Determine the full size in case we need to use it as fallback. wxSize sz; if ( (width == wxDefaultCoord && (sizeFlags & wxSIZE_AUTO_WIDTH)) || (height == wxDefaultCoord && (sizeFlags & wxSIZE_AUTO_HEIGHT)) ) { sz = DoGetSizeFromClientSize( wxSize( totWidth, totHeight ) ) ; } // change the width / height only when specified if ( width == wxDefaultCoord ) { if ( sizeFlags & wxSIZE_AUTO_WIDTH ) width = sz.x; else width = widthOld; } if ( height == wxDefaultCoord ) { if ( sizeFlags & wxSIZE_AUTO_HEIGHT ) height = sz.y; else height = heightOld; } wxControl::DoSetSize( x_offset, y_offset, width, height, wxSIZE_AUTO ); // But now recompute the full size again because it could have changed. // This notably happens if the previous full size was too small to fully // fit the box margins. sz = DoGetSizeFromClientSize( wxSize( totWidth, totHeight ) ) ; // arrange radio buttons int x_start, y_start; x_start = ( width - sz.x ) / 2; y_start = ( height - sz.y ) / 2; x_offset = x_start; y_offset = y_start; current = m_radioButtonCycle; #if defined(__INTEL_COMPILER) && 1 /* VDM auto patch */ # pragma ivdep # pragma swp # pragma unroll # pragma prefetch # if 0 # pragma simd noassert # endif #endif /* VDM auto patch */ for (i = 0 ; i < (int)m_noItems; i++) { // not to do for the zero button! if ((i > 0) && ((i % GetMajorDim()) == 0)) { if (m_windowStyle & wxRA_SPECIFY_ROWS) { x_offset += maxWidth + charWidth; y_offset = y_start; } else { x_offset = x_start; y_offset += maxHeight + space; } } current->SetSize( x_offset, y_offset, eachWidth[i], eachHeight[i] ); current = current->NextInCycle(); if (m_windowStyle & wxRA_SPECIFY_ROWS) y_offset += maxHeight + space; else x_offset += maxWidth + charWidth; } }
// Get text size wxSize ExtTextCtrl::GetTextSize() const { wxString text(this->GetValue()); int widthTextMax = 0, heightTextTotal = 0, heightLineDefault = 0; int heightLine = 0; bool lastWasAmpersand = false; wxString curLine; for (const wxChar* pc = text; ; pc++) { if (*pc == '\n' || *pc == '\0') { if ( !curLine ) { // we can't use GetTextExtent - it will return 0 for both width // and height and an empty line should count in height // calculation if (!heightLineDefault ) heightLineDefault = heightLine; if (!heightLineDefault) GetTextExtent(wxT("W"), 0, &heightLineDefault); heightTextTotal += heightLineDefault; } else { int widthLine; GetTextExtent(curLine, &widthLine, &heightLine); if (widthLine > widthTextMax) widthTextMax = widthLine; heightTextTotal += heightLine; } if (*pc == '\n') { curLine.Empty(); } else { // the end of string break; } } else { // we shouldn't take into account the '&' which just introduces the // mnemonic characters and so are not shown on the screen -- except // when it is preceded by another '&' in which case it stands for a // literal ampersand if (*pc == '&') { if (!lastWasAmpersand) { lastWasAmpersand = true; // skip the statement adding pc to curLine below continue; } // it is a literal ampersand lastWasAmpersand = false; } curLine += *pc; } } return wxSize(widthTextMax, heightTextTotal); }
void wxSlider::MacUpdateDimensions() { // actually in the current systems this should never be possible, but later reparenting // may become a reality if ( (ControlHandle) m_macControl == NULL ) return ; if ( GetParent() == NULL ) return ; WindowRef rootwindow = (WindowRef) MacGetRootWindow() ; if ( rootwindow == NULL ) return ; int xborder, yborder; int minValWidth, maxValWidth, textwidth, textheight; int sliderBreadth; xborder = yborder = 0; if (GetWindowStyle() & wxSL_LABELS) { wxString text; int ht; // Get maximum text label width and height text.Printf(wxT("%d"), m_rangeMin); GetTextExtent(text, &minValWidth, &textheight); text.Printf(wxT("%d"), m_rangeMax); GetTextExtent(text, &maxValWidth, &ht); if(ht > textheight) { textheight = ht; } textwidth = (minValWidth > maxValWidth ? minValWidth : maxValWidth); xborder = textwidth + wxSLIDER_BORDERTEXT; yborder = textheight + wxSLIDER_BORDERTEXT; // Get slider breadth if(GetWindowStyle() & wxSL_AUTOTICKS) { sliderBreadth = wxSLIDER_DIMENSIONACROSS_WITHTICKMARKS; } else { sliderBreadth = wxSLIDER_DIMENSIONACROSS_ARROW; } if(GetWindowStyle() & wxSL_VERTICAL) { m_macMinimumStatic->Move(sliderBreadth + wxSLIDER_BORDERTEXT, m_height - yborder - textheight); m_macMaximumStatic->Move(sliderBreadth + wxSLIDER_BORDERTEXT, 0); m_macValueStatic->Move(0, m_height - textheight); } else { m_macMinimumStatic->Move(0, sliderBreadth + wxSLIDER_BORDERTEXT); m_macMaximumStatic->Move(m_width - xborder - maxValWidth / 2, sliderBreadth + wxSLIDER_BORDERTEXT); m_macValueStatic->Move(m_width - textwidth, 0); } } Rect oldBounds ; GetControlBounds( (ControlHandle) m_macControl , &oldBounds ) ; int new_x = m_x + MacGetLeftBorderSize() + m_macHorizontalBorder ; int new_y = m_y + MacGetTopBorderSize() + m_macVerticalBorder ; int new_width = m_width - MacGetLeftBorderSize() - MacGetRightBorderSize() - 2 * m_macHorizontalBorder - xborder ; int new_height = m_height - MacGetTopBorderSize() - MacGetBottomBorderSize() - 2 * m_macVerticalBorder - yborder ; GetParent()->MacWindowToRootWindow( & new_x , & new_y ) ; bool doMove = new_x != oldBounds.left || new_y != oldBounds.top ; bool doResize = ( oldBounds.right - oldBounds.left ) != new_width || (oldBounds.bottom - oldBounds.top ) != new_height ; if ( doMove || doResize ) { InvalWindowRect( rootwindow, &oldBounds ) ; if ( doMove ) { UMAMoveControl( (ControlHandle) m_macControl , new_x , new_y ) ; } if ( doResize ) { UMASizeControl( (ControlHandle) m_macControl , new_width , new_height ) ; } } }
wxSize wxSpeedButton::DoGetBestSize(void) { int i,n; int w,h; int bn; int bw, bh; int gw, gh; int lw, lh; // max size of the bitmaps bw = 0; bh = 0; GetGlyphSize(mGlyphUp, gw, gh); if (gw > bw) bw = gw; if (gh > bh) bh = gh; GetGlyphSize(mGlyphDown, gw, gh); if (gw > bw) bw = gw; if (gh > bh) bh = gh; GetGlyphSize(mGlyphDisabled, gw, gh); if (gw > bw) bw = gw; if (gh > bh) bh = gh; mGlyphSize.Set(bw, bh); // max size of the t n = inStyle | wxCLIP_CHILDREN;ext label lw = 0; lh = 0; if (! GetLabel().IsEmpty()) GetTextExtent(GetLabel(), &lw, &lh); mLabelSize.Set(lw, lh); // border size is a magiv number, imperically determined using the // wxNativeRenderer to draw the button bn = 2; // best size depends upon the alignment i = GetWindowStyleFlag(); if (((i & wxBU_LEFT) != 0) || ((i & wxBU_RIGHT) != 0)) { w = bn + mMargin + bw + mMargin + lw + mMargin + bn; n = (bh > lh) ? bh : lh; h = bn + mMargin + n + mMargin + bn; } else if (((i & wxBU_TOP) != 0) || ((i & wxBU_BOTTOM) != 0)) { n = (bw > lw) ? bw : lw; w = bn + mMargin + n + mMargin + bn; h = bn + mMargin + bh + mMargin + lh + mMargin + bn; } else { // assume BU_LEFT w = bn + mMargin + bw + mMargin + lw + mMargin + bn; n = (bh > lh) ? bh : lh; h = bn + mMargin + n + mMargin + bn; }; mBestSize.Set(w, h); // done return mBestSize; }
int wxTreeListCtrl::WidthFor(const wxString& text) const { return GetTextExtent(text).x; }
CSimpleGUIPanel::CSimpleGUIPanel(wxWindow* parent) : wxPanel(parent, -1, wxDefaultPosition, wxDefaultSize, wxCLIP_CHILDREN | wxBORDER_NONE) { wxLogTrace(wxT("Function Start/End"), wxT("CSimpleGUIPanel::CSimpleGUIPanel - Overloaded Constructor Function Begin")); CSkinAdvanced* pSkinAdvanced = wxGetApp().GetSkinManager()->GetAdvanced(); wxASSERT(pSkinAdvanced); wxASSERT(wxDynamicCast(pSkinAdvanced, CSkinAdvanced)); m_taskPanel = NULL; m_projPanel = NULL; m_oldWorkCount = 0; m_bNewNoticeAlert = false; m_bNoticesButtonIsRed = false; m_irefreshCount = 0; checkForNewNoticesTimer = new wxTimer(this, ID_SIMPLEMESSAGECHECKTIMER); checkForNewNoticesTimer->Start(5000); dlgOpen = false; m_sSuspendString = _("Suspend"); m_sResumeString = _("Resume"); m_sSuspendButtonToolTip = _("Suspend Computing"); m_sResumeButtonToolTip = _("Resume Computing"); m_taskPanel = new CSimpleTaskPanel(this); m_projPanel = new CSimpleProjectPanel(this); // Box Sizer mainSizer = new wxBoxSizer(wxVERTICAL); mainSizer->AddSpacer(ADJUSTFORYDPI(68)); mainSizer->Add(m_taskPanel, 1, wxLEFT | wxRIGHT | wxEXPAND | wxALIGN_CENTER, SIDEMARGINS); mainSizer->AddSpacer(ADJUSTFORYDPI(8)); mainSizer->Add(m_projPanel, 0, wxLEFT | wxRIGHT | wxEXPAND | wxALIGN_CENTER, SIDEMARGINS); mainSizer->AddSpacer(ADJUSTFORYDPI(8)); wxBoxSizer* buttonsSizer; buttonsSizer = new wxBoxSizer( wxHORIZONTAL ); m_NoticesButton = new wxButton( this, ID_SGNOTICESBUTTON, _("Notices"), wxDefaultPosition, wxDefaultSize, 0 ); m_NoticesButton->SetToolTip( _("Open a window to view notices from projects or BOINC")); buttonsSizer->Add( m_NoticesButton, 0, wxEXPAND | wxALIGN_LEFT, 0 ); buttonsSizer->AddStretchSpacer(); int suspendWidth, resumeWidth, y; GetTextExtent(m_sSuspendString, &suspendWidth, &y); GetTextExtent(m_sResumeString, &resumeWidth, &y); m_bIsSuspended = suspendWidth > resumeWidth; m_SuspendResumeButton = new wxButton( this, ID_SGSUSPENDRESUMEBUTTON, m_bIsSuspended ? m_sSuspendString : m_sResumeString, wxDefaultPosition, wxDefaultSize, 0 ); m_SuspendResumeButton->SetToolTip(wxEmptyString); buttonsSizer->Add( m_SuspendResumeButton, 0, wxEXPAND | wxALIGN_RIGHT, 0 ); buttonsSizer->AddStretchSpacer(); m_HelpButton = new wxButton( this, ID_SIMPLE_HELP, _("Help"), wxDefaultPosition, wxDefaultSize, 0 ); buttonsSizer->Add( m_HelpButton, 0, wxEXPAND | wxALIGN_RIGHT, 0 ); wxString helpTip; helpTip.Printf(_("Get help with %s"), pSkinAdvanced->GetApplicationShortName().c_str()); m_HelpButton->SetToolTip(helpTip); mainSizer->Add( buttonsSizer, 0, wxLEFT | wxRIGHT | wxEXPAND, 2 * SIDEMARGINS ); mainSizer->AddSpacer(ADJUSTFORYDPI(10)); SetSizer(mainSizer); Layout(); mainSizer->Fit(GetParent()); SetBackgroundBitmap(); #ifdef __WXMAC__ // Tell accessibility aids to ignore this panel (but not its contents) HIObjectSetAccessibilityIgnored((HIObjectRef)GetHandle(), true); if (compareOSVersionTo(10, 7) >= 0) { m_iRedRingRadius = 4; } else { m_iRedRingRadius = 12; } #endif m_SuspendResumeButton->Disable(); OnFrameRender(); wxLogTrace(wxT("Function Start/End"), wxT("CSimpleGUIPanel::CSimpleGUIPanel - Overloaded Constructor Function End")); }
void GribRequestSetting::InitRequestConfig() { wxFileConfig *pConf = GetOCPNConfigObject(); if(pConf) { pConf->SetPath ( _T( "/PlugIns/GRIB" ) ); wxString l; int m; pConf->Read ( _T( "MailRequestConfig" ), &m_RequestConfigBase, _T( "000220XX........0" ) ); pConf->Read ( _T( "MailSenderAddress" ), &l, _T("") ); m_pSenderAddress->ChangeValue( l ); pConf->Read ( _T( "MailRequestAddresses" ), &m_MailToAddresses, _T("[email protected];[email protected]") ); pConf->Read ( _T( "ZyGribLogin" ), &l, _T("") ); m_pLogin->ChangeValue( l ); pConf->Read ( _T( "ZyGribCode" ), &l, _T("") ); m_pCode->ChangeValue( l ); pConf->Read ( _T( "SendMailMethod" ), &m_SendMethod, 0 ); pConf->Read ( _T( "MovingGribSpeed" ), &m, 0 ); m_sMovingSpeed->SetValue( m ); pConf->Read ( _T( "MovingGribCourse" ), &m, 0 ); m_sMovingCourse->SetValue( m ); m_cManualZoneSel->SetValue( m_SavedZoneSelMode != AUTO_SELECTION ); //has been read in GriUbICtrlBar dialog implementation or updated previously m_cUseSavedZone->SetValue( m_SavedZoneSelMode == SAVED_SELECTION ); fgZoneCoordinatesSizer->ShowItems( m_SavedZoneSelMode != AUTO_SELECTION ); m_cUseSavedZone->Show( m_SavedZoneSelMode != AUTO_SELECTION ); if( m_cManualZoneSel->GetValue() ) { pConf->Read ( _T( "RequestZoneMaxLat" ), &m, 0 ); m_spMaxLat->SetValue( m ); pConf->Read ( _T( "RequestZoneMinLat" ), &m, 0 ); m_spMinLat->SetValue( m ); pConf->Read ( _T( "RequestZoneMaxLon" ), &m, 0 ); m_spMaxLon->SetValue( m ); pConf->Read ( _T( "RequestZoneMinLon" ), &m, 0 ); m_spMinLon->SetValue( m ); SetCoordinatesText(); } //if GriDataConfig has been corrupted , take the standard one to fix a crash if( m_RequestConfigBase.Len() != wxString (_T( "000220XX.............." ) ).Len() ) m_RequestConfigBase = _T( "000220XX.............." ); } //populate model, mail to, waves model choices wxString s1[] = {_T("GFS"),_T("COAMPS"),_T("RTOFS")}; for( unsigned int i= 0; i<(sizeof(s1) / sizeof(wxString));i++) m_pModel->Append( s1[i] ); wxString s2[] = {_T("Saildocs"),_T("zyGrib")}; for( unsigned int i= 0; i<(sizeof(s2) / sizeof(wxString));i++) m_pMailTo->Append( s2[i] ); wxString s3[] = {_T("WW3-GLOBAL"),_T("WW3-MEDIT")}; for( unsigned int i= 0; i<(sizeof(s3) / sizeof(wxString));i++) m_pWModel->Append( s3[i] ); m_rButtonYes->SetLabel(_("Send")); m_rButtonApply->SetLabel(_("Save")); m_tResUnit->SetLabel(wxString::Format( _T("\u00B0"))); m_sCourseUnit->SetLabel(wxString::Format( _T("\u00B0"))); //Set wxSpinCtrl sizing int w,h; GetTextExtent( _T("-360"), &w, &h, 0, 0, OCPNGetFont(_("Dialog"), 10)); // optimal text control size w += 30; h += 4; m_sMovingSpeed->SetMinSize( wxSize(w, h) ); m_sMovingCourse->SetMinSize( wxSize(w, h) ); m_spMaxLat->SetMinSize( wxSize(w, h) ); m_spMinLat->SetMinSize( wxSize(w, h) ); m_spMaxLon->SetMinSize( wxSize(w, h) ); m_spMinLon->SetMinSize( wxSize(w, h) ); //add tooltips m_pSenderAddress->SetToolTip(_("Address used to send request eMail. (Mandatory for LINUX)")); m_pLogin->SetToolTip(_("This is your zyGrib's forum access Login")); m_pCode->SetToolTip(_("Get this Code in zyGrib's forum ( This is not your password! )")); m_sMovingSpeed->SetToolTip(_("Enter your forescasted Speed (in Knots)")); m_sMovingCourse->SetToolTip(_("Enter your forecasted Course")); long i,j,k; ( (wxString) m_RequestConfigBase.GetChar(0) ).ToLong( &i ); //MailTo m_pMailTo->SetSelection(i); ( (wxString) m_RequestConfigBase.GetChar(1) ).ToLong( &i ); //Model m_pModel->SetSelection(i); m_cMovingGribEnabled->SetValue(m_RequestConfigBase.GetChar(16) == 'X' );//Moving Grib ( (wxString) m_RequestConfigBase.GetChar(2) ).ToLong( &i ); //Resolution ( (wxString) m_RequestConfigBase.GetChar(3) ).ToLong( &j ); //interval ( (wxString) m_RequestConfigBase.GetChar(4) ).ToLong( &k, 16 ); //Time Range k--; // range max = 2 to 16 stored in hexa from 1 to f #ifdef __WXMSW__ //show / hide sender elemants as necessary m_pSenderSizer->ShowItems(false); #else if(m_SendMethod == 0 ) m_pSenderSizer->ShowItems(false); else m_pSenderSizer->ShowItems(true); //possibility to use "sendmail" method with Linux #endif m_tMouseEventTimer.Connect(wxEVT_TIMER, wxTimerEventHandler( GribRequestSetting::OnMouseEventTimer ), NULL, this); m_RenderZoneOverlay = 0; ApplyRequestConfig( i, j ,k); ( (wxString) m_RequestConfigBase.GetChar(5) ).ToLong( &j ); //Waves model m_pWModel->SetSelection( j ); m_pWind->Enable( false ); //always selected if available m_pPress->Enable( false ); DimeWindow( this ); //aplly global colours scheme m_AllowSend = true; m_MailImage->SetValue( WriteMail() ); }
void wxSlider::DoSetSize(int x, int y, int w, int h, int sizeFlags) { int yborder = 0; int minValWidth, maxValWidth, textheight; int sliderBreadth; int width = w; if (GetWindowStyle() & wxSL_LABELS) { wxString text; int ht, valValWidth; // Get maximum text label width and height text.Printf(wxT("%d"), ValueInvertOrNot( m_rangeMin ) ); GetTextExtent(text, &minValWidth, &textheight); text.Printf(wxT("%d"), ValueInvertOrNot( m_rangeMax ) ); GetTextExtent(text, &maxValWidth, &ht); if (ht > textheight) textheight = ht; if (GetWindowStyle() & wxSL_HORIZONTAL) { if ( m_macMinimumStatic ) { w -= minValWidth / 2; x += minValWidth / 2; } if ( m_macMaximumStatic ) w -= maxValWidth / 2; } // Labels have this control's parent as their parent // so if this control is not at 0,0 relative to the parent // the labels need to know the position of this control // relative to its parent in order to size properly, so // move the control first so we can use GetPosition() wxControl::DoSetSize( x, y, w, h, sizeFlags ); if (GetWindowStyle() & wxSL_VERTICAL) // If vertical, use current value text.Printf(wxT("%d"), (int)GetPeer()->GetValue()); else // Use max so that the current value doesn't drift as centering would need to change text.Printf(wxT("%d"), m_rangeMax); GetTextExtent(text, &valValWidth, &ht); yborder = textheight + wxSLIDER_BORDERTEXT; // Get slider breadth if (GetWindowStyle() & wxSL_AUTOTICKS) sliderBreadth = wxSLIDER_DIMENSIONACROSS_WITHTICKMARKS; else sliderBreadth = wxSLIDER_DIMENSIONACROSS_ARROW; if (GetWindowStyle() & wxSL_VERTICAL) { h = h - yborder; if ( m_macMinimumStatic ) m_macMinimumStatic->Move(GetPosition().x + sliderBreadth + wxSLIDER_BORDERTEXT, GetPosition().y + h - yborder); if ( m_macMaximumStatic ) m_macMaximumStatic->Move(GetPosition().x + sliderBreadth + wxSLIDER_BORDERTEXT, GetPosition().y + 0); if ( m_macValueStatic ) m_macValueStatic->Move(GetPosition().x + sliderBreadth + wxSLIDER_BORDERTEXT, GetPosition().y + (h / 2) - (ht / 2)); } else { if ( m_macMinimumStatic ) m_macMinimumStatic->Move(GetPosition().x, GetPosition().y + sliderBreadth + wxSLIDER_BORDERTEXT); if ( m_macMaximumStatic ) m_macMaximumStatic->Move(GetPosition().x + w - maxValWidth, GetPosition().y + sliderBreadth + wxSLIDER_BORDERTEXT); if ( m_macValueStatic ) m_macValueStatic->Move(GetPosition().x + (w / 2) - (valValWidth / 2), GetPosition().y + sliderBreadth + wxSLIDER_BORDERTEXT); } } // yet another hack since this is a composite control // when wxSlider has its size hardcoded, we're not allowed to // change the size. But when the control has labels, we DO need // to resize the internal Mac control to accommodate the text labels. // We need to trick the wxWidgets resize mechanism so that we can // resize the slider part of the control ONLY. // TODO: Can all of this code go in the conditional wxSL_LABELS block? int minWidth = m_minWidth; if (GetWindowStyle() & wxSL_LABELS) { // make sure we don't allow the entire control to be resized accidentally if (width == GetSize().x) m_minWidth = -1; } // If the control has labels, we still need to call this again because // the labels alter the control's w and h values. wxControl::DoSetSize( x, y, w, h, sizeFlags ); m_minWidth = minWidth; }
wxSize wxGradientButton::DoGetBestSize() const { wxSize labelSize = wxDefaultSize; GetTextExtent(m_Label, &labelSize.x, &labelSize.y); return wxSize(wxMax(40, labelSize.x + 20), wxMax(20, labelSize.y + 10)); }
//------------------------------------------------------------------------- // drawGraticule() //------------------------------------------------------------------------- void PlotScalar::drawGraticule(wxAutoBufferedPaintDC& dc) { float t, a; int x, y, text_w, text_h; char buf[15]; wxString s; float sec_to_px; float a_to_py; wxBrush ltGraphBkgBrush; ltGraphBkgBrush.SetStyle(wxBRUSHSTYLE_TRANSPARENT); ltGraphBkgBrush.SetColour(*wxBLACK); dc.SetBrush(ltGraphBkgBrush); dc.SetPen(wxPen(BLACK_COLOR, 1)); sec_to_px = (float)m_rGrid.GetWidth()/m_t_secs; a_to_py = (float)m_rGrid.GetHeight()/(m_a_max - m_a_min); // upper LH coords of plot area are (PLOT_BORDER + XLEFT_OFFSET, PLOT_BORDER) // lower RH coords of plot area are (PLOT_BORDER + XLEFT_OFFSET + m_rGrid.GetWidth(), // PLOT_BORDER + m_rGrid.GetHeight()) // Vertical gridlines dc.SetPen(m_penShortDash); for(t=0; t<=m_t_secs; t+=m_graticule_t_step) { x = t*sec_to_px; if (m_mini) { dc.DrawLine(x, m_rGrid.GetHeight(), x, 0); } else { x += PLOT_BORDER + XLEFT_OFFSET; dc.DrawLine(x, m_rGrid.GetHeight() + PLOT_BORDER, x, PLOT_BORDER); } if (!m_mini) { sprintf(buf, "%2.1fs", t); GetTextExtent(buf, &text_w, &text_h); dc.DrawText(buf, x - text_w/2, m_rGrid.GetHeight() + PLOT_BORDER + YBOTTOM_TEXT_OFFSET); } } // Horizontal gridlines dc.SetPen(m_penDotDash); for(a=m_a_min; a<m_a_max; a+=m_graticule_a_step) { y = m_rGrid.GetHeight() - a*a_to_py + m_a_min*a_to_py; if (m_mini) { dc.DrawLine(0, y, m_rGrid.GetWidth(), y); } else { y += PLOT_BORDER; dc.DrawLine(PLOT_BORDER + XLEFT_OFFSET, y, (m_rGrid.GetWidth() + PLOT_BORDER + XLEFT_OFFSET), y); } if (!m_mini) { sprintf(buf, m_a_fmt, a); GetTextExtent(buf, &text_w, &text_h); dc.DrawText(buf, PLOT_BORDER + XLEFT_OFFSET - text_w - XLEFT_TEXT_OFFSET, y-text_h/2); } } }
//----------------------------------------------------------------------------- // Name: Render3DText() // Desc: Renders 3D text //----------------------------------------------------------------------------- HRESULT CD3DFont::Render3DText( TCHAR* strText, DWORD dwFlags, float r, float g, float b, float a ) { D3DMATERIAL8 mtrl; if( m_pd3dDevice == NULL ) return E_FAIL; // Setup renderstate m_pd3dDevice->CaptureStateBlock( m_dwSavedStateBlock ); m_pd3dDevice->ApplyStateBlock( m_dwDrawTextStateBlock ); m_pd3dDevice->SetVertexShader( D3DFVF_FONT3DVERTEX ); m_pd3dDevice->SetPixelShader( NULL ); m_pd3dDevice->SetStreamSource( 0, m_pVB, sizeof(FONT3DVERTEX) ); m_pd3dDevice->SetRenderState( D3DRS_ZENABLE, TRUE ); m_pd3dDevice->SetRenderState( D3DRS_ZFUNC, D3DCMP_LESSEQUAL ); D3DUtil_InitMaterial( mtrl, r, g, b, a ); m_pd3dDevice->SetMaterial(&mtrl); // Set filter states if( dwFlags & D3DFONT_FILTERED ) { m_pd3dDevice->SetTextureStageState( 0, D3DTSS_MINFILTER, D3DTEXF_LINEAR ); m_pd3dDevice->SetTextureStageState( 0, D3DTSS_MAGFILTER, D3DTEXF_LINEAR ); } // Position for each text element FLOAT x = 0.0f; FLOAT y = 0.0f; // Center the text block at the origin if( dwFlags & D3DFONT_CENTERED ) { SIZE sz; GetTextExtent( strText, &sz ); x = -(((FLOAT)sz.cx)/10.0f)/2.0f; y = -(((FLOAT)sz.cy)/10.0f)/2.0f; } // Turn off culling for two-sided text if( dwFlags & D3DFONT_TWOSIDED ) m_pd3dDevice->SetRenderState( D3DRS_CULLMODE, D3DCULL_NONE ); FLOAT fStartX = x; TCHAR c; // Fill vertex buffer FONT3DVERTEX* pVertices; DWORD dwVertex = 0L; DWORD dwNumTriangles = 0L; m_pVB->Lock( 0, 0, (BYTE**)&pVertices, D3DLOCK_DISCARD ); while( c = *strText++ ) { if( c == '\n' ) { x = fStartX; y -= (m_fTexCoords[0][3]-m_fTexCoords[0][1])*m_dwTexHeight/10.0f; } if( c == _T('\01')) { // Unlock, render, and relock the vertex buffer m_pVB->Unlock(); m_pd3dDevice->DrawPrimitive( D3DPT_TRIANGLELIST, 0, dwNumTriangles ); m_pVB->Lock( 0, 0, (BYTE**)&pVertices, D3DLOCK_DISCARD ); dwNumTriangles = 0L; float g1 = (float)((int)(0xFF&*strText++) / 255.f); float b1 = (float)((int)(0xFF&*strText++) / 255.f); float r1 = (float)((int)(0xFF&*strText++) / 255.f); float a1 = (float)((int)(0xFF&*strText++) / 255.f); D3DUtil_InitMaterial( mtrl, r1,b1,g1,a1 );/*((float)(*strText++))/255.0f, ((float)(*strText++))/255.0f, // ((float)(*strText++))/255.0f, ((float)(*strText++))/255.0f );*/ m_pd3dDevice->SetMaterial(&mtrl); continue; } if( c < 32 ) continue; FLOAT tx1 = m_fTexCoords[c-32][0]; FLOAT ty1 = m_fTexCoords[c-32][1]; FLOAT tx2 = m_fTexCoords[c-32][2]; FLOAT ty2 = m_fTexCoords[c-32][3]; FLOAT w = (tx2-tx1) * m_dwTexWidth / ( 10.0f * m_fTextScale ); FLOAT h = (ty2-ty1) * m_dwTexHeight / ( 10.0f * m_fTextScale ); if( c != _T(' ') ) { *pVertices++ = InitFont3DVertex( D3DXVECTOR3(x+0,y+0,0), D3DXVECTOR3(0,0,-1), tx1, ty2 ); *pVertices++ = InitFont3DVertex( D3DXVECTOR3(x+0,y+h,0), D3DXVECTOR3(0,0,-1), tx1, ty1 ); *pVertices++ = InitFont3DVertex( D3DXVECTOR3(x+w,y+0,0), D3DXVECTOR3(0,0,-1), tx2, ty2 ); *pVertices++ = InitFont3DVertex( D3DXVECTOR3(x+w,y+h,0), D3DXVECTOR3(0,0,-1), tx2, ty1 ); *pVertices++ = InitFont3DVertex( D3DXVECTOR3(x+w,y+0,0), D3DXVECTOR3(0,0,-1), tx2, ty2 ); *pVertices++ = InitFont3DVertex( D3DXVECTOR3(x+0,y+h,0), D3DXVECTOR3(0,0,-1), tx1, ty1 ); dwNumTriangles += 2; if( dwNumTriangles*3 > (MAX_NUM_VERTICES-6) ) { // Unlock, render, and relock the vertex buffer m_pVB->Unlock(); m_pd3dDevice->DrawPrimitive( D3DPT_TRIANGLELIST, 0, dwNumTriangles ); m_pVB->Lock( 0, 0, (BYTE**)&pVertices, D3DLOCK_DISCARD ); dwNumTriangles = 0L; } } x += w; } // Unlock and render the vertex buffer m_pVB->Unlock(); if( dwNumTriangles > 0 ) m_pd3dDevice->DrawPrimitive( D3DPT_TRIANGLELIST, 0, dwNumTriangles ); // Restore the modified renderstates m_pd3dDevice->ApplyStateBlock( m_dwSavedStateBlock ); return S_OK; }
//----------------------------------------------------------------------------- // Name: Render3DText() // Desc: Renders 3D text //----------------------------------------------------------------------------- HRESULT CD3DFont::Render3DText( const TCHAR* strText, DWORD dwFlags ) { if( m_pd3dDevice == NULL ) return E_FAIL; // Setup renderstate m_pStateBlockSaved->Capture(); m_pStateBlockDrawText->Apply(); m_pd3dDevice->SetFVF( D3DFVF_FONT3DVERTEX ); m_pd3dDevice->SetPixelShader( NULL ); m_pd3dDevice->SetStreamSource( 0, m_pVB, 0, sizeof(FONT3DVERTEX) ); // Set filter states if( dwFlags & D3DFONT_FILTERED ) { m_pd3dDevice->SetSamplerState( 0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR ); m_pd3dDevice->SetSamplerState( 0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR ); } // Position for each text element FLOAT x = 0.0f; FLOAT y = 0.0f; // Center the text block at the origin (not the viewport) if( dwFlags & D3DFONT_CENTERED_X ) { SIZE sz; GetTextExtent( strText, &sz ); x = -(((FLOAT)sz.cx)/10.0f)/2.0f; } if( dwFlags & D3DFONT_CENTERED_Y ) { SIZE sz; GetTextExtent( strText, &sz ); y = -(((FLOAT)sz.cy)/10.0f)/2.0f; } // Turn off culling for two-sided text if( dwFlags & D3DFONT_TWOSIDED ) m_pd3dDevice->SetRenderState( D3DRS_CULLMODE, D3DCULL_NONE ); // Adjust for character spacing x -= m_dwSpacing / 10.0f; FLOAT fStartX = x; TCHAR c; // Fill vertex buffer FONT3DVERTEX* pVertices; DWORD dwNumTriangles = 0L; m_pVB->Lock( 0, 0, (void**)&pVertices, D3DLOCK_DISCARD ); while( (c = *strText++) != 0 ) { if( c == '\n' ) { x = fStartX; y -= (m_fTexCoords[0][3]-m_fTexCoords[0][1])*m_dwTexHeight/10.0f; } if( (c-32) < 0 || (c-32) >= 128-32 ) continue; FLOAT tx1 = m_fTexCoords[c-32][0]; FLOAT ty1 = m_fTexCoords[c-32][1]; FLOAT tx2 = m_fTexCoords[c-32][2]; FLOAT ty2 = m_fTexCoords[c-32][3]; FLOAT w = (tx2-tx1) * m_dwTexWidth / ( 10.0f * m_fTextScale ); FLOAT h = (ty2-ty1) * m_dwTexHeight / ( 10.0f * m_fTextScale ); if( c != _T(' ') ) { *pVertices++ = InitFont3DVertex( D3DXVECTOR3(x+0,y+0,0), D3DXVECTOR3(0,0,-1), tx1, ty2 ); *pVertices++ = InitFont3DVertex( D3DXVECTOR3(x+0,y+h,0), D3DXVECTOR3(0,0,-1), tx1, ty1 ); *pVertices++ = InitFont3DVertex( D3DXVECTOR3(x+w,y+0,0), D3DXVECTOR3(0,0,-1), tx2, ty2 ); *pVertices++ = InitFont3DVertex( D3DXVECTOR3(x+w,y+h,0), D3DXVECTOR3(0,0,-1), tx2, ty1 ); *pVertices++ = InitFont3DVertex( D3DXVECTOR3(x+w,y+0,0), D3DXVECTOR3(0,0,-1), tx2, ty2 ); *pVertices++ = InitFont3DVertex( D3DXVECTOR3(x+0,y+h,0), D3DXVECTOR3(0,0,-1), tx1, ty1 ); dwNumTriangles += 2; if( dwNumTriangles*3 > (MAX_NUM_VERTICES-6) ) { // Unlock, render, and relock the vertex buffer m_pVB->Unlock(); m_pd3dDevice->DrawPrimitive( D3DPT_TRIANGLELIST, 0, dwNumTriangles ); m_pVB->Lock( 0, 0, (void**)&pVertices, D3DLOCK_DISCARD ); dwNumTriangles = 0L; } } x += w - (2 * m_dwSpacing) / 10.0f; } // Unlock and render the vertex buffer m_pVB->Unlock(); if( dwNumTriangles > 0 ) m_pd3dDevice->DrawPrimitive( D3DPT_TRIANGLELIST, 0, dwNumTriangles ); // Restore the modified renderstates m_pStateBlockSaved->Apply(); return S_OK; }
static void pbarOnNewPos (const CONTROL* pCtrl, PROGRESSDATA* pData, unsigned int new_pos) { double d; unsigned int old_pos; int range = pData->nMax - pData->nMin; int old_prog, new_prog, width; RECT rc_client; if (range == 0 || new_pos == pData->nPos) return; old_pos = pData->nPos; pData->nPos = new_pos; pbarNormalizeParams (pCtrl, pData, pCtrl->dwStyle & PBS_NOTIFY); if (old_pos == pData->nPos) return; GetClientRect ((HWND)pCtrl, &rc_client); if (pCtrl->dwStyle & PBS_VERTICAL) width = RECTH (rc_client) - (WIDTH_PBAR_BORDER << 1); else width = RECTW (rc_client) - (WIDTH_PBAR_BORDER << 1); old_prog = old_pos - pData->nMin; d = (old_prog*1.0)/range; old_prog = (int) (d * width); new_prog = pData->nPos - pData->nMin; d = (new_prog*1.0)/range; new_prog = (int) (d * width); if (pCtrl->dwStyle & PBS_VERTICAL) { #if 0 old_prog = rc_client.bottom - WIDTH_PBAR_BORDER - old_prog; new_prog = rc_client.bottom - WIDTH_PBAR_BORDER - new_prog; rc_client.top = MIN (old_prog, new_prog) - 4; rc_client.bottom = MAX (old_prog, new_prog) + 4; #endif } else { HDC hdc; char text [10]; RECT rc_text; SIZE text_ext; sprintf (text, "%.0f%%", (d*100)); hdc = GetClientDC ((HWND)pCtrl); GetTextExtent (hdc, text, -1, &text_ext); ReleaseDC (hdc); rc_text.left = rc_client.left + ((RECTW(rc_client) - text_ext.cx) >> 1); rc_text.top = rc_client.top + ((RECTH(rc_client) - text_ext.cy) >> 1); rc_text.right = rc_text.left + text_ext.cx; rc_text.bottom = rc_text.top + text_ext.cy; InvalidateRect ((HWND)pCtrl, &rc_client, TRUE); rc_client.left = MIN (old_prog, new_prog); rc_client.right = MAX (old_prog, new_prog); } InvalidateRect ((HWND)pCtrl, &rc_client, TRUE); }
/* recalculate widths of the tabs after a page added or removed. */ static void recalc_tab_widths (HWND hwnd, PPROPSHEETDATA propsheet, DWORD dwStyle) { PPROPPAGE page; if (propsheet->page_count == 0) return; if (dwStyle & PSS_COMPACTTAB) { HDC hdc; SIZE ext; int total_width = 0; hdc = GetClientDC (hwnd); page = propsheet->head; while (page) { page->width = 0; if (page->title) { GetTextExtent (hdc, page->title, -1, &ext); page->width = ext.cx + TAB_MARGIN; } if (page->icon) { page->width += get_metrics (MWM_ICONX); } if (page->width < _MIN_TAB_WIDTH) { page->width = _MIN_TAB_WIDTH; } total_width += page->width; /*added by lfzhang*/ if (total_width > propsheet->head_rc.right){ total_width -= page->width; page->width = propsheet->head_rc.right - total_width; total_width += page->width; break; } page = page->next; } ReleaseDC (hdc); /* old_code if (total_width > propsheet->head_rc.right) { int new_width = 0, step = 0; page = propsheet->head; step = (total_width - propsheet->head_rc.right)/propsheet->page_count; if (step == 0) step = 1; while (page) { page->width -= step; if (page->width < _MIN_TAB_WIDTH) { page->width = _MIN_TAB_WIDTH; } if (!(page->next) && (new_width + page->width > propsheet->head_rc.right)) { page->width = propsheet->head_rc.right - new_width; } else new_width += page->width; page = page->next; } total_width = new_width; }*/ propsheet->head_width = total_width; } else { int width; //width = propsheet->head_rc.right * 8 / (propsheet->page_count * 10); width = propsheet->head_rc.right / propsheet->page_count; //if (width < _MIN_TAB_WIDTH) //width = propsheet->head_rc.right / propsheet->page_count; page = propsheet->head; while (page) { page->width = width; page = page->next; } //propsheet->head_width = width * propsheet->page_count; propsheet->head_width = propsheet->head_rc.right; } }
static void pbarOnDraw (HWND hwnd, HDC hdc, PROGRESSDATA* pData, BOOL fVertical) { RECT rcClient; int x, y, w, h; ldiv_t ndiv_progress; unsigned int nAllPart; unsigned int nNowPart; int whOne, nRem; int ix, iy; int i; int step; if (pData->nMax == pData->nMin) return; if ((pData->nMax - pData->nMin) > 5) step = 5; else step = 1; GetClientRect (hwnd, &rcClient); x = rcClient.left + WIDTH_PBAR_BORDER; y = rcClient.top + WIDTH_PBAR_BORDER; w = RECTW (rcClient) - (WIDTH_PBAR_BORDER << 1); h = RECTH (rcClient) - (WIDTH_PBAR_BORDER << 1); ndiv_progress = ldiv (pData->nMax - pData->nMin, step); nAllPart = ndiv_progress.quot; ndiv_progress = ldiv (pData->nPos - pData->nMin, step); nNowPart = ndiv_progress.quot; if (fVertical) ndiv_progress = ldiv (h, nAllPart); else ndiv_progress = ldiv (w, nAllPart); whOne = ndiv_progress.quot; nRem = ndiv_progress.rem; SetBrushColor (hdc, GetWindowElementColorEx (hwnd, BKC_HILIGHT_NORMAL)); if (whOne >= 4) { if (fVertical) { for (i = 0, iy = y + h - 1; i < nNowPart; ++i) { if ((iy - whOne) < y) whOne = iy - y; FillBox (hdc, x + 1, iy - whOne, w - 2, whOne - 1); iy -= whOne; if(nRem > 0) { iy --; nRem --; } } } else { for (i = 0, ix = x + 1; i < nNowPart; ++i) { if ((ix + whOne) > (x + w)) whOne = x + w - ix; FillBox (hdc, ix, y + 1, whOne - 1, h - 2); ix += whOne; if(nRem > 0) { ix ++; nRem --; } } } } else { // no vertical support double d = (nNowPart*1.0)/nAllPart; if (fVertical) { int prog = (int)(h*d); FillBox (hdc, x + 1, rcClient.bottom - WIDTH_PBAR_BORDER - prog, w - 2, prog); } else { char szText[8]; SIZE text_ext; RECT rc_clip = rcClient; int prog = (int)(w*d); FillBox (hdc, x, y + 1, (int)(w*d), h - 2); SetBkMode (hdc, BM_TRANSPARENT); sprintf (szText, "%.0f%%", (d*100)); GetTextExtent (hdc, szText, -1, &text_ext); x += ((w - text_ext.cx) >> 1); y += ((h - text_ext.cy) >> 1); rc_clip.right = prog; SelectClipRect (hdc, &rc_clip); SetTextColor (hdc, GetWindowElementColorEx (hwnd, FGC_HILIGHT_NORMAL)); SetBkColor (hdc, GetWindowElementColorEx (hwnd, BKC_HILIGHT_NORMAL)); TextOut (hdc, x, y, szText); rc_clip.right = rcClient.right; rc_clip.left = prog; SelectClipRect (hdc, &rc_clip); SetTextColor (hdc, GetWindowElementColorEx (hwnd, FGC_CONTROL_NORMAL)); SetBkColor (hdc, GetWindowBkColor (hwnd)); TextOut (hdc, x, y, szText); } } }
void VSTEffectDialog::BuildPlain() { mNames = new wxStaticText *[mAEffect->numParams]; mSliders = new wxSlider *[mAEffect->numParams]; mDisplays = new wxStaticText *[mAEffect->numParams]; mLabels = new wxStaticText *[mAEffect->numParams]; wxBoxSizer *vSizer = new wxBoxSizer(wxVERTICAL); vSizer->Add(BuildProgramBar(), 0, wxALIGN_CENTER); wxScrolledWindow *sw = new wxScrolledWindow(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxVSCROLL | wxTAB_TRAVERSAL); // Try to give the window a sensible default/minimum size wxSize sz = GetParent()->GetSize(); sw->SetMinSize(wxSize(wxMax(600, sz.GetWidth() * 2 / 3), sz.GetHeight() / 2)); sw->SetScrollRate(0, 20); vSizer->Add(sw, 1, wxEXPAND | wxALL, 5); // Preview, OK, & Cancel buttons vSizer->Add(CreateStdButtonSizer(this, ePreviewButton|eCancelButton|eOkButton), 0, wxEXPAND); SetSizer(vSizer); wxSizer *paramSizer = new wxStaticBoxSizer(wxVERTICAL, sw, _("Effect Settings")); wxFlexGridSizer *gridSizer = new wxFlexGridSizer(4, 0, 0); gridSizer->AddGrowableCol(1); // Find the longest parameter name. int namew = 0; int w; int h; for (int i = 0; i < mAEffect->numParams; i++) { wxString text = mEffect->GetString(effGetParamName, i); if (text.Right(1) != wxT(':')) { text += wxT(':'); } GetTextExtent(text, &w, &h); if (w > namew) { namew = w; } } GetTextExtent(wxT("HHHHHHHH"), &w, &h); for (int i = 0; i < mAEffect->numParams; i++) { mNames[i] = new wxStaticText(sw, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(namew, -1), wxALIGN_RIGHT | wxST_NO_AUTORESIZE); gridSizer->Add(mNames[i], 0, wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT | wxALL, 5); mSliders[i] = new wxSlider(sw, ID_VST_SLIDERS + i, 0, 0, 1000, wxDefaultPosition, wxSize(200, -1)); gridSizer->Add(mSliders[i], 0, wxALIGN_CENTER_VERTICAL | wxEXPAND | wxALL, 5); mDisplays[i] = new wxStaticText(sw, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(w, -1), wxALIGN_RIGHT | wxST_NO_AUTORESIZE); gridSizer->Add(mDisplays[i], 0, wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT | wxALL, 5); mLabels[i] = new wxStaticText(sw, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(w, -1), wxALIGN_LEFT | wxST_NO_AUTORESIZE); gridSizer->Add(mLabels[i], 0, wxALIGN_CENTER_VERTICAL | wxALIGN_LEFT | wxALL, 5); } paramSizer->Add(gridSizer, 1, wxEXPAND | wxALL, 5); sw->SetSizer(paramSizer); Layout(); Fit(); SetSizeHints(GetSize()); RefreshParameters(); mSliders[0]->SetFocus(); }
// here we figure out if we are over a URL or not BOOL CGridURLCell::OverURL(CPoint& pt, CString& strURL) { //TRACE2("Checking point %d,%d\n",pt.x,pt.y); BOOL bOverURL = FALSE; CSize size = GetTextExtent(GetText()); // Add left of cell so we know if we clicked on text or not pt.x += m_Rect.left; CPoint center = m_Rect.CenterPoint(); if ((m_nFormat & DT_RIGHT) && pt.x >= (m_Rect.right - size.cx)) { bOverURL = TRUE; } else if ((m_nFormat & DT_CENTER) && ((center.x - (size.cx / 2)) <= pt.x) && (pt.x <= (center.x + (size.cx / 2))) ) { bOverURL = TRUE; } else if (pt.x <= (size.cx + m_Rect.left)) { bOverURL = TRUE; } if (!bOverURL) return FALSE; // We are over text - but are we over a URL? bOverURL = FALSE; strURL = GetText(); // Use float, otherwise we get an incorrect letter from the point float width = (float)size.cx / (float)strURL.GetLength(); // remove left of cell so we have original point again pt.x -= m_Rect.left; if (m_nFormat & DT_RIGHT) { int wide = m_Rect.Width() - size.cx; pt.x -= wide; if (pt.x <= 0) return FALSE; } if (m_nFormat & DT_CENTER) { int wide = m_Rect.Width() - size.cx; pt.x -= (wide / 2); if (pt.x <= 0 || pt.x > (size.cx + (wide / 2))) return FALSE; } // Turn point into a letter int ltrs = (int)((float)pt.x / width); #if !defined(_WIN32_WCE) || (_WIN32_WCE > 210) // Find spaces before and after letter, process text between int endSpace = strURL.Find(_T(' '), ltrs); if (endSpace != -1) strURL.Delete(endSpace, strURL.GetLength() - endSpace); int beginSpace = strURL.ReverseFind(_T(' ')); if (beginSpace != -1) strURL.Delete(0, ++beginSpace); #endif // Does text have url return HasUrl(strURL); }
CSimpleProjectPanel::CSimpleProjectPanel( wxWindow* parent ) : CSimplePanelBase( parent ) { wxSize sz; wxString str = wxEmptyString; wxWindowDC dc(this); m_UsingAccountManager = -1; // Force action the first time m_CurrentSelectedProjectURL[0] = '\0'; m_sAddProjectString = _("Add Project"); m_sSynchronizeString = _("Synchronize"); m_sTotalWorkDoneString = _("Work done for this project"); m_sAddProjectToolTip = _("Volunteer for any or all of 30+ projects in many areas of science"); m_sSynchronizeToolTip = _("Synchronize projects with account manager system"); m_GotBGBitMap = false; // Can't be made until parent has been laid out. SetForegroundColour(*wxBLACK); wxBoxSizer* bSizer1; bSizer1 = new wxBoxSizer( wxVERTICAL ); wxBoxSizer* bSizer2; bSizer2 = new wxBoxSizer( wxHORIZONTAL ); bSizer1->AddSpacer(ADJUSTFORYDPI(5)); m_myProjectsLabel = new CTransparentStaticText( this, wxID_ANY, _("Projects:"), wxDefaultPosition, wxDefaultSize, 0 ); m_myProjectsLabel->Wrap( -1 ); bSizer2->Add( m_myProjectsLabel, 0, wxRIGHT, ADJUSTFORXDPI(5) ); bSizer2->AddStretchSpacer(); int addProjectWidth, synchronizeWidth, y; GetTextExtent(m_sAddProjectString, &addProjectWidth, &y); GetTextExtent(m_sSynchronizeString, &synchronizeWidth, &y); m_TaskAddProjectButton = new CTransparentButton( this, ID_ADDROJECTBUTTON, (addProjectWidth > synchronizeWidth) ? m_sAddProjectString : m_sSynchronizeString, wxDefaultPosition, wxDefaultSize, 0 ); bSizer2->Add( m_TaskAddProjectButton, 0, wxRIGHT | wxEXPAND | wxALIGN_RIGHT, SIDEMARGINS ); bSizer1->Add( bSizer2, 0, wxEXPAND | wxTOP | wxLEFT, ADJUSTFORXDPI(10) ); #ifndef __WXMAC__ bSizer1->AddSpacer(ADJUSTFORYDPI(5)); #endif #if TESTBIGICONPOPUP m_ProjectSelectionCtrl = new CBOINCBitmapComboBox( this, ID_SGPROJECTSELECTOR, wxT(""), wxDefaultPosition, wxSize(-1, 42), 4, tempArray, wxCB_READONLY ); CSkinSimple* pSkinSimple = wxGetApp().GetSkinManager()->GetSimple(); bmArray[0] = *pSkinSimple->GetProjectImage()->GetBitmap(); m_ProjectSelectionCtrl->SetItemBitmap(0, bmArray[0]); bmArray[1] = wxBitmap((const char**)sah_40_xpm); m_ProjectSelectionCtrl->SetItemBitmap(1, bmArray[1]); bmArray[2] = wxBitmap((const char**)einstein_icon_xpm); m_ProjectSelectionCtrl->SetItemBitmap(3, bmArray[2]); // m_ProjectSelectionCtrl->SetStringSelection(tempArray[1]); m_ProjectSelectionCtrl->SetSelection(1); #else m_ProjectSelectionCtrl = new CBOINCBitmapComboBox( this, ID_SGPROJECTSELECTOR, wxT(""), wxDefaultPosition, wxSize(-1, 42), 0, NULL, wxCB_READONLY); #endif // TODO: Might want better wording for Project Selection Combo Box tooltip str = _("Select a project to access with the controls below"); m_ProjectSelectionCtrl->SetToolTip(str); bSizer1->Add( m_ProjectSelectionCtrl, 0, wxLEFT | wxRIGHT | wxEXPAND, SIDEMARGINS ); #ifndef __WXMAC__ bSizer1->AddSpacer(ADJUSTFORYDPI(8)); #endif // Make sure m_TotalCreditValue string is large enough m_fDisplayedCredit = 9999999999.99; str.Printf(wxT("%s: %.0f"), m_sTotalWorkDoneString.c_str(), m_fDisplayedCredit); m_TotalCreditValue = new CTransparentStaticText( this, wxID_ANY, str, wxDefaultPosition, wxDefaultSize, wxST_NO_AUTORESIZE ); m_TotalCreditValue->Wrap( -1 ); bSizer1->Add( m_TotalCreditValue, 0, wxLEFT | wxRIGHT | wxEXPAND, SIDEMARGINS ); bSizer1->AddSpacer(ADJUSTFORYDPI(5)); wxBoxSizer* bSizer3; bSizer3 = new wxBoxSizer( wxHORIZONTAL ); m_ProjectWebSitesButton = new CSimpleProjectWebSitesPopupButton( this, ID_PROJECTWEBSITESBUTTON, _("Project Web Pages"), wxDefaultPosition, wxDefaultSize, 0 ); bSizer3->Add( m_ProjectWebSitesButton, 0, wxEXPAND | wxALIGN_LEFT, 0 ); bSizer3->AddStretchSpacer(); m_ProjectCommandsButton = new CSimpleProjectCommandPopupButton( this, ID_PROJECTCOMMANDBUTTON, _("Project Commands"), wxDefaultPosition, wxDefaultSize, 0 ); bSizer3->Add( m_ProjectCommandsButton, 0, wxEXPAND | wxALIGN_RIGHT, 0 ); bSizer1->Add( bSizer3, 0, wxLEFT | wxRIGHT | wxEXPAND, SIDEMARGINS ); bSizer1->AddSpacer(ADJUSTFORYDPI(10)); // Temporarily insert a dummy entry so sizer can // get correct height of m_ProjectSelectionCtrl CSkinSimple* pSkinSimple = wxGetApp().GetSkinManager()->GetSimple(); wxBitmap* defaultBM = pSkinSimple->GetProjectImage()->GetBitmap(); m_ProjectSelectionCtrl->Insert("", *defaultBM, 0, (void*)NULL); this->SetSizer( bSizer1 ); this->Layout(); // Remove the dummy entry m_ProjectSelectionCtrl->Delete(0); m_TaskAddProjectButton->SetToolTip(wxEmptyString); m_TaskAddProjectButton->Disable(); }
void gYAxis::paint(gGraph & w,int left,int top, int width, int height) { int x,y;//,yh=0; //Todo: clean this up as there is a lot of duplicate code between the sections if (0) {//w.graphView()->usePixmapCache()) { /* if (w.invalidate_yAxisImage) { if (!m_image.isNull()) { w.graphView()->deleteTexture(m_textureID); m_image=QImage(); } if (height<0) return; if (height>2000) return; int labelW=0; EventDataType miny=w.min_y; EventDataType maxy=w.max_y; if (miny<0) { // even it up if it's starts negative miny=-MAX(fabs(miny),fabs(maxy)); } w.roundY(miny,maxy); EventDataType dy=maxy-miny; static QString fd="0"; GetTextExtent(fd,x,y); yh=y; m_image=QImage(width,height+y+4,QImage::Format_ARGB32_Premultiplied); m_image.fill(Qt::transparent); QPainter paint(&m_image); double max_yticks=round(height / (y+14.0)); // plus spacing between lines double mxy=MAX(fabs(maxy),fabs(miny)); double mny=miny; if (miny<0) { mny=-mxy; } double rxy=mxy-mny; int myt; bool fnd=false; for (myt=max_yticks;myt>2;myt--) { float v=rxy/float(myt); if (v==int(v)) { fnd=true; break; } } if (fnd) max_yticks=myt; double yt=1/max_yticks; double ymult=height/rxy; double min_ytick=rxy*yt; float ty,h; if (min_ytick<=0) { qDebug() << "min_ytick error in gYAxis::paint() in" << w.title(); return; } if (min_ytick>=1000000) { min_ytick=100; } //lines=w.backlines(); for (double i=miny; i<=maxy+min_ytick-0.00001; i+=min_ytick) { ty=(i - miny) * ymult; if (dy<5) { fd=Format(i*m_yaxis_scale,2); } else { fd=Format(i*m_yaxis_scale,1); } GetTextExtent(fd,x,y); if (x>labelW) labelW=x; h=(height-2)-ty; h+=yh; #ifndef Q_OS_MAC // stupid pixel alignment rubbish, I really should be using floats.. h+=1; #endif if (h<0) continue; paint.setBrush(Qt::black); paint.drawText(width-8-x,h+y/2,fd); paint.setPen(m_line_color); paint.drawLine(width-4,h,width,h); double z=(min_ytick/4)*ymult; double g=h; for (int i=0;i<3;i++) { g+=z; if (g>height+yh) break; paint.drawLine(width-3,g,width,g); } } paint.end(); m_image=QGLWidget::convertToGLFormat(m_image); m_textureID=w.graphView()->bindTexture(m_image,GL_TEXTURE_2D,GL_RGBA,QGLContext::NoBindOption); w.invalidate_yAxisImage=false; } if (!m_image.isNull()) { glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glEnable(GL_TEXTURE_2D); w.graphView()->drawTexture(QPoint(left,(top+height)-m_image.height()+5),m_textureID); glDisable(GL_TEXTURE_2D); glDisable(GL_BLEND); } */ } else { if (height<0) return; if (height>2000) return; int labelW=0; EventDataType miny; EventDataType maxy; if (w.zoomY()==0 && PROFILE.appearance->allowYAxisScaling()) { miny=w.physMinY(); maxy=w.physMaxY(); } else { miny=w.min_y; maxy=w.max_y; if (miny<0) { // even it up if it's starts negative miny=-MAX(fabs(miny),fabs(maxy)); } } w.roundY(miny,maxy); EventDataType dy=maxy-miny; static QString fd="0"; GetTextExtent(fd,x,y); double max_yticks=round(height / (y+14.0)); // plus spacing between lines double mxy=MAX(fabs(maxy),fabs(miny)); double mny=miny; if (miny<0) { mny=-mxy; } double rxy=mxy-mny; int myt; bool fnd=false; for (myt=max_yticks;myt>2;myt--) { float v=rxy/float(myt); if (v==int(v)) { fnd=true; break; } } if (fnd) max_yticks=myt; double yt=1/max_yticks; double ymult=height/rxy; double min_ytick=rxy*yt; //if (dy>5) { // min_ytick=round(min_ytick); //} else { //} float ty,h; if (min_ytick<=0) { qDebug() << "min_ytick error in gYAxis::paint() in" << w.title(); return; } if (min_ytick>=1000000) { min_ytick=100; } lines=w.backlines(); GLuint line_color=m_line_color.rgba(); for (double i=miny; i<=maxy+min_ytick-0.00001; i+=min_ytick) { ty=(i - miny) * ymult; if (dy<5) { fd=Format(i*m_yaxis_scale,2); } else { fd=Format(i*m_yaxis_scale,1); } GetTextExtent(fd,x,y); // performance bottleneck.. if (x>labelW) labelW=x; h=top+height-ty; if (h<top) continue; w.renderText(fd,left+width-8-x,(h+(y/2.0)),0,m_text_color,defaultfont); lines->add(left+width-4,h,left+width,h,line_color); double z=(min_ytick/4)*ymult; double g=h; for (int i=0;i<3;i++) { g+=z; if (g>top+height) break; lines->add(left+width-3,g,left+width,g,line_color); if (lines->full()) { qWarning() << "vertarray bounds exceeded in gYAxis for " << w.title() << "graph" << "MinY =" <<miny << "MaxY =" << maxy << "min_ytick=" <<min_ytick; break; } } if (lines->full()) { qWarning() << "vertarray bounds exceeded in gYAxis for " << w.title() << "graph" << "MinY =" <<miny << "MaxY =" << maxy << "min_ytick=" <<min_ytick; break; } } } }