ReactOS 0.4.16-dev-1946-g52006dd
paint.c File Reference
#include "editor.h"
Include dependency graph for paint.c:

Go to the source code of this file.

Macros

#define DD(x)   ((para->fmt.wBorders & (x)) ? (pen_width + 1) : 0)
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (richedit)
 
static void draw_paragraph (ME_Context *c, ME_Paragraph *para)
 
static BOOL editor_opaque (ME_TextEditor *editor)
 
void editor_draw (ME_TextEditor *editor, HDC hDC, const RECT *update)
 
void ME_Repaint (ME_TextEditor *editor)
 
void ME_UpdateRepaint (ME_TextEditor *editor, BOOL update_now)
 
void ME_RewrapRepaint (ME_TextEditor *editor)
 
int ME_twips2pointsX (const ME_Context *c, int x)
 
int ME_twips2pointsY (const ME_Context *c, int y)
 
static int calc_y_offset (const ME_Context *c, ME_Style *style)
 
static COLORREF get_text_color (ME_Context *c, ME_Style *style, BOOL highlight)
 
static COLORREF get_back_color (ME_Context *c, ME_Style *style, BOOL highlight)
 
static HPEN get_underline_pen (ME_Style *style, COLORREF color)
 
static void draw_underline (ME_Context *c, ME_Run *run, int x, int y, COLORREF color)
 
static void draw_space (ME_Context *c, ME_Run *run, int x, int y, BOOL selected, BOOL actually_draw, int ymin, int cy)
 
static void get_selection_rect (ME_Context *c, ME_Run *run, int from, int to, int cy, RECT *r)
 
static void draw_text (ME_Context *c, ME_Run *run, int x, int y, BOOL selected, RECT *sel_rect)
 
static void draw_text_with_style (ME_Context *c, ME_Run *run, int x, int y, int nSelFrom, int nSelTo, int ymin, int cy)
 
static void ME_DebugWrite (HDC hDC, const POINT *pt, LPCWSTR szText)
 
static void draw_run (ME_Context *c, int x, int y, ME_Cursor *cursor)
 
static int ME_GetBorderPenWidth (const ME_Context *c, int idx)
 
int ME_GetParaBorderWidth (const ME_Context *c, int flags)
 
static void ME_DrawParaDecoration (ME_Context *c, ME_Paragraph *para, int y, RECT *bounds)
 
static void draw_table_borders (ME_Context *c, ME_Paragraph *para)
 
static void draw_para_number (ME_Context *c, ME_Paragraph *para)
 
static void enable_show_scrollbar (ME_TextEditor *editor, INT bar, BOOL enable)
 
static void set_scroll_range_pos (ME_TextEditor *editor, INT bar, SCROLLINFO *info, BOOL set_range, BOOL notify)
 
void scroll_abs (ME_TextEditor *editor, int x, int y, BOOL notify)
 
void scroll_h_abs (ME_TextEditor *editor, int x, BOOL notify)
 
void scroll_v_abs (ME_TextEditor *editor, int y, BOOL notify)
 
void ME_ScrollUp (ME_TextEditor *editor, int cy)
 
void ME_ScrollDown (ME_TextEditor *editor, int cy)
 
void ME_ScrollLeft (ME_TextEditor *editor, int cx)
 
void ME_ScrollRight (ME_TextEditor *editor, int cx)
 
void ME_UpdateScrollBar (ME_TextEditor *editor)
 
void editor_ensure_visible (ME_TextEditor *editor, ME_Cursor *cursor)
 
void ME_InvalidateSelection (ME_TextEditor *editor)
 
BOOL ME_SetZoom (ME_TextEditor *editor, int numerator, int denominator)
 

Variables

struct {
   unsigned   width: 8
 
   unsigned   pen_style: 4
 
