void Screen::showAll() { if(pvga->isReady==false) return; if( pvga->vgaDataID != this->lastVgaDataID) { this->lastVgaDataID = pvga->vgaDataID; HBRUSH hBrush; hBrush = (HBRUSH)GetStockObject(BLACK_BRUSH); SelectObject(bufferHDC, hBrush); Rectangle(bufferHDC,0,0, lf.lfWidth*pvga->charPerRow, lf.lfHeight*pvga->charPerCol); char* pcharacter = (char*)(pvga->textMemAddr + (pvga->currentPage*pvga->charPerRow*pvga->charPerCol)*2); for(int i=0; i< pvga->charPerCol; i++) { for(int j=0; j< pvga->charPerRow; j++) { char achar=pvga->getChar(j, i); U1 char_property = pvga->getPro(j,i); if(achar == 0) continue; wchar_t unicodeChar; int ilen= MultiByteToWideChar(437,0,&achar,1,&unicodeChar,1);// SetTextColor(this->bufferHDC, property2FontColor(pvga->getPro(j, i))); SetBkMode(this->bufferHDC, OPAQUE); SetBkColor(this->bufferHDC, property2BkColor(pvga->getPro(j, i))); TextOut(this->bufferHDC, j*lf.lfWidth, i*lf.lfHeight,(LPWSTR)&unicodeChar, 1); } } } ::BitBlt(hdc,0,0,this->clientWidth, this->clientHeight, bufferHDC, 0, 0,SRCCOPY); flashCursor();//闪烁光标 }
reg_t GfxControls32::kernelEditText(const reg_t controlObject) { SegManager *segMan = _segMan; TextEditor editor; reg_t textObject = readSelector(_segMan, controlObject, SELECTOR(text)); editor.text = _segMan->getString(textObject); editor.foreColor = readSelectorValue(_segMan, controlObject, SELECTOR(fore)); editor.backColor = readSelectorValue(_segMan, controlObject, SELECTOR(back)); editor.skipColor = readSelectorValue(_segMan, controlObject, SELECTOR(skip)); editor.fontId = readSelectorValue(_segMan, controlObject, SELECTOR(font)); editor.maxLength = readSelectorValue(_segMan, controlObject, SELECTOR(width)); editor.bitmap = readSelector(_segMan, controlObject, SELECTOR(bitmap)); editor.cursorCharPosition = 0; editor.cursorIsDrawn = false; editor.borderColor = readSelectorValue(_segMan, controlObject, SELECTOR(borderColor)); reg_t titleObject = readSelector(_segMan, controlObject, SELECTOR(title)); int16 titleHeight = 0; GuiResourceId titleFontId = readSelectorValue(_segMan, controlObject, SELECTOR(titleFont)); if (!titleObject.isNull()) { GfxFont *titleFont = _gfxCache->getFont(titleFontId); titleHeight += _gfxText32->scaleUpHeight(titleFont->getHeight()) + 1; if (editor.borderColor != -1) { titleHeight += 2; } } int16 width = 0; int16 height = titleHeight; GfxFont *editorFont = _gfxCache->getFont(editor.fontId); height += _gfxText32->scaleUpHeight(editorFont->getHeight()) + 1; _gfxText32->setFont(editor.fontId); int16 emSize = _gfxText32->getCharWidth('M', true); width += editor.maxLength * emSize + 1; if (editor.borderColor != -1) { width += 4; height += 2; } Common::Rect editorPlaneRect(width, height); editorPlaneRect.translate(readSelectorValue(_segMan, controlObject, SELECTOR(x)), readSelectorValue(_segMan, controlObject, SELECTOR(y))); reg_t planeObj = readSelector(_segMan, controlObject, SELECTOR(plane)); Plane *sourcePlane = g_sci->_gfxFrameout->getVisiblePlanes().findByObject(planeObj); if (sourcePlane == nullptr) { sourcePlane = g_sci->_gfxFrameout->getPlanes().findByObject(planeObj); if (sourcePlane == nullptr) { error("Could not find plane %04x:%04x", PRINT_REG(planeObj)); } } editorPlaneRect.translate(sourcePlane->_gameRect.left, sourcePlane->_gameRect.top); editor.textRect = Common::Rect(2, titleHeight + 2, width - 1, height - 1); editor.width = width; if (editor.bitmap.isNull()) { TextAlign alignment = (TextAlign)readSelectorValue(_segMan, controlObject, SELECTOR(mode)); if (titleObject.isNull()) { bool dimmed = readSelectorValue(_segMan, controlObject, SELECTOR(dimmed)); editor.bitmap = _gfxText32->createFontBitmap(width, height, editor.textRect, editor.text, editor.foreColor, editor.backColor, editor.skipColor, editor.fontId, alignment, editor.borderColor, dimmed, true, false); } else { error("Titled bitmaps are not known to be used by any game. Please submit a bug report with details about the game you were playing and what you were doing that triggered this error. Thanks!"); } } drawCursor(editor); Plane *plane = new Plane(editorPlaneRect, kPlanePicTransparent); plane->changePic(); g_sci->_gfxFrameout->addPlane(*plane); CelInfo32 celInfo; celInfo.type = kCelTypeMem; celInfo.bitmap = editor.bitmap; ScreenItem *screenItem = new ScreenItem(plane->_object, celInfo, Common::Point(), ScaleInfo()); plane->_screenItemList.add(screenItem); // frameOut must be called after the screen item is // created, and before it is updated at the end of the // event loop, otherwise it has both created and updated // flags set which crashes the engine (it runs updates // before creations) g_sci->_gfxFrameout->frameOut(true); EventManager *eventManager = g_sci->getEventManager(); bool clearTextOnInput = true; bool textChanged = false; for (;;) { // We peek here because the last event needs to be allowed to // dispatch a second time to the normal event handling system. // In the actual engine, the event is always consumed and then // the last event just gets posted back to the event manager for // reprocessing, but instead, we only remove the event from the // queue *after* we have determined it is not a defocusing event const SciEvent event = eventManager->getSciEvent(SCI_EVENT_ANY | SCI_EVENT_PEEK); bool focused = true; // Original engine did not have a QUIT event but we have to handle it if (event.type == SCI_EVENT_QUIT) { focused = false; break; } else if (event.type == SCI_EVENT_MOUSE_PRESS && !editorPlaneRect.contains(event.mousePosSci)) { focused = false; } else if (event.type == SCI_EVENT_KEYBOARD) { switch (event.character) { case SCI_KEY_ESC: case SCI_KEY_UP: case SCI_KEY_DOWN: case SCI_KEY_TAB: case SCI_KEY_SHIFT_TAB: case SCI_KEY_ENTER: focused = false; break; } } if (!focused) { break; } // Consume the event now that we know it is not one of the // defocusing events above if (event.type != SCI_EVENT_NONE) eventManager->getSciEvent(SCI_EVENT_ANY); // NOTE: In the original engine, the font and bitmap were // reset here on each iteration through the loop, but it // doesn't seem like this should be necessary since // control is not yielded back to the VM until input is // received, which means there is nothing that could modify // the GfxText32's state with a different font in the // meantime bool shouldDeleteChar = false; bool shouldRedrawText = false; uint16 lastCursorPosition = editor.cursorCharPosition; if (event.type == SCI_EVENT_KEYBOARD) { switch (event.character) { case SCI_KEY_LEFT: clearTextOnInput = false; if (editor.cursorCharPosition > 0) { --editor.cursorCharPosition; } break; case SCI_KEY_RIGHT: clearTextOnInput = false; if (editor.cursorCharPosition < editor.text.size()) { ++editor.cursorCharPosition; } break; case SCI_KEY_HOME: clearTextOnInput = false; editor.cursorCharPosition = 0; break; case SCI_KEY_END: clearTextOnInput = false; editor.cursorCharPosition = editor.text.size(); break; case SCI_KEY_INSERT: clearTextOnInput = false; // Redrawing also changes the cursor rect to // reflect the new insertion mode shouldRedrawText = true; _overwriteMode = !_overwriteMode; break; case SCI_KEY_DELETE: clearTextOnInput = false; if (editor.cursorCharPosition < editor.text.size()) { shouldDeleteChar = true; } break; case SCI_KEY_BACKSPACE: clearTextOnInput = false; shouldDeleteChar = true; if (editor.cursorCharPosition > 0) { --editor.cursorCharPosition; } break; case SCI_KEY_ETX: editor.text.clear(); editor.cursorCharPosition = 0; shouldRedrawText = true; break; default: { if (event.character >= 20 && event.character < 257) { if (clearTextOnInput) { clearTextOnInput = false; editor.text.clear(); } if ( (_overwriteMode && editor.cursorCharPosition < editor.maxLength) || (editor.text.size() < editor.maxLength && _gfxText32->getCharWidth(event.character, true) + _gfxText32->getStringWidth(editor.text) < editor.textRect.width()) ) { if (_overwriteMode && editor.cursorCharPosition < editor.text.size()) { editor.text.setChar(event.character, editor.cursorCharPosition); } else { editor.text.insertChar(event.character, editor.cursorCharPosition); } ++editor.cursorCharPosition; shouldRedrawText = true; } } } } } if (shouldDeleteChar) { shouldRedrawText = true; if (editor.cursorCharPosition < editor.text.size()) { editor.text.deleteChar(editor.cursorCharPosition); } } if (shouldRedrawText) { eraseCursor(editor); _gfxText32->erase(editor.textRect, true); _gfxText32->drawTextBox(editor.text); drawCursor(editor); textChanged = true; screenItem->_updated = g_sci->_gfxFrameout->getScreenCount(); } else if (editor.cursorCharPosition != lastCursorPosition) { eraseCursor(editor); drawCursor(editor); screenItem->_updated = g_sci->_gfxFrameout->getScreenCount(); } else { flashCursor(editor); screenItem->_updated = g_sci->_gfxFrameout->getScreenCount(); } g_sci->_gfxFrameout->frameOut(true); g_sci->getSciDebugger()->onFrame(); g_sci->_gfxFrameout->throttle(); } g_sci->_gfxFrameout->deletePlane(*plane); if (readSelectorValue(segMan, controlObject, SELECTOR(frameOut))) { g_sci->_gfxFrameout->frameOut(true); } _segMan->freeBitmap(editor.bitmap); if (textChanged) { editor.text.trim(); SciArray &string = *_segMan->lookupArray(textObject); string.fromString(editor.text); } return make_reg(0, textChanged); }
DisplayContext *manageTrace(edview *xx, char *format, char *rawDataFile, int baseNum, int leftCutOff, int cutLength, int complemented, int baseSpacing, char *traceTitle, int allow_dup, int small_seq ) { char *traceName; DisplayContext *dc; int exists; Tcl_Interp *interp = EDINTERP(xx->ed); char buf[1024]; char *pname; Tcl_CmdInfo info; char *edpath; char seqbuf[1024]; if ((traceName=(char *)strrchr(rawDataFile,'/'))==NULL) traceName = rawDataFile; else traceName++; dc = getTDisplay(xx, traceName, allow_dup, small_seq, &exists); if (exists) { repositionSeq(xx, dc, baseNum); flashCursor(xx, dc); return dc; } pname = get_default_string(interp, gap5_defs, "TRACE_DISPLAY.WIN"); /* * If we're the bottom half of a join editor, combine traces with the * top half. */ if (inJoinMode(xx) && xx->link && xx == xx->link->xx[1] && !small_seq) { edpath = Tk_PathName(EDTKWIN(xx->link->xx[0]->ed)); } else { edpath = Tk_PathName(EDTKWIN(xx->ed)); } if (small_seq) { /* Mini-traces embedded in the editor */ //sprintf(seqbuf, "%d %d", small_seq, xx->lines_per_seq-1); sprintf(seqbuf, "%d %d", small_seq, 3); if (TCL_OK != Tcl_VarEval(interp, "trace_small_add ", edpath, pname, " {", rawDataFile, "} {", edpath, "} ", seqbuf, NULL)) { freeTDisplay(traceName); puts(Tcl_GetStringResult(interp)); return NULL; } } else { /* The full-blown trace display. */ if (TCL_OK != Tcl_VarEval(interp, "trace_add ", edpath, pname, " {", rawDataFile, "} {", edpath, "} {", traceTitle, "}", NULL)) { freeTDisplay(traceName); return NULL; } } strcpy(dc->path, Tcl_GetStringResult(interp)); /* Get Trace widget pointer */ if (-1 == Tcl_GetCommandInfo(interp, Tcl_GetStringResult(interp), &info)) { freeTDisplay(traceName); return NULL; } dc->tracePtr = (DNATrace *)info.clientData; /* Set orientation and cutoffs */ if (complemented) Tcl_VarEval(interp, dc->path, " complement", NULL); dc->complemented = complemented; sprintf(buf, "%s left_cutoff %d", dc->path, leftCutOff); Tcl_Eval(interp, buf); sprintf(buf, "%s right_cutoff %d", dc->path, leftCutOff + cutLength); Tcl_Eval(interp, buf); /* Tcl_VarEval(interp, "update idletasks", NULL); */ /* Adjust position */ repositionSeq(xx, dc, baseNum); return dc; }