717{
718 RECT msgRect, tempRect;
719 CopyRect(&msgRect, &r);
720
722 {
725 }
726
727 COLORREF colorHighAlpha, colorMediumAlpha;
729 {
732 }
733
734
735
737 {
738 int separatorOffset = (msgRect.bottom - msgRect.top) / 2;
739 msgRect.top = msgRect.top + separatorOffset - 1;
740 msgRect.bottom = msgRect.top + 2;
742 HBRUSH background;
744
746 FillRect(hdc, &msgRect, background);
747 DeleteObject(background);
748 }
749
750
751
753 {
754 InflateRect(&msgRect, -3, 0);
756 {
757 char timestamp[16];
758
759 strncpy_s(timestamp,
sizeof(timestamp), mLI->
msg, 12);
760 timestamp[12] = '\0';
761 DrawTextWithEffects(hdc, msgRect, mLI->
msg, DT_LEFT | DT_VCENTER | DT_NOPREFIX | DT_SINGLELINE | DT_WORD_ELLIPSIS, colorHighAlpha,
false, 0,
false, 0, 0, 0);
762 DrawTextWithEffects(hdc, msgRect, timestamp, DT_LEFT | DT_VCENTER | DT_NOPREFIX | DT_SINGLELINE | DT_WORD_ELLIPSIS, colorMediumAlpha,
false, 0,
false, 0, 0, 0);
763 }
764 else DrawTextWithEffects(hdc, msgRect, mLI->
msg, DT_LEFT | DT_VCENTER | DT_NOPREFIX | DT_SINGLELINE | DT_WORD_ELLIPSIS,
pSettings->
Console->
TextColor,
false, 0,
false, 0, 0, 0);
765
766
767 if (strlen(mLI->
url))
768 {
769 char msgWithoutURL[
sizeof(mLI->
msg)];
770 strcpy(msgWithoutURL, mLI->
msg);
771 char* msgPtr = msgWithoutURL;
772 char* urlPtr = StrStrI(msgWithoutURL, "http://");
773 if (urlPtr == NULL) urlPtr = StrStrI(msgWithoutURL, "https://");
774 if (urlPtr == NULL) urlPtr = StrStrI(msgWithoutURL, "file://");
775 if (urlPtr != NULL)
776 {
777 int n = urlPtr - msgPtr;
778 msgWithoutURL[n] = '\0';
779
780 SIZE sizeMsg, sizeURL, sizeSpace;
781 HDC fonthdc = CreateDC("DISPLAY", NULL, NULL, NULL);
782 HFONT tempFont = CreateFont(
pSettings->
Console->
FontHeight, 0, 0, 0,
pSettings->
Console->
FontWeight,
false,
false,
false, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH|FF_DONTCARE,
pSettings->
Console->
Font);
783 HGDIOBJ oldFont = SelectObject(fonthdc, tempFont);
784 GetTextExtentPoint32(fonthdc, msgWithoutURL, strlen(msgWithoutURL), &sizeMsg);
785 GetTextExtentPoint32(fonthdc, mLI->
url, strlen(mLI->
url), &sizeURL);
786 GetTextExtentPoint32(fonthdc, " ", 1, &sizeSpace);
787 if (sizeSpace.cx & 1) sizeSpace.cx += 1;
788 if (sizeSpace.cx < 4) sizeSpace.cx = 4;
789 DeleteObject(SelectObject(fonthdc, oldFont));
790 DeleteDC(fonthdc);
791
792 msgRect.left = msgRect.left + sizeMsg.cx - (sizeSpace.cx/2);
793 msgRect.right = msgRect.left + sizeURL.cx + sizeSpace.cx;
794
795
796 HBRUSH background;
799 FillRect(hdc, &msgRect, background);
800 DeleteObject(background);
801 if (
pSettings->
consoleDesktopMode)
DrawTextWithEffects(hdc, msgRect, mLI->
url, DT_CENTER | DT_VCENTER | DT_NOPREFIX | DT_SINGLELINE | DT_WORD_ELLIPSIS, 0x000000,
false, 0,
false, 0, 0, 0);
802 else DrawTextWithEffects(hdc, msgRect, mLI->
url, DT_CENTER | DT_VCENTER | DT_NOPREFIX | DT_SINGLELINE | DT_WORD_ELLIPSIS,
pSettings->
Console->
Color,
false, 0,
false, 0, 0, 0);
803 }
804 }
805 }
806
807
808
809 else
810 {
811 int msgHeight = msgRect.bottom - msgRect.top;
812 int iconSize = msgHeight - 2;
813
814 if (iconSize > 32) iconSize = 32;
815
816
817
818 RECT iconRect;
820 {
821 iconRect.left = msgRect.left + 4;
822 iconRect.top = msgRect.top + (msgHeight/2) - (iconSize/2);
823 iconRect.right = iconRect.left + iconSize;
824 iconRect.bottom = iconRect.top + iconSize;
825
826
827
828 DrawIconEx(hdc, iconRect.left, iconRect.top, mLI->
icon, iconSize, iconSize, 0, NULL, DI_NORMAL);
829 }
831
832
833 msgRect.left = iconRect.right + 3;
835 msgRect.right -= 2;
836 if (
pSettings->
consoleDesktopMode)
DrawTextWithEffects(hdc, msgRect, mLI->
msg, DT_LEFT | DT_VCENTER | DT_NOPREFIX | DT_SINGLELINE | DT_EXPANDTABS | DT_WORD_ELLIPSIS, colorHighAlpha,
false, 0,
false, 0, 0, 0);
837 else DrawTextWithEffects(hdc, msgRect, mLI->
msg, DT_LEFT | DT_VCENTER | DT_NOPREFIX | DT_SINGLELINE | DT_EXPANDTABS | DT_WORD_ELLIPSIS,
pSettings->
Console->
TextColor,
false, 0,
false, 0, 0, 0);
838 }
839}
void DrawTextWithEffects(HDC hdc, RECT r, LPSTR text, unsigned int format, COLORREF textColor, bool outline, COLORREF outlineColor, bool shadow, COLORREF shadowColor, int shadowX, int shadowY)
Definition BBApi.cpp:3519
#define CONSOLE_SEPARATOR
Definition BBApi.h:304
#define CONSOLE_REGULAR_MESSAGE
Definition BBApi.h:297
#define CONSOLE_PLAIN_MESSAGE
Definition BBApi.h:302
#define CONSOLE_INDENTED_MESSAGE
Definition BBApi.h:303
bool doubleScaleHiDPI
Definition Settings.h:326
COLORREF MixColors(COLORREF colorA, COLORREF colorB)
Definition Settings.cpp:2231
COLORREF TextColor
Definition BBApi.h:408
char msg[350]
Definition Console.h:45
int type
Definition Console.h:44
char url[256]
Definition Console.h:47
HICON icon
Definition Console.h:46