Better horizontal candidate list rendering.
Added horzcandspacing constant to add space between horizontal candidates.
This commit is contained in:
parent
4312d18cf7
commit
3dea87cdc7
1 changed files with 58 additions and 35 deletions
|
@ -1382,8 +1382,9 @@ IME_PositionCandidateList(SDL_VideoData *videodata, SIZE size)
|
||||||
static void
|
static void
|
||||||
IME_RenderCandidateList(SDL_VideoData *videodata, HDC hdc)
|
IME_RenderCandidateList(SDL_VideoData *videodata, HDC hdc)
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i, j;
|
||||||
SIZE size = {0};
|
SIZE size = {0};
|
||||||
|
SIZE candsizes[MAX_CANDLIST];
|
||||||
SIZE maxcandsize = {0};
|
SIZE maxcandsize = {0};
|
||||||
HBITMAP hbm = NULL;
|
HBITMAP hbm = NULL;
|
||||||
BYTE *bits = NULL;
|
BYTE *bits = NULL;
|
||||||
|
@ -1404,6 +1405,7 @@ IME_RenderCandidateList(SDL_VideoData *videodata, HDC hdc)
|
||||||
const COLORREF selbordercolor = RGB(0x84, 0xAC, 0xDD);
|
const COLORREF selbordercolor = RGB(0x84, 0xAC, 0xDD);
|
||||||
const COLORREF selfillcolor = RGB(0xD2, 0xE6, 0xFF);
|
const COLORREF selfillcolor = RGB(0xD2, 0xE6, 0xFF);
|
||||||
const COLORREF seltextcolor = RGB(0, 0, 0);
|
const COLORREF seltextcolor = RGB(0, 0, 0);
|
||||||
|
const int horzcandspacing = 5;
|
||||||
|
|
||||||
HPEN listpen = listborder != 0 ? CreatePen(PS_SOLID, listborder, listbordercolor) : (HPEN)GetStockObject(NULL_PEN);
|
HPEN listpen = listborder != 0 ? CreatePen(PS_SOLID, listborder, listbordercolor) : (HPEN)GetStockObject(NULL_PEN);
|
||||||
HBRUSH listbrush = CreateSolidBrush(listfillcolor);
|
HBRUSH listbrush = CreateSolidBrush(listfillcolor);
|
||||||
|
@ -1421,32 +1423,51 @@ IME_RenderCandidateList(SDL_VideoData *videodata, HDC hdc)
|
||||||
if (!*s)
|
if (!*s)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
GetTextExtentPoint32W(hdc, s, SDL_wcslen(s), &size);
|
GetTextExtentPoint32W(hdc, s, SDL_wcslen(s), &candsizes[i]);
|
||||||
maxcandsize.cx = SDL_max(maxcandsize.cx, size.cx);
|
maxcandsize.cx = SDL_max(maxcandsize.cx, candsizes[i].cx);
|
||||||
maxcandsize.cy = SDL_max(maxcandsize.cy, size.cy);
|
maxcandsize.cy = SDL_max(maxcandsize.cy, candsizes[i].cy);
|
||||||
|
|
||||||
}
|
}
|
||||||
if (!vertical)
|
if (vertical) {
|
||||||
SDL_swap(maxcandsize.cx, maxcandsize.cy);
|
size.cx =
|
||||||
|
(listborder * 2) +
|
||||||
|
(listpadding * 2) +
|
||||||
|
(candmargin * 2) +
|
||||||
|
(candborder * 2) +
|
||||||
|
(candpadding * 2) +
|
||||||
|
(maxcandsize.cx)
|
||||||
|
;
|
||||||
|
size.cy =
|
||||||
|
(listborder * 2) +
|
||||||
|
(listpadding * 2) +
|
||||||
|
((candcount + 1) * candmargin) +
|
||||||
|
(candcount * candborder * 2) +
|
||||||
|
(candcount * candpadding * 2) +
|
||||||
|
(candcount * maxcandsize.cy)
|
||||||
|
;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
size.cx =
|
||||||
|
(listborder * 2) +
|
||||||
|
(listpadding * 2) +
|
||||||
|
((candcount + 1) * candmargin) +
|
||||||
|
(candcount * candborder * 2) +
|
||||||
|
(candcount * candpadding * 2) +
|
||||||
|
((candcount - 1) * horzcandspacing);
|
||||||
|
;
|
||||||
|
|
||||||
size.cx =
|
for (i = 0; i < candcount; ++i)
|
||||||
(listborder * 2) +
|
size.cx += candsizes[i].cx;
|
||||||
(listpadding * 2) +
|
|
||||||
(candmargin * 2) +
|
size.cy =
|
||||||
(candborder * 2) +
|
(listborder * 2) +
|
||||||
(candpadding * 2) +
|
(listpadding * 2) +
|
||||||
(maxcandsize.cx)
|
(candmargin * 2) +
|
||||||
;
|
(candborder * 2) +
|
||||||
size.cy =
|
(candpadding * 2) +
|
||||||
(listborder * 2) +
|
(maxcandsize.cy)
|
||||||
(listpadding * 2) +
|
;
|
||||||
((candcount + 1) * candmargin) +
|
}
|
||||||
(candcount * candborder * 2) +
|
|
||||||
(candcount * candpadding * 2) +
|
|
||||||
(candcount * maxcandsize.cy)
|
|
||||||
;
|
|
||||||
if (!vertical)
|
|
||||||
SDL_swap(size.cx, size.cy);
|
|
||||||
|
|
||||||
bits = StartDrawToBitmap(hdc, &hbm, size.cx, size.cy);
|
bits = StartDrawToBitmap(hdc, &hbm, size.cx, size.cy);
|
||||||
|
|
||||||
|
@ -1465,19 +1486,21 @@ IME_RenderCandidateList(SDL_VideoData *videodata, HDC hdc)
|
||||||
if (!*s)
|
if (!*s)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
left = listborder + listpadding + candmargin;
|
if (vertical) {
|
||||||
top = listborder + listpadding + (i * candborder * 2) + (i * candpadding * 2) + ((i + 1) * candmargin) + (i * maxcandsize.cy);
|
left = listborder + listpadding + candmargin;
|
||||||
if (!vertical)
|
top = listborder + listpadding + (i * candborder * 2) + (i * candpadding * 2) + ((i + 1) * candmargin) + (i * maxcandsize.cy);
|
||||||
SDL_swap(size.cx, size.cy);
|
right = size.cx - listborder - listpadding - candmargin;
|
||||||
|
bottom = top + maxcandsize.cy + (candpadding * 2) + (candborder * 2);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
left = listborder + listpadding + (i * candborder * 2) + (i * candpadding * 2) + ((i + 1) * candmargin) + (i * horzcandspacing);
|
||||||
|
|
||||||
right = size.cx - listborder - listpadding - candmargin;
|
for (j = 0; j < i; ++j)
|
||||||
if (!vertical)
|
left += candsizes[j].cx;
|
||||||
SDL_swap(size.cx, size.cy);
|
|
||||||
|
|
||||||
bottom = top + maxcandsize.cy + (candpadding * 2) + (candborder * 2);
|
top = listborder + listpadding + candmargin;
|
||||||
if (!vertical) {
|
right = left + candsizes[i].cx + (candpadding * 2) + (candborder * 2);
|
||||||
SDL_swap(left, top);
|
bottom = size.cy - listborder - listpadding - candmargin;
|
||||||
SDL_swap(right, bottom);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i == videodata->ime_candsel) {
|
if (i == videodata->ime_candsel) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue