char* iupwinGetHFontAttrib(Ihandle *ih) { IwinFont* winfont = winFontGet(ih); if (!winfont) return NULL; else return (char*)winfont->hFont; }
void iupdrvFontGetMultiLineStringSize(Ihandle* ih, const char* str, int *w, int *h) { int max_w = 0; IwinFont* winfont = winFontGet(ih); if (!winfont) { if (w) *w = 0; if (h) *h = 0; return; } if (!str) { if (w) *w = 0; if (h) *h = winfont->charheight * 1; return; } if (str[0]) { SIZE size; int len, wlen; const char *nextstr; const char *curstr = str; HDC hdc = winFontGetDC(ih); HFONT oldhfont = (HFONT)SelectObject(hdc, winfont->hFont); TCHAR* wstr = iupwinStrToSystem(str); do { nextstr = iupStrNextLine(curstr, &len); if (len) { #ifdef UNICODE wlen = MultiByteToWideChar(iupwinStrGetUTF8Mode()? CP_UTF8: CP_ACP, 0, curstr, len, 0, 0); #else wlen = len; #endif size.cx = 0; GetTextExtentPoint32(hdc, wstr, wlen, &size); max_w = iupMAX(max_w, size.cx); wstr += wlen+1; } curstr = nextstr; } while(*nextstr); SelectObject(hdc, oldhfont); winFontReleaseDC(ih, hdc); } if (w) *w = max_w; if (h) *h = winfont->charheight * iupStrLineCount(str); }
void iupdrvFontGetCharSize(Ihandle* ih, int *charwidth, int *charheight) { IwinFont* winfont = winFontGet(ih); if (!winfont) { if (charwidth) *charwidth = 0; if (charheight) *charheight = 0; return; } if (charwidth) *charwidth = winfont->charwidth; if (charheight) *charheight = winfont->charheight; }
void iupdrvFontGetMultiLineStringSize(Ihandle* ih, const char* str, int *w, int *h) { int num_lin, max_w; IwinFont* winfont = winFontGet(ih); if (!winfont) { if (w) *w = 0; if (h) *h = 0; return; } if (!str) { if (w) *w = 0; if (h) *h = winfont->charheight * 1; return; } max_w = 0; num_lin = 1; if (str[0]) { SIZE size; int len; const char *nextstr; const char *curstr = str; HDC hdc = winFontGetDC(ih); HFONT oldhfont = SelectObject(hdc, winfont->hFont); do { nextstr = iupStrNextLine(curstr, &len); GetTextExtentPoint32(hdc, curstr, len, &size); max_w = iupMAX(max_w, size.cx); curstr = nextstr; if (*nextstr) num_lin++; } while(*nextstr); SelectObject(hdc, oldhfont); winFontReleaseDC(ih, hdc); } if (w) *w = max_w; if (h) *h = winfont->charheight*num_lin; }