コード例 #1
0
ファイル: childwnd.cpp プロジェクト: eiginn/waste
int handleDialogSizeMsgs(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM /*lParam*/, dlgSizeInfo *inf)
{
	char tmp[512];
	#define READINT(d,x,y) sprintf(tmp,"%s_" x,inf->name); (d) = g_config->ReadInt(tmp,(y))
	#define WRITEINT(x,y) sprintf(tmp,"%s_" x,inf->name); g_config->WriteInt(tmp,y)
	if (uMsg == WM_INITDIALOG) {
		int w,h,x,y;
		READINT(w,"width",inf->defw);
		READINT(h,"height",inf->defh);
		READINT(x,"x",inf->defx);
		READINT(y,"y",inf->defy);

		if (w>0&&h>0) {
			SetWindowPos(hwndDlg,NULL,x,y,w,h,SWP_NOACTIVATE|SWP_NOZORDER);
		};
	}
	else if (uMsg == WM_MOVE) {
		WINDOWPLACEMENT wp={sizeof(wp),};
		GetWindowPlacement(hwndDlg,&wp);
		if (wp.showCmd != SW_SHOWMAXIMIZED && wp.showCmd != SW_SHOWMINIMIZED) {
			RECT r;
			GetWindowRect(hwndDlg,&r);
			WRITEINT("x",r.left);
			WRITEINT("y",r.top);
		};
	}
	else if (uMsg == WM_SIZE) {
		if (wParam == SIZE_MAXIMIZED) {
			WRITEINT("maximized",1);
		};
		if (wParam == SIZE_RESTORED) {
			WINDOWPLACEMENT wp={sizeof(wp),};
			GetWindowPlacement(hwndDlg,&wp);
			if (wp.showCmd != SW_SHOWMAXIMIZED) {
				ShowWindow(hwndDlg,SW_SHOW);
				ShowWindow(hwndDlg,SW_RESTORE);
				WRITEINT("maximized",0);
			};
		};
		int m;
		READINT(m,"maximized",0);
		if (!m) {
			WINDOWPLACEMENT wp={sizeof(wp),};
			GetWindowPlacement(hwndDlg,&wp);
			if (wp.showCmd != SW_SHOWMAXIMIZED && wp.showCmd != SW_SHOWMINIMIZED) {
				RECT r;
				GetWindowRect(hwndDlg,&r);
				WRITEINT("width",r.right-r.left);
				WRITEINT("height",r.bottom-r.top);
			};
		};
	};
	return 0;
#undef READINT
#undef WRITEINT
}
コード例 #2
0
ファイル: init.c プロジェクト: rdebath/sgt
static void signalpipe_readdata(sel_rfd *rfd, void *vdata, size_t len)
{
    struct init_ctx *ctx = (struct init_ctx *)sel_rfd_get_ctx(rfd);
    int status;
    pid_t pid;

    while ((pid = waitpid(-1, &status, WNOHANG)) > 0) {
	if (pid == ctx->child_pid && (WIFEXITED(pid) || WIFSIGNALED(pid))) {
	    /*
	     * The main child process has terminated. Send its
	     * exit code.
	     */
	    unsigned char intbuf[4];
	    WRITEINT(intbuf, status);
	    protowrite(ctx->control_wfd, CMD_EXITCODE,
		       intbuf, 4, (void *)NULL);

	    ctx->got_exitcode = 1;
	}
    }
}
コード例 #3
0
ファイル: love.c プロジェクト: geekyfox/digiart
void write_header(FILE* f, int width, int height) {
	int byte_width = width * 3;
	while (byte_width % 4) byte_width++;
	int bitmap_size = byte_width * height;
	WRITESHO(0x4D42);
	WRITEINT(bitmap_size + 54);
	WRITEINT(0);
	WRITEINT(54);
	WRITEINT(40);
	WRITEINT(width);
	WRITEINT(height);
	WRITESHO(1);
	WRITESHO(24);
	WRITEINT(0);
	WRITEINT(bitmap_size);
	WRITEINT(2835);
	WRITEINT(2835);
	WRITEINT(0);
	WRITEINT(0);
}
コード例 #4
0
ファイル: x_misc.c プロジェクト: danomatika/ofxPd
static void oscformat_list(t_oscformat *x, t_symbol *s, int argc, t_atom *argv)
{
    int typeindex = 0, j, msgindex, msgsize, datastart, ndata;
    t_atom *msg;
    char *sp, *formatp = x->x_format->s_name, typecode;
        /* pass 1: go through args to find overall message size */
    for (j = ndata = 0, sp = formatp, msgindex = 0; j < argc;)
    {
        if (*sp)
            typecode = *sp++;
        else if (argv[j].a_type == A_SYMBOL)
            typecode = 's';
        else typecode = 'f';
        if (typecode == 's')
            msgindex += ROUNDUPTO4(strlen(argv[j].a_w.w_symbol->s_name) + 1);
        else if (typecode == 'b')
        {
            int blobsize = 0x7fffffff, blobindex;
                /* check if we have a nonnegative size field */
            if (argv[j].a_type == A_FLOAT &&
                (int)(argv[j].a_w.w_float) >= 0)
                    blobsize = (int)(argv[j].a_w.w_float);
            if (blobsize > argc - j - 1)
                blobsize = argc - j - 1;    /* if no or bad size, eat it all */
            msgindex += 4 + ROUNDUPTO4(blobsize);
            j += blobsize;
        }
        else msgindex += 4;
        j++;
        ndata++;
    }
    datastart = (int)(ROUNDUPTO4(strlen(x->x_pathbuf)+1) + ROUNDUPTO4(ndata + 2));
    msgsize = datastart + msgindex;
    msg = (t_atom *)alloca(msgsize * sizeof(t_atom));
    putstring(msg, &typeindex, x->x_pathbuf);
    SETFLOAT(&msg[typeindex], ',');
    typeindex++;
        /* pass 2: fill in types and data portion of packet */
    for (j = 0, sp = formatp, msgindex = datastart; j < argc;)
    {
        if (*sp)
            typecode = *sp++;
        else if (argv[j].a_type == A_SYMBOL)
            typecode = 's';
        else typecode = 'f';
        SETFLOAT(&msg[typeindex], typecode & 0xff);
        typeindex++;
        if (typecode == 'f')
        {
            union
            {
                float z_f;
                uint32_t z_i;
            } z;
            z.z_f = atom_getfloat(&argv[j]);
            WRITEINT(msg+msgindex, z.z_i);
            msgindex += 4;
        }
        else if (typecode == 'i')
        {
            int dat = atom_getfloat(&argv[j]);
            WRITEINT(msg+msgindex, dat);
            msgindex += 4;
        }
        else if (typecode == 's')
            putstring(msg, &msgindex, argv[j].a_w.w_symbol->s_name);
        else if (typecode == 'b')
        {
            int blobsize = 0x7fffffff, blobindex;
            if (argv[j].a_type == A_FLOAT &&
                (int)(argv[j].a_w.w_float) >= 0)
                    blobsize = (int)(argv[j].a_w.w_float);
            if (blobsize > argc - j - 1)
                blobsize = argc - j - 1;
            WRITEINT(msg+msgindex, blobsize);
            msgindex += 4;
            for (blobindex = 0; blobindex < blobsize; blobindex++)
                SETFLOAT(msg+msgindex+blobindex,
                    (argv[j+1+blobindex].a_type == A_FLOAT ?
                        argv[j+1+blobindex].a_w.w_float :
                        (argv[j+1+blobindex].a_type == A_SYMBOL ?
                            argv[j+1+blobindex].a_w.w_symbol->s_name[0] & 0xff :
                            0)));
            j += blobsize;
            while (blobsize & 3)
                SETFLOAT(msg+msgindex+blobsize, 0), blobsize++;
            msgindex += blobsize;
        }
        j++;
    }
    SETFLOAT(&msg[typeindex], 0);
    typeindex++;
    while (typeindex & 3)
        SETFLOAT(&msg[typeindex], 0), typeindex++;
    if (typeindex != datastart || msgindex != msgsize)
        bug("oscformat: typeindex %d, datastart %d, msgindex %d, msgsize %d",
            typeindex, datastart, msgindex, msgsize);
    /* else post("datastart %d, msgsize %d", datastart, msgsize); */
    outlet_list(x->x_obj.ob_outlet, 0, msgsize, msg);
}