ReactOS 0.4.16-dev-814-g656a5dc
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 184 of file paint.c.

185{
186 int offs = 0, twips = 0;
187
188 if ((style->fmt.dwMask & style->fmt.dwEffects) & CFM_OFFSET)
189 twips = style->fmt.yOffset;
190
191 if ((style->fmt.dwMask & style->fmt.dwEffects) & (CFM_SUPERSCRIPT | CFM_SUBSCRIPT))
192 {
193 if (style->fmt.dwEffects & CFE_SUPERSCRIPT) twips = style->fmt.yHeight/3;
194 if (style->fmt.dwEffects & CFE_SUBSCRIPT) twips = -style->fmt.yHeight/12;
195 }
196
197 if (twips) offs = ME_twips2pointsY( c, twips );
198
199 return offs;
200}
Arabic default style
Definition: afstyles.h:94
int ME_twips2pointsY(const ME_Context *c, int y)
Definition: paint.c:175
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 912 of file paint.c.

913{
914 int x, y;
915 COLORREF old_text;
916
917 if (para->fmt.wNumbering)
918 {
919 select_style( c, para->para_num.style );
920 old_text = SetTextColor( c->hDC, get_text_color( c, para->para_num.style, FALSE ) );
921
922 x = c->pt.x + para->para_num.pt.x;
923 y = c->pt.y + para->pt.y + para->para_num.pt.y;
924
925 ExtTextOutW( c->hDC, x, y, 0, NULL, para->para_num.text->szData, para->para_num.text->nLen, NULL );
926
927 SetTextColor( c->hDC, old_text );
928 }
929}
#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:202
void select_style(ME_Context *c, ME_Style *s) DECLSPEC_HIDDEN
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:214
PARAFORMAT2 fmt
Definition: editstr.h:203
long y
Definition: polytest.cpp:48
DWORD COLORREF
Definition: windef.h:300
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:918

Referenced by draw_paragraph().

◆ draw_paragraph()

static void draw_paragraph ( ME_Context c,
ME_Paragraph para 
)
static

Definition at line 931 of file paint.c.

