/*---------------------------------------------------------------------------------------------- Draw the combo control. ----------------------------------------------------------------------------------------------*/ bool IconComboCombo::OnDrawThisItem(DRAWITEMSTRUCT * pdis) { AssertPtr(pdis); AssertPtr(m_pival); #ifdef JT_4_3_01_IMPLEMENTED HDC hdc = pdis->hDC; Rect rc(pdis->rcItem); UINT state = pdis->itemState; int ival = *m_pival; SIZE sizeMargins = { ::GetSystemMetrics(SM_CXEDGE), ::GetSystemMetrics(SM_CYEDGE) }; // Draw the down arrow. ::DrawFrameControl(hdc, &m_rcArrowButton, DFC_SCROLL, DFCS_SCROLLDOWN | (m_fPushed || (state & ODS_SELECTED) ? DFCS_PUSHED : 0) | ((state & ODS_DISABLED) ? DFCS_INACTIVE : 0)); ::DrawEdge(hdc, &rc, EDGE_SUNKEN, BF_RECT); // Must reduce the size of the "client" area of the button due to edge thickness. rc.Inflate(-sizeMargins.cx, -sizeMargins.cy); // This is old code from UiColor.cpp. It may be some help if we get around to implementing // this control fully. // Select and realize the palette. HPALETTE hpalOld = g_ct.RealizePalette(hdc); // Fill background. rc.right -= m_rcArrowButton.right - m_rcArrowButton.left; HPEN hpenOld = (HPEN)::SelectObject(hdc, ::GetStockObject(NULL_PEN)); // HBRUSH hbrBackground = AfGdi::CreateSolidBrush(((state & ODS_DISABLED) || // clr == CLR_DEFAULT) ? ::GetSysColor(COLOR_3DFACE) : RGB(255, 255, 255)); HBRUSH hbrBackground = AfGdi::CreateSolidBrush(((state & ODS_DISABLED) || clr == CLR_DEFAULT) ? ::GetSysColor(COLOR_3DFACE) : ::GetSysColor(COLOR_WINDOW)); HBRUSH hbrOld = AfGdi::SelectObjectBrush(hdc, hbrBackground); ::Rectangle(hdc, rc.left, rc.top, rc.right + 1, rc.bottom + 1); // If knNinch or conflicting then leave control blank. if ((clr != (COLORREF)knNinch) && (clr != (COLORREF)knNinch + 1)) { // Fill a small box with color. int nBoxHeight = rc.bottom - rc.top - 4; RECT rcBox = { rc.left + 2, rc.top + 2, rc.left + 2 + nBoxHeight, rc.bottom - 2 }; if (!m_fShowText) ::SetRect(&rcBox, rc.left + 2, rc.top + 2, rc.right - 2, rc.bottom - 2); COLORREF clr2 = clr; if (clr2 == kclrTransparent) clr2 = ::GetSysColor(COLOR_WINDOW); // clr2 = kclrWhite; HBRUSH hbr = AfGdi::CreateSolidBrush(((state & ODS_DISABLED) || clr2 == CLR_DEFAULT) ? ::GetSysColor(COLOR_3DFACE) : PALETTERGB(GetRValue(clr2), GetGValue(clr2), GetBValue(clr2))); HBRUSH hbrT = AfGdi::SelectObjectBrush(hdc, hbr); ::Rectangle(hdc, rcBox.left, rcBox.top, rcBox.right, rcBox.bottom); AfGdi::SelectObjectBrush(hdc, hbrT); ::FrameRect(hdc, &rcBox, (HBRUSH)::GetStockObject(BLACK_BRUSH)); AfGdi::DeleteObjectBrush(hbr); if (hpalOld) ::SelectPalette(hdc, hpalOld, false); if (m_fShowText) { // Write out the text to the right of the box //COLORREF clrOldBk = ::SetBkColor(hdc, RGB(255,255,255)); COLORREF clrOldBk = ::SetBkColor(hdc, ::GetSysColor(COLOR_WINDOW)); Rect rcT(rcBox.right + 2, rcBox.top - 1, rc.right - 1, rcBox.bottom + 1); HFONT hfontOld = AfGdi::SelectObjectFont(hdc, ::GetStockObject(DEFAULT_GUI_FONT)); StrAnsi sta(g_ct.GetColorRid(g_ct.GetIndexFromColor(clr))); ::DrawText(hdc, sta.Chars(), -1, &rcT, DT_LEFT); AfGdi::SelectObjectFont(hdc, hfontOld, AfGdi::OLD); ::SetBkColor(hdc, clrOldBk); } } if (hpenOld) ::SelectObject(hdc, hpenOld); AfGdi::SelectObjectBrush(hdc, hbrOld, AfGdi::OLD); AfGdi::DeleteObjectBrush(hbrBackground); // Draw focus rect if (state & ODS_FOCUS) { Rect rcT; rcT.Set(rc.left + 1, rc.top + 1, rc.right - 1, rc.bottom - 1); ::DrawFocusRect(hdc, &rcT); } #endif JT_4_3_01_IMPLEMENTED return true; }
/*---------------------------------------------------------------------------------------------- Make an edit box to allow editing. hwnd is the parent hwnd. rc is the size of the child window. Store the hwnd and return true. @param hwnd @param rc @param dxpCursor @param fTopCursor @param tpte @return true if successful TODO: To handle extra long field contents (and RTL?) the button cannot be a child of the edit control, because they must occupy seperate rectangles inside the field proper. ----------------------------------------------------------------------------------------------*/ bool AfDeFeEdBoxBut::BeginEdit(HWND hwnd, Rect &rc, int dxpCursor, bool fTopCursor, TptEditable tpte) { if (!SuperClass::BeginEdit(hwnd, rc, dxpCursor, fTopCursor)) return false; DeEditPtr qde; qde.Create(); qde->SetEditable(tpte); qde->m_pdee = this; IActionHandler * pacth = BeginTempEdit(); ILgWritingSystemFactoryPtr qwsf; GetLpInfo()->GetDbInfo()->GetLgWritingSystemFactory(&qwsf); AssertPtr(qwsf); #if 1 int nRet = 0; ComBool fRTL = FALSE; IWritingSystemPtr qws; CheckHr(qwsf->get_EngineOrNull(m_ws, &qws)); if (qws) CheckHr(qws->get_RightToLeft(&fRTL)); if (fRTL) qde->Create(hwnd, kwidEditChild, WS_CHILD | ES_RIGHT | ES_AUTOHSCROLL, NULL, m_qtss, qwsf, m_ws, pacth); else #endif qde->Create(hwnd, kwidEditChild, WS_CHILD | ES_LEFT | ES_AUTOHSCROLL, NULL, m_qtss, qwsf, m_ws, pacth); m_hwnd = qde->Hwnd(); Rect rcT(rc.left + 2, rc.top + 1, rc.right, rc.bottom); nRet = ::MoveWindow(m_hwnd, rcT.left, rcT.top, rcT.Width(), rcT.Height(), true); #if 99-99 Rect rcParentClient; Rect rcParent; ::GetClientRect(hwnd, &rcParentClient); ::GetWindowRect(hwnd, &rcParent); Rect rcEdit; Rect rcEditClient; ::GetWindowRect(m_hwnd, &rcEdit); ::GetClientRect(m_hwnd, &rcEditClient); #endif Rect rcTb; ::GetClientRect(m_hwnd, &rcTb); rcTb.left = rcTb.right - 16; rcTb.bottom = rcTb.top + Min((int)rcTb.bottom - (int)rcTb.top, (int)kdxpButtonHeight); WndCreateStruct wcsButton; wcsButton.InitChild(_T("BUTTON"), m_hwnd, kwidEditChild); wcsButton.style |= WS_VISIBLE | BS_OWNERDRAW; wcsButton.SetRect(rcTb); DeButtonPtr qdb; qdb.Create(); qdb->CreateAndSubclassHwnd(wcsButton); qdb->m_pdee = this; m_hwndButton = qdb->Hwnd(); #if 1-1 // Resize the edit control window to exclude the button nRet = ::MoveWindow(m_hwnd, rcT.left, rcT.top, rcT.Width() - 18, rcT.Height(), true); #endif // Add text to the window. ::SendMessage(m_hwnd, FW_EM_SETSTYLE, m_chrp.clrBack, (LPARAM)&m_qfsp->m_stuSty); ::SendMessage(m_hwnd, EM_SETMARGINS, EC_RIGHTMARGIN | EC_LEFTMARGIN, MAKELPARAM(0, 18)); ::ShowWindow(m_hwnd, SW_SHOW); //::SendMessage(m_hwnd, WM_SETFONT, (WPARAM)::GetStockObject(DEFAULT_GUI_FONT), 0); // Foreground/background colors are set via WM_CTLCOLOREDIT in AfDeFeWnd. // Set cursor to desired offset. //int ich; //ich = LOWORD(::SendMessage(m_hwnd, EM_CHARFROMPOS, 0, dxpCursor)); // For some reason the above always comes back with -1 instead of the correct index. // Is this a bug in TssEdit or am I doing something wrong? //::SendMessage(m_hwnd, EM_SETSEL, ich, ich); //::mouse_event(MOUSEEVENTF_LEFTDOWN,0,0,0,0); // Send LButton to place cursor in edit ctrl. #if 99-99 Rect rcEditNew; Rect rcEditNewClient; Rect rcBut; Rect rcButClient; ::GetWindowRect(m_hwnd, &rcEditNew); ::GetClientRect(m_hwnd, &rcEditNewClient); ::GetWindowRect(m_hwndButton, &rcBut); ::GetClientRect(m_hwndButton, &rcButClient); #endif return true; }