   unsigned   dble: 1
 
border_details []
 
static const COLORREF pen_colors [16]
 

Macro Definition Documentation

◆ DD

#define DD (   x)    ((para->fmt.wBorders & (x)) ? (pen_width + 1) : 0)

Function Documentation

◆ calc_y_offset()

static int calc_y_offset ( const ME_Context c,
ME_Style style 
)
static

Definition at line 188 of file paint.c.

189{
190 int offs = 0, twips = 0;
191
192 if ((style->fmt.dwMask & style->fmt.dwEffects) & CFM_OFFSET)
193 twips = style->fmt.yOffset;
194
195 if ((style->fmt.dwMask & style->fmt.dwEffects) & (CFM_SUPERSCRIPT | CFM_SUBSCRIPT))
196 {
197 if (style->fmt.dwEffects & CFE_SUPERSCRIPT) twips = style->fmt.yHeight/3;
198 if (style->fmt.dwEffects & CFE_SUBSCRIPT) twips = -style->fmt.yHeight/12;
199 }
200
201 if (twips) offs = ME_twips2pointsY( c, twips );
202
203 return offs;
204}
Arabic default style
Definition: afstyles.h:94
int ME_twips2pointsY(const ME_Context *c, int y)
Definition: paint.c:179
const GLubyte * c
Definition: glext.h:8905
#define CFM_OFFSET
Definition: richedit.h:359
#define CFE_SUPERSCRIPT
Definition: richedit.h:413
#define CFM_SUBSCRIPT
Definition: richedit.h:348
#define CFE_SUBSCRIPT
Definition: richedit.h:412
#define CFM_SUPERSCRIPT
Definition: richedit.h:349

Referenced by draw_space(), and draw_text_with_style().

◆ draw_para_number()

static void draw_para_number ( ME_Context c,
ME_Paragraph para 
)
static

Definition at line 916 of file paint.c.

917{
918 int x, y;
919 COLORREF old_text;
920
921 if (para->fmt.wNumbering)
922 {
923 select_style( c, para->para_num.style );
924 old_text = SetTextColor( c->hDC, get_text_color( c, para->para_num.style, FALSE ) );
925
926 x = c->pt.x + para->para_num.pt.x;
927 y = c->pt.y + para->pt.y + para->para_num.pt.y;
928
929 ExtTextOutW( c->hDC, x, y, 0, NULL, para->para_num.text->szData, para->para_num.text->nLen, NULL );
930
931 SetTextColor( c->hDC, old_text );
932 }
933}
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
static COLORREF get_text_color(ME_Context *c, ME_Style *style, BOOL highlight)
Definition: paint.c:206
void select_style(ME_Context *c, ME_Style *s)
Definition: style.c:369
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
WORD wNumbering
Definition: richedit.h:668
struct para_num para_num
Definition: editstr.h:215
PARAFORMAT2 fmt
Definition: editstr.h:204
long y
Definition: polytest.cpp:48
DWORD COLORREF
Definition: windef.h:94
BOOL WINAPI ExtTextOutW(_In_ HDC hdc, _In_ int x, _In_ int y, _In_ UINT options, _In_opt_ const RECT *lprect, _In_reads_opt_(c) LPCWSTR lpString, _In_ UINT c, _In_reads_opt_(c) const INT *lpDx)
COLORREF WINAPI SetTextColor(_In_ HDC, _In_ COLORREF)
Definition: text.c:917

Referenced by draw_paragraph().

◆ draw_paragraph()

static void draw_paragraph ( ME_Context c,
ME_Paragraph para 
)
static

Definition at line 935 of file paint.c.

936{
937 int align = SetTextAlign(c->hDC, TA_BASELINE);
939 ME_Cell *cell;
940 ME_Run *run;
941 RECT rc, bounds;
942 int y;
943 int height = 0, baseline = 0, no=0;
944 BOOL visible = FALSE;
945
946 rc.left = c->pt.x;
947 rc.right = c->rcView.right;
948
949 y = c->pt.y + para->pt.y;
950 if ((cell = para_cell( para )))
951 {
952 rc.left = c->pt.x + cell->pt.x;
953 rc.right = rc.left + cell->nWidth;
954 }
955 if (para->nFlags & MEPF_ROWSTART)
956 {
957 cell = table_row_first_cell( para );
958 rc.right = c->pt.x + cell->pt.x;
959 }
960 else if (para->nFlags & MEPF_ROWEND)
961 {
962 cell = table_row_end_cell( para );
963 rc.left = c->pt.x + cell->pt.x + cell->nWidth;
964 }
965 ME_DrawParaDecoration(c, para, y, &bounds);
966 y += bounds.top;
967 if (bounds.left || bounds.right)
968 {
969 rc.left = max(rc.left, c->pt.x + bounds.left);
970 rc.right = min(rc.right, c->pt.x - bounds.right
971 + max(c->editor->sizeWindow.cx,
972 c->editor->nTotalWidth));
973 }
974
975 for (p = para_get_di( para )->next; p != para_get_di( para_next( para ) ); p = p->next)
976 {
977 switch(p->type) {
978 case diParagraph:
979 assert(FALSE);
980 break;
981 case diStartRow:
982 y += height;
983 rc.top = y;
984 if (para->nFlags & (MEPF_ROWSTART|MEPF_ROWEND)) {
985 rc.bottom = y + para->nHeight;
986 } else {
987 rc.bottom = y + p->member.row.nHeight;
988 }
989 visible = RectVisible(c->hDC, &rc);
990 if (editor_opaque( c->editor ) && visible)
991 PatBlt(c->hDC, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, PATCOPY);
992 if (bounds.right)
993 {
994 /* If scrolled to the right past the end of the text, then
995 * there may be space to the right of the paragraph border. */
996 RECT after_bdr = rc;
997 after_bdr.left = rc.right + bounds.right;
998 after_bdr.right = c->rcView.right;
999 if (editor_opaque( c->editor ) && RectVisible( c->hDC, &after_bdr ))
1000 PatBlt(c->hDC, after_bdr.left, after_bdr.top, after_bdr.right - after_bdr.left,
1001 after_bdr.bottom - after_bdr.top, PATCOPY);
1002 }
1003 if (me_debug)
1004 {
1005 WCHAR buf[128];
1006 POINT pt = c->pt;
1007 wsprintfW( buf, L"row[%d]", no );
1008 pt.y = 12+y;
1009 ME_DebugWrite(c->hDC, &pt, buf);
1010 }
1011
1012 height = p->member.row.nHeight;
1013 baseline = p->member.row.nBaseline;
1014 break;
1015 case diRun:
1016 assert(para);
1017 run = &p->member.run;
1018 if (visible && me_debug) {
1019 RECT rc;
1020 rc.left = c->pt.x + run->pt.x;
1021 rc.right = rc.left + run->nWidth;
1022 rc.top = c->pt.y + para->pt.y + run->pt.y;
1023 rc.bottom = rc.top + height;
1024 TRACE("rc = %s\n", wine_dbgstr_rect(&rc));
1026 }
1027 if (visible)
1028 {
1030
1031 cursor.run = run;
1032 cursor.para = para;
1033 cursor.nOffset = 0;
1034 draw_run( c, c->pt.x + run->pt.x, c->pt.y + para->pt.y + run->pt.y + baseline, &cursor );
1035 }
1036 if (me_debug)
1037 {
1038 WCHAR buf[2560];
1039 POINT pt;
1040 pt.x = c->pt.x + run->pt.x;
1041 pt.y = c->pt.y + para->pt.y + run->pt.y;
1042 wsprintfW( buf, L"[%d:%x] %ls", no, p->member.run.nFlags, get_text( &p->member.run, 0 ));
1043 ME_DebugWrite(c->hDC, &pt, buf);
1044 }
1045 break;
1046 default:
1047 break;
1048 }
1049 no++;
1050 }
1051
1052 if (editor_opaque( c->editor ) && para_cell( para ))
1053 {
1054 /* Clear any space at the bottom of the cell after the text. */
1055 rc.top = c->pt.y + para->pt.y + para->nHeight;
1056 rc.bottom = c->pt.y + cell->pt.y + cell->nHeight;
1057 PatBlt( c->hDC, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, PATCOPY );
1058 }
1059
1060 draw_table_borders( c, para );
1061 draw_para_number( c, para );
1062
1063 SetTextAlign( c->hDC, align );
1064}
static const char * wine_dbgstr_rect(const RECT *prc)
Definition: atltest.h:160
static WCHAR no[MAX_STRING_RESOURCE_LEN]
Definition: object.c:2340
BOOL me_debug
Definition: editor.c:254
static void ME_DebugWrite(HDC hDC, const POINT *pt, LPCWSTR szText)
Definition: paint.c:451
static BOOL editor_opaque(ME_TextEditor *editor)
Definition: paint.c:28
static void draw_para_number(ME_Context *c, ME_Paragraph *para)
Definition: paint.c:916
static void draw_run(ME_Context *c, int x, int y, ME_Cursor *cursor)
Definition: paint.c:461
static void ME_DrawParaDecoration(ME_Context *c, ME_Paragraph *para, int y, RECT *bounds)
Definition: paint.c:556
static void draw_table_borders(ME_Context *c, ME_Paragraph *para)
Definition: paint.c:717
#define assert(x)
Definition: debug.h:53
#define pt(x, y)
Definition: drawing.c:79
#define L(x)
Definition: resources.c:13
int align(int length, int align)
Definition: dsound8.c:36
ME_Cell * table_row_end_cell(ME_Paragraph *para)
Definition: table.c:178
static ME_DisplayItem * para_get_di(ME_Paragraph *para)
Definition: editor.h:236
ME_Cell * table_row_first_cell(ME_Paragraph *para)
Definition: table.c:170
ME_Cell * para_cell(ME_Paragraph *para)
Definition: para.c:127
static WCHAR * get_text(const ME_Run *run, int offset)
Definition: editor.h:41
ME_Paragraph * para_next(ME_Paragraph *para)
Definition: para.c:57
#define MEPF_ROWSTART
Definition: editstr.h:142
#define MEPF_ROWEND
Definition: editstr.h:143
@ diStartRow
Definition: editstr.h:86
@ diRun
Definition: editstr.h:85
@ diParagraph
Definition: editstr.h:83
unsigned int BOOL
Definition: ntddk_ex.h:94
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
GLfloat GLfloat p
Definition: glext.h:8902
const char cursor[]
Definition: icontest.c:13
#define min(a, b)
Definition: monoChain.cc:55
static unsigned __int64 next
Definition: rand_nt.c:6
#define TRACE(s)
Definition: solgame.cpp:4
POINT pt
Definition: editstr.h:226
int nHeight
Definition: editstr.h:227
int nWidth
Definition: editstr.h:227
POINT pt
Definition: editstr.h:167
int nWidth
Definition: editstr.h:164
long x
Definition: polytest.cpp:48
Definition: windef.h:99
LONG right
Definition: windef.h:102
LONG bottom
Definition: windef.h:103
LONG top
Definition: windef.h:101
LONG left
Definition: windef.h:100
#define max(a, b)
Definition: svc.c:63
UINT WINAPI SetTextAlign(_In_ HDC, _In_ UINT)
Definition: text.c:882
BOOL WINAPI RectVisible(_In_ HDC, _In_ LPCRECT)
#define PATCOPY
Definition: wingdi.h:335
BOOL WINAPI PatBlt(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int, _In_ DWORD)
#define TA_BASELINE
Definition: wingdi.h:928
int WINAPI FrameRect(_In_ HDC, _In_ LPCRECT, _In_ HBRUSH)
#define COLOR_GRAYTEXT
Definition: winuser.h:943
int WINAPIV wsprintfW(_Out_ LPWSTR, _In_ _Printf_format_string_ LPCWSTR,...)
HBRUSH WINAPI GetSysColorBrush(_In_ int)
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by editor_draw().

◆ draw_run()

static void draw_run ( ME_Context c,
int  x,
int  y,
ME_Cursor cursor 
)
static

Definition at line 461 of file paint.c.

462{
463 ME_Row *row;
464 ME_Run *run = cursor->run;
465 int runofs = run_char_ofs( run, cursor->nOffset );
466 LONG nSelFrom, nSelTo;
467
468 if (run->nFlags & MERF_HIDDEN) return;
469
471 ME_GetSelectionOfs(c->editor, &nSelFrom, &nSelTo);
472
473 /* Draw selected end-of-paragraph mark */
474 if (run->nFlags & MERF_ENDPARA)
475 {
476 if (runofs >= nSelFrom && runofs < nSelTo)
477 {
478 draw_space( c, run, x, y, TRUE, FALSE,
479 c->pt.y + run->para->pt.y + row->pt.y, row->nHeight );
480 }
481 return;
482 }
483
484 if (run->nFlags & (MERF_TAB | MERF_ENDCELL))
485 {
486 BOOL selected = runofs >= nSelFrom && runofs < nSelTo;
487
488 draw_space( c, run, x, y, selected, TRUE,
489 c->pt.y + run->para->pt.y + row->pt.y, row->nHeight );
490 return;
491 }
492
493 if (run->nFlags & MERF_GRAPHICS)
494 draw_ole( c, x, y, run, (runofs >= nSelFrom) && (runofs < nSelTo) );
495 else
496 draw_text_with_style( c, run, x, y, nSelFrom - runofs, nSelTo - runofs,
497 c->pt.y + run->para->pt.y + row->pt.y, row->nHeight );
498}
static char selected[MAX_PATH+1]
Definition: dirdlg.c:7
#define TRUE
Definition: types.h:120
int ME_GetSelectionOfs(ME_TextEditor *editor, LONG *from, LONG *to)
Definition: caret.c:42
static void draw_space(ME_Context *c, ME_Run *run, int x, int y, BOOL selected, BOOL actually_draw, int ymin, int cy)
Definition: paint.c:287
static void draw_text_with_style(ME_Context *c, ME_Run *run, int x, int y, int nSelFrom, int nSelTo, int ymin, int cy)
Definition: paint.c:386
struct png_info_def *typedef unsigned char **typedef struct png_info_def *typedef struct png_info_def *typedef struct png_info_def *typedef unsigned char ** row
Definition: typeof.h:78
int run_char_ofs(ME_Run *run, int ofs)
Definition: run.c:233
ME_Row * row_from_cursor(ME_Cursor *cursor)
Definition: row.c:74
void draw_ole(ME_Context *c, int x, int y, ME_Run *run, BOOL selected)
Definition: richole.c:5785
#define MERF_TAB
Definition: editstr.h:105
#define MERF_ENDPARA
Definition: editstr.h:120
#define MERF_HIDDEN
Definition: editstr.h:124
#define MERF_ENDCELL
Definition: editstr.h:107
#define MERF_GRAPHICS
Definition: editstr.h:103
long LONG
Definition: pedump.c:60
struct tagME_Paragraph * para
Definition: editstr.h:161
int nFlags
Definition: editstr.h:165

Referenced by draw_paragraph().

◆ draw_space()

static void draw_space ( ME_Context c,
ME_Run run,
int  x,
int  y,
BOOL  selected,
BOOL  actually_draw,
int  ymin,
int  cy 
)
static

Definition at line 287 of file paint.c.

289{
290 HDC hdc = c->hDC;
291 BOOL old_style_selected = FALSE;
292 RECT rect;
293 COLORREF back_color = 0;
294
295 SetRect( &rect, x, ymin, x + run->nWidth, ymin + cy );
296
297 if (c->editor->bHideSelection || (!c->editor->bHaveFocus && (c->editor->props & TXTBIT_HIDESELECTION)))
298 selected = FALSE;
299 if (c->editor->bEmulateVersion10)
300 {
301 old_style_selected = selected;
302 selected = FALSE;
303 }
304
305 if (selected)
306 back_color = ITextHost_TxGetSysColor( c->editor->texthost, COLOR_HIGHLIGHT );
307
308 if (actually_draw)
309 {
310 COLORREF text_color = get_text_color( c, run->style, selected );
311 COLORREF old_text, old_back;
312 int y_offset = calc_y_offset( c, run->style );
313 static const WCHAR space[1] = {' '};
314
315 select_style( c, run->style );
316 old_text = SetTextColor( hdc, text_color );
317 if (selected) old_back = SetBkColor( hdc, back_color );
318
319 ExtTextOutW( hdc, x, y - y_offset, selected ? ETO_OPAQUE : 0, &rect, space, 1, &run->nWidth );
320
321 if (selected) SetBkColor( hdc, old_back );
322 SetTextColor( hdc, old_text );
323
324 draw_underline( c, run, x, y - y_offset, text_color );
325 }
326 else if (selected)
327 {
328 HBRUSH brush = CreateSolidBrush( back_color );
329 FillRect( hdc, &rect, brush );
330 DeleteObject( brush );
331 }
332
333 if (old_style_selected)
334 PatBlt( hdc, x, ymin, run->nWidth, cy, DSTINVERT );
335}
static int calc_y_offset(const ME_Context *c, ME_Style *style)
Definition: paint.c:188
static void draw_underline(ME_Context *c, ME_Run *run, int x, int y, COLORREF color)
Definition: paint.c:264
#define ITextHost_TxGetSysColor(This, a)
Definition: editor.h:357
pKey DeleteObject()
HDC hdc
Definition: main.c:9
static HDC
Definition: imagelist.c:88
_Out_opt_ int _Out_opt_ int * cy
Definition: commctrl.h:586
& rect
Definition: startmenu.cpp:1413
ME_Style * style
Definition: editstr.h:160
#define TXTBIT_HIDESELECTION
Definition: textserv.h:190
COLORREF WINAPI SetBkColor(_In_ HDC, _In_ COLORREF)
Definition: dc.c:999
#define DSTINVERT
Definition: wingdi.h:327
#define ETO_OPAQUE
Definition: wingdi.h:647
int WINAPI FillRect(HDC, LPCRECT, HBRUSH)
HBRUSH WINAPI CreateSolidBrush(_In_ COLORREF)
#define COLOR_HIGHLIGHT
Definition: winuser.h:937
BOOL WINAPI SetRect(_Out_ LPRECT, _In_ int, _In_ int, _In_ int, _In_ int)

Referenced by draw_run().

◆ draw_table_borders()

static void draw_table_borders ( ME_Context c,
ME_Paragraph para 
)
static

Definition at line 717 of file paint.c.

718{
719 if (!c->editor->bEmulateVersion10) /* v4.1 */
720 {
721 if (para_cell( para ))
722 {
723 RECT rc;
724 ME_Cell *cell = para_cell( para );
725 ME_Paragraph *after_row;
726 HPEN pen, oldPen;
727 LOGBRUSH logBrush;
728 HBRUSH brush;
730 POINT oldPt;
731 int width;
732 BOOL atTop = (para == cell_first_para( cell ));
733 BOOL atBottom = (para == cell_end_para( cell ));
734 int top = c->pt.y + (atTop ? cell->pt.y : para->pt.y);
735 int bottom = (atBottom ?
736 c->pt.y + cell->pt.y + cell->nHeight :
737 top + para->nHeight + (atTop ? cell->yTextOffset : 0));
738 rc.left = c->pt.x + cell->pt.x;
739 rc.right = rc.left + cell->nWidth;
740 if (atTop)
741 {
742 /* Erase gap before text if not all borders are the same height. */
743 width = max(ME_twips2pointsY(c, cell->border.top.width), 1);
744 rc.top = top + width;
745 width = cell->yTextOffset - width;
746 rc.bottom = rc.top + width;
747 if (width && editor_opaque( c->editor ))
748 PatBlt(c->hDC, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, PATCOPY);
749 }
750 /* Draw cell borders.
751 * The order borders are draw in is left, top, bottom, right in order
752 * to be consistent with native richedit. This is noticeable from the
753 * overlap of borders of different colours. */
754 if (!(para->nFlags & MEPF_ROWEND))
755 {
756 rc.top = top;
757 rc.bottom = bottom;
758 if (cell->border.left.width > 0)
759 {
760 color = cell->border.left.colorRef;
762 }
763 else
764 {
765 color = RGB(192,192,192);
766 width = 1;
767 }
768 logBrush.lbStyle = BS_SOLID;
769 logBrush.lbColor = color;
770 logBrush.lbHatch = 0;
772 width, &logBrush, 0, NULL);
773 oldPen = SelectObject(c->hDC, pen);
774 MoveToEx(c->hDC, rc.left, rc.top, &oldPt);
775 LineTo(c->hDC, rc.left, rc.bottom);
776 SelectObject(c->hDC, oldPen);
777 DeleteObject(pen);
778 MoveToEx(c->hDC, oldPt.x, oldPt.y, NULL);
779 }
780
781 if (atTop)
782 {
783 if (cell->border.top.width > 0)
784 {
785 brush = CreateSolidBrush(cell->border.top.colorRef);
786 width = max(ME_twips2pointsY(c, cell->border.top.width), 1);
787 }
788 else
789 {
791 width = 1;
792 }
793 rc.top = top;
794 rc.bottom = rc.top + width;
795 FillRect(c->hDC, &rc, brush);
796 if (cell->border.top.width > 0)
797 DeleteObject(brush);
798 }
799
800 /* Draw the bottom border if at the last paragraph in the cell, and when
801 * in the last row of the table. */
802 if (atBottom)
803 {
804 int oldLeft = rc.left;
806 after_row = para_next( table_row_end( para ) );
807 if (after_row->nFlags & MEPF_ROWSTART)
808 {
809 ME_Cell *next_end;
810 next_end = table_row_end_cell( after_row );
811 assert( next_end && !cell_next( next_end ) );
812 rc.left = c->pt.x + next_end->pt.x;
813 }
814 if (rc.left < rc.right)
815 {
816 if (cell->border.bottom.width > 0)
817 brush = CreateSolidBrush(cell->border.bottom.colorRef);
818 else
820 rc.bottom = bottom;
821 rc.top = rc.bottom - width;
822 FillRect(c->hDC, &rc, brush);
823 if (cell->border.bottom.width > 0)
824 DeleteObject(brush);
825 }
826 rc.left = oldLeft;
827 }
828
829 /* Right border only drawn if at the end of the table row. */
830 if (!cell_next( cell_next( cell ) ) && !(para->nFlags & MEPF_ROWSTART))
831 {
832 rc.top = top;
833 rc.bottom = bottom;
834 if (cell->border.right.width > 0)
835 {
836 color = cell->border.right.colorRef;
838 }
839 else
840 {
841 color = RGB(192,192,192);
842 width = 1;
843 }
844 logBrush.lbStyle = BS_SOLID;
845 logBrush.lbColor = color;
846 logBrush.lbHatch = 0;
848 width, &logBrush, 0, NULL);
849 oldPen = SelectObject(c->hDC, pen);
850 MoveToEx(c->hDC, rc.right - 1, rc.top, &oldPt);
851 LineTo(c->hDC, rc.right - 1, rc.bottom);
852 SelectObject(c->hDC, oldPen);
853 DeleteObject(pen);
854 MoveToEx(c->hDC, oldPt.x, oldPt.y, NULL);
855 }
856 }
857 }
858 else /* v1.0 - 3.0 */
859 {
860 /* Draw simple table border */
861 if (para_in_table( para ))
862 {
863 HPEN pen = NULL, oldpen = NULL;
864 int i, firstX, startX, endX, rowY, rowBottom, nHeight;
865 POINT oldPt;
866
867 pen = CreatePen(PS_SOLID, 0, para->border.top.colorRef);
868 oldpen = SelectObject(c->hDC, pen);
869
870 /* Find the start relative to the text */
871 firstX = c->pt.x + para_first_run( para )->pt.x;
872 /* Go back by the horizontal gap, which is stored in dxOffset */
873 firstX -= ME_twips2pointsX(c, para->fmt.dxOffset);
874 /* The left edge, stored in dxStartIndent affected just the first edge */
875 startX = firstX - ME_twips2pointsX(c, para->fmt.dxStartIndent);
876 rowY = c->pt.y + para->pt.y;
877 if (para->fmt.dwMask & PFM_SPACEBEFORE)
878 rowY += ME_twips2pointsY(c, para->fmt.dySpaceBefore);
879 nHeight = para_first_row( para )->nHeight;
880 rowBottom = rowY + nHeight;
881
882 /* Draw horizontal lines */
883 MoveToEx(c->hDC, firstX, rowY, &oldPt);
884 i = para->fmt.cTabCount - 1;
885 endX = startX + ME_twips2pointsX(c, para->fmt.rgxTabs[i] & 0x00ffffff) + 1;
886 LineTo(c->hDC, endX, rowY);
887 /* The bottom of the row only needs to be drawn if the next row is
888 * not a table. */
889 if (!(para_next( para ) && para_in_table( para_next( para ) ) && para->nRows == 1))
890 {
891 /* Decrement rowBottom to draw the bottom line within the row, and
892 * to not draw over this line when drawing the vertical lines. */
893 rowBottom--;
894 MoveToEx(c->hDC, firstX, rowBottom, NULL);
895 LineTo(c->hDC, endX, rowBottom);
896 }
897
898 /* Draw vertical lines */
899 MoveToEx(c->hDC, firstX, rowY, NULL);
900 LineTo(c->hDC, firstX, rowBottom);
901 for (i = 0; i < para->fmt.cTabCount; i++)
902 {
903 int rightBoundary = para->fmt.rgxTabs[i] & 0x00ffffff;
904 endX = startX + ME_twips2pointsX(c, rightBoundary);
905 MoveToEx(c->hDC, endX, rowY, NULL);
906 LineTo(c->hDC, endX, rowBottom);
907 }
908
909 MoveToEx(c->hDC, oldPt.x, oldPt.y, NULL);
910 SelectObject(c->hDC, oldpen);
911 DeleteObject(pen);
912 }
913 }
914}
int ME_twips2pointsX(const ME_Context *c, int x)
Definition: paint.c:171
unsigned width
Definition: paint.c:502
#define RGB(r, g, b)
Definition: precomp.h:71
ME_Row * para_first_row(ME_Paragraph *para)
Definition: para.c:132
ME_Paragraph * cell_first_para(ME_Cell *cell)
Definition: table.c:202
ME_Cell * cell_next(ME_Cell *cell)
Definition: table.c:192
ME_Paragraph * table_row_end(ME_Paragraph *para)
Definition: table.c:127
BOOL para_in_table(ME_Paragraph *para)
Definition: para.c:122
ME_Run * para_first_run(ME_Paragraph *para)
Definition: para.c:104
ME_Paragraph * cell_end_para(ME_Cell *cell)
Definition: table.c:207
GLint GLint GLsizei width
Definition: gl.h:1546
GLuint color
Definition: glext.h:6243
GLdouble GLdouble GLdouble GLdouble top
Definition: glext.h:10859
GLint GLint bottom
Definition: glext.h:7726
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define PFM_SPACEBEFORE
Definition: richedit.h:847
LONG dySpaceBefore
Definition: richedit.h:676
DWORD dwMask
Definition: richedit.h:667
LONG dxOffset
Definition: richedit.h:672
LONG rgxTabs[MAX_TAB_STOPS]
Definition: richedit.h:675
SHORT cTabCount
Definition: richedit.h:674
LONG dxStartIndent
Definition: richedit.h:670
UINT lbStyle
Definition: wingdi.h:2193
ULONG_PTR lbHatch
Definition: wingdi.h:2195
COLORREF lbColor
Definition: wingdi.h:2194
ME_Border bottom
Definition: editstr.h:190
ME_Border right
Definition: editstr.h:191
ME_Border left
Definition: editstr.h:189
ME_Border top
Definition: editstr.h:188
COLORREF colorRef
Definition: editstr.h:183
ME_BorderRect border
Definition: editstr.h:225
int yTextOffset
Definition: editstr.h:228
ME_BorderRect border
Definition: editstr.h:208
int nHeight
Definition: editstr.h:234
HGDIOBJ WINAPI GetStockObject(_In_ int)
HPEN WINAPI ExtCreatePen(_In_ DWORD iPenStyle, _In_ DWORD cWidth, _In_ const LOGBRUSH *plbrush, _In_ DWORD cStyle, _In_reads_opt_(cStyle) const DWORD *pstyle)
#define LTGRAY_BRUSH
Definition: wingdi.h:900
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1546
BOOL WINAPI MoveToEx(_In_ HDC, _In_ int, _In_ int, _Out_opt_ LPPOINT)
#define PS_GEOMETRIC
Definition: wingdi.h:583
HPEN WINAPI CreatePen(_In_ int, _In_ int, _In_ COLORREF)
#define PS_JOIN_MITER
Definition: wingdi.h:598
BOOL WINAPI LineTo(_In_ HDC, _In_ int, _In_ int)
#define BS_SOLID
Definition: wingdi.h:1086
#define PS_SOLID
Definition: wingdi.h:586
#define PS_ENDCAP_FLAT
Definition: wingdi.h:596

