Example #1
0
LRESULT CALLBACK
frameproc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	switch(message)
	{
	case WM_SETFOCUS:
		PostMessage(hwnd, WM_APP+5, 0, 0);
		return 0;
	case WM_APP+5:
		SetFocus(hwndview);
		return 0;

	case WM_DESTROY:
		PostQuitMessage(0);
		return 0;

	case WM_SYSCOMMAND:
		if (wParam == ID_ABOUT)
		{
			winhelp(&gapp);
			return 0;
		}
		if (wParam == ID_DOCINFO)
		{
			info();
			return 0;
		}
		if (wParam == SC_MAXIMIZE)
			gapp.shrinkwrap = 0;
		break;

	case WM_SIZE:
	{
		// More generally, you should use GetEffectiveClientRect
		// if you have a toolbar etc.
		RECT rect;
		GetClientRect(hwnd, &rect);
		MoveWindow(hwndview, rect.left, rect.top,
		rect.right-rect.left, rect.bottom-rect.top, TRUE);
		return 0;
	}

	case WM_SIZING:
		gapp.shrinkwrap = 0;
		break;

	case WM_NOTIFY:
	case WM_COMMAND:
		return SendMessage(hwndview, message, wParam, lParam);

	case WM_CLOSE:
		if (!pdfapp_preclose(&gapp))
			return 0;
	}

	return DefWindowProc(hwnd, message, wParam, lParam);
}
Example #2
0
int winloop()
{
    int x, y, c, marked, t0, inited;
    x= 10;
    y= 8;
    inited= 0; 
    marked= 0; 
    t0=time(0);
    steps=0;
    while(1) {
        c= igetkey();
			//system("echo start_winloop_igetkey >> /home/bbs/stiger.test");
		steps++;
		if(c=='q' || c==Ctrl('C')) return 0;
        if((c==KEY_UP||c=='k')&&y>1) y--;
        if((c==KEY_DOWN||c=='j')&&y<16) y++;
        if((c==KEY_LEFT||c=='h')&&x>1) x--;
        if((c==KEY_RIGHT||c=='l')&&x<30) x++;
        move(20,0);
        prints("й╠╪Д: %d ", time(0)-t0);
        move(21,0);
        prints("вЬ╠Й: %3d, %3d", x, y);
        move(y-1,x*2-2);
//modified by stiger,2001,6,12,╦дуЩmarkedмЁ╪ф╣д╢МнС
        if(ganyingshi)
        {
        	marknum=o[x-1][y-1]+o[x-1][y]+o[x-1][y+1]+o[x][y-1]+o[x][y+1]+o[x+1][y-1]+o[x+1][y]+o[x+1][y+1];
        	if((m[x][y]!=1)&&(num_mine_beside(x, y)==8-marknum)) {
        	    	if(o[x-1][y-1]!=1) { if(!m[x-1][y-1]) {m[x-1][y-1]=1;   marked++; }  winsh(x-1,y-1);}     	
        		if(o[x-1][y]!=1) { if(!m[x-1][y]) {m[x-1][y]=1;   marked++; } winsh(x-1,y);}     	
        		if(o[x-1][y+1]!=1) { if(!m[x-1][y+1]) {m[x-1][y+1]=1;   marked++;}  winsh(x-1,y+1);}     	
        		if(o[x][y-1]!=1) { if(!m[x][y-1]) {m[x][y-1]=1;   marked++; } winsh(x,y-1);}     	
        		if(o[x][y+1]!=1) { if(!m[x][y+1]) {m[x][y+1]=1;   marked++;}  winsh(x,y+1);}
        		if(o[x+1][y-1]!=1) { if(!m[x+1][y-1]) {m[x+1][y-1]=1;   marked++;}  winsh(x+1,y-1);}     	
        		if(o[x+1][y]!=1) { if(!m[x+1][y]) {m[x+1][y]=1;   marked++;}  winsh(x+1,y);}     	
         		if(o[x+1][y+1]!=1) { if(!m[x+1][y+1]) {m[x+1][y+1]=1;   marked++;}  winsh(x+1,y+1);}     	
        	}
        	if(num_mine_beside(x, y)==num_mark_beside(x, y)) dblclick(x,y); 
        }
//add by stiger,2001,6,12,╦дуЩmarkedотй╬╣днйлБ
        move(20,30);
        prints("╠Й╪г: %d ", marked);
//add end
        if(c=='H') winhelp();
        if(c=='d'|| c=='D') winrefresh();
        if(c=='f'|| c=='F'){
             if(!inited) {
                  wininit(x, y);
                  inited= 1;
             } 
             dig(x, y);      
        } 
        if((c==83|| c==115)&&!o[x][y]) {
             if(m[x][y]){
                  m[x][y]=0;
                  marked--;
             } else {
                  m[x][y]=1;
                  marked++;
             }
             winsh(x, y);
//add by stiger,2001,6,12
        	move(20,30);
        	prints("╠Й╪г: %d ", marked);
//add end
        }
        if(checkwin()==1) {
            /*add by stiger*/
            stiger=steps*1.0/(time(0)-t0);
            move(22,0);
            prints("вё╨ьдЦё║дЦЁи╧╕акё║ф╫╬Ыц©цК%lf╡╫",stiger);
            gameover= 0;
 	    	win_checkrec(time(0)-t0);/* added by soff ╫Ьппеепп╪Л╡И */
            return 1;
        }
        if(gameover) {
            move(22,0);
            prints("╨эре╨╤ё╛дЦй╖╟эак... тыю╢р╩╢н╟иё║                                 ");
            gameover= 0;
            return 1;
        }
        move(y-1,x*2-2);
        refresh();
    }
	return 1;
}
Example #3
0
void
winloop()
{
	int x, y, c, marked, t0, inited;
	char buf[100];
	x = 10;
	y = 8;
	inited = 0;
	marked = 0;
	clearbuf();
	t0 = time(0);
	while (1) {
		c = egetch();
		if (c == 257 && y > 1)
			y--;
		if (c == 258 && y < 16)
			y++;
		if (c == 260 && x > 1)
			x--;
		if (c == 259 && x < 30)
			x++;
		move(0, 20);
		sprintf(buf, "ʱ¼ä: %d ", (int) (time(0) - t0));
		prints(buf);
		move(40, 20);
		sprintf(buf, "񈬀: %d ", marked);
		prints(buf);
		move(0, 22);
		sprintf(buf, "×ø±ê: %3d, %3d", x, y);
		prints(buf);
		move(x * 2 - 2, y - 1);
		if (c == 'h' || c == 'H')
			winhelp();
		if (c == 'd' || c == 'D')
			winrefresh();
		if (c == 'a' || c == 'A') {
			if (!inited) {
				wininit(x, y);
				inited = 1;
			}
			dig(x, y);
		}
		if ((c == 83 || c == 115) && !o[x][y]) {
			if (m[x][y]) {
				m[x][y] = 0;
				marked--;
			} else {
				m[x][y] = 1;
				marked++;
			}
			winsh(x, y);
		}
		if (checkwin() == 1) {
			move(0, 22);
			prints("×£ºØÄ㣡Äã³É¹¦ÁË£¡                    ");
			{
				char buf[100];
				sprintf(buf, "finished in %d s.",
					(int) (time(0) - t0));
				win_checkrec(time(0) - t0);
				winminelog(buf);
			}
			gameover = 0;
			return;
		}
		if (gameover) {
			move(0, 22);
			prints("ºÜÒź¶£¬Äãʧ°ÜÁË... ÔÙÀ´Ò»´Î°É£¡    ");
			{
				char buf[100];
				sprintf(buf, "failed in %d s.",
					(int) (time(0) - t0));
				winminelog(buf);
			}
			gameover = 0;
			return;
		}
		move(x * 2 - 2, y - 1);
		refresh();
	}
}
Example #4
0
void pdfapp_onkey(pdfapp_t *app, int c)
{
	int oldpage = app->pageno;
	enum panning panto = PAN_TO_TOP;
	int loadpage = 1;

	if (app->isediting)
	{
		int n = strlen(app->search);
		if (c < ' ')
		{
			if (c == '\b' && n > 0)
			{
				app->search[n - 1] = 0;
				winrepaintsearch(app);
			}
			if (c == '\n' || c == '\r')
			{
				app->isediting = 0;
				if (n > 0)
				{
					winrepaintsearch(app);
					pdfapp_onkey(app, 'n');
				}
				else
					winrepaint(app);
			}
			if (c == '\033')
			{
				app->isediting = 0;
				winrepaint(app);
			}
		}
		else
		{
			if (n + 2 < sizeof app->search)
			{
				app->search[n] = c;
				app->search[n + 1] = 0;
				winrepaintsearch(app);
			}
		}
		return;
	}

	/*
	 * Save numbers typed for later
	 */

	if (c >= '0' && c <= '9')
	{
		app->number[app->numberlen++] = c;
		app->number[app->numberlen] = '\0';
	}

	switch (c)
	{

	case '?':
		winhelp(app);
		break;

	case 'q':
		winclose(app);
		break;

	/*
	 * Zoom and rotate
	 */

	case '+':
	case '=':
		app->resolution *= ZOOMSTEP;
		if (app->resolution > MAXRES)
			app->resolution = MAXRES;
		pdfapp_showpage(app, 0, 1, 1);
		break;
	case '-':
		app->resolution /= ZOOMSTEP;
		if (app->resolution < MINRES)
			app->resolution = MINRES;
		pdfapp_showpage(app, 0, 1, 1);
		break;

	case 'L':
		app->rotate -= 90;
		pdfapp_showpage(app, 0, 1, 1);
		break;
	case 'R':
		app->rotate += 90;
		pdfapp_showpage(app, 0, 1, 1);
		break;

	case 'c':
		app->grayscale ^= 1;
		pdfapp_showpage(app, 0, 1, 1);
		break;

#ifndef NDEBUG
	case 'a':
		app->rotate -= 15;
		pdfapp_showpage(app, 0, 1, 1);
		break;
	case 's':
		app->rotate += 15;
		pdfapp_showpage(app, 0, 1, 1);
		break;
#endif

	/*
	 * Pan view, but dont need to repaint image
	 */

	case 'w':
		app->shrinkwrap = 1;
		app->panx = app->pany = 0;
		pdfapp_showpage(app, 0, 0, 1);
		break;

	case 'h':
		app->panx += app->image->w / 10;
		pdfapp_showpage(app, 0, 0, 1);
		break;

	case 'j':
		app->pany -= app->image->h / 10;
		pdfapp_showpage(app, 0, 0, 1);
		break;

	case 'k':
		app->pany += app->image->h / 10;
		pdfapp_showpage(app, 0, 0, 1);
		break;

	case 'l':
		app->panx -= app->image->w / 10;
		pdfapp_showpage(app, 0, 0, 1);
		break;

	/*
	 * Page navigation
	 */

	case 'g':
	case '\n':
	case '\r':
		if (app->numberlen > 0)
			app->pageno = atoi(app->number);
		else
			app->pageno = 1;
		break;

	case 'G':
		app->pageno = app->pagecount;
		break;

	case 'm':
		if (app->numberlen > 0)
		{
			int idx = atoi(app->number);

			if (idx >= 0 && idx < nelem(app->marks))
				app->marks[idx] = app->pageno;
		}
		else
		{
			if (app->histlen + 1 == 256)
			{
				memmove(app->hist, app->hist + 1, sizeof(int) * 255);
				app->histlen --;
			}
			app->hist[app->histlen++] = app->pageno;
		}
		break;

	case 't':
		if (app->numberlen > 0)
		{
			int idx = atoi(app->number);

			if (idx >= 0 && idx < nelem(app->marks))
				if (app->marks[idx] > 0)
					app->pageno = app->marks[idx];
		}
		else if (app->histlen > 0)
			app->pageno = app->hist[--app->histlen];
		break;

	/*
	 * Back and forth ...
	 */

	case ',':
		panto = PAN_TO_BOTTOM;
		if (app->numberlen > 0)
			app->pageno -= atoi(app->number);
		else
			app->pageno--;
		break;

	case '.':
		panto = PAN_TO_TOP;
		if (app->numberlen > 0)
			app->pageno += atoi(app->number);
		else
			app->pageno++;
		break;

	case 'b':
		panto = DONT_PAN;
		if (app->numberlen > 0)
			app->pageno -= atoi(app->number);
		else
			app->pageno--;
		break;

	case ' ':
		panto = DONT_PAN;
		if (app->numberlen > 0)
			app->pageno += atoi(app->number);
		else
			app->pageno++;
		break;

	case '<':
		panto = PAN_TO_TOP;
		app->pageno -= 10;
		break;
	case '>':
		panto = PAN_TO_TOP;
		app->pageno += 10;
		break;

	/*
	 * Reloading the file...
	 */

	case 'r':
		panto = DONT_PAN;
		oldpage = -1;
		winreloadfile(app);
		break;

	/*
	 * Searching
	 */

	case '/':
		app->isediting = 1;
		app->search[0] = 0;
		app->hit = -1;
		app->hitlen = 0;
		winrepaintsearch(app);
		break;

	case 'n':
		pdfapp_searchforward(app, &panto);
		loadpage = 0;
		break;

	case 'N':
		pdfapp_searchbackward(app, &panto);
		loadpage = 0;
		break;

	}

	if (c < '0' || c > '9')
		app->numberlen = 0;

	if (app->pageno < 1)
		app->pageno = 1;
	if (app->pageno > app->pagecount)
		app->pageno = app->pagecount;

	if (app->pageno != oldpage)
	{
		switch (panto)
		{
		case PAN_TO_TOP:
			app->pany = 0;
			break;
		case PAN_TO_BOTTOM:
			app->pany = -2000;
			break;
		case DONT_PAN:
			break;
		}
		pdfapp_showpage(app, loadpage, 1, 1);
	}
}
Example #5
0
int winloop()
{
    int x, y, c, marked, t0, inited;
    char buf[100];
    x= 10;
    y= 8;
    inited= 0; 
    marked= 0; 
    clearbuf();
    t0= time(0);
    while(1) {
        c= egetch();
        if((c==257||c=='k')&&y>1) y--;
        if((c==258||c=='j')&&y<16) y++;
        if((c==260||c=='h')&&x>1) x--;
        if((c==259||c=='l')&&x<30) x++;
        move(0, 20);
        //% sprintf(buf, "时间: %ld ", time(0)-t0);
        sprintf(buf, "\xca\xb1\xbc\xe4: %ld ", time(0)-t0);
        prints(buf);
        move(40, 20);
        //% sprintf(buf, "标记: %d ", marked);
        sprintf(buf, "\xb1\xea\xbc\xc7: %d ", marked);
        prints(buf);
        move(0, 21);
        //% sprintf(buf, "坐标: %3d, %3d", x, y);
        sprintf(buf, "\xd7\xf8\xb1\xea: %3d, %3d", x, y);
        prints(buf);
        move(x*2-2, y-1);
        if(c=='H') winhelp();
        if(c=='d'|| c=='D') winrefresh();
        if(c=='f'|| c=='F'){
             if(!inited) {
                  wininit(x, y);
                  inited= 1;
             } 
             dig(x, y);      
        } 
        if((c==83|| c==115)&&!o[x][y]) {
             if(m[x][y]){
                  m[x][y]=0;
                  marked--;
             } else {
                  m[x][y]=1;
                  marked++;
             }
             winsh(x, y);
        }
        if(checkwin()==1) {
            move(0, 22);
            //% prints("祝贺你!你成功了!                    ");
            prints("\xd7\xa3\xba\xd8\xc4\xe3\xa3\xa1\xc4\xe3\xb3\xc9\xb9\xa6\xc1\xcb\xa3\xa1                    ");
            {  char buf[100];
               sprintf(buf, "finished in %ld s.", time(0)-t0);
               syslog(buf);
            }
            gameover= 0;
 	    win_checkrec(time(0)-t0);/* added by soff 进行排行检查 */
            return;
        }
        if(gameover) {
            move(0, 22);
            //% prints("很遗憾,你失败了... 再来一次吧!                                 ");
            prints("\xba\xdc\xd2\xc5\xba\xb6\xa3\xac\xc4\xe3\xca\xa7\xb0\xdc\xc1\xcb... \xd4\xd9\xc0\xb4\xd2\xbb\xb4\xce\xb0\xc9\xa3\xa1                                 ");
            {  char buf[100];
               sprintf(buf, "failed in %ld s.", time(0)-t0);
               syslog(buf);
            }
            gameover= 0;
            return;
        }
        move(x*2-2, y-1);
        refresh();
    }
}