Ejemplo n.º 1
0
void structHyperPage :: v_dataChanged () {
	int oldError = Melder_hasError ();   // this method can be called during error time
	(void) v_goToPage (currentPageTitle);
	if (Melder_hasError () && ! oldError) Melder_flushError (NULL);
	HyperPage_clear (this);
	updateVerticalScrollBar (this);
}
Ejemplo n.º 2
0
void HyperPage_goToPage_i (I, long i) {
	iam (HyperPage);
	my v_goToPage_i (i);   // catch -> HyperPage_clear (me); ?
	my top = 0;
	HyperPage_clear (me);
	updateVerticalScrollBar (me);   /* Scroll to the top (my top == 0). */
}
Ejemplo n.º 3
0
void structTableEditor :: v_dataChanged () {
	Table table = static_cast<Table> (our data);
	if (topRow > table -> rows.size) topRow = table -> rows.size;
	if (leftColumn > table -> numberOfColumns) leftColumn = table -> numberOfColumns;
	updateVerticalScrollBar (this);
	updateHorizontalScrollBar (this);
	Graphics_updateWs (our graphics.get());
}
Ejemplo n.º 4
0
static void gui_drawingarea_cb_resize (I, GuiDrawingAreaResizeEvent event) {
	iam (HyperPage);
	if (my g == NULL) return;
	Graphics_setWsViewport (my g, 0, event -> width, 0, event -> height);
	Graphics_setWsWindow (my g, 0.0, my rightMargin = event -> width / resolution,
		PAGE_HEIGHT - event -> height / resolution, PAGE_HEIGHT);
	Graphics_updateWs (my g);
	updateVerticalScrollBar (me);
}
Ejemplo n.º 5
0
static void do_forth (HyperPage me) {
	if (my historyPointer >= 19 || ! my history [my historyPointer + 1]. page) return;
	autostring page = Melder_wcsdup_f (my history [++ my historyPointer]. page);
	int top = my history [my historyPointer]. top;
	if (my v_goToPage (page.peek())) {
		my top = top;
		HyperPage_clear (me);
		updateVerticalScrollBar (me);
	}
}
Ejemplo n.º 6
0
static void do_back (HyperPage me) {
	if (my historyPointer <= 0) return;
	autostring page = Melder_wcsdup_f (my history [-- my historyPointer]. page);   // temporary, because pointer will be moved
	int top = my history [my historyPointer]. top;
	if (my v_goToPage (page.peek())) {
		my top = top;
		HyperPage_clear (me);
		updateVerticalScrollBar (me);
	}
}
Ejemplo n.º 7
0
static void gui_cb_verticalScroll (I, GuiScrollBarEvent	event) {
	iam (HyperPage);
	double value = event -> scrollBar -> f_getValue ();
	if (value != my top) {
		my top = value;
		Graphics_clearWs (my g);
		initScreen (me);
		my v_draw ();   // do not wait for expose event
		updateVerticalScrollBar (me);
	}
}
Ejemplo n.º 8
0
static void menu_cb_pageDown (EDITOR_ARGS) {
	EDITOR_IAM (HyperPage);
	if (! my verticalScrollBar) return;
	int value = my verticalScrollBar -> f_getValue () + 24;
	if (value > (int) (PAGE_HEIGHT * 5) - 25) value = (int) (PAGE_HEIGHT * 5) - 25;
	if (value != my top) {
		my top = value;
		Graphics_clearWs (my g);
		initScreen (me);
		my v_draw ();   // do not wait for expose event
		updateVerticalScrollBar (me);
	}
}
Ejemplo n.º 9
0
int HyperPage_goToPage (I, const wchar_t *title) {
	iam (HyperPage);
	switch (my v_goToPage (title)) {
		case -1: return 0;
		case 0: HyperPage_clear (me); return 0;
	}
	saveHistory (me, title);   /* Last chance: HyperPage_clear will destroy "title" !!! */
	Melder_free (my currentPageTitle);
	my currentPageTitle = Melder_wcsdup_f (title);
	my top = 0;
	HyperPage_clear (me);
	updateVerticalScrollBar (me);   /* Scroll to the top (my top == 0). */
	return 1;	
}
Ejemplo n.º 10
0
static void gui_drawingarea_cb_expose (I, GuiDrawingAreaExposeEvent event) {
	iam (HyperPage);
	(void) event;
	if (my g == NULL) return;   // Could be the case in the very beginning.
	Graphics_clearWs (my g);
	initScreen (me);
	my v_draw ();
	if (my entryHint && my entryPosition) {
		Melder_free (my entryHint);
		my top = 5.0 * (PAGE_HEIGHT - my entryPosition);
		if (my top < 0) my top = 0;
		Graphics_clearWs (my g);
		initScreen (me);
		my v_draw ();
		updateVerticalScrollBar (me);
	}
}
Ejemplo n.º 11
0
void HyperPage_init (HyperPage me, const wchar_t *title, Data data) {
	resolution = Gui_getResolution (NULL);
	Editor_init (me, 0, 0, 6 * resolution + 30, 800, title, data);
	#if motif
		Melder_assert (XtWindow (my drawingArea -> d_widget));
	#endif
	my g = Graphics_create_xmdrawingarea (my drawingArea);
	Graphics_setAtSignIsLink (my g, TRUE);
	Graphics_setDollarSignIsCode (my g, TRUE);
	Graphics_setFont (my g, kGraphics_font_TIMES);
	if (prefs_font != kGraphics_font_TIMES && prefs_font != kGraphics_font_HELVETICA)
		prefs_font = kGraphics_font_TIMES;   // ensure Unicode compatibility
	my font = prefs_font;
	setFontSize (me, prefs_fontSize);	

struct structGuiDrawingAreaResizeEvent event = { my drawingArea, 0 };
event. width  = my drawingArea -> f_getWidth  ();
event. height = my drawingArea -> f_getHeight ();
gui_drawingarea_cb_resize (me, & event);

	updateVerticalScrollBar (me);   // scroll to the top (my top == 0)
}
Ejemplo n.º 12
0
void CHexViewView::draw(CDC *dc) {
  CHexViewDoc *doc = GetDocument();
  ASSERT_VALID(doc);

  const CRect cr = updateSettings(dc);

  if(m_docSize > 0) {

    const bool    showAddr          = m_settings->getShowAddr();
    const bool    showAscii         = m_settings->getShowAscii();
    const __int64 indexByte0TopLine = m_topLine * m_lineSize;

    ByteArray content;
    doc->getBytes(indexByte0TopLine, m_lineSize * m_pageSize.cy, content);

    const BYTE      *buffer         = content.getData();
    const AddrRange  selection    = getSelection();

    if(showAddr) { // paint headline with offset from leftmost byte address
      dc->FillSolidRect(0, 0, cr.Width(), m_addrTextSize.cy, m_settings->getAddrBackColor());
      setAddrColor(dc, true);
      for(int col = 0, xPos = m_contentRect.left; col < m_lineSize; col++, xPos += m_byteSize.cx) {
        if(xPos > m_contentRect.right) {
          break;
        }
        dc->TextOut(xPos, 0, m_addrFormat.offsetToString(col).cstr());
      }
      setAddrColor(dc, false);
    }

#define OFFSET_LEFTMOSTBYTE(row) ((row)*m_lineSize + m_lineOffset)

    const BYTE *lastByte = &content[content.size()-1];
    setReverseVideo(dc, false);
    for(int row = 0, yPos = m_contentRect.top; yPos <= m_contentRect.bottom; row++, yPos += m_byteSize.cy) {
      const BYTE *bp = buffer + OFFSET_LEFTMOSTBYTE(row);
      if(bp > lastByte) {
        break;
      }
      if(showAddr) {
        setAddrColor(dc, true);
        dc->TextOut(0,yPos, getAddrAsString(indexByte0TopLine + OFFSET_LEFTMOSTBYTE(row)).cstr());
        setAddrColor(dc, false);
      }
      __int64 addr = indexByte0TopLine + OFFSET_LEFTMOSTBYTE(row);
      for(int col = 0, xPos = m_contentRect.left; (col < m_lineSize) && (xPos <= m_contentRect.right) && (bp <= lastByte); col++, xPos += m_byteSize.cx, bp++, addr++) {
        if(!selection.isEmpty()) {
          if(selection.contains(addr)) {
            if(!m_reverseVideo) {
              setReverseVideo(dc, true);
            }
          } else if(m_reverseVideo) {
            setReverseVideo(dc, false);
          }
        }

        TCHAR tmp[40];
        if(showAscii && isprint(*bp)) {
          if(!m_asciiColor) {
            setAsciiColor(dc, true);
          }
          _stprintf(tmp, m_asciiFormat, *bp);
        } else {
          if(m_asciiColor) {
            setAsciiColor(dc, false);
          }
          _stprintf(tmp, m_radixFormat, *bp);
        }
        dc->TextOut(xPos, yPos, tmp);
      }
    }
  }

  showCaret();

  if(m_maxTopLine == 0) { // all bytes shown. hide scrollbar
    ShowScrollBar(SB_VERT, FALSE);
  } else {
    // dont use SetScrollPos as it is only 16-bit int
    ShowScrollBar(SB_VERT, TRUE );

    updateVerticalScrollBar();
  }

  if(m_docSize == 0 || m_maxLineOffset == 0) {
    ShowScrollBar(SB_HORZ, FALSE);
  } else {
    ShowScrollBar(SB_HORZ, TRUE );
    SCROLLINFO scrollInfo;
    GetScrollInfo(SB_HORZ, &scrollInfo);
    scrollInfo.nMin  = 0;
    scrollInfo.nMax  = m_lineSize - 1;
    scrollInfo.nPos  = m_lineOffset;
    scrollInfo.nPage = m_pageSize.cx;
    SetScrollInfo(SB_HORZ, &scrollInfo);
  }
}