Exemplo n.º 1
0
 void printSinglePage(SkCanvas& canvas)
 {
     IntRect pageRect(0, 0, kPageWidth, kPageHeight);
     GraphicsContext context(&canvas, nullptr);
     printContext().begin(kPageWidth, kPageHeight);
     printContext().outputLinkAndLinkedDestinations(context, &document(), pageRect);
     printContext().end();
 }
 void printSinglePage(SkCanvas& canvas)
 {
     IntRect pageRect(0, 0, kPageWidth, kPageHeight);
     printContext().begin(pageRect.width(), pageRect.height());
     document().view()->updateAllLifecyclePhases();
     SkPictureBuilder pictureBuilder(pageRect);
     GraphicsContext& context = pictureBuilder.context();
     context.setPrinting(true);
     document().view()->paintContents(&context, GlobalPaintPrinting, pageRect);
     pictureBuilder.endRecording()->playback(&canvas);
     printContext().outputLinkedDestinations(&canvas, pageRect);
     printContext().end();
 }
Exemplo n.º 3
0
int main(int argc, char **argv)
{
    /* Mainly only for safety */
    setupSignal();
    
    /* Initialize decoder's */
    DecoderSet(dInstr);
    
    banner(argc,argv);
    
    if( (u2AnonContext = parseCommandLine(argc,argv)) == NULL)
    {
	/* XXX */
	CleanExit(1);
    }
    
    if(u2AnonContext->verbose_flag)
    {
	printContext(u2AnonContext);
    }

    if( fileOperation(u2AnonContext))
    {
	/* XXX */
	CleanExit(1);
    }
    
    
    CleanExit(0); 
    /* Exit here but remove the compile warn ...*/
    return 0;
}
Exemplo n.º 4
0
int PrintContext::pageNumberForElement(Element* element,
                                       const FloatSize& pageSizeInPixels) {
  element->document().updateStyleAndLayout();

  LocalFrame* frame = element->document().frame();
  FloatRect pageRect(FloatPoint(0, 0), pageSizeInPixels);
  PrintContext printContext(frame);
  printContext.begin(pageRect.width(), pageRect.height());

  LayoutBoxModelObject* box = enclosingBoxModelObject(element->layoutObject());
  if (!box)
    return -1;

  FloatSize scaledPageSize = pageSizeInPixels;
  scaledPageSize.scale(frame->view()->contentsSize().width() /
                       pageRect.width());
  printContext.computePageRectsWithPageSize(scaledPageSize);

  int top = box->pixelSnappedOffsetTop(box->offsetParent());
  int left = box->pixelSnappedOffsetLeft(box->offsetParent());
  size_t pageNumber = 0;
  for (; pageNumber < printContext.pageCount(); pageNumber++) {
    const IntRect& page = printContext.pageRect(pageNumber);
    if (page.x() <= left && left < page.maxX() && page.y() <= top &&
        top < page.maxY())
      return pageNumber;
  }
  return -1;
}
Exemplo n.º 5
0
int PrintContext::pageNumberForElement(Element* element, const FloatSize& pageSizeInPixels)
{
    // Make sure the element is not freed during the layout.
    RefPtrWillBeRawPtr<Element> protect(element);
    element->document().updateLayout();

    RenderBoxModelObject* box = enclosingBoxModelObject(element->renderer());
    if (!box)
        return -1;

    LocalFrame* frame = element->document().frame();
    FloatRect pageRect(FloatPoint(0, 0), pageSizeInPixels);
    PrintContext printContext(frame);
    printContext.begin(pageRect.width(), pageRect.height());
    FloatSize scaledPageSize = pageSizeInPixels;
    scaledPageSize.scale(frame->view()->contentsSize().width() / pageRect.width());
    printContext.computePageRectsWithPageSize(scaledPageSize, false);

    int top = box->pixelSnappedOffsetTop();
    int left = box->pixelSnappedOffsetLeft();
    size_t pageNumber = 0;
    for (; pageNumber < printContext.pageCount(); pageNumber++) {
        const IntRect& page = printContext.pageRect(pageNumber);
        if (page.x() <= left && left < page.maxX() && page.y() <= top && top < page.maxY())
            return pageNumber;
    }
    return -1;
}
Exemplo n.º 6
0
String PrintContext::pageProperty(LocalFrame* frame, const char* propertyName, int pageNumber)
{
    Document* document = frame->document();
    PrintContext printContext(frame);
    printContext.begin(800); // Any width is OK here.
    document->updateLayout();
    RefPtr<RenderStyle> style = document->styleForPage(pageNumber);

    // Implement formatters for properties we care about.
    if (!strcmp(propertyName, "margin-left")) {
        if (style->marginLeft().isAuto())
            return String("auto");
        return String::number(style->marginLeft().value());
    }
    if (!strcmp(propertyName, "line-height"))
        return String::number(style->lineHeight().value());
    if (!strcmp(propertyName, "font-size"))
        return String::number(style->fontDescription().computedPixelSize());
    if (!strcmp(propertyName, "font-family"))
        return style->fontDescription().family().family().string();
    if (!strcmp(propertyName, "size"))
        return String::number(style->pageSize().width().value()) + ' ' + String::number(style->pageSize().height().value());

    return String("pageProperty() unimplemented for: ") + propertyName;
}
Exemplo n.º 7
0
String PrintContext::pageProperty(LocalFrame* frame,
                                  const char* propertyName,
                                  int pageNumber) {
  Document* document = frame->document();
  PrintContext printContext(frame);
  // Any non-zero size is OK here. We don't care about actual layout. We just
  // want to collect @page rules and figure out what declarations apply on a
  // given page (that may or may not exist).
  printContext.begin(800, 1000);
  RefPtr<ComputedStyle> style = document->styleForPage(pageNumber);

  // Implement formatters for properties we care about.
  if (!strcmp(propertyName, "margin-left")) {
    if (style->marginLeft().isAuto())
      return String("auto");
    return String::number(style->marginLeft().value());
  }
  if (!strcmp(propertyName, "line-height"))
    return String::number(style->lineHeight().value());
  if (!strcmp(propertyName, "font-size"))
    return String::number(style->getFontDescription().computedPixelSize());
  if (!strcmp(propertyName, "font-family"))
    return style->getFontDescription().family().family().getString();
  if (!strcmp(propertyName, "size"))
    return String::number(style->pageSize().width()) + ' ' +
           String::number(style->pageSize().height());

  return String("pageProperty() unimplemented for: ") + propertyName;
}
Exemplo n.º 8
0
void GLWindow::initializeGL()
{
    initializeOpenGLFunctions();
    printContext();
    glClearColor(0.0f,0.9f,1.0f,10.f);
    shader.compile("../Renderer/shader.vert","../Renderer/shader.frag");
    connect(this,SIGNAL(frameSwapped()),this,SLOT(update()));
}
Exemplo n.º 9
0
int PrintContext::numberOfPages(Frame& frame, const FloatSize& pageSizeInPixels)
{
    PrintContext printContext(&frame);
    if (!printContext.beginAndComputePageRectsWithPageSize(frame, pageSizeInPixels))
        return -1;

    return printContext.pageCount();
}
Exemplo n.º 10
0
void computePageRectsForFrame(Frame* frame, const IntRect& printRect, float headerHeight, float footerHeight, float userScaleFactor, Vector<IntRect>& outPages, int& outPageHeight)
{
    PrintContext printContext(frame);
    float pageHeight = 0;
    printContext.computePageRects(printRect, headerHeight, footerHeight, userScaleFactor, pageHeight);
    outPageHeight = static_cast<int>(pageHeight);
    outPages = printContext.pageRects();
}
Exemplo n.º 11
0
int main(int argc, char **args) {

    if (argc < 3) {
        printf("  barrier <threadcount> <repetitions>\n");
        exit(0);
    }

    int threadCount = atoi(args[1]);
    int repetitionCount = atoll(args[2]);

    assert(threadCount > 0);
    assert(repetitionCount > 0);

    Context *context = newContext(threadCount, repetitionCount);
    pthread_t t[threadCount];
    ThreadInfo infos[threadCount];

    printContext(context);
    printf("\n");

    /* start all threads */
    for (int i = 0; i < threadCount; ++i) {
        infos[i].index = i;
        infos[i].c = context;
        if(pthread_create( &t[i], NULL, Thread, (void *)&(infos[i]))){
            perror("pthread_create");
            exit(-1);
        }
    }

    /* join all threads */
    for (int i = 0; i < threadCount; ++i){
        if(pthread_join(t[i], NULL)){
            perror("pthread_join");
            exit(-1);
        }
    }

    printContext(context);

    finishContext(context);

    return 0;
}
Exemplo n.º 12
0
void LogoRenderer::initialize()
{
    initializeOpenGLFunctions();
    printContext();

    /* Build and compile our shader program */
    // Vertex shader
    GLuint vertexShader = glCreateShader(GL_VERTEX_SHADER);
    glShaderSource(vertexShader, 1, &vertexShaderSource, NULL);
    glCompileShader(vertexShader);
    // Check for compile time errors
    GLint success;
    GLchar infoLog[512];
    glGetShaderiv(vertexShader, GL_COMPILE_STATUS, &success);
    if (!success)
    {
        glGetShaderInfoLog(vertexShader, 512, NULL, infoLog);
        qDebug() << "ERROR:SHADER::VERTEX::COMPILATION_FAILED\n" << infoLog;
    }

    // Fragment shader
    GLint fragmentShader = glCreateShader(GL_FRAGMENT_SHADER);
    glShaderSource(fragmentShader, 1, &fragmentShaderSource, NULL);
    glCompileShader(fragmentShader);
    // Check for compile time error
    glGetShaderiv(fragmentShader, GL_COMPILE_STATUS, &success);
    if (!success)
    {
        glGetShaderInfoLog(fragmentShader, 512, NULL, infoLog);
        qDebug() << "ERROR::SHADER::FRAGMENT::COMPILATION_FAILED\n" << infoLog;
    }
    // Link shaders
    shaderProgram = glCreateProgram();
    glAttachShader(shaderProgram, vertexShader);
    glAttachShader(shaderProgram, fragmentShader);
    glLinkProgram(shaderProgram);
    // Check for linking errors
    glGetProgramiv(shaderProgram, GL_LINK_STATUS, &success);
    if (!success)
    {
        glGetProgramInfoLog(shaderProgram, 512, NULL, infoLog);
        qDebug() << "ERROR::SHADER::PROGRAM::LINKING_FAILED\n" << infoLog;
    }
    glDeleteShader(vertexShader);
    glDeleteShader(fragmentShader);

    vao_vbo_glDrawArrays_Init();
    //    vao_vbo_ebo_glDrawElements_Init();

    m_fAngle = 0;
    m_fScale = 1;
    m_fps = 0.0f;
}
Exemplo n.º 13
0
int PrintContext::numberOfPages(LocalFrame* frame, const FloatSize& pageSizeInPixels)
{
    frame->document()->updateLayout();

    FloatRect pageRect(FloatPoint(0, 0), pageSizeInPixels);
    PrintContext printContext(frame);
    printContext.begin(pageRect.width(), pageRect.height());
    // Account for shrink-to-fit.
    FloatSize scaledPageSize = pageSizeInPixels;
    scaledPageSize.scale(frame->view()->contentsSize().width() / pageRect.width());
    printContext.computePageRectsWithPageSize(scaledPageSize, false);
    return printContext.pageCount();
}
Exemplo n.º 14
0
/* members and contexts for the new class                       */
static local VOID SetClass(HWND hDlg, Class currClass)
{
  INT   i;
  List  instances, members;

  /* Update list of instances */
  SendDlgItemMessage(hDlg, LB_INSTANCES ,LB_RESETCONTENT, 0, 0L);

  /* Clear the redraw flag */
  SendDlgItemMessage(hDlg, LB_INSTANCES ,WM_SETREDRAW, FALSE, 0L);

  for(instances=cclass(currClass).instances; !isNull(instances); instances=tl(instances)) {
    if(!isNull(instances)) {
     SendDlgItemMessage(hDlg, LB_INSTANCES ,LB_ADDSTRING, 0, (LONG)(LPSTR) hd(instances));
    }
    SendDlgItemMessage(hDlg, LB_INSTANCES, LB_SETCURSEL, 0, 0L);
  }

 /* Set the redraw flag and force repaint. */
 SendDlgItemMessage(hDlg, LB_INSTANCES ,WM_SETREDRAW, TRUE, 0L);
 InvalidateRect(GetDlgItem(hDlg, LB_INSTANCES), NULL, TRUE);


  /* Update list of members */

  /* Clear the redraw flag */
  SendDlgItemMessage(hDlg, LB_MEMBERS ,WM_SETREDRAW, FALSE, 0L);

  SendDlgItemMessage(hDlg, LB_MEMBERS ,LB_RESETCONTENT, 0, 0L);
  if (cclass(currClass).numMembers > 0) {
    for(members=cclass(currClass).members, i=0 ;i < cclass(currClass).numMembers; members=tl(members), i++) {
     SendDlgItemMessage(hDlg, LB_MEMBERS ,LB_ADDSTRING, 0, (LONG)(LPSTR) hd(members));
    }
    SendDlgItemMessage(hDlg, LB_MEMBERS, LB_SETCURSEL, 0, 0L);
  }

 /* Set the redraw flag and force repaint. */
 SendDlgItemMessage(hDlg, LB_MEMBERS ,WM_SETREDRAW, TRUE, 0L);
 InvalidateRect(GetDlgItem(hDlg, LB_MEMBERS), NULL, TRUE);


  /* Update context */
  SendDlgItemMessage(hDlg, LB_CONTEXT ,LB_RESETCONTENT, 0, 0L);
  if(nonNull(cclass(currClass).supers)) {
    printContext(stdstr, cclass(currClass).supers);
    fprintf     (stdstr,"\n");
    SendDlgItemMessage(hDlg, LB_CONTEXT ,LB_ADDSTRING, 0, (LONG)(LPSTR) stdstrbuff);
  }
}
Exemplo n.º 15
0
void PrintContext::spoolAllPagesWithBoundaries(Frame* frame, GraphicsContext& graphicsContext, const FloatSize& pageSizeInPixels)
{
    if (!frame->document() || !frame->view() || !frame->document()->renderer())
        return;

    frame->document()->updateLayout();

    PrintContext printContext(frame);
    printContext.begin(pageSizeInPixels.width(), pageSizeInPixels.height());

    float pageHeight;
    printContext.computePageRects(FloatRect(FloatPoint(0, 0), pageSizeInPixels), 0, 0, 1, pageHeight);

    const float pageWidth = pageSizeInPixels.width();
    const Vector<IntRect>& pageRects = printContext.pageRects();
    int totalHeight = pageRects.size() * (pageSizeInPixels.height() + 1) - 1;

    // Fill the whole background by white.
    graphicsContext.setFillColor(Color(255, 255, 255));
    graphicsContext.fillRect(FloatRect(0, 0, pageWidth, totalHeight));

    graphicsContext.save();
    graphicsContext.translate(0, totalHeight);
    graphicsContext.scale(FloatSize(1, -1));

    int currentHeight = 0;
    for (size_t pageIndex = 0; pageIndex < pageRects.size(); pageIndex++) {
        // Draw a line for a page boundary if this isn't the first page.
        if (pageIndex > 0) {
            graphicsContext.save();
            graphicsContext.setStrokeColor(Color(0, 0, 255));
            graphicsContext.setFillColor(Color(0, 0, 255));
            graphicsContext.drawLine(IntPoint(0, currentHeight),
                                     IntPoint(pageWidth, currentHeight));
            graphicsContext.restore();
        }

        graphicsContext.save();
        graphicsContext.translate(0, currentHeight);
        printContext.spoolPage(graphicsContext, pageIndex, pageWidth);
        graphicsContext.restore();

        currentHeight += pageSizeInPixels.height() + 1;
    }

    graphicsContext.restore();
}
Exemplo n.º 16
0
void PrintContext::spoolAllPagesWithBoundaries(Frame& frame, GraphicsContext& graphicsContext, const FloatSize& pageSizeInPixels)
{
    PrintContext printContext(&frame);
    if (!printContext.beginAndComputePageRectsWithPageSize(frame, pageSizeInPixels))
        return;

    const float pageWidth = pageSizeInPixels.width();
    const Vector<IntRect>& pageRects = printContext.pageRects();
    int totalHeight = pageRects.size() * (pageSizeInPixels.height() + 1) - 1;

    // Fill the whole background by white.
    graphicsContext.setFillColor(Color(255, 255, 255));
    graphicsContext.fillRect(FloatRect(0, 0, pageWidth, totalHeight));

    graphicsContext.save();

    int currentHeight = 0;
    for (size_t pageIndex = 0; pageIndex < pageRects.size(); pageIndex++) {
        // Draw a line for a page boundary if this isn't the first page.
        if (pageIndex > 0) {
#if PLATFORM(COCOA)
            int boundaryLineY = currentHeight;
#else
            int boundaryLineY = currentHeight - 1;
#endif
            graphicsContext.save();
            graphicsContext.setStrokeColor(Color(0, 0, 255));
            graphicsContext.setFillColor(Color(0, 0, 255));
            graphicsContext.drawLine(IntPoint(0, boundaryLineY), IntPoint(pageWidth, boundaryLineY));
            graphicsContext.restore();
        }

        graphicsContext.save();
        graphicsContext.translate(0, currentHeight);
        printContext.spoolPage(graphicsContext, pageIndex, pageWidth);
        graphicsContext.restore();

        currentHeight += pageSizeInPixels.height() + 1;
    }

    graphicsContext.restore();
}
Exemplo n.º 17
0
/*
        search
        ~ Takes in a word, hashes it to find the word in the hash table 
        ~ Creates a descending list of the songs_and_freqs array for that word.

*/
void WordTable::search(){
	string word;
	//cout << "Put Word " << endl;
	cin >> word;
	uint32_t hash = hashWord(alphaOnly(word));
	
	if (table[hash]!= NULL) {
		wordNode* node = table[hash];
		
		Sort(node);
		
		//songs_and_freqs array now in descending order
		//calls printContext 
		for (size_t i = 0; i < node->numSongs; i++){
		  printContext(node->songs_and_freqs[i].song, node->word);
		}
	}
	
	cout << "<END OF REPORT>" << endl;
}
Exemplo n.º 18
0
String externalRepresentation(Frame* frame, RenderAsTextBehavior behavior)
{
    PrintContext printContext(frame);
    if (behavior & RenderAsTextPrintingMode) {
        if (!frame->contentRenderer())
            return String();
        printContext.begin(frame->contentRenderer()->width());
    }

    if (!(behavior & RenderAsTextDontUpdateLayout))
        frame->document()->updateLayout();

    RenderObject* o = frame->contentRenderer();
    if (!o)
        return String();

    TextStream ts;
    if (o->hasLayer()) {
        RenderLayer* l = toRenderBox(o)->layer();
        writeLayers(ts, l, l, IntRect(l->x(), l->y(), l->width(), l->height()), 0, behavior);
        writeSelection(ts, o);
    }
    return ts.release();
}
Exemplo n.º 19
0
/* Handles browse classes dialog box */
LRESULT CALLBACK BrowseClassesDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
  INT           	i;
  static Class 	     	currClass;
  Class	       	     	theClass;
  Inst	       	     	theInst;
  Name	       	     	theMember;
  WORD                	NotifyCode, wId;
  HBITMAP             	hBitmap;
  RECT                	aRect, DlgRect;
  HBITMAP             	hBmp;
  BITMAP	      	bm;
  DRAWITEMSTRUCT FAR   *lpdis;
  LPMEASUREITEMSTRUCT 	lpmis;
  LPCOMPAREITEMSTRUCT 	lpcis;
  BOOL                	Selected = FALSE;
  static HBITMAP      	hCBm, hCSelBm, hIBm, hISelBm, hMBm, hMSelBm;
  String		string;
  CHAR			string1[256];

  NotifyCode = HIWORD (wParam);
  wId        = LOWORD (wParam);

  switch (msg) {
    case WM_INITDIALOG:
      CenterDialogInParent(hDlg);
      SetDialogFont (hDlg, hDialogFont);

      SendDlgItemMessage(hDlg, LB_CLASS,   LB_SETHORIZONTALEXTENT, (WPARAM)300, 0L);
      SendDlgItemMessage(hDlg, LB_MEMBERS, LB_SETHORIZONTALEXTENT, (WPARAM)400, 0L);

      /* Create list of classes and set current class */
      for(i=CLASSMIN; i<classMax(); i++) {
	SendDlgItemMessage(hDlg, LB_CLASS ,LB_ADDSTRING, 0, (LPARAM)(LPSTR) i);
      }
      SendDlgItemMessage(hDlg, LB_CLASS, LB_SETCURSEL, 0, 0L);
      currClass = (Class) SendDlgItemMessage(hDlg, LB_CLASS ,LB_GETITEMDATA, (WPARAM) SendDlgItemMessage(hDlg, LB_CLASS ,LB_GETCURSEL, 0, 0L), 0L);
      SetClass(hDlg, currClass);

      /* Create Bitmaps */
      hCBm = LoadBitmap (hThisInstance, "CLASSBMP");
      MapBitmap (hCBm, RGB(0,128,128), GetSysColor(COLOR_WINDOW));
      hCSelBm = LoadBitmap (hThisInstance, "CLASSBMP");
      MapBitmap (hCSelBm, RGB(0,128,128), GetSysColor(COLOR_HIGHLIGHT));
      hIBm = LoadBitmap (hThisInstance, "INSTANCEBMP");
      MapBitmap (hIBm, RGB(0,128,128), GetSysColor(COLOR_WINDOW));
      hISelBm = LoadBitmap (hThisInstance, "INSTANCEBMP");
      MapBitmap (hISelBm, RGB(0,128,128), GetSysColor(COLOR_HIGHLIGHT));
      hMBm = LoadBitmap (hThisInstance, "MEMBERBMP");
      MapBitmap (hMBm, RGB(0,128,128), GetSysColor(COLOR_WINDOW));
      hMSelBm = LoadBitmap (hThisInstance, "MEMBERBMP");
      MapBitmap (hMSelBm, RGB(0,128,128), GetSysColor(COLOR_HIGHLIGHT));
      return TRUE;

    case WM_DESTROY:
      /* Destroy Bitmaps */
      DeleteObject (hCBm);
      DeleteObject (hCSelBm);
      DeleteObject (hIBm);
      DeleteObject (hISelBm);
      DeleteObject (hMBm);
      DeleteObject (hMSelBm);
      break;

    case WM_CTLCOLORBTN:
    case WM_CTLCOLORDLG:
    case WM_CTLCOLOREDIT:
    case WM_CTLCOLORLISTBOX:
    case WM_CTLCOLORMSGBOX:
    case WM_CTLCOLORSCROLLBAR:
    case WM_CTLCOLORSTATIC:
      break;

    case WM_PAINT: {
      HDC 	   hDC;
      PAINTSTRUCT  Ps;

      BeginPaint(hDlg, &Ps);
      hDC = Ps.hdc;

      /* Paint classes Bitmap */
      GetWindowRect(hDlg, &DlgRect);
      GetWindowRect(GetDlgItem(hDlg, ID_PLACEBITMAP), &aRect);

      hBitmap = LoadMappedBitmap(hThisInstance, "CLASSESDLGBMP");
      DrawBitmap(hDC, hBitmap,
		 aRect.left-DlgRect.left-GetSystemMetrics(SM_CXDLGFRAME),
		 aRect.top-DlgRect.top-GetSystemMetrics(SM_CYDLGFRAME)-GetSystemMetrics(SM_CYCAPTION));
      DeleteObject(hBitmap);
      EndPaint(hDlg, &Ps);
    }
    break;

    case WM_COMPAREITEM: {

      lpcis = (COMPAREITEMSTRUCT FAR *) lParam;

      switch (wParam) {
	case LB_CLASS:	    return strcmp (textToStr(cclass(lpcis->itemData1).text),
					   textToStr(cclass(lpcis->itemData2).text));

	case LB_INSTANCES:  if (nonNull(inst(lpcis->itemData1).specifics)) {
                        	printContext(stdstr,inst(lpcis->itemData1).specifics);
                        	fprintf(stdstr," => ");
                            }
                            printPred(stdstr,inst(lpcis->itemData1).head);
			    fprintf(stdstr,"\n");
			    strcpy (string1, stdstrbuff);
			    if (nonNull(inst(lpcis->itemData2).specifics)) {
                        	printContext(stdstr,inst(lpcis->itemData2).specifics);
                        	fprintf(stdstr," => ");
                            }
			    printPred(stdstr,inst(lpcis->itemData2).head);
			    fprintf(stdstr,"\n");
			    return strcmp (string1, stdstrbuff);

	case LB_MEMBERS:    printExp (stdstr, lpcis->itemData1);
			    fprintf(stdstr,"\n");
			    strcpy (string1, stdstrbuff);
			    printExp (stdstr, lpcis->itemData2);
			    fprintf(stdstr,"\n");
			    return strcmp (string1, stdstrbuff);

	}
      }
      break;

    case WM_MEASUREITEM:

      lpdis = (DRAWITEMSTRUCT FAR *) lParam;

      if (lpdis->CtlID == LB_CLASS ||
	  lpdis->CtlID == LB_INSTANCES ||
	  lpdis->CtlID == LB_MEMBERS ) {

	lpmis = (LPMEASUREITEMSTRUCT) lParam;

	/* Set the height of the list box items to Bitmap height */
	hBmp = LoadBitmap(hThisInstance, "CLASSBMP");
	GetObject(hBmp, sizeof(BITMAP), &bm);
	DeleteObject(hBmp);
	lpmis->itemHeight = bm.bmHeight+1;
	lpmis->itemWidth = 50000;

	return TRUE;
      }
      break;

    case WM_DRAWITEM:

      lpdis = (DRAWITEMSTRUCT FAR *) lParam;

      if (lpdis->CtlID == LB_CLASS ||
	  lpdis->CtlID == LB_INSTANCES ||
	  lpdis->CtlID == LB_MEMBERS ) {

	if (lpdis->itemID == (UINT)-1) {
	  return TRUE;
	}

	switch (lpdis->itemAction) {
	  case ODA_DRAWENTIRE:
	  case ODA_SELECT:
	  case ODA_FOCUS:
	    if ((lpdis->itemState & ODS_SELECTED) /*&& (lpdis->itemState & ODS_FOCUS)*/) {
	      SetBkColor(lpdis->hDC, GetSysColor(COLOR_HIGHLIGHT));
	      SetTextColor(lpdis->hDC, GetSysColor(COLOR_HIGHLIGHTTEXT));
	      Selected = TRUE;
	    }
	    else {
	      SetBkColor(lpdis->hDC, GetSysColor(COLOR_WINDOW));
	      SetTextColor(lpdis->hDC, GetSysColor(COLOR_WINDOWTEXT));
	    }
	    break;
	  default:
	    return FALSE;
	}

	switch (lpdis->CtlID) {
	  case LB_CLASS:     theClass = (Class) SendDlgItemMessage(hDlg, lpdis->CtlID, LB_GETITEMDATA, lpdis->itemID, 0);
			     printPred(stdstr,cclass(theClass).head);
			     fprintf (stdstr, "   -- in %s\n", textToStr(module(cclass(theClass).mod).text));
			     ExtTextOut(lpdis->hDC, lpdis->rcItem.left+21, lpdis->rcItem.top, ETO_OPAQUE, &(lpdis->rcItem), stdstrbuff, strlen(stdstrbuff), NULL);
			     hBmp = Selected ? hCSelBm : hCBm;

			     break;

	  case LB_INSTANCES: theInst = (Inst) SendDlgItemMessage(hDlg, lpdis->CtlID, LB_GETITEMDATA, lpdis->itemID, 0);
                 	     if (nonNull(inst(theInst).specifics)) {
                        	printContext(stdstr,inst(theInst).specifics);
                        	fprintf(stdstr," => ");
                             }
      			     printPred(stdstr,inst(theInst).head);
			     fprintf  (stdstr, "   -- in %s \n", textToStr(module(moduleOfScript(scriptThisInst(theInst))).text));
			     ExtTextOut(lpdis->hDC, lpdis->rcItem.left+21, lpdis->rcItem.top, ETO_OPAQUE, &(lpdis->rcItem), stdstrbuff, strlen(stdstrbuff), NULL);
			     hBmp = Selected ? hISelBm : hIBm;
			     break;


	  case LB_MEMBERS:   theMember = (Name) SendDlgItemMessage(hDlg, lpdis->CtlID, LB_GETITEMDATA, lpdis->itemID, 0);
			     printExp(stdstr,theMember);
			     fprintf(stdstr, " :: ");
			     printType(stdstr,name(theMember).type);
			     fprintf(stdstr,"\n");
			     ExtTextOut(lpdis->hDC, lpdis->rcItem.left+21, lpdis->rcItem.top, ETO_OPAQUE, &(lpdis->rcItem), stdstrbuff, strlen(stdstrbuff), NULL);
			     hBmp = Selected ? hMSelBm : hMBm;
			     break;
	}
	DrawBitmap (lpdis->hDC, hBmp, (lpdis->rcItem.left)+4, lpdis->rcItem.top);

	/* If selected draw rectangle */
	if ((lpdis->itemState & ODS_SELECTED)&&(lpdis->itemState & ODS_FOCUS)) {
	  DrawFocusRect(lpdis->hDC, &(lpdis->rcItem));
	}

	return TRUE;
      }

    case WM_COMMAND:
      switch (wId) {
        case LB_CLASS:
	  switch(NotifyCode) {
	    case LBN_SELCHANGE: /* select a new class */
	      currClass = (Class) SendDlgItemMessage(hDlg, LB_CLASS ,LB_GETITEMDATA, SendDlgItemMessage(hDlg, LB_CLASS ,LB_GETCURSEL, 0, 0L), 0L);
	      SetClass(hDlg, currClass);
	      break;

	    case LBN_DBLCLK: { /* Open in text editor script file with class definition */
	      currClass = (Class) SendDlgItemMessage(hDlg, LB_CLASS ,LB_GETITEMDATA, SendDlgItemMessage(hDlg, LB_CLASS ,LB_GETCURSEL, 0, 0L), 0L);

	      currClass = (Class) SendDlgItemMessage(hDlg, LB_CLASS ,LB_GETITEMDATA, SendDlgItemMessage(hDlg, LB_CLASS ,LB_GETCURSEL, 0, 0L), 0L);
	      setLastEdit(getScriptName(scriptThisClass(currClass)), cclass(currClass).line);
	      runEditor();
	      
	      
	    }
	    break;
	  }
	  break;

	case LB_MEMBERS:
	case LB_INSTANCES:
	  switch(NotifyCode) {/* Open in text editor script file with instance definition */
	    case LBN_DBLCLK: {
	      Inst  currInst;

	      currInst = (Inst) SendDlgItemMessage(hDlg, LB_INSTANCES, LB_GETITEMDATA, SendDlgItemMessage(hDlg, LB_INSTANCES ,LB_GETCURSEL, 0, 0L), 0L);

	      /* Find instance module */
	      setLastEdit(getScriptName(scriptThisInst(currInst)), inst(currInst).line);
	      runEditor();
	      
	    }
	    break;
	  }
	  break;

	case ID_HIERARCHY: /* Draw classes hierarchy */
	  DrawClassesHierarchy();
	  break;

	case ID_EDITCLASS: /* Pushed on Edit class button */
	  if (SendDlgItemMessage(hDlg, LB_CLASS, LB_GETCURSEL, 0, 0L) != LB_ERR)
	    DlgSendMessage(hDlg, WM_COMMAND, LB_CLASS, MAKELONG(0, LBN_DBLCLK));
	  break;

	case ID_EDITINSTANCE: /* Pushed on Edit instance button */
	  if (SendDlgItemMessage(hDlg, LB_INSTANCES, LB_GETCURSEL, 0, 0L) != LB_ERR)
	    DlgSendMessage(hDlg, WM_COMMAND, LB_INSTANCES, MAKELONG(0, LBN_DBLCLK));
	  break;

	case IDCANCEL: /* Close dialog */
	case IDOK:
	  EndDialog(hDlg, TRUE);
	  return TRUE;

	default:
	  return TRUE;
      }
  }
  return FALSE;
}
Exemplo n.º 20
0
void LogoRenderer::initialize()
{
    initializeOpenGLFunctions();
    printContext();

//    Sleep(5000);

    /* Build and compile our shader program */
    // Vertex shader
    GLuint vertexShader = glCreateShader(GL_VERTEX_SHADER);
    glShaderSource(vertexShader, 1, &vertexShaderSource, NULL);
    glCompileShader(vertexShader);
    // Check for compile time errors
    GLint success;
    GLchar infoLog[512];
    glGetShaderiv(vertexShader, GL_COMPILE_STATUS, &success);
    if (!success)
    {
        glGetShaderInfoLog(vertexShader, 512, NULL, infoLog);
        std::cout << "ERROR:SHADER::VERTEX::COMPILATION_FAILED\n" << infoLog << std::endl;
    }

    // Fragment shader
    GLint fragmentShader = glCreateShader(GL_FRAGMENT_SHADER);
    glShaderSource(fragmentShader, 1, &fragmentShaderSource, NULL);
    glCompileShader(fragmentShader);
    // Check for compile time error
    glGetShaderiv(fragmentShader, GL_COMPILE_STATUS, &success);
    if (!success)
    {
        glGetShaderInfoLog(fragmentShader, 512, NULL, infoLog);
        std::cout << "ERROR::SHADER::FRAGMENT::COMPILATION_FAILED\n" << infoLog << std::endl;
    }
    // Link shaders
    shaderProgram = glCreateProgram();
    glAttachShader(shaderProgram, vertexShader);
    glAttachShader(shaderProgram, fragmentShader);
    glLinkProgram(shaderProgram);
    // Check for linking errors
    glGetProgramiv(shaderProgram, GL_LINK_STATUS, &success);
    if (!success)
    {
        glGetProgramInfoLog(shaderProgram, 512, NULL, infoLog);
        std::cout << "ERROR::SHADER::PROGRAM::LINKING_FAILED\n" << infoLog << std::endl;
    }
    glDeleteShader(vertexShader);
    glDeleteShader(fragmentShader);


    /* Set up vertex data (and buffer(s)) and attribute pointers */
    GLfloat vertices[] = {
        -0.5f, -0.5f, 0.0f,
        0.5f, -0.5f, 0.0f,
        0.0f,  0.5f, 0.0f
    };

    glGenVertexArrays(1, &VAO);
    glGenBuffers(1, &VBO);

    // 1. 绑定VAO
    glBindVertexArray(VAO);

    // 2. 把我们的顶点数组复制到一个顶点缓冲中,提供给OpenGL使用
    glBindBuffer(GL_ARRAY_BUFFER, VBO);
    glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW);

    // 3. 设置顶点属性指针
    glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 3 * sizeof(GLfloat), (GLvoid*)0);
    glEnableVertexAttribArray(0);

    //4. 解绑 VBO VAO
    glBindBuffer(GL_ARRAY_BUFFER, 0);
    glBindVertexArray(0);


    /*
    glClearColor(0.1f, 0.1f, 0.2f, 1.0f);

    QOpenGLShader *vshader1 = new QOpenGLShader(QOpenGLShader::Vertex, &program1);
//    const char *vsrc1 =
//            "#version 330 core\n"
//            "in vec4 vertex;\n"
//            "in vec3 normal;\n"
//            "uniform mat4 matrix;\n"
//            "out vec4 tCorlor;\n"
//            "void main(void)\n"
//            "{\n"
//            "    vec3 toLight = normalize(vec3(0.0, 0.3, 1.0));\n"
//            "    float angle = max(dot(normal, toLight), 0.0);\n"
//            "    vec3 col = vec3(0.40, 1.0, 0.0);\n"
//            "    tCorlor = vec4(col * 0.2 + col * 0.8 * angle, 1.0);\n"
//            "    tCorlor = clamp(tCorlor, 0.0, 1.0);\n"
//            "    gl_Position = matrix * vertex;\n"
//            "}\n";

    const char *vsrc1 =
            "#version 330 core\n"
            "in vec4 vertex;\n"
            "in vec3 normal;\n"
            "uniform mat4 matrix;\n"
            "void main()\n"
            "{\n"
            "    gl_Position = matrix * vertex;\n"
            "}\n";
    vshader1->compileSourceCode(vsrc1);

    QOpenGLShader *fshader1 = new QOpenGLShader(QOpenGLShader::Fragment, &program1);
    const char *fsrc1 =
            "#version 330 core\n"
            "out vec4 color;\n"
            "void main()\n"
            "{\n"
            " color = vec4(1.0f, 0.0f, 0.0f, 1.0f);\n"
            "}\n";
    fshader1->compileSourceCode(fsrc1);

    program1.addShader(vshader1);
    program1.addShader(fshader1);
    program1.link();

    vertexAttr1 = program1.attributeLocation("vertex");
    normalAttr1 = program1.attributeLocation("normal");
    matrixUniform1 = program1.uniformLocation("matrix");

    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );

    m_fAngle = 0;
    m_fScale = 1;
    createGeometry();
*/
}
Exemplo n.º 21
0
/* Handles browse Tycons dialog box */
LRESULT CALLBACK BrowseTyconsDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
  static        	List tyconList = NIL;
  List          	tycons=NIL;
  Tycon         	tc;
  UINT          	theTycon;
  WORD          	NotifyCode, wId;
  RECT          	aRect, DlgRect;
  HBITMAP       	hBitmap;
  HBITMAP       	hBmp;
  BITMAP	       	bm;
  static HBITMAP 	hTCBm, hTCSelBm, hDBm, hDSelBm, hTSBm, hTSSelBm,
			hNTBm, hNTSelBm, hSBm, hSSelBm, hIBm, hISelBm;
  CHAR	        	Buffer[300];
  DRAWITEMSTRUCT FAR    *lpdis;
  LPMEASUREITEMSTRUCT 	lpmis;
  BOOL                	Selected = FALSE;
  Inst			theInst;

  NotifyCode = HIWORD (wParam);
  wId        = LOWORD (wParam);

  switch (msg) {

    case WM_INITDIALOG:
      CenterDialogInParent(hDlg);
      SetDialogFont (hDlg, hDialogFont);
      tyconList = addTyconsMatching((String)0, NIL);

      /* Clear the redraw flag */
      SendDlgItemMessage(hDlg, LB_TYCONS ,WM_SETREDRAW, FALSE, 0L);

      for (tycons=tyconList; nonNull(tycons); tycons=tl(tycons)) {
	if (nonNull(tycons)) {
	  tc = hd(tycons);
	  fprintf(stdstr, "%s   -- in %s\n",textToStr(tycon(tc).text),textToStr(module(tycon(tc).mod).text));
	  SendDlgItemMessage(hDlg, LB_TYCONS ,LB_ADDSTRING, 0, (LONG)(LPSTR) stdstrbuff);
	  SendDlgItemMessage(hDlg, LB_TYCONS, LB_SETCURSEL, 0, 0L);
	}
      /* Set the redraw flag and force repaint. */
      SendDlgItemMessage(hDlg, LB_TYCONS ,WM_SETREDRAW, TRUE, 0L);
      InvalidateRect(GetDlgItem(hDlg, LB_TYCONS), NULL, TRUE);
      }

      theTycon = 0;
      SetTycon(hDlg, theTycon, tyconList);

      hTCBm = LoadBitmap (hThisInstance, "TYPECONSBMP");
      MapBitmap (hTCBm, RGB(0,128,128), GetSysColor(COLOR_WINDOW));
      hTCSelBm = LoadBitmap (hThisInstance, "TYPECONSBMP");
      MapBitmap (hTCSelBm, RGB(0,128,128), GetSysColor(COLOR_HIGHLIGHT));
      hDBm = LoadBitmap (hThisInstance, "DATACONSBMP");
      MapBitmap (hDBm, RGB(0,128,128), GetSysColor(COLOR_WINDOW));
      hDSelBm = LoadBitmap (hThisInstance, "DATACONSBMP");
      MapBitmap (hDSelBm, RGB(0,128,128), GetSysColor(COLOR_HIGHLIGHT));
      hTSBm = LoadBitmap (hThisInstance, "TYPESINBMP");
      MapBitmap (hTSBm, RGB(0,128,128), GetSysColor(COLOR_WINDOW));
      hTSSelBm = LoadBitmap (hThisInstance, "TYPESINBMP");
      MapBitmap (hTSSelBm, RGB(0,128,128), GetSysColor(COLOR_HIGHLIGHT));
      hNTBm = LoadBitmap (hThisInstance, "NEWTYPEBMP");
      MapBitmap (hNTBm, RGB(0,128,128), GetSysColor(COLOR_WINDOW));
      hNTSelBm = LoadBitmap (hThisInstance, "NEWTYPEBMP");
      MapBitmap (hNTSelBm, RGB(0,128,128), GetSysColor(COLOR_HIGHLIGHT));
      hSBm = LoadBitmap (hThisInstance, "SELECTORBMP");
      MapBitmap (hSBm, RGB(0,128,128), GetSysColor(COLOR_WINDOW));
      hSSelBm = LoadBitmap (hThisInstance, "SELECTORBMP");
      MapBitmap (hSSelBm, RGB(0,128,128), GetSysColor(COLOR_HIGHLIGHT));
      hIBm = LoadBitmap (hThisInstance, "INSTANCEBMP");
      MapBitmap (hIBm, RGB(0,128,128), GetSysColor(COLOR_WINDOW));
      hISelBm = LoadBitmap (hThisInstance, "INSTANCEBMP");
      MapBitmap (hISelBm, RGB(0,128,128), GetSysColor(COLOR_HIGHLIGHT));

      /* set focus to search box (must return FALSE) */
      SetFocus (GetDlgItem(hDlg, IDC_SEARCHTYCON));
      return FALSE;

    case WM_DESTROY:
      DeleteObject(hTCBm);
      DeleteObject(hTCSelBm);
      DeleteObject(hDBm);
      DeleteObject(hDSelBm);
      DeleteObject(hTSBm);
      DeleteObject(hTSSelBm);
      DeleteObject(hNTBm);
      DeleteObject(hNTSelBm);
      DeleteObject(hSBm);
      DeleteObject(hSSelBm);
      DeleteObject(hIBm);
      DeleteObject(hISelBm);

      break;

    case WM_CTLCOLORBTN:
    case WM_CTLCOLORDLG:
    case WM_CTLCOLOREDIT:
    case WM_CTLCOLORLISTBOX:
    case WM_CTLCOLORMSGBOX:
    case WM_CTLCOLORSCROLLBAR:
    case WM_CTLCOLORSTATIC:
      break;


    case WM_MEASUREITEM:

      lpdis = (DRAWITEMSTRUCT FAR *) lParam;

      if (lpdis->CtlID == LB_TYCONS ||
	  lpdis->CtlID == LB_CONS   ||
	  lpdis->CtlID == LB_TYCONSINST) {

	lpmis = (LPMEASUREITEMSTRUCT) lParam;

	/* Set the height of the list box items to Bitmap height */
	hBmp = LoadBitmap(hThisInstance, "CLASSBMP");
	GetObject(hBmp, sizeof(BITMAP), &bm);
	DeleteObject(hBmp);

	lpmis->itemHeight = bm.bmHeight+1;

	return TRUE;
      }
      break;

    case WM_DRAWITEM:

      lpdis = (DRAWITEMSTRUCT FAR *) lParam;

      if (lpdis->CtlID == LB_TYCONS ||
	  lpdis->CtlID == LB_CONS   ||
	  lpdis->CtlID == LB_TYCONSINST) {

	if (lpdis->itemID == (UINT)-1) {
	  return TRUE;
	}

	switch (lpdis->itemAction) {
	  case ODA_DRAWENTIRE:
	  case ODA_SELECT:
	  case ODA_FOCUS:
	    if ((lpdis->itemState & ODS_SELECTED) /*&& (lpdis->itemState & ODS_FOCUS)*/) {
	      SetBkColor(lpdis->hDC, GetSysColor(COLOR_HIGHLIGHT));
	      SetTextColor(lpdis->hDC, GetSysColor(COLOR_HIGHLIGHTTEXT));
	      Selected = TRUE;
	    }
	    else {
	      SetBkColor(lpdis->hDC, GetSysColor(COLOR_WINDOW));
	      SetTextColor(lpdis->hDC, GetSysColor(COLOR_WINDOWTEXT));
	    }
	    break;

	  default:
	    return FALSE;
	}

	SendDlgItemMessage(hDlg, lpdis->CtlID, LB_GETTEXT, lpdis->itemID, (LPARAM) Buffer);

	ExtTextOut(lpdis->hDC, lpdis->rcItem.left+21, lpdis->rcItem.top, ETO_OPAQUE, &(lpdis->rcItem), Buffer, strlen(Buffer), NULL);

	switch (lpdis->CtlID) {
	  case LB_TYCONS:   theTycon = (UINT) lpdis->itemID;
			    tc = nth(theTycon,tyconList);

			    switch(tycon(tc).what) {
			      case RESTRICTSYN:
			      case SYNONYM:     hBmp = Selected ? hTSSelBm : hTSBm;
					        break;
			      case DATATYPE:    hBmp = Selected ? hTCSelBm : hTCBm;
					        break;
			      case NEWTYPE:     hBmp = Selected ? hNTSelBm : hNTBm;
					        break;
			    }
			    break;

	  case LB_CONS:	    if (lpdis->itemID>=(UINT)numCfuns)
				hBmp = Selected ? hSSelBm : hSBm;
			    else
				hBmp = Selected ? hDSelBm : hDBm;
			    break;
          case LB_TYCONSINST:
			    theInst = (Inst) SendDlgItemMessage(hDlg, lpdis->CtlID, LB_GETITEMDATA, lpdis->itemID, 0);
                 	    if (nonNull(inst(theInst).specifics)) {
                        	printContext(stdstr,inst(theInst).specifics);
                        	fprintf(stdstr," => ");
                            }
       			    printPred(stdstr,inst(theInst).head);
			    fprintf  (stdstr, "   -- in %s \n", textToStr(module(moduleOfScript(scriptThisInst(theInst))).text));
			    ExtTextOut(lpdis->hDC, lpdis->rcItem.left+21, lpdis->rcItem.top, ETO_OPAQUE, &(lpdis->rcItem), stdstrbuff, strlen(stdstrbuff), NULL);
			    
			    hBmp = Selected ? hISelBm : hIBm;
			    break;
	}

	DrawBitmap (lpdis->hDC, hBmp, (lpdis->rcItem.left)+4, lpdis->rcItem.top);

	/* If selected draw rectangle */
	if ((lpdis->itemState & ODS_SELECTED)&&(lpdis->itemState & ODS_FOCUS)) {
	  DrawFocusRect(lpdis->hDC, &(lpdis->rcItem));
	}

	return TRUE;
      }

    case WM_PAINT: {
      HDC 	   hDC;
      PAINTSTRUCT  Ps;

      BeginPaint(hDlg, &Ps);
      hDC = Ps.hdc;

      /* Paint classes Bitmap */
      GetWindowRect(hDlg, &DlgRect);
      GetWindowRect(GetDlgItem(hDlg, ID_PLACEBITMAP), &aRect);

      hBitmap = LoadMappedBitmap(hThisInstance, "TYCONSDLGBMP");
      DrawBitmap(hDC, hBitmap,
		 aRect.left-DlgRect.left-GetSystemMetrics(SM_CXDLGFRAME),
		 aRect.top-DlgRect.top-GetSystemMetrics(SM_CYDLGFRAME)-GetSystemMetrics(SM_CYCAPTION));

      DeleteObject(hBitmap);
      EndPaint(hDlg, &Ps);
    }
    break;

    case WM_COMMAND:
      switch (LOWORD(wId)) {
	case LB_TYCONS:
	  switch(NotifyCode) {
	    case LBN_SELCHANGE: {
	      /* A new tycon was selected */
	      theTycon = (UINT) SendDlgItemMessage(hDlg, LB_TYCONS ,LB_GETCURSEL, 0, 0L);
	      SetTycon(hDlg, theTycon, tyconList);
	    }
	    break;

	    case LBN_DBLCLK: {
	      /* Open in text editor script file with instance definition */
	      INT    TheTycon;
	      Tycon  tc;

	      /* Get selected tycon */
	      TheTycon = (UINT) SendDlgItemMessage(hDlg, LB_TYCONS ,LB_GETCURSEL, 0, 0L);
	      tc = nth(TheTycon,tyconList);

	      if (isTycon(tc) && tycon(tc).line) {
 	        setLastEdit(getScriptName(scriptThisTycon(tc)), tycon(tc).line);
	        runEditor();
	      }
	      else {
		MessageBox(hDlg, "Primitive type:\nNo definition available.", appName, MB_ICONINFORMATION | MB_OK);
	      }
	    }
	    break;
	}
	break;

	case LB_TYCONSINST:
	  switch(NotifyCode) {
	    case LBN_DBLCLK: {
	      Inst  currInst;

	      currInst = (Inst) SendDlgItemMessage(hDlg, LB_TYCONSINST, LB_GETITEMDATA, SendDlgItemMessage(hDlg, LB_TYCONSINST ,LB_GETCURSEL, 0, 0L), 0L);

	      /* Find instance module */
	      setLastEdit(getScriptName(scriptThisInst(currInst)), inst(currInst).line);
	      runEditor();
	    }
	    break;
	}
	break;


	case IDC_SEARCHTYCON:  /* Search a name */
	  switch(HIBYTE(wId)) {
	    case HIBYTE(EN_CHANGE): {
	      CHAR    Buffer[300];

	      /* Get edit control contents */
	      SendDlgItemMessage(hDlg, IDC_SEARCHTYCON, WM_GETTEXT, 300, (LPARAM) ((LPSTR) Buffer));

	      /* Search in names list box */
	      SendDlgItemMessage(hDlg, LB_TYCONS, LB_SELECTSTRING, 0, (LPARAM) ((LPSTR) Buffer));

	      /* Update window contents */
	      DlgSendMessage(hDlg, WM_COMMAND, LB_TYCONS, MAKELONG(0, LBN_SELCHANGE));
	    }
	    break;
	  }
	  break;

	case LB_CONS:
	  switch(NotifyCode) {
	    case LBN_DBLCLK: {

	      /* Open in text editor script file with constructor definition */
	      DlgSendMessage(hDlg, WM_COMMAND, ID_EDITTYCON, 0L);
	      break;
	    }
	  }
	  break;


	case ID_EDITTYCON: /* Pushed on Edit tycon button */
	  if (SendDlgItemMessage(hDlg, LB_TYCONS, LB_GETCURSEL, 0, 0L) != LB_ERR)
	    DlgSendMessage(hDlg, WM_COMMAND, LB_TYCONS, MAKELONG(0, LBN_DBLCLK));
	    break;


        case ID_EDITTYCONSINST:
	  if (SendDlgItemMessage(hDlg, LB_TYCONSINST, LB_GETCURSEL, 0, 0L) != LB_ERR)
	    DlgSendMessage(hDlg, WM_COMMAND, LB_TYCONSINST, MAKELONG(0, LBN_DBLCLK));
	    break;

	case IDCANCEL:  /* Close dialog */
	case IDOK:
	  EndDialog(hDlg, TRUE);
	  return TRUE;

	default:
	  return TRUE;
     }
  }
  return FALSE;
}
Exemplo n.º 22
0
void Wikidiff2::diffLines(const StringVector & lines1, const StringVector & lines2,
		int numContextLines, int maxMovedLines)
{
	// first do line-level diff
	StringDiff linediff(lines1, lines2);

	int from_index = 1, to_index = 1;

	// Should a line number be printed before the next context line?
	// Set to true initially so we get a line number on line 1
	bool showLineNumber = true;

	for (int i = 0; i < linediff.size(); ++i) {
		int n, j, n1, n2;
		// Line 1 changed, show heading with no leading context
		if (linediff[i].op != DiffOp<String>::copy && i == 0) {
			printBlockHeader(1, 1);
		}

		switch (linediff[i].op) {
			case DiffOp<String>::add:
				// inserted lines
				n = linediff[i].to.size();
				for (j=0; j<n; j++) {
					if (!printMovedLineDiff(linediff, i, j, maxMovedLines)) {
						printAdd(*linediff[i].to[j]);
					}
				}
				to_index += n;
				break;
			case DiffOp<String>::del:
				// deleted lines
				n = linediff[i].from.size();
				for (j=0; j<n; j++) {
					if (!printMovedLineDiff(linediff, i, j, maxMovedLines)) {
						printDelete(*linediff[i].from[j]);
					}
				}
				from_index += n;
				break;
			case DiffOp<String>::copy:
				// copy/context
				n = linediff[i].from.size();
				for (j=0; j<n; j++) {
					if ((i != 0 && j < numContextLines) /*trailing*/
							|| (i != linediff.size() - 1 && j >= n - numContextLines)) /*leading*/ {
						if (showLineNumber) {
							printBlockHeader(from_index, to_index);
							showLineNumber = false;
						}
						printContext(*linediff[i].from[j]);
					} else {
						showLineNumber = true;
					}
					from_index++;
					to_index++;
				}
				break;
			case DiffOp<String>::change:
				// replace, i.e. we do a word diff between the two sets of lines
				n1 = linediff[i].from.size();
				n2 = linediff[i].to.size();
				n = std::min(n1, n2);
				for (j=0; j<n; j++) {
					printWordDiff(*linediff[i].from[j], *linediff[i].to[j]);
				}
				from_index += n;
				to_index += n;
				break;
		}
		// Not first line anymore, don't show line number by default
		showLineNumber = false;
	}
}