Referenced by draw_paragraph().

◆ draw_text()

static void draw_text ( ME_Context c,
ME_Run run,
int  x,
int  y,
BOOL  selected,
RECT sel_rect 
)
static

Definition at line 348 of file paint.c.

349{
350 COLORREF text_color = get_text_color( c, run->style, selected );
351 COLORREF back_color = get_back_color( c, run->style, selected );
352 COLORREF old_text, old_back = 0;
353 const WCHAR *text = get_text( run, 0 );
354 ME_String *masked = NULL;
355 const BOOL paint_bg = ( selected
356 || ( ( run->style->fmt.dwMask & CFM_BACKCOLOR )
357 && !(CFE_AUTOBACKCOLOR & run->style->fmt.dwEffects) )
358 );
359
360 if (c->editor->password_char)
361 {
362 masked = ME_MakeStringR( c->editor->password_char, run->len );
363 text = masked->szData;
364 }
365
366 old_text = SetTextColor( c->hDC, text_color );
367 if (paint_bg) old_back = SetBkColor( c->hDC, back_color );
368
369 if (run->para->nFlags & MEPF_COMPLEX)
370 ScriptTextOut( c->hDC, &run->style->script_cache, x, y, paint_bg ? ETO_OPAQUE : 0, sel_rect,
371 &run->script_analysis, NULL, 0, run->glyphs, run->num_glyphs, run->advances,
372 NULL, run->offsets );
373 else
374 ExtTextOutW( c->hDC, x, y, paint_bg ? ETO_OPAQUE : 0, sel_rect, text, run->len, NULL );
375
376 if (paint_bg) SetBkColor( c->hDC, old_back );
377 SetTextColor( c->hDC, old_text );
378
379 draw_underline( c, run, x, y, text_color );
380
381 ME_DestroyString( masked );
382 return;
383}
const WCHAR * text
Definition: package.c:1794
static COLORREF get_back_color(ME_Context *c, ME_Style *style, BOOL highlight)
Definition: paint.c:222
HRESULT WINAPI ScriptTextOut(const HDC hdc, SCRIPT_CACHE *psc, int x, int y, UINT fuOptions, const RECT *lprc, const SCRIPT_ANALYSIS *psa, const WCHAR *pwcReserved, int iReserved, const WORD *pwGlyphs, int cGlyphs, const int *piAdvance, const int *piJustify, const GOFFSET *pGoffset)
Definition: usp10.c:3616
void ME_DestroyString(ME_String *s)
Definition: string.c:96
ME_String * ME_MakeStringR(WCHAR cRepeat, int nMaxChars)
Definition: string.c:85
#define MEPF_COMPLEX
Definition: editstr.h:144
#define CFM_BACKCOLOR
Definition: richedit.h:357
#define CFE_AUTOBACKCOLOR
Definition: richedit.h:425
DWORD dwMask
Definition: richedit.h:306
DWORD dwEffects
Definition: richedit.h:307
int num_glyphs
Definition: editstr.h:171
GOFFSET * offsets
Definition: editstr.h:175
int * advances
Definition: editstr.h:174
WORD * glyphs
Definition: editstr.h:172
SCRIPT_ANALYSIS script_analysis
Definition: editstr.h:170
int len
Definition: editstr.h:163
WCHAR * szData
Definition: editstr.h:54
CHARFORMAT2W fmt
Definition: editstr.h:71
SCRIPT_CACHE script_cache
Definition: editstr.h:76