932{
933 int align = SetTextAlign(c->hDC, TA_BASELINE);
935 ME_Cell *cell;
936 ME_Run *run;
937 RECT rc, bounds;
938 int y;
939 int height = 0, baseline = 0, no=0;
940 BOOL visible = FALSE;
941
942 rc.left = c->pt.x;
943 rc.right = c->rcView.right;
944
945 y = c->pt.y + para->pt.y;
946 if ((cell = para_cell( para )))
947 {
948 rc.left = c->pt.x + cell->pt.x;
949 rc.right = rc.left + cell->nWidth;
950 }
951 if (para->nFlags & MEPF_ROWSTART)
952 {
953 cell = table_row_first_cell( para );
954 rc.right = c->pt.x + cell->pt.x;
955 }
956 else if (para->nFlags & MEPF_ROWEND)
957 {
958 cell = table_row_end_cell( para );
959 rc.left = c->pt.x + cell->pt.x + cell->nWidth;
960 }
961 ME_DrawParaDecoration(c, para, y, &bounds);
962 y += bounds.top;
963 if (bounds.left || bounds.right)
964 {
965 rc.left = max(rc.left, c->pt.x + bounds.left);
966 rc.right = min(rc.right, c->pt.x - bounds.right
967 + max(c->editor->sizeWindow.cx,
968 c->editor->nTotalWidth));
969 }
970
971 for (p = para_get_di( para )->next; p != para_get_di( para_next( para ) ); p = p->next)
972 {
973 switch(p->type) {
974 case diParagraph:
975 assert(FALSE);
976 break;
977 case diStartRow:
978 y += height;
979 rc.top = y;
980 if (para->nFlags & (MEPF_ROWSTART|MEPF_ROWEND)) {
981 rc.bottom = y + para->nHeight;
982 } else {
983 rc.bottom = y + p->member.row.nHeight;
984 }
985 visible = RectVisible(c->hDC, &rc);
986 if (editor_opaque( c->editor ) && visible)
987 PatBlt(c->hDC, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, PATCOPY);
988 if (bounds.right)
989 {
990 /* If scrolled to the right past the end of the text, then
991 * there may be space to the right of the paragraph border. */
992 RECT after_bdr = rc;
993 after_bdr.left = rc.right + bounds.right;
994 after_bdr.right = c->rcView.right;
995 if (editor_opaque( c->editor ) && RectVisible( c->hDC, &after_bdr ))
996 PatBlt(c->hDC, after_bdr.left, after_bdr.top, after_bdr.right - after_bdr.left,
997 after_bdr.bottom - after_bdr.top, PATCOPY);
998 }
999 if (me_debug)
1000 {
1001 WCHAR buf[128];
1002 POINT pt = c->pt;
1003 wsprintfW( buf, L"row[%d]", no );
1004 pt.y = 12+y;
1005 ME_DebugWrite(c->hDC, &pt, buf);
1006 }
1007
1008 height = p->member.row.nHeight;
1009 baseline = p->member.row.nBaseline;
1010 break;
1011 case diRun:
1012 assert(para);
1013 run = &p->member.run;
1014 if (visible && me_debug) {
1015 RECT rc;
1016 rc.left = c->pt.x + run->pt.x;
1017 rc.right = rc.left + run->nWidth;
1018 rc.top = c->pt.y + para->pt.y + run->pt.y;
1019 rc.bottom = rc.top + height;
1020 TRACE("rc = %s\n", wine_dbgstr_rect(&rc));
1022 }
1023 if (visible)
1024 {
1026
1027 cursor.run = run;
1028 cursor.para = para;
1029 cursor.nOffset = 0;
1030 draw_run( c, c->pt.x + run->pt.x, c->pt.y + para->pt.y + run->pt.y + baseline, &cursor );
1031 }
1032 if (me_debug)
1033 {
1034 WCHAR buf[2560];
1035 POINT pt;
1036 pt.x = c->pt.x + run->pt.x;
1037 pt.y = c->pt.y + para->pt.y + run->pt.y;
1038 wsprintfW( buf, L"[%d:%x] %ls", no, p->member.run.nFlags, get_text( &p->member.run, 0 ));
1039 ME_DebugWrite(c->hDC, &pt, buf);
1040 }
1041 break;
1042 default:
1043 break;
1044 }
1045 no++;
1046 }
1047
1048 if (editor_opaque( c->editor ) && para_cell( para ))
1049 {
1050 /* Clear any space at the bottom of the cell after the text. */
1051 rc.top = c->pt.y + para->pt.y + para->nHeight;
1052 rc.bottom = c->pt.y + cell->pt.y + cell->nHeight;
1053 PatBlt( c->hDC, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, PATCOPY );
1054 }
1055
1056 draw_table_borders( c, para );
1057 draw_para_number( c, para );
1058
1059 SetTextAlign( c->hDC, align );
1060}
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:256
static void ME_DebugWrite(HDC hDC, const POINT *pt, LPCWSTR szText)
Definition: paint.c:447
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:912
static void draw_run(ME_Context *c, int x, int y, ME_Cursor *cursor)
Definition: paint.c:457
static void ME_DrawParaDecoration(ME_Context *c, ME_Paragraph *para, int y, RECT *bounds)
Definition: paint.c:552
static void draw_table_borders(ME_Context *c, ME_Paragraph *para)
Definition: paint.c:713
#define assert(x)
Definition: debug.h:53
#define pt(x, y)
Definition: drawing.c:79
int align(int length, int align)
Definition: dsound8.c:36
ME_Cell * para_cell(ME_Paragraph *para) DECLSPEC_HIDDEN
Definition: para.c:127
static ME_DisplayItem * para_get_di(ME_Paragraph *para)
Definition: editor.h:237
ME_Paragraph * para_next(ME_Paragraph *para) DECLSPEC_HIDDEN
Definition: para.c:57
ME_Cell * table_row_first_cell(ME_Paragraph *para) DECLSPEC_HIDDEN
Definition: table.c:170
ME_Cell * table_row_end_cell(ME_Paragraph *para) DECLSPEC_HIDDEN
Definition: table.c:178
static WCHAR * get_text(const ME_Run *run, int offset)
Definition: editor.h:42
#define MEPF_ROWSTART
Definition: editstr.h:143
#define MEPF_ROWEND
Definition: editstr.h:144
@ diStartRow
Definition: editstr.h:87
@ diRun
Definition: editstr.h:86
@ diParagraph
Definition: editstr.h:84
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
#define L(x)
Definition: ntvdm.h:50
static unsigned __int64 next
Definition: rand_nt.c:6
#define TRACE(s)
Definition: solgame.cpp:4
POINT pt
Definition: editstr.h:225
int nHeight
Definition: editstr.h:226
int nWidth
Definition: editstr.h:226
POINT pt
Definition: editstr.h:166
int nWidth
Definition: editstr.h:163
long x
Definition: polytest.cpp:48
LONG right
Definition: windef.h:308
LONG bottom
Definition: windef.h:309
LONG top
Definition: windef.h:307
LONG left
Definition: windef.h:306
#define max(a, b)
Definition: svc.c:63
UINT WINAPI SetTextAlign(_In_ HDC, _In_ UINT)
Definition: text.c:883
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:935
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 457 of file paint.c.

