+ fix: small bug preventing Statusbar relative width settings smaller than 1/10 of width

This commit is contained in:
Rainer Kottenhoff 2018-04-26 11:55:02 +02:00
parent 3c697511f4
commit 4bdb4a7e70
4 changed files with 14 additions and 11 deletions

Binary file not shown.

View File

@ -1007,7 +1007,7 @@ LONG StatusCalcPaneWidth(HWND hwnd,LPCWSTR lpsz)
SelectObject(hdc,hfold);
ReleaseDC(hwnd,hdc);
return (size.cx + 12L);
return (size.cx + 8L);
}
@ -2887,8 +2887,8 @@ int ReadVectorFromString(LPCWSTR wchStrg, int* iVector, int iCount, int iMin, in
while (*p) {
int iValue;
if (swscanf_s(p, L"%i", &iValue) == 1) {
if ((n < iCount) && (iValue >= iMin) && (iValue <= iMax)) {
iVector[n++] = iValue;
if (n < iCount) {
iVector[n++] = min(max(iValue, iMin), iMax);
}
}
p = StrEnd(p) + 1;

View File

@ -742,29 +742,31 @@ static int g_aSBSOrder[STATUS_SECTOR_COUNT];
// _StatusbarSetSections()
//
//
static void __fastcall _StatusbarSetSections(int cx)
static void __fastcall _StatusbarSetSections(int width)
{
static int lastCX = -1;
if (!bShowStatusbar || (cx == lastCX)) { return; } // static calculation
static int lastWinWidth = -1;
width -= STAUSBAR_RIGHT_MARGIN;
if (!bShowStatusbar || (width < 0) || (width == lastWinWidth)) { return; } // static calculation
// prepare sector array
for (int i = 0; i < STATUS_SECTOR_COUNT; ++i) {
g_vStatusbarSectionWidth[i] = -1;
g_aSBSOrder[i] = -1;
g_aSBSOrder[i] = i;
}
int vSections[STATUS_SECTOR_COUNT];
ReadVectorFromString(g_tchStatusbarSections, vSections, STATUS_SECTOR_COUNT, 0, (STATUS_SECTOR_COUNT - 1), -1);
int vWeights[STATUS_SECTOR_COUNT];
ReadVectorFromString(g_tchStatusbarRelWidths, vWeights, STATUS_SECTOR_COUNT, 0, (STATUS_SECTOR_COUNT - 1), 1);
ReadVectorFromString(g_tchStatusbarRelWidths, vWeights, STATUS_SECTOR_COUNT, 0, 4096, 1);
int cnt = 0;
int totalWeight = 0;
for (int i = 0; i < STATUS_SECTOR_COUNT; ++i) {
int const iID = vSections[i];
if (iID != -1) {
g_vStatusbarSectionWidth[iID] = (cx * vWeights[iID]);
g_vStatusbarSectionWidth[iID] = (width * vWeights[iID]);
totalWeight += vWeights[iID];
g_aSBSOrder[cnt++] = iID;
}
@ -777,7 +779,7 @@ static void __fastcall _StatusbarSetSections(int cx)
}
}
}
lastCX = cx;
lastWinWidth = width;
}

View File

@ -91,8 +91,9 @@ typedef enum {
} STATUS_SECTOR_T;
#define STATUSBAR_DEFAULT_IDS L"0 1 2 3 4 5 6 7 8 9 10"
#define STATUSBAR_SECTION_WIDTH L"2 2 3 2 2 2 2 1 1 1 3"
#define STATUSBAR_SECTION_WIDTH L"20 20 28 20 20 20 20 7 7 7 36"
#define STATUSBAR_EXTION_PREFIXES L"Ln ,Col ,Sel ,SelLn ,Occ ,,,,,,,,"
#define STAUSBAR_RIGHT_MARGIN 20
// --------------------------------------------------------------------------