static void clickColor(control c, int argument) { int element = cmatch(gettext(guielement), GuiElementNames); dialogColors[element] = nametorgb(ColorName[argument]); setforeground(guisample, dialogColors[whichfg[element]]); setbackground(guisample, dialogColors[whichbg[element]]); }
// MW-2011-09-06: [[ Redraw ]] Added 'sprite' option - if true, ink and opacity are not set. void MCPlayer::draw(MCDC *dc, const MCRectangle& p_dirty, bool p_isolated, bool p_sprite) { MCRectangle dirty; dirty = p_dirty; if (!p_isolated) { // MW-2011-09-06: [[ Redraw ]] If rendering as a sprite, don't change opacity or ink. if (!p_sprite) { dc -> setopacity(blendlevel * 255 / 100); dc -> setfunction(ink); } // MW-2009-06-11: [[ Bitmap Effects ]] if (m_bitmap_effects == NULL) dc -> begin(false); else { if (!dc -> begin_with_effects(m_bitmap_effects, rect)) return; dirty = dc -> getclip(); } } if (MClook == LF_MOTIF && state & CS_KFOCUSED && !(extraflags & EF_NO_FOCUS_BORDER)) drawfocus(dc, p_dirty); setforeground(dc, DI_BACK, False); dc->setbackground(MCscreen->getwhite()); dc->setfillstyle(FillOpaqueStippled, nil, 0, 0); dc->fillrect(rect); dc->setbackground(MCzerocolor); dc->setfillstyle(FillSolid, nil, 0, 0); if (getflag(F_SHOW_BORDER)) { if (getflag(F_3D)) draw3d(dc, rect, ETCH_SUNKEN, borderwidth); else drawborder(dc, rect, borderwidth); } if (!p_isolated) { dc -> end(); } }
static editor neweditor(void) { int x, y, w, h, w0, h0; editor c; menuitem m; textbox t; long flags; font editorfn = (consolefn ? consolefn : FixedFont); EditorData p = neweditordata(0, NULL); DWORD rand; w = (pagercol + 1)*fontwidth(editorfn); h = (pagerrow + 1)*fontheight(editorfn) + 1; #ifdef USE_MDI if(ismdi()) { RECT *pR = RgetMDIsize(); w0 = pR->right; h0 = pR->bottom; } else { #endif w0 = devicewidth(NULL); h0 = deviceheight(NULL); #ifdef USE_MDI } #endif x = (w0 - w) / 2; x = x > 20 ? x : 20; y = (h0 - h) / 2; y = y > 20 ? y : 20; rand = GetTickCount(); w0 = 0.4*x; h0 = 0.4*y; w0 = w0 > 20 ? w0 : 20; h0 = h0 > 20 ? h0 : 20; x += (rand % w0) - w0/2; y += ((rand/w0) % h0) - h0/2; flags = StandardWindow | Menubar; #ifdef USE_MDI if (ismdi()) flags |= Document; #endif c = (editor) newwindow("", rect(x, y, w, h), flags); t = newrichtextarea(NULL, rect(0, 0, w, h)); setdata(c, t); setdata(t, p); gsetcursor(c, ArrowCursor); setforeground(c, guiColors[editorfg]); setbackground(c, guiColors[editorbg]); setbackground(t, guiColors[editorbg]); #ifdef USE_MDI if (ismdi() && (RguiMDI & RW_TOOLBAR)) { int btsize = 24; rect r = rect(2, 2, btsize, btsize); control tb, bt; addto(c); MCHECK(tb = newtoolbar(btsize + 4)); addto(tb); MCHECK(bt = newtoolbutton(open_image, r, menueditoropen)); MCHECK(addtooltip(bt, G_("Open script"))); setdata(bt, c); r.x += (btsize + 1) ; MCHECK(bt = newtoolbutton(save_image, r, menueditorsave)); MCHECK(addtooltip(bt, G_("Save script"))); setdata(bt, c); r.x += (btsize + 6); MCHECK(bt = newtoolbutton(copy1_image, r, menueditorrun)); MCHECK(addtooltip(bt, G_("Run line or selection"))); setdata(bt, t); r.x += (btsize + 6); MCHECK(bt = newtoolbutton(console_image, r, editorconsole)); MCHECK(addtooltip(bt, G_("Return focus to Console"))); r.x += (btsize + 6); MCHECK(bt = newtoolbutton(print_image, r, editorprint)); MCHECK(addtooltip(bt, G_("Print script"))); setdata(bt, t); MCHECK(addtooltip(bt, G_("Print"))); } #endif addto(c); /* Right-click context menu */ MCHECK(m = gpopup(editormenuact, EditorPopup)); setdata(m, t); setdata(EditorPopup[0].m, t); setdata(EditorPopup[2].m, t); setdata(p->mpopcut = EditorPopup[4].m, t); setdata(p->mpopcopy = EditorPopup[5].m, t); setdata(EditorPopup[6].m, t); setdata(p->mpopdelete = EditorPopup[7].m, t); setdata(EditorPopup[9].m, t); addto(c); MCHECK(m = newmenubar(editormenuact)); setdata(m, t); MCHECK(newmenu(G_("File"))); MCHECK(m = newmenuitem(G_("New script"), 'N', menueditornew)); setdata(m, c); MCHECK(m = newmenuitem(G_("Open script..."), 'O', menueditoropen)); setdata(m, c); MCHECK(m = newmenuitem(G_("Save"), 'S', menueditorsave)); setdata(m, c); MCHECK(m = newmenuitem(G_("Save as..."), 0, menueditorsaveas)); setdata(m, c); MCHECK(m = newmenuitem("-", 0, NULL)); MCHECK(m = newmenuitem(G_("Print..."), 0, editorprint)); setdata(m, t); MCHECK(m = newmenuitem("-", 0, NULL)); MCHECK(m = newmenuitem(G_("Close script"), 0, menueditorclose)); setdata(m, c); MCHECK(newmenu(G_("Edit"))); MCHECK(m = newmenuitem(G_("Undo"), 'Z', editorundo)); setdata(m, t); MCHECK(m = newmenuitem("-", 0, NULL)); MCHECK(p->mcut = newmenuitem(G_("Cut"), 'X', editorcut)); setdata(p->mcut, t); MCHECK(p->mcopy = newmenuitem(G_("Copy"), 'C', editorcopy)); setdata(p->mcopy, t); MCHECK(m = newmenuitem(G_("Paste"), 'V', editorpaste)); setdata(m, t); MCHECK(p->mdelete = newmenuitem(G_("Delete"), 0, editordelete)); setdata(p->mdelete, t); MCHECK(m = newmenuitem(G_("Select all"), 'A', editorselectall)); setdata(m, t); MCHECK(newmenuitem(G_("Clear console"), 'L', menuclear)); MCHECK(m = newmenuitem("-", 0, NULL)); MCHECK(m = newmenuitem(G_("Run line or selection"), 'R', menueditorrun)); setdata(m, t); MCHECK(m = newmenuitem(G_("Run all"), 0, editorrunall)); setdata(m, t); MCHECK(m = newmenuitem("-", 0, NULL)); MCHECK(p->mfind = newmenuitem(G_("Find..."), 'F', editorfind)); setdata(p->mfind, t); MCHECK(p->mreplace = newmenuitem(G_("Replace..."), 'H', editorreplace)); setdata(p->mreplace, t); MCHECK(m = newmenuitem("-", 0, NULL)); MCHECK(newmenuitem(G_("GUI preferences..."), 0, menuconfig)); /* Packages menu should go here */ p->pmenu = (PkgMenuItems) malloc(sizeof(struct structPkgMenuItems)); RguiPackageMenu(p->pmenu); #ifdef USE_MDI newmdimenu(); /* Create and fill the 'Window' menu */ #endif MCHECK(m = newmenu(G_("Help"))); MCHECK(newmenuitem(G_("Editor"), 0, menueditorhelp)); MCHECK(newmenuitem("-", 0, NULL)); p->hmenu = (HelpMenuItems) malloc(sizeof(struct structHelpMenuItems)); RguiCommonHelp(m, p->hmenu); settextfont(t, editorfn); setforeground(t, guiColors[editorfg]); setresize(c, editorresize); setclose(c, editorclose); setdel(c, editordel); setdel(t, textboxdel); setonfocus(c, editorfocus); setkeyaction(t, editorcontrolkeydown); setkeydown(t, editorasciikeydown); /* Store pointer to new editor in global array */ REditors[neditors] = c; ++neditors; return c; }
// MW-2011-09-06: [[ Redraw ]] Added 'sprite' option - if true, ink and opacity are not set. void MCEPS::draw(MCDC *dc, const MCRectangle &dirty, bool p_isolated, bool p_sprite) { MCRectangle trect = rect; if (flags & F_SHOW_BORDER) trect = MCU_reduce_rect(trect, borderwidth); if (flags & F_OPAQUE) { setforeground(dc, DI_BACK, False); dc->fillrect(trect); } if (state & (CS_SIZE | CS_MOVE)) { dc->setlineatts(0, LineDoubleDash, CapButt, JoinBevel); dc->setforeground(dc->getblack()); dc->setbackground(dc->getwhite()); dc->setfillstyle(FillSolid, nil, 0, 0); dc->setdashes(0, dashlist, 2); MCLineSegment segs[2]; segs[0].x1 = segs[1].x1 = trect.x; segs[0].x2 = segs[1].x2 = trect.x + trect.width; segs[0].y1 = segs[1].y2 = trect.y; segs[0].y2 = segs[1].y1 = trect.y + trect.height; dc->drawsegments(segs, 2); dc->setlineatts(0, LineSolid, CapButt, JoinBevel); dc->setbackground(MCzerocolor); } #ifdef HAVE_EPS else { const char *psprolog = postscript; uint4 psprologlength = 0; const char *ps; uint4 length; if ((pagecount == 0) || (pagecount == 1)) { ps = postscript; length = strlen(postscript); } else { psprologlength = pageIndex[0]; ps = &postscript[pageIndex[curpage - 1] - 1]; if (curpage != pagecount) length = pageIndex[curpage] - pageIndex[curpage - 1]; else length = size - pageIndex[curpage - 1]; } setforeground(dc, DI_FORE, False); const char *fontname; uint2 fheight, fontsize, fontstyle; MCFontStruct *font; getfontatts(fontname, fheight, fontsize, fontstyle, font); dc->draweps(trect.x * xf, -(trect.y * yf), angle, xscale, yscale, tx, ty, prolog, psprolog, psprologlength, ps, length, fontname, fontsize, fontstyle, font, trect); } #endif if (flags & F_SHOW_BORDER) trect = MCU_reduce_rect(trect, -borderwidth); if (flags & F_SHOW_BORDER) if (flags & F_3D) draw3d(dc, trect, ETCH_SUNKEN, borderwidth); else drawborder(dc, trect, borderwidth); if (getstate(CS_KFOCUSED)) drawfocus(dc, dirty); if (state & CS_SELECTED) drawselected(dc); }