/* Paint the thumb in the area specified by w->top and w->shown. The old area is erased. The painting and erasing is done cleverly so that no flickering will occur. */ static void PaintThumb(ScrollbarWidget w) { Position oldtop, oldbot, newtop, newbot; oldtop = w->scrollbar.topLoc; oldbot = oldtop + w->scrollbar.shownLength; newtop = w->scrollbar.length * w->scrollbar.top; newbot = newtop + (int)(w->scrollbar.length * w->scrollbar.shown); if (newbot < newtop + (int)w->scrollbar.min_thumb) newbot = newtop + w->scrollbar.min_thumb; w->scrollbar.topLoc = newtop; w->scrollbar.shownLength = newbot - newtop; if (XtIsRealized((Widget)w)) { if (newtop < oldtop) FillArea(w, newtop, XawMin(newbot, oldtop), 1); if (newtop > oldtop) FillArea(w, oldtop, XawMin(newtop, oldbot), 0); if (newbot < oldbot) FillArea(w, XawMax(newbot, oldtop), oldbot, 0); if (newbot > oldbot) FillArea(w, XawMax(newtop, oldbot), newbot, 1); } }
int main_handler(int type, int par1, int par2) { int i; if (type == EVT_SHOW) { ClearScreen(); FullUpdate(); DrawRect(10, 18, 580, 104, 0); for(i=0; i<16; i++) { FillArea(12+i*36, 20, 36, 100, i*0x111111); } FullUpdate(); FineUpdate(); } if (type == EVT_KEYPRESS) { CloseApp(); } return 0; }
//**************************************************************************************** COLORREF CImageStyle::OnDrawControlBarCaption (CDC* pDC, CBCGPDockingControlBar* pBar, BOOL /*bActive*/, CRect rectCaption, CRect /*rectButtons*/) { CRgn rgn; rgn.CreateRectRgnIndirect (rectCaption); pDC->SelectClipRgn (&rgn); FillArea (pDC, rectCaption, pBar, FALSE, TRUE); return RGB (0, 0, 0); }
//********************************************************************************* void CImageStyle::OnFillOutlookPageButton (CDC* pDC, const CRect& rect, BOOL /*bIsHighlighted*/, BOOL /*bIsPressed*/, COLORREF& clrText) { CRgn rgn; rgn.CreateRectRgnIndirect (rect); pDC->SelectClipRgn (&rgn); FillArea (pDC, rect, &((CMainFrame*) AfxGetMainWnd ())->GetOutlookBar (), FALSE, FALSE); pDC->SelectClipRgn (NULL); clrText = m_clrText; }
//**************************************************************************************** void CImageStyle::OnFillBarBackground (CDC* pDC, CBCGPBaseControlBar* pBar, CRect rectClient, CRect /*rectClip*/, BOOL bNCArea) { if (!bNCArea) { CRgn rgn; rgn.CreateRectRgnIndirect (&rectClient); pDC->SelectClipRgn (&rgn); } FillArea (pDC, rectClient, pBar, pBar->IsFloating (), bNCArea); pDC->SelectClipRgn (NULL); }
static void draw_jump_info(char* text) { int x, y, w, h; SetFont(menu_n_font, BLACK); w = StringWidth("999%") + 20; if (StringWidth(text) > w - 10) w = StringWidth(text) + 20; h = (menu_n_font->height * 3) / 2; x = ScreenWidth() - w - 5; y = ScreenHeight() - h - 30; FillArea(x + 1, y + 1, w - 2, h - 2, WHITE); DrawRect(x + 1, y, w - 2, h, BLACK); DrawRect(x, y + 1, w, h - 2, BLACK); DrawTextRect(x, y, w, h, text, ALIGN_CENTER | VALIGN_MIDDLE); PartialUpdateBW(x, y, w, h); }
int main(int argc, char **argv) { char *file = NULL; int Do_Start = 1, tmp; int m, p, i, j, n, nchars, theight, twidth, xclick, yclick; int downx = 1000, downy = 1000, upx, upy; long id, winclick; Real xmax, xmin, ymax, ymin, xdiff, ydiff, xgrid_spacing, ygrid_spacing; Real *x, *y, *nls; LineFunction linetype = StartLine; char axis[100], line[256]; FILE *fd; x = (Real *)malloc(1000000 * sizeof(Real)); y = (Real *)malloc(1000000 * sizeof(Real)); nls = (Real *)malloc(1000 * sizeof(Real)); if (x == NULL || y == NULL || nls == NULL) { fprintf(stderr, "Can't allocate initial memory\n"); exit(1); } ymax = xmax = -HUGE_VAL; ymin = xmin = HUGE_VAL; for (i = 1; i < argc; i++) { if (*argv[i] == '-') { if (!strcmp(argv[i], "-nl")) linetype = StartPoint; else if (argv[i][1] == '\0') /* use stdin */ file = argv[i]; else { fprintf(stderr, "Usage:\n\t %s [options] [file]\n\n", argv[0]); fprintf(stderr, "where options include:\n" " -pt plot with points instead of lines\n\n"); fprintf(stderr, "file name `-' specifies stdin\n" "if no file name is specified, " "the default is \"%s\"\n\n", DEFAULT_DATA_FILE); return EXIT_FAILURE; } } else file = argv[i]; } if (file && !strcmp(file, "-")) { fd = stdin; file = "stdin"; } else { if (file == NULL) file = DEFAULT_DATA_FILE; if ((fd = fopen(file, "r")) == NULL) { fprintf(stderr, "%s: can't open file \"%s\"\n", argv[0], file); return EXIT_FAILURE; } } m = 0; p = 0; while (fgets(line, sizeof(line), fd) != NULL) { if (sscanf(line, "%f %f", &x[m], &y[m]) == 2) { if (x[m] > xmax) xmax = x[m]; else if (x[m] < xmin) xmin = x[m]; if (y[m] > ymax) ymax = y[m]; else if (y[m] < ymin) ymin = y[m]; m++; } else { nls[p] = m; p++; } } nls[p++] = m; if (m == 0) return; signal(SIGTERM, nice_end); signal(SIGSTOP, nice_end); signal(SIGTSTP, nice_end); signal(SIGINT, nice_end); signal(SIGQUIT, nice_end); if (!InitializeGraphics(1)) return EXIT_FAILURE; n = 1; do { axis_round(&xmin, &xmax, &xgrid_spacing); axis_round(&ymin, &ymax, &ygrid_spacing); id = CreateWin(0, 0, GRX_SCALE, GRX_SCALE); if (id == 0) { fprintf(stderr, "Help id = 0\n"); return EXIT_FAILURE; } /* Fill the window in black for real eye-catching graphics! */ ForeColor(0); StartFill(id); FillArea(0, 0, GRX_SCALE, GRX_SCALE); Done(); /* draw outline box in white */ ForeColor(7); /* Draw outline box */ StartLine(id); Extend(1000, 1000); Extend(1000, 9000); Extend(9000, 9000); Extend(9000, 1000); Extend(1000, 1000); Done(); /* Draw the data - either lines or dots */ xdiff = 8000 / (xmax - xmin); ydiff = 8000 / (ymax - ymin); for (i = j = 0; j < p; j++) { int n = 0; ForeColor(j % 6 + 1); while (((x[i] < xmin) || (x[i] > xmax) || (y[i] < ymin) || (y[i] > ymax)) && (i < nls[j])) i++; while (i < nls[j]) { if (n == 0) linetype(id); Extend(1000 + (x[i] - xmin) * xdiff, 9000 - (y[i] - ymin) * ydiff); n++; if (n > 450) { Done(); n = 0; continue; } i++; while ((i < nls[j]) && ((x[i] < xmin) || (x[i] > xmax) || (y[i] < ymin) || (y[i] > ymax))) i++; } if (n > 0) Done(); } /* Do axis labels in black */ ForeColor(7); QueryWin(id, &twidth, &theight); PlaceText(id, GRX_SCALE / 2, 0, HCENTER_TEXT | TOP_TEXT, file); PlaceText(id, GRX_SCALE / 2, GRX_SCALE, HCENTER_TEXT | BOTTOM_TEXT, "X"); PlaceText(id, 0, GRX_SCALE / 2, LEFT_TEXT | VCENTER_TEXT, "Y"); sprintf(axis, "%f", ymax); nchars = 1000 / twidth; axis[nchars] = 0; PlaceText(id, GRX_SCALE / 10, GRX_SCALE / 10, RIGHT_TEXT | TOP_TEXT, axis); sprintf(axis, "%f", ymin); axis[nchars] = 0; PlaceText(id, GRX_SCALE / 10, 9 * GRX_SCALE / 10, RIGHT_TEXT | BOTTOM_TEXT, axis); sprintf(axis, "%f", xmax); PlaceText(id, 9 * GRX_SCALE / 10, 9 * GRX_SCALE / 10, HCENTER_TEXT | TOP_TEXT, axis); sprintf(axis, "%f", xmin); PlaceText(id, GRX_SCALE / 10, 9 * GRX_SCALE / 10, HCENTER_TEXT | TOP_TEXT, axis); fflush(stdout); do { n = WaitForCarriageReturn(&winclick, &xclick, &yclick); switch (n) { case 1: downx = xclick; downy = yclick; break; case 2: upx = xclick; upy = yclick; if (upx < downx) { tmp = downx; downx = upx; upx = tmp; } if (upy < downy) { tmp = downy; downy = upy; upy = tmp; } xmin = (xmax - xmin) * (downx - 1000) / (8000) + xmin; xmax = (xmax - xmin) * (upx - 1000) / (8000) + xmin; ymax = ymax - (ymax - ymin) * (downy - 1000) / (8000); ymin = ymax - (ymax - ymin) * (upy - 1000) / (8000); break; } } while (n && (n != 2)); } while (n); nice_end(EXIT_SUCCESS); return EXIT_SUCCESS; }
static void PaintThumb (ScrollbarWidget sbw, XEvent *event) { Dimension s = sbw->threeD.shadow_width; Position oldtop = sbw->scrollbar.topLoc; Position oldbot = oldtop + sbw->scrollbar.shownLength; Dimension margin = MARGIN (sbw); Dimension tzl = sbw->scrollbar.length - margin - margin; Position newtop, newbot; Position floor = sbw->scrollbar.length - margin; newtop = margin + (int)(tzl * sbw->scrollbar.top); newbot = newtop + (int)(tzl * sbw->scrollbar.shown); if (sbw->scrollbar.shown < 1.) newbot++; if (newbot < newtop + (int)sbw->scrollbar.min_thumb + 2 * (int)sbw->threeD.shadow_width) newbot = newtop + sbw->scrollbar.min_thumb + 2 * sbw->threeD.shadow_width; if ( newbot >= floor ) { newtop = floor-(newbot-newtop)+1; newbot = floor; } sbw->scrollbar.topLoc = newtop; sbw->scrollbar.shownLength = newbot - newtop; if (XtIsRealized ((Widget) sbw)) { /* 3D thumb wanted ? */ if (s) { if (newtop < oldtop) FillArea(sbw, oldtop, oldtop + s, 0); if (newtop > oldtop) FillArea(sbw, oldtop, MIN(newtop, oldbot), 0); if (newbot < oldbot) FillArea(sbw, MAX(newbot, oldtop), oldbot, 0); if (newbot > oldbot) FillArea(sbw, oldbot - s, oldbot, 0); if (sbw->scrollbar.orientation == XtorientHorizontal) { _ShadowSurroundedBox((Widget)sbw, (ThreeDWidget)sbw, newtop, s, newbot, sbw->core.height - s, sbw->threeD.relief, TRUE); } else { _ShadowSurroundedBox((Widget)sbw, (ThreeDWidget)sbw, s, newtop, sbw->core.width - s, newbot, sbw->threeD.relief, TRUE); } } else { /* Note to Mitch: FillArea is (now) correctly implemented to not draw over shadows or the arrows. Therefore setting clipmasks doesn't seem to be necessary. Correct me if I'm wrong! */ if (newtop < oldtop) FillArea(sbw, newtop, MIN(newbot, oldtop), 1); if (newtop > oldtop) FillArea(sbw, oldtop, MIN(newtop, oldbot), 0); if (newbot < oldbot) FillArea(sbw, MAX(newbot, oldtop), oldbot, 0); if (newbot > oldbot) FillArea(sbw, MAX(newtop, oldbot), newbot, 1); } } }
void CImageStyle::OnEraseTabsArea (CDC* pDC, CRect rect, const CBCGPBaseTabWnd* pTabWnd) { ASSERT_VALID (pDC); FillArea (pDC, rect, pTabWnd, FALSE, FALSE); }
/* * DrawAreaWinProc - window procedure for the drawing area window * - this window is an MDI window */ MRESULT CALLBACK DrawAreaWinProc( HWND hwnd, WPI_MSG msg, WPI_PARAM1 wparam, WPI_PARAM2 lparam ) { static WPI_POINT start_pt = { -1, -1 }; static WPI_POINT end_pt = { -1, -1 }; static WPI_POINT prev_pt = { -1, -1 }; static WPI_POINT new_pt = { -1, -1 }; static WPI_POINT pt1; static BOOL flbuttondown = FALSE; static BOOL frbuttondown = FALSE; static BOOL fdraw_shape = FALSE; static BOOL firsttime; static BOOL wasicon; int mousebutton; WPI_POINT pointsize; WPI_POINT pt2; #ifndef __OS2_PM__ CREATESTRUCT *cs; MDICREATESTRUCT *mdi_cs; MINMAXINFO *minmax; #endif img_node *node; int i; switch ( msg ) { case WM_CREATE: #ifndef __OS2_PM__ cs = (CREATESTRUCT __FAR *)lparam; mdi_cs = (MDICREATESTRUCT __FAR *)cs->lpCreateParams; node = (img_node *)mdi_cs->lParam; for( i = 0; i < node->num_of_images; i++ ) { node[i].hwnd = hwnd; } AddImageNode( node ); CreateUndoStack( node ); setTheCursor( -1, hwnd ); wasicon = FALSE; #endif firsttime = TRUE; i = i; return( 0 ); case WM_MDIACTIVATE: if( IMGED_GET_MDI_FACTIVATE( hwnd, wparam, lparam ) ) { if( _wpi_isiconic( hwnd ) ) { wasicon = TRUE; break; } else { wasicon = FALSE; FocusOnImage( hwnd ); } } return( 0 ); #ifndef __OS2_PM__ case WM_GETMINMAXINFO: node = SelectImage( hwnd ); if( node != NULL ) { minmax = (MINMAXINFO *)lparam; minmax->ptMinTrackSize.x = node->width + 2 * _wpi_getsystemmetrics( SM_CXFRAME ); minmax->ptMinTrackSize.y = node->height + 2 * _wpi_getsystemmetrics( SM_CYFRAME ) + _wpi_getsystemmetrics( SM_CYCAPTION ) - 1; } break; #endif case UM_SHOWVIEWWINDOW: ShowViewWindows( hwnd ); return 0; case WM_SIZE: if ( _imgwpi_issizerestored( wparam ) ) { ResizeChild( lparam, hwnd, firsttime ); firsttime = FALSE; if( wasicon ) { FocusOnImage( hwnd ); wasicon = FALSE; } #ifndef __OS2_PM__ } else if ( _imgwpi_issizeminimized( wparam ) ) { node = SelectImage( hwnd ); HideViewWindow( hwnd ); DeleteActiveImage(); ClearImageText(); SendMessage( ClientWindow, WM_MDINEXT, (WPARAM)(LPVOID)hwnd, 0L ); wasicon = TRUE; #endif } return( 0 ); #ifndef __OS2_PM__ case WM_CHAR: pointsize = GetPointSize( hwnd ); if( LOWORD( wparam ) == ESC_CHAR ) { if( !(lparam & 0x40000000) ) { switch( toolType ) { case IMGED_PASTE: fdraw_shape = FALSE; flbuttondown = FALSE; frbuttondown = FALSE; DontPaste( hwnd, &pt1, pointsize ); break; case IMGED_LINE: case IMGED_RECTO: case IMGED_RECTF: case IMGED_CIRCLEO: case IMGED_CIRCLEF: case IMGED_CLIP: if( !flbuttondown && !frbuttondown ) { break; } fdraw_shape = FALSE; flbuttondown = FALSE; frbuttondown = FALSE; if( toolType == IMGED_LINE ) { OutlineLine( hwnd, &start_pt, &prev_pt, &new_pt, TRUE ); } else if( toolType == IMGED_CLIP ) { OutlineClip( hwnd, &start_pt, &prev_pt, &new_pt, TRUE ); SetRectExists( FALSE ); } else { OutlineRegion( hwnd, &start_pt, &prev_pt, &new_pt, TRUE ); } break; default: break; } } } return( 0 ); #endif case WM_MOUSEMOVE: pointsize = GetPointSize( hwnd ); #ifdef __OS2_PM__ WinSetPointer( HWND_DESKTOP, hCursor[cursorIndex] ); #endif IMGED_MAKEPOINT( wparam, lparam, new_pt ); switch( toolType ) { case IMGED_SNAP: #ifndef __OS2_PM__ OutlineSnap(); #endif break; case IMGED_PASTE: pt1.x = new_pt.x / pointsize.x; pt1.y = new_pt.y / pointsize.y; pt2.x = prev_pt.x / pointsize.x; pt2.y = prev_pt.y / pointsize.y; if( pt1.x != pt2.x || pt1.y != pt2.y ) { DragClipBitmap( hwnd, &pt1, pointsize ); } SetPosInStatus( &new_pt, &pointsize, hwnd ); break; case IMGED_FREEHAND: case IMGED_BRUSH: if( flbuttondown ) { Paint( hwnd, &prev_pt, &new_pt, LMOUSEBUTTON ); } else if( frbuttondown ) { Paint( hwnd, &prev_pt, &new_pt, RMOUSEBUTTON ); } SetPosInStatus( &new_pt, &pointsize, hwnd ); break; case IMGED_LINE: case IMGED_RECTO: case IMGED_RECTF: case IMGED_CIRCLEO: case IMGED_CIRCLEF: case IMGED_CLIP: if( flbuttondown || frbuttondown ) { if( new_pt.x / pointsize.x != end_pt.x / pointsize.x || new_pt.y / pointsize.y != end_pt.y / pointsize.y ) { if( toolType == IMGED_LINE ) { OutlineLine( hwnd, &start_pt, &new_pt, &prev_pt, FALSE ); } else if( toolType == IMGED_CLIP ) { OutlineClip( hwnd, &start_pt, &new_pt, &prev_pt, FALSE ); } else { OutlineRegion( hwnd, &start_pt, &new_pt, &prev_pt, FALSE ); } end_pt = new_pt; SetSizeInStatus( hwnd, &start_pt, &new_pt, &pointsize ); } } else { SetPosInStatus( &new_pt, &pointsize, hwnd ); } break; case IMGED_FILL: SetPosInStatus( &new_pt, &pointsize, hwnd ); break; default: SetPosInStatus( &new_pt, &pointsize, hwnd ); break; } prev_pt = new_pt; return( 0 ); case WM_LBUTTONDOWN: case WM_RBUTTONDOWN: pointsize = GetPointSize( hwnd ); SetCapture( hwnd ); if( msg == WM_LBUTTONDOWN ) { if( frbuttondown ) { break; } #ifdef __OS2_PM__ node = GetCurrentNode(); if( hwnd != node->hwnd ) { break; } #endif flbuttondown = TRUE; mousebutton = LMOUSEBUTTON; } else { if( flbuttondown ) { break; } node = GetCurrentNode(); if( hwnd != node->hwnd ) { break; } frbuttondown = TRUE; mousebutton = RMOUSEBUTTON; } fdraw_shape = TRUE; IMGED_MAKEPOINT( wparam, lparam, start_pt ); IMGED_MAKEPOINT( wparam, lparam, new_pt ); switch( toolType ) { case IMGED_SNAP: #ifndef __OS2_PM__ TransferImage( hwnd ); #endif fdraw_shape = FALSE; flbuttondown = FALSE; frbuttondown = FALSE; break; case IMGED_FREEHAND: case IMGED_BRUSH: BeginFreeHand( hwnd ); DrawSinglePoint( hwnd, &start_pt, mousebutton ); break; case IMGED_LINE: IMGED_MAKEPOINT( wparam, lparam, end_pt ); OutlineLine( hwnd, &start_pt, &new_pt, &prev_pt, TRUE ); break; case IMGED_RECTO: case IMGED_RECTF: case IMGED_CIRCLEO: case IMGED_CIRCLEF: IMGED_MAKEPOINT( wparam, lparam, end_pt ); OutlineRegion( hwnd, &start_pt, &new_pt, &prev_pt, TRUE ); break; case IMGED_CLIP: IMGED_MAKEPOINT( wparam, lparam, end_pt ); RedrawPrevClip( hwnd ); OutlineClip( hwnd, &start_pt, &new_pt, &prev_pt, TRUE ); break; case IMGED_FILL: FillArea( &start_pt, mousebutton ); RecordImage( hwnd ); break; case IMGED_HOTSPOT: SetIsSaved( hwnd, FALSE ); prev_pt.x = start_pt.x / pointsize.x; prev_pt.y = start_pt.y / pointsize.y; SetNewHotSpot( &prev_pt ); break; default: break; } prev_pt = new_pt; return 0; case WM_LBUTTONUP: case WM_RBUTTONUP: pointsize = GetPointSize( hwnd ); IMGED_MAKEPOINT( wparam, lparam, end_pt ); IMGED_MAKEPOINT( wparam, lparam, new_pt ); if( msg == WM_LBUTTONUP ) { mousebutton = LMOUSEBUTTON; } else { mousebutton = RMOUSEBUTTON; } if( fdraw_shape ) { switch( toolType ) { case IMGED_PASTE: PasteImage( &start_pt, pointsize, hwnd ); flbuttondown = FALSE; frbuttondown = FALSE; break; case IMGED_FREEHAND: case IMGED_BRUSH: if( flbuttondown || frbuttondown ) { EndFreeHand( hwnd ); RecordImage( hwnd ); } break; case IMGED_LINE: DrawLine( hwnd, &start_pt, &end_pt, mousebutton ); RecordImage( hwnd ); break; case IMGED_RECTO: case IMGED_RECTF: case IMGED_CIRCLEO: case IMGED_CIRCLEF: DisplayRegion( hwnd, &start_pt, &end_pt, mousebutton ); RecordImage( hwnd ); break; case IMGED_CLIP: SetClipRect( hwnd, &start_pt, &end_pt, pointsize ); break; default: break; } fdraw_shape = FALSE; } ReleaseCapture(); flbuttondown = FALSE; frbuttondown = FALSE; prev_pt = new_pt; return( 0 ); case WM_PAINT: RepaintDrawArea( hwnd ); return( 0 ); case WM_QUERYENDSESSION: case WM_CLOSE: if( lastChanceSave( hwnd ) ) { CloseCurrentImage( hwnd ); return( (MRESULT)1 ); } else { return( (MRESULT)0 ); } #ifndef __OS2_PM__ case WM_DESTROY: SetCursor( LoadCursor( NULL, IDC_ARROW ) ); return( 0 ); #endif default: break; } return( _imgwpi_defMDIchildproc( hwnd, msg, wparam, lparam ) ); } /* DrawAreaWinProc */