internal override void GetTitleTextRect(int index, ref NativeWindowCommon.RECT rc) { // draw_column_titles() from cnt_pnt.cpp //InflateRect(&Rect, -factor, -factor); rc.left++; rc.top++; // Get_Divider_Cordinates(Gui, Ctrl, col + 1, &paintRect.right, &paintRect.left); rc.left = tableControl.GetColumnRectangle(index, false).Left; rc.left -= tableControl.BorderHeight; // start from bounds and not clientrectangle rc.top -= tableControl.BorderHeight; rc.right = GetTextRightCoordinate(index, rc.left); //paintRect.right -= PIX_BETWEEN_DEVIDER_AND_DIT * factor; //paintRect.left += PIX_BETWEEN_DEVIDER_AND_DIT * factor rc.right -= PIX_BETWEEN_DIVIDER_AND_DIT * TableControl.Factor; rc.left += PIX_BETWEEN_DIVIDER_AND_DIT * TableControl.Factor; //paintRect.bottom = Rect.top + Ctrl->TitleHeight - PIX_BETWEEN_DEVIDER_AND_DIT; //paintRect.top = Rect.top + PIX_BETWEEN_DEVIDER_AND_DIT; rc.bottom = rc.top + this.tableControl.TitleHeight - PIX_BETWEEN_DIVIDER_AND_DIT; rc.top = rc.top + PIX_BETWEEN_DIVIDER_AND_DIT * TableControl.Factor; }
/// <summary> /// paint header background /// </summary> /// <param name="pcust"></param> /// <param name="rect"></param> internal virtual void PaintBackGround(NativeCustomDraw.NMCUSTOMDRAW pcust, NativeWindowCommon.RECT rect) { if (TitleBrush != IntPtr.Zero) { NativeWindowCommon.FillRect(pcust.hdc, ref rect, TitleBrush); } }
/// <summary> /// get title text rect /// </summary> /// <param name="index"></param> /// <param name="rc"></param> internal override void GetTitleTextRect(int index, ref NativeWindowCommon.RECT rc) { // draw_column_titles() from cnt_pnt.cpp rc.top -= tableControl.BorderHeight; //if (Ctrl->Style & (CTRL_STYLE_THICK) || Ctrl->Style & (CTRL_STYLE_THIN)) // InflateRect(&Rect, -factor, -factor); if (tableControl.BorderType == util.BorderType.Thick || tableControl.BorderType == util.BorderType.Thin) { rc.top++; } //paintRect.bottom = Rect.top + Ctrl->TitleHeight - PIX_BETWEEN_DEVIDER_AND_DIT; //paintRect.top = Rect.top + PIX_BETWEEN_DEVIDER_AND_DIT; rc.bottom = rc.top + tableControl.TitleHeight - PIX_BETWEEN_DIVIDER_AND_DIT; rc.top += PIX_BETWEEN_DIVIDER_AND_DIT; //paintRect.right -= ((COL_DIVIDER - 1) * factor); //paintRect.left += ((COL_DIVIDER - 1) * factor); rc.left += (TwoDTableStyleRenderer.MARGIN - 1) * TableControl.Factor; rc.right -= (TwoDTableStyleRenderer.MARGIN - 1) * TableControl.Factor + 1; if (tableControl.RightToLeftLayout && index != 0) { rc.left--; } }
/// <summary> /// Draw the text. /// </summary> /// <param name="hdc"></param> /// <param name="color"></param> /// <param name="rect"></param> /// <param name="topOffset"></param> /// <param name="orientation"></param> /// <param name="fontDescription"></param> /// <param name="text"></param> /// <param name="contentAlignment"></param> /// <param name="flags"></param> public static void DrawText(IntPtr hdc, Color color, Rectangle rect, int topOffset, int orientation, FontDescription fontDescription, String text, ContentAlignment contentAlignment, int flags, bool rightToLeft) { NativeWindowCommon.SetBkMode(hdc, NativeWindowCommon.TRANSPARENT); NativeWindowCommon.SetTextColor(hdc, ColorTranslator.ToWin32(color)); #if !PocketPC // QCR #439182 & 430913: the font is used for a control before even being initialized. // TODO: We need a better fix that avoids calling get_Font() for logical controls that are not initialized properly. if (fontDescription == null) { fontDescription = new FontDescription(Control.DefaultFont); } #endif NativeWindowCommon.RECT rc = new NativeWindowCommon.RECT(); rc.left = rect.Left; rc.right = rect.Right; rc.top = rect.Top + topOffset; rc.bottom = rect.Bottom; #if !PocketPC if (orientation != 0) { PrintRotatedText(hdc, fontDescription, orientation, text, rect, contentAlignment, rc, rightToLeft); } else #endif { IntPtr hFont = fontDescription.FontHandle; NativeWindowCommon.SelectObject(hdc, hFont); NativeWindowCommon.DrawText(hdc, text, text.Length, ref rc, flags); } }
/// <summary> /// vertical table scroll /// </summary> /// <param name="scrollEventType">Scroll Event Type</param> /// <param name="newPos">the new position</param> /// <param name="oldPos">the old position</param> /// <param name="scrollWindow">true, if we need to scroll the window right away</param> protected override void ScrollVertically(ScrollEventType scrollEventType, int newPos, int oldPos, bool scrollWindow) { NativeScroll.SCROLLINFO sc = ScrollInfo(NativeScroll.SB_VERT); int maxScroll = sc.nMax - sc.nPage + 1; if (newPos > maxScroll) { newPos = maxScroll; } if (newPos < 0) { newPos = 0; } NativeScroll.SetScrollPos(this.Handle, NativeScroll.SB_VERT, newPos, true); _topIndex = newPos - RecordsBeforeCurrentView; if (scrollWindow) { NativeWindowCommon.RECT rc = new NativeWindowCommon.RECT(); rc.top = ClientRectangle.Top + _header.Height; rc.left = ClientRectangle.Left; rc.right = ClientRectangle.Right; rc.bottom = ClientRectangle.Bottom; NativeScroll.ScrollWindowEx(this.Handle, 0, (oldPos - newPos) * RowHeight, ref rc, (IntPtr)null, (IntPtr)null, (IntPtr)null, 0); } base.ScrollVertically(scrollEventType, newPos, oldPos, scrollWindow); }
/// <summary> /// /// </summary> /// <param name="hdc"></param> /// <param name="fontDescription"></param> /// <param name="orientation"></param> /// <param name="text"></param> /// <param name="rectangle"></param> /// <param name="contentAlignment"></param> /// <param name="rect"></param> internal static void PrintRotatedText(IntPtr hdc, FontDescription fontDescription, int orientation, string text, Rectangle rectangle, ContentAlignment contentAlignment, NativeWindowCommon.RECT rect, bool rightToLeft) { IntPtr hFont; Point point; // get the original font and its LOGFONT NativeWindowCommon.LOGFONT logfont = fontDescription.LogFont; // Set the rotation angle logfont.lfEscapement = logfont.lfOrientation = orientation; // create the new, rotated font hFont = NativeWindowCommon.CreateFontIndirect(logfont); NativeWindowCommon.SelectObject(hdc, hFont); point = CalculateStartCoordinates(hdc, rectangle, orientation, text, contentAlignment); uint fuOptions = NativeWindowCommon.ETO_CLIPPED; if (rightToLeft) { fuOptions = NativeWindowCommon.ETO_RTLREADING; } NativeWindowCommon.ExtTextOut(hdc, point.X, point.Y, fuOptions, ref rect, text, (uint)text.Length, null); NativeWindowCommon.DeleteObject(hFont); }
internal override void DrawDivider(IntPtr hdc, int index, ref NativeWindowCommon.RECT rect, int headerHeight) { rect.right--; IntPtr pen = header.DividerColor != Color.Empty ? HeaderDividerPen : HeaderItemBorderPen; DrawLine(hdc, new Point(rect.right, 0), new Point(rect.right, headerHeight), pen); }
/// <summary> /// paint background of header /// </summary> /// <param name="pcust"></param> /// <param name="rect"></param> internal override void PaintBackGround(NativeCustomDraw.NMCUSTOMDRAW pcust, NativeWindowCommon.RECT rect) { // Fill bg color base.PaintBackGround(pcust, rect); // draw bottom line rect.bottom--; DrawLine(pcust.hdc, new Point(rect.left, rect.bottom), new Point(rect.right, rect.bottom)); }
/// <summary> /// Paint the dividers /// Code from table_3d_paint() Ctrl_pnt.cpp /// </summary> /// <param name="hdc"></param> /// <param name="rect"></param> /// <param name="headerHeight"></param> internal override void DrawDivider(IntPtr hdc, int index, ref NativeWindowCommon.RECT rect, int headerHeight) { // Since we have white line at top , start the divider from 1 rect.top++; int left, right; // order of line is reverse for rtl hence swap left and right if (tableControl.RightToLeftLayout) { right = (rect.right) - TwoDTableStyleRenderer.MARGIN * TableControl.Factor + TableControl.Factor - 1; left = rect.right - 1; } else { left = (rect.right) - TwoDTableStyleRenderer.MARGIN * TableControl.Factor + TableControl.Factor - 1; right = rect.right - 1; } // Gui->ctx->gui_.dc_->frame_rect(&Rect1, FIX_SYS_COLOR_BTNSHADOW, factor, 0L); DrawLine(hdc, new Point(left, rect.top), new Point(left, headerHeight), ButtonShadowPen); left = tableControl.RightToLeftLayout ? left - 1 : left + 1; DrawLine(hdc, new Point(left, rect.top), new Point(left, headerHeight), ButtonShadowPen); // Rect1.left += 2 * factor; // Rect1.right += 2 * factor; // Gui->ctx->gui_.dc_->frame_rect(&Rect1, FIX_SYS_COLOR_BTNHIGHLIGHT, factor, 0L); DrawLine(hdc, new Point(right, rect.top), new Point(right, headerHeight), ButtonHighlightPen); right = tableControl.RightToLeftLayout ? right + 1 : right - 1; DrawLine(hdc, new Point(right, rect.top), new Point(right, headerHeight), ButtonHighlightPen); // Rect1.top = Rect1.bottom = TitleRect.top; // Rect1.left -= factor; // Rect1.right -= factor; // Gui->ctx->gui_.dc_->line_to(&Rect1, FIX_SYS_COLOR_BTNSHADOW, factor, 0L); int x = tableControl.RightToLeftLayout ? left - (2 * TableControl.Factor) : left + (2 * TableControl.Factor); DrawLine(hdc, new Point(left, rect.top), new Point(x, rect.top), ButtonShadowPen); // Rect1.left -= factor; // Rect1.bottom = Rect1.top = TitleRect.bottom - factor; // Gui->ctx->gui_.dc_->line_to(&Rect1, FIX_SYS_COLOR_BTNHIGHLIGHT, factor, 0L); x = tableControl.RightToLeftLayout ? right + (2 * TableControl.Factor) : right - (2 * TableControl.Factor); DrawLine(hdc, new Point(right, headerHeight - TableControl.Factor), new Point(x, headerHeight - TableControl.Factor), ButtonHighlightPen); }
/// <summary> /// Draw Header section filter /// </summary> /// <param name="hdc"></param> /// <param name="rct"></param> /// <param name="g"></param> public void DrawFilter(IntPtr hdc, NativeWindowCommon.RECT rct) { //Filter line drawing int x = rct.right - FILTER_WIDTH; int bottomY = 0; Header.HeaderRenderer.DrawLine(hdc, new Point(x, bottomY), new Point(x, Header.FilterHeight)); //Filter highlight drawing NativeWindowCommon.RECT rectHighlight = new NativeWindowCommon.RECT() { bottom = Header.FilterHeight, top = 0, left = rct.right - FILTER_WIDTH + 1, right = rct.right + 1 }; if ((FilterColor != Color.Empty) && !Header.OnSectionResize) { if (Header.TitleColor != Color.Empty) { Header.HighlightBrush = NativeWindowCommon.CreateSolidBrush(ColorTranslator.ToWin32(FilterColor)); } else { Header.HighlightBrush = NativeWindowCommon.CreateSolidBrush(ColorTranslator.ToWin32(Color.FromArgb(255, 149, 202, 255))); } NativeWindowCommon.FillRect(hdc, ref rectHighlight, Header.HighlightBrush); NativeWindowCommon.DeleteObject(Header.HighlightBrush); } int filterWidthIcon = FILTER_WIDTH / 3; //Filter arrow drawing NativeWindowCommon.POINT[] points = new NativeWindowCommon.POINT[3]; //right points[0].x = rct.right - filterWidthIcon; points[0].y = rct.top + (rct.bottom - rct.top) / 2 - 2; // center point points[1].x = rct.right - FILTER_WIDTH / 2; points[1].y = points[0].y + filterWidthIcon / 2; // left point points[2].x = points[0].x - filterWidthIcon; points[2].y = points[0].y; NativeWindowCommon.SelectObject(hdc, Header.FilterBrush); NativeWindowCommon.SelectObject(hdc, Header.FilterPen); NativeWindowCommon.Polygon(hdc, points, 3); }
/// <summary> /// draw divider /// </summary> /// <param name="hdc"></param> /// <param name="rect"></param> /// <param name="headerHeight"></param> internal override void DrawDivider(IntPtr hdc, int index, ref NativeWindowCommon.RECT rect, int headerHeight) { rect.right--; // cannot paint on boundaries so reduce size by 1 pixel if (index == 0 && tableControl.RightToLeftLayout) // for painting, reduce the right of first column { rect.right--; } int x = (rect.right) - TwoDTableStyleRenderer.MARGIN * TableControl.Factor + TableControl.Factor; DrawLine(hdc, new Point(x, 0), new Point(x, headerHeight)); DrawLine(hdc, new Point(rect.right, 0), new Point(rect.right, headerHeight)); }
protected void PaintDividers(NativeCustomDraw.NMCUSTOMDRAW pcust, ref NativeWindowCommon.RECT rect, int difference) { // paint divider for last header only when "Show Last Divider " of table control is true if (header.ShowDividers) { // Check if last divider is to be painted . // For last section , last divider should be painted when 'ShowLastDivider' property is set to true bool showlastDivider = (pcust.dwItemSpec.ToInt32() == header.Sections.Count - 1 ? header.ShowLastDivider : true); if (showlastDivider) { DrawDivider(pcust.hdc, pcust.dwItemSpec.ToInt32(), ref rect, header.DividerHeight); } } }
internal override void PaintBackGround(NativeCustomDraw.NMCUSTOMDRAW pcust, NativeWindowCommon.RECT rect) { base.PaintBackGround(pcust, rect); // draw top lines //SetRect(&TitleRect, Rect.left, Rect.top, Rect.right, Rect.top); //Gui->ctx->gui_.dc_->line_to(&TitleRect, TitleTopLeftColor, factor, 0L); DrawLine(pcust.hdc, new Point(rect.left, rect.top), new Point(rect.right, rect.top), WhitePen); // dark //SetRect(&TitleRect, Rect.left + factor, Rect.top + factor, Rect.right - factor, Rect.top + factor); //Gui->ctx->gui_.dc_->line_to(&TitleRect, FIX_SYS_COLOR_3DLIGHT, factor, 0L); DrawLine(pcust.hdc, new Point(rect.left + TableControl.Factor, rect.top + 1), new Point(rect.right, rect.top + TableControl.Factor), lightPen); // dark // draw bottom lines //SetRect(&TitleRect, Rect.left, Rect.top + Ctrl->TitleHeight - 2 * factor, Rect.right, Rect.top + Ctrl->TitleHeight - 2 * factor); //Gui->ctx->gui_.dc_->line_to(&TitleRect, TitleBottomBorder, factor, 0L); rect.bottom--; DrawLine(pcust.hdc, new Point(rect.left, rect.bottom), new Point(rect.right, rect.bottom)); // dark //SetRect(&TitleRect, Rect.left + factor, Rect.top + Ctrl->TitleHeight - 3 * factor, Rect.right - factor, Rect.top + Ctrl->TitleHeight - 3 * factor); //Gui->ctx->gui_.dc_->line_to(&TitleRect, FIX_SYS_COLOR_BTNSHADOW, factor, 0L); rect.bottom--; DrawLine(pcust.hdc, new Point(rect.left, rect.bottom), new Point(rect.right, rect.bottom), darkpen); // draw left lines if (!tableControl.RightToLeftLayout && rect.left == 0) // draw only for 1st section { // SetRect(&TitleRect, Rect.left, Rect.top, Rect.right, Rect.top); // Gui->ctx->gui_.dc_->line_to(&TitleRect, TitleTopLeftColor, factor, 0L); DrawLine(pcust.hdc, new Point(0, rect.top), new Point(0, rect.bottom), WhitePen); //SetRect(&TitleRect, Rect.left + factor, Rect.top + factor, Rect.left + factor, Rect.top + Ctrl->TitleHeight - 3 * factor); //Gui->ctx->gui_.dc_->line_to(&TitleRect, FIX_SYS_COLOR_3DLIGHT, factor, 0L); DrawLine(pcust.hdc, new Point(1, rect.top + 1), new Point(1, rect.bottom), lightPen); } else if (tableControl.RightToLeftLayout && rect.right == (tableControl.Bounds.Right - 2 * tableControl.BorderHeight)) { DrawLine(pcust.hdc, new Point(rect.right - 1, rect.top), new Point(rect.right - 1, rect.bottom), WhitePen); //SetRect(&TitleRect, Rect.left + factor, Rect.top + factor, Rect.left + factor, Rect.top + Ctrl->TitleHeight - 3 * factor); //Gui->ctx->gui_.dc_->line_to(&TitleRect, FIX_SYS_COLOR_3DLIGHT, factor, 0L); DrawLine(pcust.hdc, new Point(rect.right - 2, rect.top + 1), new Point(rect.right - 2, rect.bottom), lightPen); } }
/// <summary> /// perform horizontal scroll /// </summary> /// <param name="value"></param> /// <param name="newValue"></param> private void ScrollHorizontally(int value, int newValue) { NativeScroll.SCROLLINFO sc = ScrollInfo(NativeScroll.SB_HORZ); int maxValue = sc.nMax - sc.nPage; if (newValue < 0) { newValue = 0; } if (newValue > maxValue) { newValue = maxValue; } NativeScroll.SetScrollPos(this.Handle, NativeScroll.SB_HORZ, newValue, true); NativeWindowCommon.RECT rc = new NativeWindowCommon.RECT(); NativeScroll.ScrollWindowEx(this.Handle, value - newValue, 0, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, ref rc, NativeScroll.SW_SCROLLCHILDREN | NativeScroll.SW_INVALIDATE | NativeScroll.SW_ERASE); _corner.X = getXCorner(); }
internal override void PaintBackGround(NativeCustomDraw.NMCUSTOMDRAW pcust, NativeWindowCommon.RECT rect) { if (header.TitleColor != Color.Empty) { if (header.ShowBottomBorder) { PaintBottomBorderOnColoredHeader(pcust, ref rect); } base.PaintBackGround(pcust, rect); } else if (header.DividerColor != Color.Empty) { if (header.ShowBottomBorder) { PaintBottomBorderOnSystemHeader(pcust, ref rect, 0); } } }
/// <summary> /// calc text rect /// use ContentAlignment.MiddleRight for the calculation because if we use ContentAlignment.MiddleCenter /// then GuiUtils.CalcTextRect() returns wrong results. The problem is that the height returned by GuiUtils.CalcTextRect() /// will be of a single line always. /// /// </summary> /// <param name="g"></param> /// <param name="rect"></param> /// <param name="font"></param> /// <param name="text"></param> /// <param name="flags"></param> /// <param name="retCalcTextRect"></param> public static void CalcTextRect(Graphics g, Rectangle rect, FontDescription font, String text, int flags, out NativeWindowCommon.RECT retCalcTextRect) { IntPtr hdc1; IntPtr hFont1; hdc1 = g.GetHdc(); hFont1 = font.FontHandle; NativeWindowCommon.SelectObject(hdc1, hFont1); retCalcTextRect = new NativeWindowCommon.RECT(); retCalcTextRect.left = rect.Left; retCalcTextRect.right = rect.Right; retCalcTextRect.top = rect.Top; retCalcTextRect.bottom = rect.Bottom; int calcRectFlags = (int)(TextFormatFlags)flags | 0x400; // TextFormatFlags.CalcRect == 0x400 == DT_CALCRECT NativeWindowCommon.DrawText(hdc1, text, text.Length, ref retCalcTextRect, calcRectFlags); g.ReleaseHdc(hdc1); }
internal override void DrawDivider(IntPtr hdc, int index, ref NativeWindowCommon.RECT rect, int headerHeight) { int left = rect.right - (2 * TableControl.Factor); // Gui->ctx->gui_.dc_->line_to (&DividerRect, DividerColor, factor, 0L); DrawLine(hdc, new Point(left, rect.top), new Point(left, headerHeight - TableControl.Factor)); //SetRect(&DividerRect, Tmp - factor, Rect.top + factor, Tmp - factor, Rect.top + tableCtrl->TitleHeight - 2 * factor); //Gui->ctx->gui_.dc_->line_to(&DividerRect, DividerLeftBorderColor, factor, 0L); int x1 = tableControl.RightToLeftLayout ? left + TableControl.Factor : left - TableControl.Factor; DrawLine(hdc, new Point(x1, rect.top + TableControl.Factor), new Point(x1, headerHeight - TableControl.Factor), ButtonShadowPen); //SetRect(&DividerRect, Tmp + factor, Rect.top + factor, Tmp + factor, Rect.top + tableCtrl->TitleHeight - 2 * factor); //Gui->ctx->gui_.dc_->line_to(&DividerRect, DividerRightBorderColor, factor, 0L); int x2 = tableControl.RightToLeftLayout ? left - TableControl.Factor : left + TableControl.Factor; DrawLine(hdc, new Point(x2, rect.top + TableControl.Factor), new Point(x2, headerHeight - TableControl.Factor), WhitePen); }
/// <summary> /// handle WM_SIZING to support correct minimun windth/height behavior /// origin : OnSizing from main_menu.cpp( for mdi frame), gui.cpp (for form itself) /// </summary> /// <param name="form"></param> /// <param name="se"></param> private static void OnSizing(Form form, SizingEventArgs se) { #if !PocketPC NativeWindowCommon.RECT rect = se.DragRect; if (form.IsMdiContainer) { //calulate correct rectangle after dragging considering minimum height/width from mdi children foreach (var item in form.MdiChildren) { if (GuiUtils.isMaximizedInMDIFrame(item)) //this chid affects minimum height/width { GuiUtils.UpdateByMinimun(se.SizingEdge, ref rect, item); } } } //consider minimin height/width of mdi frame itself GuiUtils.UpdateByMinimun(se.SizingEdge, ref rect, form); se.DragRect = rect; #endif }
internal override void PaintBackGround(NativeCustomDraw.NMCUSTOMDRAW pcust, NativeWindowCommon.RECT rect) { base.PaintBackGround(pcust, rect); // top line //SetRect(&TitleRect, Rect.left, Rect.top, Rect.right, Rect.top); //Gui->ctx->gui_.dc_->line_to(&TitleRect, TitleTopLeftColor, factor, 0L); DrawLine(pcust.hdc, new Point(rect.left, rect.top), new Point(rect.right, rect.top), WhitePen); // dark // bottom lines //SetRect(&Rect1, Rect.left, Row, Rect.right, Row); //Gui->ctx->gui_.dc_->line_to(&Rect1, FIX_SYS_COLOR_BTNTEXT, factor, 0L); rect.bottom--; DrawLine(pcust.hdc, new Point(rect.left, rect.bottom), new Point(rect.right, rect.bottom), darkpen); //Rect1.bottom -= factor; //Gui->ctx->gui_.dc_->line_to(&Rect1, FIX_SYS_COLOR_BTNSHADOW, factor, 0L); rect.bottom--; DrawLine(pcust.hdc, new Point(rect.left, rect.bottom), new Point(rect.right, rect.bottom), ButtonShadowPen); // draw left for first header section when we are not dragging if (!isSectionDragging) { if (rect.left == 0) { DrawLine(pcust.hdc, new Point(rect.left, rect.top), new Point(rect.left, rect.bottom), tableControl.RightToLeftLayout ? ButtonShadowPen : WhitePen); } // draw right borders for last header section if (rect.right == (tableControl.Bounds.Right - 2 * tableControl.BorderHeight)) { DrawLine(pcust.hdc, new Point(rect.right - 1, rect.top), new Point(rect.right - 1, rect.bottom), tableControl.RightToLeftLayout ? WhitePen : ButtonShadowPen); } } }
/// <summary> /// draw header section title /// </summary> /// <param name="hdc"></param> /// <param name="rc"></param> internal void DrawTitle(IntPtr hdc, NativeWindowCommon.RECT rc, int index, bool supportsMultilineText, bool addEndEllipsesFlag, bool rightToLeftLayout) { Header.HeaderRenderer.GetTitleTextRect(index, ref rc); using (Graphics gr = Graphics.FromHdc(hdc)) { //draw sort icon if (SortMark != HeaderSectionSortMarks.Non && !HasFilter) { int iconWindth = SortIconWidth(); DrawSortMark(hdc, rc, gr); rc.right -= iconWindth + Header.SORT_ICON_LEFT_RIGHT_MARGIN; } if (HasFilter) { rc.right -= HeaderSection.FILTER_WIDTH + Header.SORT_ICON_LEFT_RIGHT_MARGIN; } //draw ... in the end of text if width is too short int width = rc.right - rc.left; int format = NativeWindowCommon.DT_EDITCONTROL | NativeWindowCommon.DT_EXTERNALLEADING; if (supportsMultilineText) { format |= NativeWindowCommon.DT_WORDBREAK; } StringBuilder stringBuilder = new StringBuilder(Text); if (addEndEllipsesFlag) { //for windows CE && orientated fonts DT_END_ELLIPSIS style is not supported //http://support.microsoft.com/kb/249678 format |= NativeWindowCommon.DT_END_ELLIPSIS; } if (Environment.OSVersion.Platform == PlatformID.WinCE) { if (Text.IndexOf("\n") != -1) { SizeF size = gr.MeasureString(text, Font); int cur, len = cur = text.Length; while (size.Width > width && cur > 1) { cur = --len; stringBuilder.Length = len; while (cur > 1 && len - cur < 3) { stringBuilder[--cur] = '.'; } size = gr.MeasureString(stringBuilder.ToString(), Font); } } } NativeWindowCommon.SetBkMode(hdc, NativeWindowCommon.TRANSPARENT); NativeWindowCommon.SetTextColor(hdc, ColorTranslator.ToWin32(Color)); #if !PocketPC if (FontOrientation != 0) { Rectangle rectangle = new Rectangle(rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top); ControlRenderer.PrintRotatedText(hdc, FontDescription, FontOrientation, stringBuilder.ToString(), rectangle, ContentAlignment, rc, rightToLeftLayout); } else #endif { //text flags are exactly the same as DrawText DT_*** flags format |= (int)Utils.ContentAlignment2TextFlags(ContentAlignment); if (isSingleLine()) { format |= NativeWindowCommon.DT_SINGLELINE; } IntPtr hFont = FontDescription.FontHandle; NativeWindowCommon.SelectObject(hdc, hFont); NativeWindowCommon.DrawText(hdc, stringBuilder.ToString(), stringBuilder.Length, ref rc, format); } #if !PocketPC //Set the rectangle back if (HasFilter) { rc.right += HeaderSection.FILTER_WIDTH + Header.SORT_ICON_LEFT_RIGHT_MARGIN; DrawFilter(hdc, rc); } #endif } }
private void PaintBottomBorderOnSystemHeader(NativeCustomDraw.NMCUSTOMDRAW pcust, ref NativeWindowCommon.RECT rect, int diff) { if (rect.bottom == header.Height) { rect.bottom--; if ((header.TableLineDivider) || (!header.TableLineDivider && (header.DividerColor != Color.Empty))) { DrawLine(pcust.hdc, new Point(rect.left, rect.bottom), new Point(rect.right + diff, rect.bottom), HeaderDividerPen); } } }
private void PaintBottomBorderOnColoredHeader(NativeCustomDraw.NMCUSTOMDRAW pcust, ref NativeWindowCommon.RECT rect) { if (rect.bottom == header.Height) { rect.bottom--; IntPtr pen = header.DividerColor != Color.Empty ? HeaderDividerPen : HeaderItemBorderPen; DrawLine(pcust.hdc, new Point(rect.left, rect.bottom), new Point(rect.right, rect.bottom), pen); } }
internal virtual void PaintItemBackGround(NativeCustomDraw.NMCUSTOMDRAW pcust, NativeWindowCommon.RECT rect) { if (rect.left < rect.right) { PaintBackGround(pcust, rect); } PaintDividers(pcust, ref rect, 0); }
public SizingEventArgs(NativeWindowCommon.SizingEdges sizingEdge, NativeWindowCommon.RECT dragRect) : base() { SizingEdge = sizingEdge; DragRect = dragRect; }
/// <summary> /// get the title rect /// </summary> /// <param name="index"></param> /// <param name="rc"></param> internal virtual void GetTitleTextRect(int index, ref NativeWindowCommon.RECT rc) { NativeWindowCommon.InflateRect(ref rc, -2, -2); }
/// <summary> /// draw divider /// </summary> /// <param name="hdc"></param> /// <param name="rect"></param> /// <param name="headerHeight"></param> internal abstract void DrawDivider(IntPtr hdc, int index, ref NativeWindowCommon.RECT rect, int headerHeight);
/// <summary> /// drow sort marking on the column /// </summary> /// <param name="hdc"></param> /// <param name="rc"></param> /// <param name="gr"></param> void DrawSortMark(IntPtr hdc, NativeWindowCommon.RECT rc, Graphics gr) { int iconWidth = SortIconWidth(); int topBottomMargin = (this.Header.Height - iconWidth) / 2; int iconHeight = SortIconHeight(); NativeWindowCommon.POINT[] points = new NativeWindowCommon.POINT[3]; if (SortMark == HeaderSectionSortMarks.Up) { points[0].x = rc.right - Header.SORT_ICON_LEFT_RIGHT_MARGIN; points[0].y = (rc.bottom + iconHeight) / 2; // center point points[1].x = points[0].x - iconWidth / 2; points[1].y = points[0].y - iconHeight; // left point points[2].x = points[0].x - iconWidth; points[2].y = points[0].y; } else if (SortMark == HeaderSectionSortMarks.Down) { //right points[0].x = rc.right - Header.SORT_ICON_LEFT_RIGHT_MARGIN; points[0].y = (rc.bottom - iconHeight) / 2; // center point points[1].x = points[0].x - iconWidth / 2; points[1].y = points[0].y + iconHeight; // left point points[2].x = points[0].x - iconWidth; points[2].y = points[0].y; } #if !PocketPC if (Application.RenderWithVisualStyles) { //draw XP style sort triangle NativeWindowCommon.SelectObject(hdc, Header.SortBrush); NativeWindowCommon.SelectObject(hdc, Header.SortPen); NativeWindowCommon.Polygon(hdc, points, 3); } else #endif { //draw windows 2000 style sort triangle Point[] points1 = new Point[3] { new Point(points[0].x, points[0].y), new Point(points[1].x, points[1].y), new Point(points[2].x, points[2].y) }; NativeWindowCommon.MoveToEx(hdc, points1[0].X, points1[0].Y, IntPtr.Zero); NativeWindowCommon.SelectObject(hdc, Header.WhitePen); NativeWindowCommon.LineTo(hdc, points1[1].X, points1[1].Y); NativeWindowCommon.SelectObject(hdc, Header.ButtonShadowPen); NativeWindowCommon.LineTo(hdc, points1[2].X, points1[2].Y); if (SortMark == HeaderSectionSortMarks.Up) { NativeWindowCommon.SelectObject(hdc, Header.WhitePen); } else { NativeWindowCommon.SelectObject(hdc, Header.ButtonShadowPen); } NativeWindowCommon.LineTo(hdc, points1[0].X, points1[0].Y); } }