Referenced by draw_text_with_style().

◆ draw_text_with_style()

static void draw_text_with_style ( ME_Context c,
ME_Run run,
int  x,
int  y,
int  nSelFrom,
int  nSelTo,
int  ymin,
int  cy 
)
static

Definition at line 386 of file paint.c.

388{
389 HDC hDC = c->hDC;
390 int yOffset = 0;
391 BOOL selected = (nSelFrom < run->len && nSelTo >= 0
392 && nSelFrom < nSelTo && !c->editor->bHideSelection &&
393 (c->editor->bHaveFocus || !(c->editor->props & TXTBIT_HIDESELECTION)));
394 BOOL old_style_selected = FALSE;
395 RECT sel_rect;
396 HRGN clip = NULL, sel_rgn = NULL;
397
398 yOffset = calc_y_offset( c, run->style );
399
400 if (selected)
401 {
402 get_selection_rect( c, run, nSelFrom, nSelTo, cy, &sel_rect );
403 OffsetRect( &sel_rect, x, ymin );
404
405 if (c->editor->bEmulateVersion10)
406 {
407 old_style_selected = TRUE;
408 selected = FALSE;
409 }
410 else
411 {
412 sel_rgn = CreateRectRgnIndirect( &sel_rect );
413 clip = CreateRectRgn( 0, 0, 0, 0 );
414 if (GetClipRgn( hDC, clip ) != 1)
415 {
416 DeleteObject( clip );
417 clip = NULL;
418 }
419 }
420 }
421
422 select_style( c, run->style );
423
424 if (sel_rgn) ExtSelectClipRgn( hDC, sel_rgn, RGN_DIFF );
425
426 if (!(run->style->fmt.dwEffects & CFE_AUTOBACKCOLOR)
427 && (run->style->fmt.dwMask & CFM_BACKCOLOR) )
428 {
429 RECT tmp_rect;
430 get_selection_rect( c, run, 0, run->len, cy, &tmp_rect );
431 OffsetRect( &tmp_rect, x, ymin );
432 draw_text( c, run, x, y - yOffset, FALSE, &tmp_rect );
433 }
434 else
435 draw_text( c, run, x, y - yOffset, FALSE, NULL );
436
437 if (sel_rgn)
438 {
439 ExtSelectClipRgn( hDC, clip, RGN_COPY );
440 ExtSelectClipRgn( hDC, sel_rgn, RGN_AND );
441 draw_text( c, run, x, y - yOffset, TRUE, &sel_rect );
442 ExtSelectClipRgn( hDC, clip, RGN_COPY );
443 if (clip) DeleteObject( clip );
444 DeleteObject( sel_rgn );
445 }
446
447 if (old_style_selected)
448 PatBlt( hDC, sel_rect.left, ymin, sel_rect.right - sel_rect.left, cy, DSTINVERT );
449}
static HDC hDC
Definition: 3dtext.c:33
int yOffset
Definition: appswitch.c:58
static void get_selection_rect(ME_Context *c, ME_Run *run, int from, int to, int cy, RECT *r)
Definition: paint.c:337
static void draw_text(ME_Context *c, ME_Run *run, int x, int y, BOOL selected, RECT *sel_rect)
Definition: paint.c:348
HRGN WINAPI CreateRectRgn(_In_ int, _In_ int, _In_ int, _In_ int)
#define RGN_DIFF
Definition: wingdi.h:358
int WINAPI GetClipRgn(_In_ HDC, _In_ HRGN)
#define RGN_COPY
Definition: wingdi.h:357
#define RGN_AND
Definition: wingdi.h:356
HRGN WINAPI CreateRectRgnIndirect(_In_ LPCRECT)
int WINAPI ExtSelectClipRgn(_In_ HDC, _In_opt_ HRGN, _In_ int)
BOOL WINAPI OffsetRect(_Inout_ LPRECT, _In_ int, _In_ int)

Referenced by draw_run().

◆ draw_underline()

static void draw_underline ( ME_Context c,
ME_Run run,
int  x,
int  y,
COLORREF  color 
)
static

Definition at line 264 of file paint.c.

265{
266 HPEN pen;
267
268 pen = get_underline_pen( run->style, color );
269 if (pen)
270 {
271 HPEN old_pen = SelectObject( c->hDC, pen );
272 MoveToEx( c->hDC, x, y + 1, NULL );
273 LineTo( c->hDC, x + run->nWidth, y + 1 );
274 SelectObject( c->hDC, old_pen );
275 DeleteObject( pen );
276 }
277 return;
278}
static HPEN get_underline_pen(ME_Style *style, COLORREF color)
Definition: paint.c:237

Referenced by draw_space(), and draw_text().

◆ editor_draw()

void editor_draw ( ME_TextEditor editor,
HDC  hDC,
const RECT update 
)

Definition at line 33 of file paint.c.

