//**************************************************************************** // $Module type: Class // $Module name: cWinTextBox // $Author : ????????? // Sergey V. Natarow // Nils G. Svedmyr // Created : 2004-05-16 @ 12:52 // // Description : // // $Rev History: // 2004-05-16 Module header created //**************************************************************************** Use cBaseWinControl.pkg Use cWinTextBox.h Class cWinTextBox Is A cBaseWinControl Procedure Construct_Object Set External_Class_Name "cTextBox" To "static" // Set External_Message WM_DRAWITEM To Wmsg_onDrawItem Set External_Message WM_ERASEBKGND To WMMSG_Erasebkgnd // Forward Send Construct_Object // Property Integer private_pbParentColor True Property Integer Border_Style Public BORDER_NONE Property Integer Border_Color Public clBlack Property Integer Border_Width Public 1 // Set Window_Style To SS_NOTIFY True Set Skip_state To True Set Focus_Mode To Pointer_Only Set FontWeight To 400 // End_Procedure // ----------------------------------- COLORS ------------------------------------------- Procedure DoSetParentsColor Set Color To (Color(parent(Self))) Set TextColor To (TextColor(parent(Self))) End_Procedure Procedure Set UseParentColorState Integer bParentColor Set private_pbParentColor To bParentColor If bParentColor Begin Send DoSetParentsColor End End_Procedure Function UseParentColorState Returns Integer Function_Return (private_pbParentColor(Self)) End_Function Procedure Page Integer iState // Remove all style bits: Set Window_Style To $FFFF False Set Window_Style To SS_OWNERDRAW True Forward Send Page iState End_Procedure Procedure OnParentColorChange // This is broadcasted by containers whenever they change color Send DoSetParentsColor End_Procedure // // ----------------------- DRAW ----------------------------- Procedure DrawLabel Handle hDC Integer iShad Integer iX Integer iY Integer iRet iColor iBX iBY iBA Integer iT iB iL iR Handle hOldF String sData sRc sSRc Pointer lpData lpRc lpSRc // // Font Move (SelectObject(hDc, ControlFont(Self))) To hOldF Move (Label(Self)+Character(0)) To sData GetAddress Of sData To lpData // ZeroType tRect To sRc GetAddress Of sRc To lpRc If iShad Begin ZeroType tRect To sSRc GetAddress Of sSRc To lpSRc Move (SetRectEf(lpSRc, 5, 1, iX-7, iY+1)) To iRet Move (SetTextColor(hDc, clWhite)) To iRet Move (DrawText(hDc, lpData, -1, lpSRc, piTextAlignFlags(Self) )) To iRet Move (SetTextColor(hDc, clDkGray)) To iRet End Else Move (SetRectEf(lpRc, 4, 0, iX-8, iY )) To iRet // Move (DrawText(hDc, lpData, -1, lpRc, piTextAlignFlags(Self) )) To iRet // Move (SelectObject(hDc, hOldF)) To hOldF End_Procedure Procedure DrawControl Handle hDC Handle hBrush hPen hOldB hOldP Integer iGMode iGFrom iGTo iX iY iRet Integer iColor iTextColor iShad iBorder iFlag iBW String sRect Pointer pRect // Get piColor To iColor Get piTextColor To iTextColor // Get Private.pbShadowState To iShad Get Border_Style To iBorder // Move (CreateSolidBrush(iColor)) To hBrush If (iBorder=BORDER_NORMAL) Begin Get Border_Width To iBW Move (CreatePenEf(PS_SOLID, iBW, Border_Color(Self))) To hPen End Else Move (CreatePenEf(PS_SOLID, 1, iColor)) To hPen // Move (SelectObject(hDC, hPen)) To hOldP Move (SelectObject(hDC, hBrush)) To hOldB Move (Hi(guisize(Self))) To iY Move (Low(guisize(Self))) To iX // If ((iBorder=BORDER_DIALOG)Or(iBorder=BORDER_WINDOWEDGE)) Begin ZeroType tRect To sRect Put iY To sRect At tRect.Bottom Put iX To sRect At tRect.Right GetAddress Of sRect To pRect Move (DrawFrameControlEf(hDc, pRect, DFC_BUTTON, DFCS_BUTTONPUSH )) To iRet End Else If ((iBorder=BORDER_STATICEDGE)Or(iBorder=BORDER_CLIENTEDGE)) Begin ZeroType tRect To sRect Put iY To sRect At tRect.Bottom Put iX To sRect At tRect.Right GetAddress Of sRect To pRect Move (DrawFrameControlEf(hDc, pRect, DFC_BUTTON, (DFCS_BUTTONPUSH Ior DFCS_PUSHED ) )) To iRet End If (iBorder=BORDER_NORMAL) Move (Rectangle(hDC, 0, 0, iX, iY)) To iRet // Get Gradient_Mode To iGMode If iGMode Begin Get piGradientFrom To iGFrom Get piGradientTo To iGTo If (iBorder=BORDER_DIALOG) Move (DrawGradient(hDC, iGMode, iGFrom, iGTo, 2, 2, iX-2, iY-2)) To iRet Else If (iBorder=BORDER_CLIENTEDGE) Move (DrawGradient(hDC, iGMode, iGFrom, iGTo, 2, 2, iX-2, iY-2)) To iRet Else If (iBorder=BORDER_STATICEDGE) Move (DrawGradient(hDC, iGMode, iGFrom, iGTo, 1, 1, iX-1, iY-1)) To iRet Else If (iBorder=BORDER_NORMAL) Move (DrawGradient(hDC, iGMode, iGFrom, iGTo, iBW, iBW, iX-iBW, iY-iBW)) To iRet Else If (iBorder=BORDER_WINDOWEDGE) Move (DrawGradient(hDC, iGMode, iGFrom, iGTo, 1, 1, iX-1, iY-1)) To iRet Else Move (DrawGradient(hDC, iGMode, iGFrom, iGTo, 0, 0, iX, iY)) To iRet End Else Begin If (iBorder=BORDER_DIALOG) Move (Rectangle(hDC, 2, 2, iX-2, iY-2)) To iRet Else If (iBorder=BORDER_CLIENTEDGE) Move (Rectangle(hDC, 2, 2, iX-2, iY-2)) To iRet Else If (iBorder=BORDER_STATICEDGE) Move (Rectangle(hDC, 1, 1, iX-1, iY-1)) To iRet Else If (iBorder=BORDER_NORMAL) Move (Rectangle(hDC, iBW, iBW, iX-iBW, iY-iBW)) To iRet Else If (iBorder=BORDER_WINDOWEDGE) Move (Rectangle(hDC, 1, 1, iX-1, iY-1)) To iRet Else Move (Rectangle(hDC, 0, 0, iX, iY)) To iRet End // Move (SetBkMode(hDC, TRANSPARENT)) To iRet Move (SetTextColor(hDc, iTextColor)) To iRet If (Label(Self)<>"") Send DrawLabel hDC iShad iX iY // Move (SelectObject(hDC, hOldP)) To hOldP Move (SelectObject(hDC, hOldB)) To hOldB Move (DeleteObject(hPen)) To iRet Move (DeleteObject(hBrush)) To iRet // End_Procedure // ----------------------- PRIVATE EVENTS ------------------------- Procedure WMMSG_Erasebkgnd Integer wParam Integer lParam Procedure_Return 1 End_Procedure // Procedure WMSG_OnDrawItem Integer wParam Integer lParam Integer iRet Integer iAct iState hDC String sItemStr Pointer pItemStr ZeroType DRAWITEMSTRUCT To sItemStr GetAddress Of sItemStr To pItemStr Move (CopyMemory(pItemStr, lParam, DRAWITEMSTRUCT_SIZE)) To iRet GetBuff From sItemStr At DRAWITEMSTRUCT.itemAction To iAct GetBuff From sItemStr At DRAWITEMSTRUCT.itemState To iState GetBuff From sItemStr At DRAWITEMSTRUCT.hDC To hDC Send DrawControl hDC Send OnPaint hDC iAct iState End_Procedure Procedure command Integer wPara Integer lPara If (Hi(wPara)=BN_CLICKED) Send onClick End_Procedure // ----------------- PUBLIC EVENTS ------------------- Procedure OnPaint Integer hDC Integer iAct Integer iState End_Procedure End_Class