458{
459 ME_Row *row;
460 ME_Run *run = cursor->run;
461 int runofs = run_char_ofs( run, cursor->nOffset );
462 int nSelFrom, nSelTo;
463
464 if (run->nFlags & MERF_HIDDEN) return;
465
467 ME_GetSelectionOfs(c->editor, &nSelFrom, &nSelTo);
468
469 /* Draw selected end-of-paragraph mark */
470 if (run->nFlags & MERF_ENDPARA)
471 {
472 if (runofs >= nSelFrom && runofs < nSelTo)
473 {
474 draw_space( c, run, x, y, TRUE, FALSE,
475 c->pt.y + run->para->pt.y + row->pt.y, row->nHeight );
476 }
477 return;
478 }
479
480 if (run->nFlags & (MERF_TAB | MERF_ENDCELL))
481 {
482 BOOL selected = runofs >= nSelFrom && runofs < nSelTo;
483
484 draw_space( c, run, x, y, selected, TRUE,
485 c->pt.y + run->para->pt.y + row->pt.y, row->nHeight );
486 return;
487 }
488
489 if (run->nFlags & MERF_GRAPHICS)
490 draw_ole( c, x, y, run, (runofs >= nSelFrom) && (runofs < nSelTo) );
491 else
492 draw_text_with_style( c, run, x, y, nSelFrom - runofs, nSelTo - runofs,
493 c->pt.y + run->para->pt.y + row->pt.y, row->nHeight );
494}
static char selected[MAX_PATH+1]
Definition: dirdlg.c:7
#define TRUE
Definition: types.h:120
int ME_GetSelectionOfs(ME_TextEditor *editor, int *from, int *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:283
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:382
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) DECLSPEC_HIDDEN
Definition: run.c:228
ME_Row * row_from_cursor(ME_Cursor *cursor) DECLSPEC_HIDDEN
Definition: row.c:74
void draw_ole(ME_Context *c, int x, int y, ME_Run *run, BOOL selected) DECLSPEC_HIDDEN
Definition: richole.c:5726
#define MERF_TAB
Definition: editstr.h:106
#define MERF_ENDPARA
Definition: editstr.h:121
#define MERF_HIDDEN
Definition: editstr.h:125
#define MERF_ENDCELL
Definition: editstr.h:108
#define MERF_GRAPHICS
Definition: editstr.h:104
struct tagME_Paragraph * para
Definition: editstr.h:160
int nFlags
Definition: editstr.h:164

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 283 of file paint.c.

285{
286 HDC hdc = c->hDC;
287 BOOL old_style_selected = FALSE;
288 RECT rect;
289 COLORREF back_color = 0;
290
291 SetRect( &rect, x, ymin, x + run->nWidth, ymin + cy );
292
293 if (c->editor->bHideSelection || (!c->editor->bHaveFocus && (c->editor->props & TXTBIT_HIDESELECTION)))
294 selected = FALSE;
295 if (c->editor->bEmulateVersion10)
296 {
297 old_style_selected = selected;
298 selected = FALSE;
299 }
300
301 if (selected)
302 back_color = ITextHost_TxGetSysColor( c->editor->texthost, COLOR_HIGHLIGHT );
303
304 if (actually_draw)
305 {
306 COLORREF text_color = get_text_color( c, run->style, selected );
307 COLORREF old_text, old_back;
308 int y_offset = calc_y_offset( c, run->style );
309 static const WCHAR space[1] = {' '};
310
311 select_style( c, run->style );
312 old_text = SetTextColor( hdc, text_color );
313 if (selected) old_back = SetBkColor( hdc, back_color );
314
315 ExtTextOutW( hdc, x, y - y_offset, selected ? ETO_OPAQUE : 0, &rect, space, 1, &run->nWidth );
316
317 if (selected) SetBkColor( hdc, old_back );
318 SetTextColor( hdc, old_text );
319
320 draw_underline( c, run, x, y - y_offset, text_color );
321 }
322 else if (selected)
323 {
324 HBRUSH brush = CreateSolidBrush( back_color );
325 FillRect( hdc, &rect, brush );
326 DeleteObject( brush );
327 }
328
329 if (old_style_selected)
330 PatBlt( hdc, x, ymin, run->nWidth, cy, DSTINVERT );
331}
static int calc_y_offset(const ME_Context *c, ME_Style *style)
Definition: paint.c:184
static void draw_underline(ME_Context *c, ME_Run *run, int x, int y, COLORREF color)
Definition: paint.c:260
#define ITextHost_TxGetSysColor(This, a)
Definition: editor.h:358
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:159
#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:929
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 713 of file paint.c.

