Definition at line 92 of file Slider.h. References mMaxVal, mMinVal, OglGui::OglWindow::mOglWnd, mPrecisionIdx, mShowTicks, mShowTickValue, mThumbH, mTickInterval, and mUpsideDown. Referenced by DisplayFunc(). 00093 { 00094 char buf[25], format[10]; 00095 int tW, tH, y, oldTickY = -100; 00096 00097 // Draw base line 00098 SetSolidLineColor(oglBLACK); 00099 DrawLine(x, mThumbH/2, x, wndH - mThumbH/2); 00100 SetSolidLineColor(oglWHITE); 00101 DrawLine(x-1, mThumbH/2, x - 1, wndH - mThumbH/2); 00102 00103 if (mShowTicks && (wndH > mThumbH + 40) && 00104 (mUpsideDown ? (x - 3 > 0) : (x + 3 < wndW))) 00105 { 00106 for(int i = mMinVal; i < mMaxVal+mTickInterval; i += mTickInterval) 00107 { 00108 int tickLen = 5; 00109 00110 if (i > mMaxVal) 00111 i = (int) mMaxVal; 00112 00113 y = (int) (mThumbH/2 + ((i-mMinVal) / 00114 (float) (mMaxVal-mMinVal)) * (wndH-mThumbH)); 00115 00116 if (mShowTickValue) 00117 { 00118 sprintf(format, "%%.%df", mPrecisionIdx); 00119 sprintf(buf, format, i / pow(10.0,mPrecisionIdx)); 00120 00121 oglSys.GetTextExtent(mOglWnd, buf, &tW, &tH); 00122 if (y - oldTickY > tH/2 + 8) 00123 { 00124 tickLen += 3; 00125 oldTickY = y; 00126 int len = mUpsideDown ? -(tickLen+5+tW) : (tickLen+2); 00127 oglSys.ShadowPrintf(mOglWnd, x + len, y - 5, oglWHITE, 00128 oglBLACK, "%s", buf); 00129 00130 } 00131 } 00132 int x1 = x + (mUpsideDown ? -2 : 0); 00133 int x2 = x1 + (mUpsideDown ? -tickLen : tickLen); 00134 SetSolidLineColor(oglWHITE); 00135 DrawLine(x1, y, x2, y); 00136 SetSolidLineColor(oglDARKGREY); 00137 DrawLine(x1, y-1, x2, y-1); 00138 } 00139 } 00140 }
|