11
11
12
12
#include " precomp.h"
13
13
14
+ // Size macros for the bitmap we use to draw LED digits
15
+
16
+ #define DIGITS_STRIP_WIDTH 104
17
+ #define DIGITS_STRIP_HEIGHT 11
18
+ #define DIGIT_WIDTH 8
19
+ #define DIGIT_HEIGHT (DIGITS_STRIP_HEIGHT)
20
+ #define PERCENT_SIGN_INDEX 10 // Index into bitmap strip where % sign lives
21
+ #define K_INDEX 11 // Index into bitmap strip where "K" lives
22
+ #define M_INDEX 12 // Index into bitmap strip where "M" lives
23
+ #define BLANK_INDEX 13 // Index into bitmap where blank digit lives
24
+
14
25
#define GRAPH_BRUSH BLACK_BRUSH
15
26
#define GRAPH_LINE_COLOR RGB (0 , 128 , 64 )
16
27
#define GRAPH_TEXT_COLOR RGB (0 , 255 , 0 )
@@ -833,11 +844,14 @@ void CPerfPage::DrawCPUDigits(LPDRAWITEMSTRUCT lpdi)
833
844
// Draw the digits into the ownder draw control
834
845
//
835
846
847
+ INT xOffset = ((lpdi->rcItem .right - lpdi->rcItem .left ) - 4 * DIGIT_WIDTH) / 2 - 2 ;
848
+ INT yOffset = (lpdi->rcItem .bottom - DIGIT_HEIGHT - g_DefSpacing);
836
849
INT xBarOffset = ((lpdi->rcItem .right - lpdi->rcItem .left ) - STRIP_WIDTH) / 2 ;
837
850
838
851
RECT rcBar;
839
852
GetWindowRect (GetDlgItem (m_hPage, IDC_MEMMETER), &rcBar);
840
- INT cBarHeight = lpdi->rcItem .bottom - lpdi->rcItem .top - (GetCurFontSize (lpdi->hDC ) + g_DefSpacing * 3 );
853
+ INT yDigit = g_Options.m_bLedNumbers ? DIGIT_HEIGHT : GetCurFontSize (lpdi->hDC );
854
+ INT cBarHeight = lpdi->rcItem .bottom - lpdi->rcItem .top - (yDigit + g_DefSpacing * 3 );
841
855
if (cBarHeight <= 0 )
842
856
{
843
857
return ;
@@ -860,11 +874,58 @@ void CPerfPage::DrawCPUDigits(LPDRAWITEMSTRUCT lpdi)
860
874
861
875
RECT rcOut = lpdi->rcItem ;
862
876
rcOut.bottom -= 4 ;
863
- DrawText (lpdi->hDC , szBuf, -1 , &rcOut, DT_SINGLELINE | DT_CENTER | DT_BOTTOM);
877
+ if (!g_Options.m_bLedNumbers )
878
+ DrawText (lpdi->hDC , szBuf, -1 , &rcOut, DT_SINGLELINE | DT_CENTER | DT_BOTTOM);
864
879
865
880
HDC hdcMem = CreateCompatibleDC (lpdi->hDC );
866
881
if (hdcMem)
867
882
{
883
+ if (g_Options.m_bLedNumbers )
884
+ {
885
+ HBITMAP hOldbmp = (HBITMAP)SelectObject (hdcMem, m_hDigits);
886
+ if (hOldbmp)
887
+ {
888
+ int Place = 100 ;
889
+ int Value = g_CPUUsage;
890
+ BOOL fDrawnYet = FALSE ;
891
+
892
+ for (int i = 0 ; i < 3 ; i++)
893
+ {
894
+ // Don't zero-pad
895
+
896
+ if (Value / Place == 0 && fDrawnYet == FALSE && Place != 1 )
897
+ {
898
+ BitBlt (lpdi->hDC , xOffset + DIGIT_WIDTH * i, yOffset,
899
+ DIGIT_WIDTH, DIGIT_HEIGHT,
900
+ hdcMem,
901
+ BLANK_INDEX * DIGIT_WIDTH, 0 ,
902
+ SRCCOPY);
903
+ }
904
+ else
905
+ {
906
+ BitBlt (lpdi->hDC , xOffset + DIGIT_WIDTH * i, yOffset,
907
+ DIGIT_WIDTH, DIGIT_HEIGHT,
908
+ hdcMem,
909
+ (Value / Place) * DIGIT_WIDTH, 0 ,
910
+ SRCCOPY);
911
+ if (Value / Place)
912
+ {
913
+ fDrawnYet = TRUE ;
914
+ }
915
+ }
916
+ Value %= Place;
917
+ Place /= 10 ;
918
+ }
919
+ }
920
+
921
+ // Percent sign
922
+
923
+ BitBlt (lpdi->hDC , xOffset + 3 * DIGIT_WIDTH, yOffset,
924
+ DIGIT_WIDTH, DIGIT_HEIGHT,
925
+ hdcMem,
926
+ PERCENT_SIGN_INDEX * DIGIT_WIDTH, 0 , SRCCOPY);
927
+ }
928
+
868
929
//
869
930
// Draw the CPU meter
870
931
//
@@ -957,10 +1018,42 @@ void CPerfPage::DrawMEMMeter(LPDRAWITEMSTRUCT lpdi)
957
1018
{
958
1019
__int64 memUsage = (g_Options.m_mmHistMode == MM_PHYSICAL) ? g_PhysMEMUsage : g_MEMUsage;
959
1020
__int64 memMax = (g_Options.m_mmHistMode == MM_PHYSICAL) ? g_PhysMEMMax : g_MEMMax;
1021
+
1022
+ // <1GB. 6 digits, K symbol.
1023
+ int cDigits = 6 ;
1024
+ int Place = 100000 ;
1025
+ BOOL fNoSymbol = FALSE ;
1026
+ BOOL fMegabytes = FALSE ;
1027
+
1028
+ // >100GB: 7 digits, no symbol, megabytes.
1029
+ if (memUsage >= 100000000 )
1030
+ {
1031
+ cDigits = 7 ;
1032
+ Place = 1000000 ;
1033
+ fNoSymbol = TRUE ;
1034
+ fMegabytes = TRUE ;
1035
+ }
1036
+ // >1GB, <100GB. 6 digits, M symbol.
1037
+ else if (memUsage >= 10000000 )
1038
+ {
1039
+ cDigits = 6 ;
1040
+ fMegabytes = TRUE ;
1041
+ }
1042
+ // >1GB, <10GB: 7 digits, no symbol, kilobytes.
1043
+ else if (memUsage >= 1000000 )
1044
+ {
1045
+ cDigits = 7 ;
1046
+ Place = 1000000 ;
1047
+ fNoSymbol = TRUE ;
1048
+ }
1049
+
960
1050
HBRUSH hBlack = (HBRUSH) GetStockObject (BLACK_BRUSH);
961
1051
HGDIOBJ hOld = SelectObject (lpdi->hDC , hBlack);
962
1052
Rectangle (lpdi->hDC , lpdi->rcItem .left , lpdi->rcItem .top , lpdi->rcItem .right , lpdi->rcItem .bottom );
963
1053
1054
+ INT xOffset = ((lpdi->rcItem .right - lpdi->rcItem .left ) -
1055
+ ((fNoSymbol ? (cDigits) : (cDigits + 1 )) * DIGIT_WIDTH)) / 2 ;
1056
+ INT yOffset = (lpdi->rcItem .bottom - DIGIT_HEIGHT - g_DefSpacing);
964
1057
INT xBarOffset = ((lpdi->rcItem .right - lpdi->rcItem .left ) - STRIP_WIDTH) / 2 ;
965
1058
966
1059
SetBkMode (lpdi->hDC , TRANSPARENT);
@@ -970,11 +1063,63 @@ void CPerfPage::DrawMEMMeter(LPDRAWITEMSTRUCT lpdi)
970
1063
StrFormatByteSize64 ( memUsage * 1024 , szBuf, ARRAYSIZE (szBuf) );
971
1064
RECT rcOut = lpdi->rcItem ;
972
1065
rcOut.bottom -= 4 ;
973
- DrawText (lpdi->hDC , szBuf, -1 , &rcOut, DT_SINGLELINE | DT_CENTER | DT_BOTTOM);
1066
+ if (!g_Options.m_bLedNumbers )
1067
+ DrawText (lpdi->hDC , szBuf, -1 , &rcOut, DT_SINGLELINE | DT_CENTER | DT_BOTTOM);
974
1068
975
1069
HDC hdcMem = CreateCompatibleDC (lpdi->hDC );
976
1070
if (hdcMem)
977
1071
{
1072
+ if (g_Options.m_bLedNumbers )
1073
+ {
1074
+ HBITMAP hOldbmp = (HBITMAP)SelectObject (hdcMem, m_hDigits);
1075
+ if (hOldbmp)
1076
+ {
1077
+ int Value = memUsage;
1078
+ if (fMegabytes )
1079
+ Value /= 1000 ;
1080
+ BOOL fDrawnYet = FALSE ;
1081
+
1082
+ for (int i = 0 ; i < cDigits; i++)
1083
+ {
1084
+ // Don't zero-pad
1085
+
1086
+ if (Value / Place == 0 && fDrawnYet == FALSE )
1087
+ {
1088
+ BitBlt (lpdi->hDC , xOffset + DIGIT_WIDTH * i, yOffset,
1089
+ DIGIT_WIDTH, DIGIT_HEIGHT,
1090
+ hdcMem,
1091
+ BLANK_INDEX * DIGIT_WIDTH, 0 ,
1092
+ SRCCOPY);
1093
+ }
1094
+ else
1095
+ {
1096
+ BitBlt (lpdi->hDC , xOffset + DIGIT_WIDTH * i, yOffset,
1097
+ DIGIT_WIDTH, DIGIT_HEIGHT,
1098
+ hdcMem,
1099
+ (Value / Place) * DIGIT_WIDTH, 0 ,
1100
+ SRCCOPY);
1101
+ if (Value / Place)
1102
+ {
1103
+ fDrawnYet = TRUE ;
1104
+ }
1105
+ }
1106
+ Value %= Place;
1107
+ Place /= 10 ;
1108
+
1109
+ };
1110
+
1111
+ if (FALSE == fNoSymbol )
1112
+ {
1113
+ // K/M
1114
+ int index = fMegabytes ? M_INDEX : K_INDEX;
1115
+ BitBlt (lpdi->hDC , xOffset + cDigits * DIGIT_WIDTH, yOffset,
1116
+ DIGIT_WIDTH, DIGIT_HEIGHT,
1117
+ hdcMem,
1118
+ index * DIGIT_WIDTH, 0 , SRCCOPY);
1119
+ }
1120
+ }
1121
+ }
1122
+
978
1123
//
979
1124
// Draw the CPU meter
980
1125
//
@@ -1392,6 +1537,11 @@ HRESULT CPerfPage::Initialize(HWND hwndParent)
1392
1537
1393
1538
CreatePens ();
1394
1539
1540
+ m_hDigits = (HBITMAP) LoadImage (g_hInstance, MAKEINTRESOURCE (LED_NUMBERS),
1541
+ IMAGE_BITMAP,
1542
+ 0 , 0 ,
1543
+ LR_DEFAULTCOLOR);
1544
+
1395
1545
m_hStripLit = (HBITMAP) LoadImage (g_hInstance, MAKEINTRESOURCE (LED_STRIP_LIT),
1396
1546
IMAGE_BITMAP,
1397
1547
0 , 0 ,
@@ -1570,6 +1720,12 @@ HRESULT CPerfPage::Destroy()
1570
1720
m_hPage = NULL ;
1571
1721
}
1572
1722
1723
+ if (m_hDigits)
1724
+ {
1725
+ DeleteObject (m_hDigits);
1726
+ m_hDigits = NULL ;
1727
+ }
1728
+
1573
1729
if (m_hStripLit)
1574
1730
{
1575
1731
DeleteObject (m_hStripLit);
0 commit comments