714{
715 if (!c->editor->bEmulateVersion10) /* v4.1 */
716 {
717 if (para_cell( para ))
718 {
719 RECT rc;
720 ME_Cell *cell = para_cell( para );
721 ME_Paragraph *after_row;
722 HPEN pen, oldPen;
723 LOGBRUSH logBrush;
724 HBRUSH brush;
726 POINT oldPt;
727 int width;
728 BOOL atTop = (para == cell_first_para( cell ));
729 BOOL atBottom = (para == cell_end_para( cell ));
730 int top = c->pt.y + (atTop ? cell->pt.y : para->pt.y);
731 int bottom = (atBottom ?
732 c->pt.y + cell->pt.y + cell->nHeight :
733 top + para->nHeight + (atTop ? cell->yTextOffset : 0));
734 rc.left = c->pt.x + cell->pt.x;
735 rc.right = rc.left + cell->nWidth;
736 if (atTop)
737 {
738 /* Erase gap before text if not all borders are the same height. */
739 width = max(ME_twips2pointsY(c, cell->border.top.width), 1);
740 rc.top = top + width;
741 width = cell->yTextOffset - width;
742 rc.bottom = rc.top + width;
743 if (width && editor_opaque( c->editor ))
744 PatBlt(c->hDC, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, PATCOPY);
745 }
746 /* Draw cell borders.
747 * The order borders are draw in is left, top, bottom, right in order
748 * to be consistent with native richedit. This is noticeable from the
749 * overlap of borders of different colours. */
750 if (!(para->nFlags & MEPF_ROWEND))
751 {
752 rc.top = top;
753 rc.bottom = bottom;
754 if (cell->border.left.width > 0)
755 {
756 color = cell->border.left.colorRef;
758 }
759 else
760 {
761 color = RGB(192,192,192);
762 width = 1;
763 }
764 logBrush.lbStyle = BS_SOLID;
765 logBrush.lbColor = color;
766 logBrush.lbHatch = 0;
768 width, &logBrush, 0, NULL);
769 oldPen = SelectObject(c->hDC, pen);
770 MoveToEx(c->hDC, rc.left, rc.top, &oldPt);
771 LineTo(c->hDC, rc.left, rc.bottom);
772 SelectObject(c->hDC, oldPen);
773 DeleteObject(pen);
774 MoveToEx(c->hDC, oldPt.x, oldPt.y, NULL);
775 }
776
777 if (atTop)
778 {
779 if (cell->border.top.width > 0)
780 {
781 brush = CreateSolidBrush(cell->border.top.colorRef);
782 width = max(ME_twips2pointsY(c, cell->border.top.width), 1);
783 }
784 else
785 {
787 width = 1;
788 }
789 rc.top = top;
790 rc.bottom = rc.top + width;
791 FillRect(c->hDC, &rc, brush);
792 if (cell->border.top.width > 0)
793 DeleteObject(brush);
794 }
795
796 /* Draw the bottom border if at the last paragraph in the cell, and when
797 * in the last row of the table. */
798 if (atBottom)
799 {
800 int oldLeft = rc.left;
802 after_row = para_next( table_row_end( para ) );
803 if (after_row->nFlags & MEPF_ROWSTART)
804 {
805 ME_Cell *next_end;
806 next_end = table_row_end_cell( after_row );
807 assert( next_end && !cell_next( next_end ) );
808 rc.left = c->pt.x + next_end->pt.x;
809 }
810 if (rc.left < rc.right)
811 {
812 if (cell->border.bottom.width > 0)
813 brush = CreateSolidBrush(cell->border.bottom.colorRef);
814 else
816 rc.bottom = bottom;
817 rc.top = rc.bottom - width;
818 FillRect(c->hDC, &rc, brush);
819 if (cell->border.bottom.width > 0)
820 DeleteObject(brush);
821 }
822 rc.left = oldLeft;
823 }
824
825 /* Right border only drawn if at the end of the table row. */
826 if (!cell_next( cell_next( cell ) ) && !(para->nFlags & MEPF_ROWSTART))
827 {
828 rc.top = top;
829 rc.bottom = bottom;
830 if (cell->border.right.width > 0)
831 {
832 color = cell->border.right.colorRef;
834 }
835 else
836 {
837 color = RGB(192,192,192);
838 width = 1;
839 }
840 logBrush.lbStyle = BS_SOLID;
841 logBrush.lbColor = color;
842 logBrush.lbHatch = 0;
844 width, &logBrush, 0, NULL);
845 oldPen = SelectObject(c->hDC, pen);
846 MoveToEx(c->hDC, rc.right - 1, rc.top, &oldPt);
847 LineTo(c->hDC, rc.right - 1, rc.bottom);
848 SelectObject(c->hDC, oldPen);
849 DeleteObject(pen);
850 MoveToEx(c->hDC, oldPt.x, oldPt.y, NULL);
851 }
852 }
853 }
854 else /* v1.0 - 3.0 */
855 {
856 /* Draw simple table border */
857 if (para_in_table( para ))
858 {
859 HPEN pen = NULL, oldpen = NULL;
860 int i, firstX, startX, endX, rowY, rowBottom, nHeight;
861 POINT oldPt;
862
863 pen = CreatePen(PS_SOLID, 0, para->border.top.colorRef);
864 oldpen = SelectObject(c->hDC, pen);
865
866 /* Find the start relative to the text */
867 firstX = c->pt.x + para_first_run( para )->pt.x;
868 /* Go back by the horizontal gap, which is stored in dxOffset */
869 firstX -= ME_twips2pointsX(c, para->fmt.dxOffset);
870 /* The left edge, stored in dxStartIndent affected just the first edge */
871 startX = firstX - ME_twips2pointsX(c, para->fmt.dxStartIndent);
872 rowY = c->pt.y + para->pt.y;
873 if (para->fmt.dwMask & PFM_SPACEBEFORE)
874 rowY += ME_twips2pointsY(c, para->fmt.dySpaceBefore);
875 nHeight = para_first_row( para )->nHeight;
876 rowBottom = rowY + nHeight;
877
878 /* Draw horizontal lines */
879 MoveToEx(c->hDC, firstX, rowY, &oldPt);
880 i = para->fmt.cTabCount - 1;
881 endX = startX + ME_twips2pointsX(c, para->fmt.rgxTabs[i] & 0x00ffffff) + 1;
882 LineTo(c->hDC, endX, rowY);
883 /* The bottom of the row only needs to be drawn if the next row is
884 * not a table. */
885 if (!(para_next( para ) && para_in_table( para_next( para ) ) && para->nRows == 1))
886 {
887 /* Decrement rowBottom to draw the bottom line within the row, and
888 * to not draw over this line when drawing the vertical lines. */
889 rowBottom--;
890 MoveToEx(c->hDC, firstX, rowBottom, NULL);
891 LineTo(c->hDC, endX, rowBottom);
892 }
893
894 /* Draw vertical lines */
895 MoveToEx(c->hDC, firstX, rowY, NULL);
896 LineTo(c->hDC, firstX, rowBottom);
897 for (i = 0; i < para->fmt.cTabCount; i++)
898 {
899 int rightBoundary = para->fmt.rgxTabs[i] & 0x00ffffff;
900 endX = startX + ME_twips2pointsX(c, rightBoundary);
901 MoveToEx(c->hDC, endX, rowY, NULL);
902 LineTo(c->hDC, endX, rowBottom);
903 }
904
905 MoveToEx(c->hDC, oldPt.x, oldPt.y, NULL);
906 SelectObject(c->hDC, oldpen);
907 DeleteObject(pen);
908 }
909 }
910}
int ME_twips2pointsX(const ME_Context *c, int x)
Definition: paint.c:167
unsigned width
Definition: paint.c:498
#define RGB(r, g, b)
Definition: precomp.h:71
ME_Paragraph * cell_end_para(ME_Cell *cell) DECLSPEC_HIDDEN
Definition: table.c:207
ME_Run * para_first_run(ME_Paragraph *para) DECLSPEC_HIDDEN
Definition: para.c:104
BOOL para_in_table(ME_Paragraph *para) DECLSPEC_HIDDEN
Definition: para.c:122
ME_Row * para_first_row(ME_Paragraph *para) DECLSPEC_HIDDEN
Definition: para.c:132
ME_Paragraph * cell_first_para(ME_Cell *cell) DECLSPEC_HIDDEN
Definition: table.c:202
ME_Cell * cell_next(ME_Cell *cell) DECLSPEC_HIDDEN
Definition: table.c:192
ME_Paragraph * table_row_end(ME_Paragraph *para) DECLSPEC_HIDDEN
Definition: table.c:127
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:1747
ULONG_PTR lbHatch
Definition: wingdi.h:1749
COLORREF lbColor
Definition: wingdi.h:1748
ME_Border bottom
Definition: editstr.h:189
ME_Border right
Definition: editstr.h:190
ME_Border left
Definition: editstr.h:188
ME_Border top
Definition: editstr.h:187
COLORREF colorRef
Definition: editstr.h:182
ME_BorderRect border
Definition: editstr.h:224
int yTextOffset
Definition: editstr.h:227
ME_BorderRect border
Definition: editstr.h:207
int nHeight
Definition: editstr.h:233
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 344 of file paint.c.