34{
35 ME_Paragraph *para;
37 ME_Cell *cell;
38 int ys, ye;
39 HRGN oldRgn;
40 RECT rc, client;
42
43 ME_InitContext( &c, editor, hDC );
44 if (!update)
45 {
46 client = c.rcView;
47 client.left -= editor->selofs;
48 update = &client;
49 }
50
51 oldRgn = CreateRectRgn(0, 0, 0, 0);
52 if (!GetClipRgn(hDC, oldRgn))
53 {
54 DeleteObject(oldRgn);
55 oldRgn = NULL;
56 }
57 IntersectClipRect( hDC, update->left, update->top, update->right, update->bottom );
58
59 brush = SelectObject( hDC, brush );
61
62 para = editor_first_para( editor );
63 /* This context point is an offset for the paragraph positions stored
64 * during wrapping. It shouldn't be modified during painting. */
65 c.pt.x = c.rcView.left - editor->horz_si.nPos;
66 c.pt.y = c.rcView.top - editor->vert_si.nPos;
67 while (para_next( para ))
68 {
69 ys = c.pt.y + para->pt.y;
70 cell = para_cell( para );
71 if (cell && para == cell_end_para( cell ))
72 ye = c.pt.y + cell->pt.y + cell->nHeight;
73 else ye = ys + para->nHeight;
74
75 if (cell && !(para->nFlags & MEPF_ROWEND) && para == cell_first_para( cell ))
76 {
77 /* the border shifts the text down */
78 ys -= para_cell( para )->yTextOffset;
79 }
80
81 /* Draw the paragraph if any of the paragraph is in the update region. */
82 if (ys < update->bottom && ye > update->top)
83 draw_paragraph( &c, para );
84 para = para_next( para );
85 }
86 if (editor_opaque( editor ))
87 {
88 if (c.pt.y + editor->nTotalLength < c.rcView.bottom)
89 { /* space after the end of the text */
90 rc.top = c.pt.y + editor->nTotalLength;
91 rc.left = c.rcView.left;
92 rc.bottom = c.rcView.bottom;
93 rc.right = c.rcView.right;
94 if (IntersectRect( &rc, &rc, update ))
95 PatBlt(hDC, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, PATCOPY);
96 }
97 if (editor->selofs)
98 { /* selection bar */
99 rc.left = c.rcView.left - editor->selofs;
100 rc.top = c.rcView.top;
101 rc.right = c.rcView.left;
102 rc.bottom = c.rcView.bottom;
103 if (IntersectRect( &rc, &rc, update ))
104 PatBlt( hDC, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, PATCOPY );
105 }
106 }
107
108 DeleteObject( SelectObject( hDC, brush ) );
109 SelectClipRgn( hDC, oldRgn );
110 if (oldRgn) DeleteObject( oldRgn );
112
113 if (editor->in_place_active) {
114 if (editor->nTotalLength != editor->nLastTotalLength || editor->nTotalWidth != editor->nLastTotalWidth)
116 editor->nLastTotalLength = editor->nTotalLength;
117 editor->nLastTotalWidth = editor->nTotalWidth;
118 }
119}
void ME_DestroyContext(ME_Context *c)
Definition: context.c:44
void ME_InitContext(ME_Context *c, ME_TextEditor *editor, HDC hDC)
Definition: context.c:23
ME_Paragraph * editor_first_para(ME_TextEditor *editor)
Definition: editor.c:276
static void draw_paragraph(ME_Context *c, ME_Paragraph *para)
Definition: paint.c:935
void ME_SendRequestResize(ME_TextEditor *editor, BOOL force)
Definition: wrap.c:1137
#define c
Definition: ke_i.h:80
static FILE * client
Definition: client.c:37
SCROLLINFO vert_si
Definition: editstr.h:449
int nLastTotalWidth
Definition: editstr.h:405
ITextHost2 * texthost
Definition: editstr.h:391
SCROLLINFO horz_si
Definition: editstr.h:449
unsigned int in_place_active
Definition: editstr.h:393
int nLastTotalLength
Definition: editstr.h:404
int WINAPI IntersectClipRect(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int)
#define TRANSPARENT
Definition: wingdi.h:950
int WINAPI SetBkMode(_In_ HDC, _In_ int)
Definition: dc.c:1056
int WINAPI SelectClipRgn(_In_ HDC, _In_opt_ HRGN)
#define COLOR_WINDOW
Definition: winuser.h:929
BOOL WINAPI IntersectRect(_Out_ LPRECT, _In_ LPCRECT, _In_ LPCRECT)

Referenced by fnTextSrv_TxDraw().

◆ editor_ensure_visible()

void editor_ensure_visible ( ME_TextEditor editor,
ME_Cursor cursor 
)

Definition at line 1210 of file paint.c.

1211{
1212 ME_Run *run = cursor->run;
1214 ME_Paragraph *para = cursor->para;
1215 int x, y, yheight;
1216
1217 if (!editor->in_place_active)
1218 return;
1219
1220 if (editor->scrollbars & ES_AUTOHSCROLL)
1221 {
1222 x = run->pt.x + ME_PointFromChar( editor, run, cursor->nOffset, TRUE );
1223 if (x > editor->horz_si.nPos + editor->sizeWindow.cx)
1224 x = x + 1 - editor->sizeWindow.cx;
1225 else if (x > editor->horz_si.nPos)
1226 x = editor->horz_si.nPos;
1227
1228 if (~editor->scrollbars & ES_AUTOVSCROLL)
1229 {
1230 scroll_h_abs( editor, x, TRUE );
1231 return;
1232 }
1233 }
1234 else
1235 {
1236 if (~editor->scrollbars & ES_AUTOVSCROLL) return;
1237 x = editor->horz_si.nPos;
1238 }
1239
1240 y = para->pt.y + row->pt.y;
1241 yheight = row->nHeight;
1242
1243 if (y < editor->vert_si.nPos)
1244 scroll_abs( editor, x, y, TRUE );
1245 else if (y + yheight > editor->vert_si.nPos + editor->sizeWindow.cy)
1246 scroll_abs( editor, x, y + yheight - editor->sizeWindow.cy, TRUE );
1247 else if (x != editor->horz_si.nPos)
1248 scroll_abs( editor, x, editor->vert_si.nPos, TRUE );
1249}
void scroll_h_abs(ME_TextEditor *editor, int x, BOOL notify)
Definition: paint.c:1121
void scroll_abs(ME_TextEditor *editor, int x, int y, BOOL notify)
Definition: paint.c:1091
int ME_PointFromChar(ME_TextEditor *editor, ME_Run *pRun, int nOffset, BOOL visual_order)
Definition: run.c:654
#define ES_AUTOVSCROLL
Definition: pedump.c:671
#define ES_AUTOHSCROLL
Definition: pedump.c:672
LONG cx
Definition: kdterminal.h:27
LONG cy
Definition: kdterminal.h:28
DWORD scrollbars
Definition: editstr.h:401

Referenced by editor_handle_message(), ME_ArrowKey(), ME_MouseMove(), ME_UpdateRepaint(), and set_selection().

◆ editor_opaque()

static BOOL editor_opaque ( ME_TextEditor editor)
inlinestatic

Definition at line 28 of file paint.c.

29{
30 return editor->back_style != TXTBACK_TRANSPARENT;
31}
TXTBACKSTYLE back_style
Definition: editstr.h:457
@ TXTBACK_TRANSPARENT
Definition: textserv.h:164

Referenced by draw_paragraph(), draw_table_borders(), editor_draw(), and ME_DrawParaDecoration().

◆ enable_show_scrollbar()

static void enable_show_scrollbar ( ME_TextEditor editor,
INT  bar,
BOOL  enable 
)
static

Definition at line 1066 of file paint.c.

1067{
1068 if (enable || editor->scrollbars & ES_DISABLENOSCROLL)
1070 if (!(editor->scrollbars & ES_DISABLENOSCROLL))
1072}
#define ITextHost_TxShowScrollBar(This, a, b)
Definition: editor.h:334
#define ITextHost_TxEnableScrollBar(This, a, b)
Definition: editor.h:335
void bar()
Definition: ehthrow.cxx:142
GLboolean enable
Definition: glext.h:11120
#define ES_DISABLENOSCROLL
Definition: richedit.h:224
#define ESB_DISABLE_BOTH
Definition: winuser.h:556

Referenced by ME_UpdateScrollBar().

◆ get_back_color()

static COLORREF get_back_color ( ME_Context c,
ME_Style style,
BOOL  highlight 
)
static

Definition at line 222 of file paint.c.

223{
225
226 if (highlight)
227 color = ITextHost_TxGetSysColor( c->editor->texthost, COLOR_HIGHLIGHT );
228 else if ( (style->fmt.dwMask & CFM_BACKCOLOR)
229 && !(style->fmt.dwEffects & CFE_AUTOBACKCOLOR) )
230 color = style->fmt.crBackColor;
231 else
232 color = ITextHost_TxGetSysColor( c->editor->texthost, COLOR_WINDOW );
233
234 return color;
235}

Referenced by draw_text().

◆ get_selection_rect()

static void get_selection_rect ( ME_Context c,
ME_Run run,
int  from,
int  to,
int  cy,
RECT r 
)
static

Definition at line 337 of file paint.c.

338{
339 from = max( 0, from );
340 to = min( run->len, to );
341 r->left = ME_PointFromCharContext( c, run, from, TRUE );
342 r->top = 0;
343 r->right = ME_PointFromCharContext( c, run, to, TRUE );
344 r->bottom = cy;
345 return;
346}
int ME_PointFromCharContext(ME_Context *c, ME_Run *pRun, int nOffset, BOOL visual_order)
Definition: run.c:613
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
CardRegion * from
Definition: spigame.cpp:19

Referenced by draw_text_with_style().

◆ get_text_color()

static COLORREF get_text_color ( ME_Context c,
ME_Style style,
BOOL  highlight 
)
static

Definition at line 206 of file paint.c.

207{
209
210 if (highlight)
211 color = ITextHost_TxGetSysColor( c->editor->texthost, COLOR_HIGHLIGHTTEXT );
212 else if ((style->fmt.dwMask & CFM_LINK) && (style->fmt.dwEffects & CFE_LINK))
213 color = RGB(0,0,255);
214 else if ((style->fmt.dwMask & CFM_COLOR) && (style->fmt.dwEffects & CFE_AUTOCOLOR))
215 color = ITextHost_TxGetSysColor( c->editor->texthost, COLOR_WINDOWTEXT );
216 else
217 color = style->fmt.crTextColor;
218
219 return color;
220}
#define CFE_AUTOCOLOR
Definition: richedit.h:414
#define CFE_LINK
Definition: richedit.h:411
#define CFM_LINK
Definition: richedit.h:337
#define CFM_COLOR
Definition: richedit.h:361
#define COLOR_WINDOWTEXT
Definition: winuser.h:932
#define COLOR_HIGHLIGHTTEXT
Definition: winuser.h:938

Referenced by draw_para_number(), draw_space(), and draw_text().

◆ get_underline_pen()

static HPEN get_underline_pen ( ME_Style style,
COLORREF  color 
)
static

Definition at line 237 of file paint.c.

238{
239 if (style->fmt.dwEffects & CFE_LINK)
240 return CreatePen( PS_SOLID, 1, color );
241
242 /* Choose the pen type for underlining the text. */
243 if (style->fmt.dwEffects & CFE_UNDERLINE)
244 {
245 switch (style->fmt.bUnderlineType)
246 {
247 case CFU_UNDERLINE:
248 case CFU_UNDERLINEWORD: /* native seems to map it to simple underline (MSDN) */
249 case CFU_UNDERLINEDOUBLE: /* native seems to map it to simple underline (MSDN) */
250 return CreatePen( PS_SOLID, 1, color );
252 return CreatePen( PS_DOT, 1, color );
253 default:
254 FIXME( "Unknown underline type (%u)\n", style->fmt.bUnderlineType );
255 /* fall through */
256 case CFU_CF1UNDERLINE: /* this type is supported in the font, do nothing */
258 break;
259 }
260 }
261 return NULL;
262}
#define FIXME(fmt,...)
Definition: precomp.h:53
#define CFU_UNDERLINEDOUBLE
Definition: richedit.h:430
#define CFU_UNDERLINEWORD
Definition: richedit.h:429
#define CFE_UNDERLINE
Definition: richedit.h:408
#define CFU_UNDERLINE
Definition: richedit.h:428
#define CFU_CF1UNDERLINE
Definition: richedit.h:447
#define CFU_UNDERLINENONE
Definition: richedit.h:427
#define CFU_UNDERLINEDOTTED
Definition: richedit.h:431
#define PS_DOT
Definition: wingdi.h:588

