Definition at line 40 of file Slider.h. References mMaxVal, mMinVal, OglGui::OglWindow::mOglWnd, mPrecisionIdx, mShowTicks, mShowTickValue, mThumbW, mTickInterval, and mUpsideDown. Referenced by DisplayFunc(). 00041 { 00042 char buf[25], format[10]; 00043 int tW, tH, x, oldTickX = -100; 00044 00045 // Show base line 00046 SetSolidLineColor(oglBLACK); 00047 DrawLine(mThumbW/2, y, wndW - mThumbW/2, y); 00048 SetSolidLineColor(oglWHITE); 00049 DrawLine(mThumbW/2, y - 1, wndW - mThumbW/2, y - 1); 00050 00051 if (mShowTicks && (wndW > mThumbW + 40) && 00052 (mUpsideDown ? (y - 3 > 0) : (y + 3 < wndH))) 00053 { 00054 for(int i = mMinVal; i < mMaxVal+mTickInterval; i += mTickInterval) 00055 { 00056 int tickLen = 5; 00057 00058 if (i > mMaxVal) i = mMaxVal; 00059 00060 x = (int) (mThumbW/2 + ((i-mMinVal) / (float)(mMaxVal-mMinVal)) 00061 * (mOglWnd->width-mThumbW)); 00062 00063 if (mShowTickValue && 00064 (mUpsideDown ? (y-11-tickLen > 0) : (y+16+tickLen < wndH))) 00065 { 00066 sprintf(format, "%%.%df", mPrecisionIdx); 00067 sprintf(buf, format, i / pow(10.0,mPrecisionIdx)); 00068 /* 00069 sprintf(buf, mShowValPerc ? "%.2f" : "%.0f", 00070 i / (mShowValPerc ? 100.0f : 1.0f)); 00071 */ 00072 oglSys.GetTextExtent(mOglWnd, buf, &tW, &tH); 00073 if (x - oldTickX > tW + 8) 00074 { 00075 tickLen += 3; 00076 oldTickX = x; 00077 int len = mUpsideDown ? -(tickLen-1+tH) : (tickLen+4); 00078 oglSys.ShadowPrintf(mOglWnd, x - tW/2 - 1, y + len, 00079 oglWHITE, oglBLACK, "%s", buf); 00080 } 00081 } 00082 int y1 = y + (mUpsideDown ? -2 : 2); 00083 int y2 = y1 + (mUpsideDown ? -tickLen : tickLen); 00084 SetSolidLineColor(oglWHITE); 00085 DrawLine(x, y1, x, y2); 00086 SetSolidLineColor(oglDARKGREY); 00087 DrawLine(x-1, y1, x-1, y2); 00088 } 00089 } 00090 }
|