345{
346 COLORREF text_color = get_text_color( c, run->style, selected );
347 COLORREF back_color = get_back_color( c, run->style, selected );
348 COLORREF old_text, old_back = 0;
349 const WCHAR *text = get_text( run, 0 );
350 ME_String *masked = NULL;
351 const BOOL paint_bg = ( selected
352 || ( ( run->style->fmt.dwMask & CFM_BACKCOLOR )
353 && !(CFE_AUTOBACKCOLOR & run->style->fmt.dwEffects) )
354 );
355
356 if (c->editor->password_char)
357 {
358 masked = ME_MakeStringR( c->editor->password_char, run->len );
359 text = masked->szData;
360 }
361
362 old_text = SetTextColor( c->hDC, text_color );
363 if (paint_bg) old_back = SetBkColor( c->hDC, back_color );
364
365 if (run->para->nFlags & MEPF_COMPLEX)
366 ScriptTextOut( c->hDC, &run->style->script_cache, x, y, paint_bg ? ETO_OPAQUE : 0, sel_rect,
367 &run->script_analysis, NULL, 0, run->glyphs, run->num_glyphs, run->advances,
368 NULL, run->offsets );
369 else
370 ExtTextOutW( c->hDC, x, y, paint_bg ? ETO_OPAQUE : 0, sel_rect, text, run->len, NULL );
371
372 if (paint_bg) SetBkColor( c->hDC, old_back );
373 SetTextColor( c->hDC, old_text );
374
375 draw_underline( c, run, x, y, text_color );
376
377 ME_DestroyString( masked );
378 return;
379}
const WCHAR * text
Definition: package.c:1794
static COLORREF get_back_color(ME_Context *c, ME_Style *style, BOOL highlight)
Definition: paint.c:218
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:3595
void ME_DestroyString(ME_String *s) DECLSPEC_HIDDEN
Definition: string.c:96
ME_String * ME_MakeStringR(WCHAR cRepeat, int nMaxChars) DECLSPEC_HIDDEN
Definition: string.c:85
#define MEPF_COMPLEX
Definition: editstr.h:145
#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:170
GOFFSET * offsets
Definition: editstr.h:174
int * advances
Definition: editstr.h:173
WORD * glyphs
Definition: editstr.h:171
SCRIPT_ANALYSIS script_analysis
Definition: editstr.h:169
int len
Definition: editstr.h:162
WCHAR * szData
Definition: editstr.h:55
CHARFORMAT2W fmt
Definition: editstr.h:72
SCRIPT_CACHE script_cache
Definition: editstr.h:77

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 382 of file paint.c.

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

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

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->nTotalLength != editor->nLastTotalLength || editor->nTotalWidth != editor->nLastTotalWidth)
115 editor->nLastTotalLength = editor->nTotalLength;
116 editor->nLastTotalWidth = editor->nTotalWidth;
117}
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:279
static void draw_paragraph(ME_Context *c, ME_Paragraph *para)
Definition: paint.c:931
void ME_SendRequestResize(ME_TextEditor *editor, BOOL force) DECLSPEC_HIDDEN
Definition: wrap.c:1128
#define c
Definition: ke_i.h:80
static FILE * client
Definition: client.c:41
SCROLLINFO vert_si
Definition: editstr.h:440
int nLastTotalWidth
Definition: editstr.h:398
ITextHost2 * texthost
Definition: editstr.h:384
SCROLLINFO horz_si
Definition: editstr.h:440
int nLastTotalLength
Definition: editstr.h:397
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:921
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 1206 of file paint.c.