Referenced by draw_underline().

◆ ME_DebugWrite()

static void ME_DebugWrite ( HDC  hDC,
const POINT pt,
LPCWSTR  szText 
)
static

Definition at line 451 of file paint.c.

451 {
454 COLORREF color = SetTextColor(hDC, RGB(128,128,128));
455 TextOutW(hDC, pt->x, pt->y, szText, lstrlenW(szText));
459}
HFONT hFont
Definition: main.c:53
#define lstrlenW
Definition: compat.h:750
#define DEFAULT_GUI_FONT
Definition: wingdi.h:909
#define TA_LEFT
Definition: wingdi.h:932
#define TA_TOP
Definition: wingdi.h:930
BOOL WINAPI TextOutW(_In_ HDC hdc, _In_ int x, _In_ int y, _In_reads_(c) LPCWSTR lpString, _In_ int c)

Referenced by draw_paragraph().

◆ ME_DrawParaDecoration()

static void ME_DrawParaDecoration ( ME_Context c,
ME_Paragraph para,
int  y,
RECT bounds 
)
static

Definition at line 556 of file paint.c.

557{
558 int idx, border_width, top_border, bottom_border;
559 RECT rc;
560 BOOL hasParaBorder;
561
562 SetRectEmpty(bounds);
563 if (!(para->fmt.dwMask & (PFM_BORDER | PFM_SPACEBEFORE | PFM_SPACEAFTER))) return;
564
565 border_width = top_border = bottom_border = 0;
566 idx = (para->fmt.wBorders >> 8) & 0xF;
567 hasParaBorder = (!(c->editor->bEmulateVersion10 &&
568 para->fmt.dwMask & PFM_TABLE &&
569 para->fmt.wEffects & PFE_TABLE) &&
570 (para->fmt.dwMask & PFM_BORDER) &&
571 idx != 0 &&
572 (para->fmt.wBorders & 0xF));
573 if (hasParaBorder)
574 {
575 /* FIXME: wBorders is not stored as MSDN says in v1.0 - 4.1 of richedit
576 * controls. It actually stores the paragraph or row border style. Although
577 * the value isn't used for drawing, it is used for streaming out rich text.
578 *
579 * wBorders stores the border style for each side (top, left, bottom, right)
580 * using nibble (4 bits) to store each border style. The rich text format
581 * control words, and their associated value are the following:
582 * \brdrdash 0
583 * \brdrdashsm 1
584 * \brdrdb 2
585 * \brdrdot 3
586 * \brdrhair 4
587 * \brdrs 5
588 * \brdrth 6
589 * \brdrtriple 7
590 *
591 * The order of the sides stored actually differs from v1.0 to 3.0 and v4.1.
592 * The mask corresponding to each side for the version are the following:
593 * mask v1.0-3.0 v4.1
594 * 0x000F top left
595 * 0x00F0 left top
596 * 0x0F00 bottom right
597 * 0xF000 right bottom
598 */
599 if (para->fmt.wBorders & 0x00B0)
600 FIXME("Unsupported border flags %x\n", para->fmt.wBorders);
601 border_width = ME_GetParaBorderWidth(c, para->fmt.wBorders);
602 if (para->fmt.wBorders & 4) top_border = border_width;
603 if (para->fmt.wBorders & 8) bottom_border = border_width;
604 }
605
606 if (para->fmt.dwMask & PFM_SPACEBEFORE)
607 {
608 bounds->top = ME_twips2pointsY(c, para->fmt.dySpaceBefore);
609 if (editor_opaque( c->editor ))
610 {
611 rc.left = c->rcView.left;
612 rc.right = c->rcView.right;
613 rc.top = y;
614 rc.bottom = y + bounds->top + top_border;
615 PatBlt(c->hDC, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, PATCOPY);
616 }
617 }
618
619 if (para->fmt.dwMask & PFM_SPACEAFTER)
620 {
621 bounds->bottom = ME_twips2pointsY(c, para->fmt.dySpaceAfter);
622 if (editor_opaque( c->editor ))
623 {
624 rc.left = c->rcView.left;
625 rc.right = c->rcView.right;
626 rc.bottom = y + para->nHeight;
627 rc.top = rc.bottom - bounds->bottom - bottom_border;
628 PatBlt(c->hDC, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, PATCOPY);
629 }
630 }
631
632 /* Native richedit doesn't support paragraph borders in v1.0 - 4.1,
633 * but might support it in later versions. */
634 if (hasParaBorder) {
635 int pen_width, rightEdge;
636 COLORREF pencr;
637 HPEN pen = NULL, oldpen = NULL;
638 POINT pt;
639
640 if (para->fmt.wBorders & 64) /* autocolor */
641 pencr = ITextHost_TxGetSysColor(c->editor->texthost,
643 else
644 pencr = pen_colors[(para->fmt.wBorders >> 12) & 0xF];
645
646 rightEdge = c->pt.x + max(c->editor->sizeWindow.cx,
647 c->editor->nTotalWidth);
648
649 pen_width = ME_GetBorderPenWidth(c, idx);
650 pen = CreatePen(border_details[idx].pen_style, pen_width, pencr);
651 oldpen = SelectObject(c->hDC, pen);
652 MoveToEx(c->hDC, 0, 0, &pt);
653
654 /* before & after spaces are not included in border */
655
656 /* helper to draw the double lines in case of corner */
657#define DD(x) ((para->fmt.wBorders & (x)) ? (pen_width + 1) : 0)
658
659 if (para->fmt.wBorders & 1)
660 {
661 MoveToEx(c->hDC, c->pt.x, y + bounds->top, NULL);
662 LineTo(c->hDC, c->pt.x, y + para->nHeight - bounds->bottom);
663 if (border_details[idx].dble) {
664 rc.left = c->pt.x + 1;
665 rc.right = rc.left + border_width;
666 rc.top = y + bounds->top;
667 rc.bottom = y + para->nHeight - bounds->bottom;
668 PatBlt(c->hDC, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, PATCOPY);
669 MoveToEx(c->hDC, c->pt.x + pen_width + 1, y + bounds->top + DD(4), NULL);
670 LineTo(c->hDC, c->pt.x + pen_width + 1, y + para->nHeight - bounds->bottom - DD(8));
671 }
672 bounds->left += border_width;
673 }
674 if (para->fmt.wBorders & 2)
675 {
676 MoveToEx(c->hDC, rightEdge - 1, y + bounds->top, NULL);
677 LineTo(c->hDC, rightEdge - 1, y + para->nHeight - bounds->bottom);
678 if (border_details[idx].dble) {
679 rc.left = rightEdge - pen_width - 1;
680 rc.right = rc.left + pen_width;
681 rc.top = y + bounds->top;
682 rc.bottom = y + para->nHeight - bounds->bottom;
683 PatBlt(c->hDC, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, PATCOPY);
684 MoveToEx(c->hDC, rightEdge - 1 - pen_width - 1, y + bounds->top + DD(4), NULL);
685 LineTo(c->hDC, rightEdge - 1 - pen_width - 1, y + para->nHeight - bounds->bottom - DD(8));
686 }
687 bounds->right += border_width;
688 }
689 if (para->fmt.wBorders & 4)
690 {
691 MoveToEx(c->hDC, c->pt.x, y + bounds->top, NULL);
692 LineTo(c->hDC, rightEdge, y + bounds->top);
693 if (border_details[idx].dble) {
694 MoveToEx(c->hDC, c->pt.x + DD(1), y + bounds->top + pen_width + 1, NULL);
695 LineTo(c->hDC, rightEdge - DD(2), y + bounds->top + pen_width + 1);
696 }
697 bounds->top += border_width;
698 }
699 if (para->fmt.wBorders & 8)
700 {
701 MoveToEx(c->hDC, c->pt.x, y + para->nHeight - bounds->bottom - 1, NULL);
702 LineTo(c->hDC, rightEdge, y + para->nHeight - bounds->bottom - 1);
703 if (border_details[idx].dble) {
704 MoveToEx(c->hDC, c->pt.x + DD(1), y + para->nHeight - bounds->bottom - 1 - pen_width - 1, NULL);
705 LineTo(c->hDC, rightEdge - DD(2), y + para->nHeight - bounds->bottom - 1 - pen_width - 1);
706 }
707 bounds->bottom += border_width;
708 }
709#undef DD
710
711 MoveToEx(c->hDC, pt.x, pt.y, NULL);
712 SelectObject(c->hDC, oldpen);
713 DeleteObject(pen);
714 }
715}
unsigned int idx
Definition: utils.c:41
unsigned pen_style
Definition: paint.c:502
static int ME_GetBorderPenWidth(const ME_Context *c, int idx)
Definition: paint.c:528
int ME_GetParaBorderWidth(const ME_Context *c, int flags)
Definition: paint.c:541
static const COLORREF pen_colors[16]
Definition: paint.c:517
static const struct @590 border_details[]
#define DD(x)
unsigned dble
Definition: paint.c:502
#define PFM_TABLE
Definition: richedit.h:870
#define PFE_TABLE
Definition: richedit.h:944
#define PFM_BORDER
Definition: richedit.h:851
#define PFM_SPACEAFTER
Definition: richedit.h:848
LONG dySpaceAfter
Definition: richedit.h:676
WORD wBorders
Definition: richedit.h:681
WORD wEffects
Definition: richedit.h:669
BOOL WINAPI SetRectEmpty(_Out_ LPRECT)

Referenced by draw_paragraph().

◆ ME_GetBorderPenWidth()

static int ME_GetBorderPenWidth ( const ME_Context c,
int  idx 
)
static

Definition at line 528 of file paint.c.

529{
530 int width = border_details[idx].width;
531
532 if (c->dpi.cx != 96)
533 width = MulDiv(width, c->dpi.cx, 96);
534
535 if (c->editor->nZoomNumerator != 0)
536 width = MulDiv(width, c->editor->nZoomNumerator, c->editor->nZoomDenominator);
537
538 return width;
539}
INT WINAPI MulDiv(INT nNumber, INT nNumerator, INT nDenominator)
Definition: muldiv.c:25

Referenced by ME_DrawParaDecoration(), and ME_GetParaBorderWidth().

◆ ME_GetParaBorderWidth()

int ME_GetParaBorderWidth ( const ME_Context c,
int  flags 
)

Definition at line 541 of file paint.c.

542{
543 int idx = (flags >> 8) & 0xF;
544 int width;
545
547 {
548 FIXME("Unsupported border value %d\n", idx);
549 return 0;
550 }
552 if (border_details[idx].dble) width = width * 2 + 1;
553 return width;
554}
#define ARRAY_SIZE(A)
Definition: main.h:20
GLbitfield flags
Definition: glext.h:7161

Referenced by ME_DrawParaDecoration(), and ME_WrapTextParagraph().

◆ ME_InvalidateSelection()

void ME_InvalidateSelection ( ME_TextEditor editor)

Definition at line 1253 of file paint.c.

1254{
1255 ME_Paragraph *sel_start, *sel_end;
1256 ME_Paragraph *repaint_start = NULL, *repaint_end = NULL;
1257 LONG nStart, nEnd;
1258 int len = ME_GetTextLength(editor);
1259
1260 ME_GetSelectionOfs(editor, &nStart, &nEnd);
1261 /* if both old and new selection are 0-char (= caret only), then
1262 there's no (inverted) area to be repainted, neither old nor new */
1263 if (nStart == nEnd && editor->nLastSelStart == editor->nLastSelEnd)
1264 return;
1266 editor_get_selection_paras( editor, &sel_start, &sel_end );
1267
1268 /* last selection markers aren't always updated, which means
1269 * they can point past the end of the document */
1270 if (editor->nLastSelStart > len || editor->nLastSelEnd > len)
1271 {
1272 repaint_start = editor_first_para( editor );
1273 repaint_end = para_prev( editor_end_para( editor ) );
1274 }
1275 else
1276 {
1277 /* if the start part of selection is being expanded or contracted... */
1278 if (nStart < editor->nLastSelStart)
1279 {
1280 repaint_start = sel_start;
1281 repaint_end = editor->last_sel_start_para;
1282 }
1283 else if (nStart > editor->nLastSelStart)
1284 {
1285 repaint_start = editor->last_sel_start_para;
1286 repaint_end = sel_start;
1287 }
1288
1289 /* if the end part of selection is being contracted or expanded... */
1290 if (nEnd < editor->nLastSelEnd)
1291 {
1292 if (!repaint_start) repaint_start = sel_end;
1293 repaint_end = editor->last_sel_end_para;
1294 }
1295 else if (nEnd > editor->nLastSelEnd)
1296 {
1297 if (!repaint_start) repaint_start = editor->last_sel_end_para;
1298 repaint_end = sel_end;
1299 }
1300 }
1301
1302 if (repaint_start)
1303 para_range_invalidate( editor, repaint_start, repaint_end );
1304 /* remember the last invalidated position */
1305 ME_GetSelectionOfs(editor, &editor->nLastSelStart, &editor->nLastSelEnd);
1307}
int ME_GetTextLength(ME_TextEditor *editor)
Definition: caret.c:83
ME_Paragraph * editor_end_para(ME_TextEditor *editor)
Definition: editor.c:282
BOOL ME_WrapMarkedParagraphs(ME_TextEditor *editor)
Definition: wrap.c:1103
void editor_get_selection_paras(ME_TextEditor *editor, ME_Paragraph **para, ME_Paragraph **para_end)
Definition: para.c:848
void para_range_invalidate(ME_TextEditor *editor, ME_Paragraph *start_para, ME_Paragraph *last_para)
Definition: wrap.c:1111
ME_Paragraph * para_prev(ME_Paragraph *para)
Definition: para.c:63
GLenum GLsizei len
Definition: glext.h:6722
ME_Paragraph * last_sel_end_para
Definition: editstr.h:419
ME_Paragraph * last_sel_start_para
Definition: editstr.h:419
LONG nLastSelEnd
Definition: editstr.h:418
LONG nLastSelStart
Definition: editstr.h:418

Referenced by editor_handle_message(), fnTextSrv_OnTxPropertyBitsChange(), ME_ArrowKey(), ME_LButtonDown(), ME_MouseMove(), set_selection(), and table_handle_tab().

◆ ME_Repaint()

void ME_Repaint ( ME_TextEditor editor)

Definition at line 121 of file paint.c.

122{
123 if (ME_WrapMarkedParagraphs(editor))
124 {
125 ME_UpdateScrollBar(editor);
126 FIXME("ME_Repaint had to call ME_WrapMarkedParagraphs\n");
127 }
128 if (!editor->freeze_count)
130}
void ME_UpdateScrollBar(ME_TextEditor *editor)
Definition: paint.c:1151
#define ITextHost_TxViewChange(This, a)
Definition: editor.h:339
DWORD freeze_count
Definition: editstr.h:437

Referenced by editor_handle_message(), ME_ArrowKey(), ME_RewrapRepaint(), scroll_abs(), set_selection(), and table_handle_tab().

◆ ME_RewrapRepaint()

void ME_RewrapRepaint ( ME_TextEditor editor)

Definition at line 160 of file paint.c.

161{
162 /* RewrapRepaint should be called whenever the control has changed in
163 * looks, but not content. Like resizing. */
164
165 editor_mark_rewrap_all( editor );
167 ME_UpdateScrollBar(editor);
168 ME_Repaint(editor);
169}
void ME_Repaint(ME_TextEditor *editor)
Definition: paint.c:121
void editor_mark_rewrap_all(ME_TextEditor *editor)
Definition: para.c:235

Referenced by editor_handle_message(), fnTextSrv_OnTxInPlaceActivate(), fnTextSrv_OnTxPropertyBitsChange(), ITextDocument2Old_fnUnfreeze(), and ME_SetZoom().

◆ ME_ScrollDown()

void ME_ScrollDown ( ME_TextEditor editor,
int  cy 
)

Definition at line 1136 of file paint.c.

1137{
1138 scroll_v_abs( editor, editor->vert_si.nPos + cy, TRUE );
1139}
void scroll_v_abs(ME_TextEditor *editor, int y, BOOL notify)
Definition: paint.c:1126

Referenced by editor_handle_message(), and ME_ArrowPageDown().

◆ ME_ScrollLeft()

void ME_ScrollLeft ( ME_TextEditor editor,
int  cx 
)

Definition at line 1141 of file paint.c.

1142{
1143 scroll_h_abs( editor, editor->horz_si.nPos - cx, TRUE );
1144}
_Out_opt_ int * cx
Definition: commctrl.h:585

Referenced by editor_handle_message().

◆ ME_ScrollRight()

void ME_ScrollRight ( ME_TextEditor editor,
int  cx 
)

Definition at line 1146 of file paint.c.

1147{
1148 scroll_h_abs( editor, editor->horz_si.nPos + cx, TRUE );
1149}

Referenced by editor_handle_message().

◆ ME_ScrollUp()

void ME_ScrollUp ( ME_TextEditor editor,
int  cy 
)

Definition at line 1131 of file paint.c.

1132{
1133 scroll_v_abs( editor, editor->vert_si.nPos - cy, TRUE );
1134}

Referenced by editor_handle_message(), and ME_ArrowPageUp().

◆ ME_SetZoom()

BOOL ME_SetZoom ( ME_TextEditor editor,
int  numerator,
int  denominator 
)

Definition at line 1310 of file paint.c.

1311{
1312 /* TODO: Zoom images and objects */
1313
1314 if (numerator == 0 && denominator == 0)
1315 {
1316 editor->nZoomNumerator = editor->nZoomDenominator = 0;
1317 return TRUE;
1318 }
1319 if (numerator <= 0 || denominator <= 0)
1320 return FALSE;
1321 if (numerator * 64 <= denominator || numerator / denominator >= 64)
1322 return FALSE;
1323
1324 editor->nZoomNumerator = numerator;
1325 editor->nZoomDenominator = denominator;
1326
1327 ME_RewrapRepaint(editor);
1328 return TRUE;
1329}
void ME_RewrapRepaint(ME_TextEditor *editor)
Definition: paint.c:160
int nZoomNumerator
Definition: editstr.h:421
int nZoomDenominator
Definition: editstr.h:421

Referenced by editor_handle_message().

◆ ME_twips2pointsX()

int ME_twips2pointsX ( const ME_Context c,
int  x 
)

Definition at line 171 of file paint.c.

172{
173 if (c->editor->nZoomNumerator == 0)
174 return x * c->dpi.cx / 1440;
175 else
176 return x * c->dpi.cx * c->editor->nZoomNumerator / 1440 / c->editor->nZoomDenominator;
177}

Referenced by adjust_para_y(), draw_table_borders(), ME_BeginRow(), ME_GetRunSizeCommon(), ME_InitContext(), and ME_WrapTextParagraph().

◆ ME_twips2pointsY()

int ME_twips2pointsY ( const ME_Context c,
int  y 
)

Definition at line 179 of file paint.c.

180{
181 if (c->editor->nZoomNumerator == 0)
182 return y * c->dpi.cy / 1440;
183 else
184 return y * c->dpi.cy * c->editor->nZoomNumerator / 1440 / c->editor->nZoomDenominator;
185}

Referenced by adjust_para_y(), calc_y_offset(), draw_table_borders(), ME_DrawParaDecoration(), ME_GetParaLineSpace(), ME_LogFontFromStyle(), and ME_WrapTextParagraph().

◆ ME_UpdateRepaint()

void ME_UpdateRepaint ( ME_TextEditor editor,
BOOL  update_now 
)

Definition at line 132 of file paint.c.

133{
134 /* Should be called whenever the contents of the control have changed */
135 BOOL wrappedParagraphs;
136
137 wrappedParagraphs = ME_WrapMarkedParagraphs(editor);
138 if (wrappedParagraphs)
139 ME_UpdateScrollBar(editor);
140
141 /* Ensure that the cursor is visible */
142 editor_ensure_visible( editor, &editor->pCursors[0] );
143
144 update_caret( editor );
145
146 if (!editor->freeze_count)
147 ITextHost_TxViewChange(editor->texthost, update_now);
148
149 ME_SendSelChange(editor);
150
151 if(editor->nEventMask & ENM_CHANGE)
152 {
153 editor->nEventMask &= ~ENM_CHANGE;
155 editor->nEventMask |= ENM_CHANGE;
156 }
157}
void ME_SendSelChange(ME_TextEditor *editor)
Definition: caret.c:1439
void update_caret(ME_TextEditor *editor)
Definition: caret.c:277
void editor_ensure_visible(ME_TextEditor *editor, ME_Cursor *cursor)
Definition: paint.c:1210
#define ITextHost_TxNotify(This, a, b)
Definition: editor.h:367
#define ENM_CHANGE
Definition: richedit.h:468
ME_Cursor * pCursors
Definition: editstr.h:396
#define EN_CHANGE
Definition: winuser.h:2051

Referenced by editor_copy_or_cut(), editor_handle_message(), fnTextSrv_TxSetText(), handle_enter(), handle_wm_char(), IRichEditOle_fnInsertObject(), ME_KeyDown(), ME_Redo(), ME_ReplaceSel(), ME_StreamIn(), ME_Undo(), and paste_emf().

◆ ME_UpdateScrollBar()

void ME_UpdateScrollBar ( ME_TextEditor editor)

Definition at line 1151 of file paint.c.

1152{
1153 /* Note that this is the only function that should ever call
1154 * SetScrollInfo with SIF_PAGE or SIF_RANGE. */
1155 BOOL enable;
1156
1157 if (ME_WrapMarkedParagraphs(editor))
1158 FIXME("ME_UpdateScrollBar had to call ME_WrapMarkedParagraphs\n");
1159
1160 /* Update horizontal scrollbar */
1161 enable = editor->nTotalWidth > editor->sizeWindow.cx;
1162 if (editor->horz_si.nPos && !enable)
1163 {
1164 scroll_h_abs( editor, 0, TRUE );
1165 /* ME_HScrollAbs will call this function, so nothing else needs to be done here. */
1166 return;
1167 }
1168
1169 if (editor->scrollbars & WS_HSCROLL && !enable ^ !editor->horz_sb_enabled)
1170 {
1171 editor->horz_sb_enabled = enable;
1173 }
1174
1175 if (editor->horz_si.nMax != editor->nTotalWidth || editor->horz_si.nPage != editor->sizeWindow.cx)
1176 {
1177 editor->horz_si.nMax = editor->nTotalWidth;
1178 editor->horz_si.nPage = editor->sizeWindow.cx;
1179 TRACE( "min = %d max = %d page = %d\n", editor->horz_si.nMin, editor->horz_si.nMax, editor->horz_si.nPage );
1180 if ((enable || editor->horz_sb_enabled) && editor->scrollbars & WS_HSCROLL)
1181 set_scroll_range_pos( editor, SB_HORZ, &editor->horz_si, TRUE, TRUE );
1182 }
1183
1184 /* Update vertical scrollbar */
1185 enable = editor->nTotalLength > editor->sizeWindow.cy && (editor->props & TXTBIT_MULTILINE);
1186
1187 if (editor->vert_si.nPos && !enable)
1188 {
1189 scroll_v_abs( editor, 0, TRUE );
1190 /* ME_VScrollAbs will call this function, so nothing else needs to be done here. */
1191 return;
1192 }
1193
1194 if (editor->scrollbars & WS_VSCROLL && !enable ^ !editor->vert_sb_enabled)
1195 {
1196 editor->vert_sb_enabled = enable;
1198 }
1199
1200 if (editor->vert_si.nMax != editor->nTotalLength || editor->vert_si.nPage != editor->sizeWindow.cy)
1201 {
1202 editor->vert_si.nMax = editor->nTotalLength;
1203 editor->vert_si.nPage = editor->sizeWindow.cy;
1204 TRACE( "min = %d max = %d page = %d\n", editor->vert_si.nMin, editor->vert_si.nMax, editor->vert_si.nPage );
1205 if ((enable || editor->vert_sb_enabled) && editor->scrollbars & WS_VSCROLL)
1206 set_scroll_range_pos( editor, SB_VERT, &editor->vert_si, TRUE, TRUE );
1207 }
1208}
static void enable_show_scrollbar(ME_TextEditor *editor, INT bar, BOOL enable)
Definition: paint.c:1066
static void set_scroll_range_pos(ME_TextEditor *editor, INT bar, SCROLLINFO *info, BOOL set_range, BOOL notify)
Definition: paint.c:1074
#define WS_VSCROLL
Definition: pedump.c:627
#define WS_HSCROLL
Definition: pedump.c:628
unsigned int horz_sb_enabled
Definition: editstr.h:451
unsigned int vert_sb_enabled
Definition: editstr.h:450
#define TXTBIT_MULTILINE
Definition: textserv.h:186
#define SB_VERT
Definition: winuser.h:553
#define SB_HORZ
Definition: winuser.h:552

Referenced by editor_handle_message(), handle_EM_SETCHARFORMAT(), ME_Repaint(), ME_RewrapRepaint(), ME_UpdateRepaint(), scroll_abs(), set_textfont_prop(), and textrange_set_font().

◆ scroll_abs()

void scroll_abs ( ME_TextEditor editor,
int  x,
int  y,
BOOL  notify 
)

Definition at line 1091 of file paint.c.

1092{
1093 int scrollX = 0, scrollY = 0;
1094
1095 if (editor->horz_si.nPos != x) {
1096 x = min(x, editor->horz_si.nMax);
1097 x = max(x, editor->horz_si.nMin);
1098 scrollX = editor->horz_si.nPos - x;
1099 editor->horz_si.nPos = x;
1100 set_scroll_range_pos( editor, SB_HORZ, &editor->horz_si, FALSE, notify );
1101 }
1102
1103 if (editor->vert_si.nPos != y) {
1104 y = min(y, editor->vert_si.nMax - (int)editor->vert_si.nPage);
1105 y = max(y, editor->vert_si.nMin);
1106 scrollY = editor->vert_si.nPos - y;
1107 editor->vert_si.nPos = y;
1108 set_scroll_range_pos( editor, SB_VERT, &editor->vert_si, FALSE, notify );
1109 }
1110
1111 if (abs(scrollX) > editor->sizeWindow.cx || abs(scrollY) > editor->sizeWindow.cy)
1113 else
1114 ITextHost_TxScrollWindowEx(editor->texthost, scrollX, scrollY,
1115 &editor->rcFormat, &editor->rcFormat,
1117 ME_UpdateScrollBar(editor);
1118 ME_Repaint(editor);
1119}
#define ITextHost_TxInvalidateRect(This, a, b)
Definition: editor.h:338
#define ITextHost_TxScrollWindowEx(This, a, b, c, d, e, f, g)
Definition: editor.h:345
#define abs(i)
Definition: fconv.c:206
int notify
Definition: msacm.c:1366
#define SW_INVALIDATE
Definition: winuser.h:2615

Referenced by editor_ensure_visible(), editor_handle_message(), ITextRange_fnScrollIntoView(), scroll_h_abs(), and scroll_v_abs().

◆ scroll_h_abs()

void scroll_h_abs ( ME_TextEditor editor,
int  x,
BOOL  notify 
)

Definition at line 1121 of file paint.c.

1122{
1123 scroll_abs( editor, x, editor->vert_si.nPos, notify );
1124}

Referenced by editor_ensure_visible(), editor_handle_message(), ME_ScrollLeft(), ME_ScrollRight(), and ME_UpdateScrollBar().

◆ scroll_v_abs()

void scroll_v_abs ( ME_TextEditor editor,
int  y,
BOOL  notify 
)

Definition at line 1126 of file paint.c.

1127{
1128 scroll_abs( editor, editor->horz_si.nPos, y, notify );
1129}

Referenced by editor_handle_message(), ME_ScrollDown(), ME_ScrollUp(), and ME_UpdateScrollBar().

◆ set_scroll_range_pos()

static void set_scroll_range_pos ( ME_TextEditor editor,
INT  bar,
SCROLLINFO info,
BOOL  set_range,
BOOL  notify 
)
static

Definition at line 1074 of file paint.c.

1075{
1076 LONG max_pos = info->nMax, pos = info->nPos;
1077
1078 /* Scale the scrollbar info to 16-bit values. */
1079 if (max_pos > 0xffff)
1080 {
1081 pos = MulDiv( pos, 0xffff, max_pos );
1082 max_pos = 0xffff;
1083 }
1084 if (set_range) ITextHost_TxSetScrollRange( editor->texthost, bar, 0, max_pos, FALSE );
1086
1087 if (notify && editor->nEventMask & ENM_SCROLL)
1089}
#define ITextHost_TxSetScrollRange(This, a, b, c, d)
Definition: editor.h:336
#define ITextHost_TxSetScrollPos(This, a, b, c)
Definition: editor.h:337
#define ENM_SCROLL
Definition: richedit.h:470
#define EN_HSCROLL
Definition: winuser.h:2053
#define EN_VSCROLL
Definition: winuser.h:2058

Referenced by ME_UpdateScrollBar(), and scroll_abs().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( richedit  )

Variable Documentation

◆ 

const struct { ... } border_details[]
Initial value:
= {
{0, PS_SOLID, FALSE},
{1, PS_SOLID, FALSE},
{2, PS_SOLID, FALSE},
{3, PS_SOLID, FALSE},
{4, PS_SOLID, FALSE},
{6, PS_SOLID, FALSE},
{8, PS_SOLID, FALSE},
{1, PS_SOLID, TRUE},
{2, PS_SOLID, TRUE},
{3, PS_SOLID, TRUE},
{1, PS_DOT , FALSE},
{2, PS_DASH, FALSE},
}
#define PS_DASH
Definition: wingdi.h:587

Referenced by ME_DrawParaDecoration(), ME_GetBorderPenWidth(), and ME_GetParaBorderWidth().

◆ dble

unsigned dble

Definition at line 502 of file paint.c.

Referenced by ME_DrawParaDecoration(), and ME_GetParaBorderWidth().

◆ pen_colors

const COLORREF pen_colors[16]
static
Initial value:
= {
RGB(0x00, 0x00, 0x00), RGB(0x00, 0x00, 0xFF),
RGB(0x00, 0xFF, 0xFF), RGB(0x00, 0xFF, 0x00),
RGB(0xFF, 0x00, 0xFF), RGB(0xFF, 0x00, 0x00),
RGB(0xFF, 0xFF, 0x00), RGB(0xFF, 0xFF, 0xFF),
RGB(0x00, 0x00, 0x80), RGB(0x00, 0x80, 0x80),
RGB(0x00, 0x80, 0x80), RGB(0x80, 0x00, 0x80),
RGB(0x80, 0x00, 0x00), RGB(0x80, 0x80, 0x00),
RGB(0x80, 0x80, 0x80), RGB(0xc0, 0xc0, 0xc0),
}

Definition at line 517 of file paint.c.

Referenced by ME_DrawParaDecoration().

◆ pen_style

unsigned pen_style

Definition at line 502 of file paint.c.

Referenced by ME_DrawParaDecoration().

◆ width