1207{
1208 ME_Run *run = cursor->run;
1210 ME_Paragraph *para = cursor->para;
1211 int x, y, yheight;
1212
1213
1214 if (editor->scrollbars & ES_AUTOHSCROLL)
1215 {
1216 x = run->pt.x + ME_PointFromChar( editor, run, cursor->nOffset, TRUE );
1217 if (x > editor->horz_si.nPos + editor->sizeWindow.cx)
1218 x = x + 1 - editor->sizeWindow.cx;
1219 else if (x > editor->horz_si.nPos)
1220 x = editor->horz_si.nPos;
1221
1222 if (~editor->scrollbars & ES_AUTOVSCROLL)
1223 {
1224 scroll_h_abs( editor, x, TRUE );
1225 return;
1226 }
1227 }
1228 else
1229 {
1230 if (~editor->scrollbars & ES_AUTOVSCROLL) return;
1231 x = editor->horz_si.nPos;
1232 }
1233
1234 y = para->pt.y + row->pt.y;
1235 yheight = row->nHeight;
1236
1237 if (y < editor->vert_si.nPos)
1238 scroll_abs( editor, x, y, TRUE );
1239 else if (y + yheight > editor->vert_si.nPos + editor->sizeWindow.cy)
1240 scroll_abs( editor, x, y + yheight - editor->sizeWindow.cy, TRUE );
1241 else if (x != editor->horz_si.nPos)
1242 scroll_abs( editor, x, editor->vert_si.nPos, TRUE );
1243}
void scroll_h_abs(ME_TextEditor *editor, int x, BOOL notify)
Definition: paint.c:1117
void scroll_abs(ME_TextEditor *editor, int x, int y, BOOL notify)
Definition: paint.c:1087
int ME_PointFromChar(ME_TextEditor *editor, ME_Run *pRun, int nOffset, BOOL visual_order) DECLSPEC_HIDDEN
Definition: run.c:649
#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:394

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

◆ 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:448
@ 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 1062 of file paint.c.

1063{
1064 if (enable || editor->scrollbars & ES_DISABLENOSCROLL)
1066 if (!(editor->scrollbars & ES_DISABLENOSCROLL))
1068}
#define ITextHost_TxShowScrollBar(This, a, b)
Definition: editor.h:335
#define ITextHost_TxEnableScrollBar(This, a, b)
Definition: editor.h:336
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 218 of file paint.c.

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

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 333 of file paint.c.

334{
335 from = max( 0, from );
336 to = min( run->len, to );
337 r->left = ME_PointFromCharContext( c, run, from, TRUE );
338 r->top = 0;
339 r->right = ME_PointFromCharContext( c, run, to, TRUE );
340 r->bottom = cy;
341 return;
342}
int ME_PointFromCharContext(ME_Context *c, ME_Run *pRun, int nOffset, BOOL visual_order) DECLSPEC_HIDDEN
Definition: run.c:608
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 202 of file paint.c.

203{
205
206 if (highlight)
207 color = ITextHost_TxGetSysColor( c->editor->texthost, COLOR_HIGHLIGHTTEXT );
208 else if ((style->fmt.dwMask & CFM_LINK) && (style->fmt.dwEffects & CFE_LINK))
209 color = RGB(0,0,255);
210 else if ((style->fmt.dwMask & CFM_COLOR) && (style->fmt.dwEffects & CFE_AUTOCOLOR))
211 color = ITextHost_TxGetSysColor( c->editor->texthost, COLOR_WINDOWTEXT );
212 else
213 color = style->fmt.crTextColor;
214
215 return color;
216}
#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:924
#define COLOR_HIGHLIGHTTEXT
Definition: winuser.h:930

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 233 of file paint.c.

234{
235 if (style->fmt.dwEffects & CFE_LINK)
236 return CreatePen( PS_SOLID, 1, color );
237
238 /* Choose the pen type for underlining the text. */
239 if (style->fmt.dwEffects & CFE_UNDERLINE)
240 {
241 switch (style->fmt.bUnderlineType)
242 {
243 case CFU_UNDERLINE:
244 case CFU_UNDERLINEWORD: /* native seems to map it to simple underline (MSDN) */
245 case CFU_UNDERLINEDOUBLE: /* native seems to map it to simple underline (MSDN) */
246 return CreatePen( PS_SOLID, 1, color );
248 return CreatePen( PS_DOT, 1, color );
249 default:
250 FIXME( "Unknown underline type (%u)\n", style->fmt.bUnderlineType );
251 /* fall through */
252 case CFU_CF1UNDERLINE: /* this type is supported in the font, do nothing */
254 break;
255 }
256 }
257 return NULL;
258}
#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 447 of file paint.c.

447 {
450 COLORREF color = SetTextColor(hDC, RGB(128,128,128));
451 TextOutW(hDC, pt->x, pt->y, szText, lstrlenW(szText));
455}
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 552 of file paint.c.

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

525{
526 int width = border_details[idx].width;
527
528 if (c->dpi.cx != 96)
529 width = MulDiv(width, c->dpi.cx, 96);
530
531 if (c->editor->nZoomNumerator != 0)
532 width = MulDiv(width, c->editor->nZoomNumerator, c->editor->nZoomDenominator);
533
534 return width;
535}
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 537 of file paint.c.

538{
539 int idx = (flags >> 8) & 0xF;
540 int width;
541
543 {
544 FIXME("Unsupported border value %d\n", idx);
545 return 0;
546 }
548 if (border_details[idx].dble) width = width * 2 + 1;
549 return width;
550}
#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 1247 of file paint.c.

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

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 119 of file paint.c.

120{
121 if (ME_WrapMarkedParagraphs(editor))
122 {
123 ME_UpdateScrollBar(editor);
124 FIXME("ME_Repaint had to call ME_WrapMarkedParagraphs\n");
125 }
127}
void ME_UpdateScrollBar(ME_TextEditor *editor)
Definition: paint.c:1147
#define ITextHost_TxViewChange(This, a)
Definition: editor.h:340

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

◆ ME_RewrapRepaint()

void ME_RewrapRepaint ( ME_TextEditor editor)

Definition at line 156 of file paint.c.

157{
158 /* RewrapRepaint should be called whenever the control has changed in
159 * looks, but not content. Like resizing. */
160
161 editor_mark_rewrap_all( editor );
163 ME_UpdateScrollBar(editor);
164 ME_Repaint(editor);
165}
void ME_Repaint(ME_TextEditor *editor)
Definition: paint.c:119
void editor_mark_rewrap_all(ME_TextEditor *editor) DECLSPEC_HIDDEN
Definition: para.c:237

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

◆ ME_ScrollDown()

void ME_ScrollDown ( ME_TextEditor editor,
int  cy 
)

Definition at line 1132 of file paint.c.

1133{
1134 scroll_v_abs( editor, editor->vert_si.nPos + cy, TRUE );
1135}
void scroll_v_abs(ME_TextEditor *editor, int y, BOOL notify)
Definition: paint.c:1122

Referenced by editor_handle_message(), and ME_ArrowPageDown().

◆ ME_ScrollLeft()

void ME_ScrollLeft ( ME_TextEditor editor,
int  cx 
)

Definition at line 1137 of file paint.c.

1138{
1139 scroll_h_abs( editor, editor->horz_si.nPos - cx, TRUE );
1140}
_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 1142 of file paint.c.

1143{
1144 scroll_h_abs( editor, editor->horz_si.nPos + cx, TRUE );
1145}

Referenced by editor_handle_message().

◆ ME_ScrollUp()

void ME_ScrollUp ( ME_TextEditor editor,
int  cy 
)

Definition at line 1127 of file paint.c.

1128{
1129 scroll_v_abs( editor, editor->vert_si.nPos - cy, TRUE );
1130}

Referenced by editor_handle_message(), and ME_ArrowPageUp().

◆ ME_SetZoom()

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

Definition at line 1304 of file paint.c.

1305{
1306 /* TODO: Zoom images and objects */
1307
1308 if (numerator == 0 && denominator == 0)
1309 {
1310 editor->nZoomNumerator = editor->nZoomDenominator = 0;
1311 return TRUE;
1312 }
1313 if (numerator <= 0 || denominator <= 0)
1314 return FALSE;
1315 if (numerator * 64 <= denominator || numerator / denominator >= 64)
1316 return FALSE;
1317
1318 editor->nZoomNumerator = numerator;
1319 editor->nZoomDenominator = denominator;
1320
1321 ME_RewrapRepaint(editor);
1322 return TRUE;
1323}
void ME_RewrapRepaint(ME_TextEditor *editor)
Definition: paint.c:156
int nZoomNumerator
Definition: editstr.h:413
int nZoomDenominator
Definition: editstr.h:413

Referenced by editor_handle_message().

◆ ME_twips2pointsX()

int ME_twips2pointsX ( const ME_Context c,
int  x 
)

Definition at line 167 of file paint.c.

168{
169 if (c->editor->nZoomNumerator == 0)
170 return x * c->dpi.cx / 1440;
171 else
172 return x * c->dpi.cx * c->editor->nZoomNumerator / 1440 / c->editor->nZoomDenominator;
173}

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 175 of file paint.c.

176{
177 if (c->editor->nZoomNumerator == 0)
178 return y * c->dpi.cy / 1440;
179 else
180 return y * c->dpi.cy * c->editor->nZoomNumerator / 1440 / c->editor->nZoomDenominator;
181}

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 129 of file paint.c.

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

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 1147 of file paint.c.

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

◆ scroll_abs()

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

Definition at line 1087 of file paint.c.

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

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 1117 of file paint.c.

1118{
1119 scroll_abs( editor, x, editor->vert_si.nPos, notify );
1120}

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 1122 of file paint.c.

1123{
1124 scroll_abs( editor, editor->horz_si.nPos, y, notify );
1125}

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 1070 of file paint.c.

1071{
1072 LONG max_pos = info->nMax, pos = info->nPos;
1073
1074 /* Scale the scrollbar info to 16-bit values. */
1075 if (max_pos > 0xffff)
1076 {
1077 pos = MulDiv( pos, 0xffff, max_pos );
1078 max_pos = 0xffff;
1079 }
1080 if (set_range) ITextHost_TxSetScrollRange( editor->texthost, bar, 0, max_pos, FALSE );
1082
1083 if (notify && editor->nEventMask & ENM_SCROLL)
1085}
#define ITextHost_TxSetScrollRange(This, a, b, c, d)
Definition: editor.h:337
#define ITextHost_TxSetScrollPos(This, a, b, c)
Definition: editor.h:338
long LONG
Definition: pedump.c:60
#define ENM_SCROLL
Definition: richedit.h:470
#define EN_HSCROLL
Definition: winuser.h:2027
#define EN_VSCROLL
Definition: winuser.h:2032

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 498 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 513 of file paint.c.

Referenced by ME_DrawParaDecoration().

◆ pen_style

unsigned pen_style

Definition at line 498 of file paint.c.

Referenced by ME_DrawParaDecoration().

◆ width