Example #1
0
/* smooth  != 0 gives continuous not segmented bar */
progressbar newprogressbar(rect r, int pbmin, int pbmax, int incr, int smooth)
{
	HWND hwnd;
	progressbar obj;
	int sm;

	ensure_window();
	r = rcanon(r);
	sm = smooth ? PBS_SMOOTH : 0 ;
	hwnd = CreateWindowEx(0, PROGRESS_CLASS, NULL,
		(WS_CHILD | WS_VISIBLE | sm),
		r.x, r.y, r.width, r.height,
		current_window->handle,
		(HMENU) child_id, this_instance, NULL);
	obj = new_object(ControlObject, hwnd, current_window);
	if (! obj) {
		DestroyWindow(hwnd);
		return NULL;
	}
	obj->die = private_delcontrol;
	obj->rect = r;
	obj->id = child_id++;
	obj->action = NULL;
	obj->state = (Visible | Enabled);
	obj->flags = ChildWindow;
	set_new_winproc(obj); /* set custom winproc */
	settextfont(obj, SystemFont);
	obj->kind = ListboxObject;
	SendMessage(hwnd, PBM_SETRANGE32, (WPARAM) pbmin, (LPARAM) pbmax);
	SendMessage(hwnd, PBM_SETSTEP, (WPARAM) incr, 0);

	return obj;
}
Example #2
0
static object newchildwin(char *kind, char *text,
		unsigned long style, rect r, actionfn fn)
{
	HWND hwnd;
	object obj;

	ensure_window();
	r = rcanon(r);

	hwnd = CreateWindow(kind, text,
		(WS_CHILD | WS_VISIBLE) | style,
		r.x, r.y, r.width, r.height,
		current_window->handle,
		(HMENU) child_id, this_instance, NULL);

	obj = new_object(ControlObject, hwnd, current_window);
	if (! obj) {
		DestroyWindow(hwnd);
		return NULL;
	}
	obj->die = private_delcontrol;
	obj->rect = r;
	obj->id = child_id++;
	obj->action = fn;
	obj->state = (Visible | Enabled);
	obj->flags = ChildWindow;
	obj->text = new_string(text);
	set_new_winproc(obj); /* set custom winproc */
	settextfont(obj, SystemFont);
	return obj;
}
Example #3
0
field newpassword(char *text, rect r)
{
	field obj = newchildwin("edit", NULL,
			WS_BORDER | ES_LEFT | ES_AUTOHSCROLL
			| ES_PASSWORD, r, NULL);
	if (obj) {
		obj->kind = FieldObject;
		settextfont(obj, SystemFont);
		settext(obj, text);
	}
	return obj;
}
Example #4
0
void editorsetfont(font f)
{
    int i, ismod;
    textbox t;
    for (i = 0; i < neditors; i++) {
	t = getdata(REditors[i]);
	ismod = ggetmodified(t);
	/* Don't change the modification flag when changing font  */
	settextfont(t, f);
	gsetmodified(t, ismod);
	show(t);
    }
}
Example #5
0
/*
 *  Create a new static text label. Now implemented using
 *  GraphApp code instead of native MS-Windows "static"
 *  text. This gives more flexibility, better cross-platform
 *  support and there are no 'look and feel' issues with
 *  labels, so no problems are introduced by doing this.
 */
control newlabel(char *text, rect r, int alignment)
{
	control obj = newcontrol(text, r);
	if (obj) {
		obj->kind = LabelObject;
		setredraw(obj, draw_label);
		setvalue(obj, alignment);
		setbackground(obj, getbackground(parentwindow(obj)));
		settextfont(obj, SystemFont);
		show(obj);
	}
	return obj;
}
Example #6
0
static void changeFont(control c)
{
    char fontname[LF_FACESIZE+4];
    
    if (samplefont) delobj(samplefont);
    
    if(ischecked(tt_font)) strcpy(fontname, "TT "); else strcpy(fontname, "");
    
    if (sampleFontNum >= 0) {
    	strcat(fontname,  FontsList[sampleFontNum]);
    } else 
    	strcat(fontname, gettext(f_font));
    
    samplefont = gnewfont(NULL, fontname, sampleStyle, samplePointsize, 0.0, 1);
    settextfont(guisample, samplefont);
    clickColor(c, getlistitem(guicolor));
}
Example #7
0
radiobutton newradiobutton(char *text, rect r, actionfn fn)
{
	radiobutton obj = newcontrol(text, r);
	if (obj) {
		obj->kind = RadioObject;
		setredraw(obj, draw_radio);
		setmousedown(obj, checkbox_mousedown);
		setmousemove(obj, checkbox_mousemove);
		setmousedrag(obj, checkbox_mousemove);
		setmouseup(obj, radio_mouseup);
		setkeydown(obj, radio_keydown);
		setaction(obj, fn);
		setbackground(obj, getbackground(parentwindow(obj)));
		settextfont(obj, SystemFont);
		show(obj);
	}
	return obj;
}
Example #8
0
checkbox newcheckbox(char *text, rect r, actionfn fn)
{
	checkbox obj = newcontrol(text, r);
	if (obj) {
		obj->kind = CheckboxObject;
		setredraw(obj, draw_checkbox);
		setmousedown(obj, checkbox_mousedown);
		setmousemove(obj, checkbox_mousemove);
		setmousedrag(obj, checkbox_mousemove);
		setmouseup(obj, checkbox_mouseup);
		setkeydown(obj, checkbox_keydown);
		setaction(obj, fn);
		setbackground(obj, getbackground(parentwindow(obj)));
		settextfont(obj, SystemFont);
		show(obj);
	}
	return obj;
}
Example #9
0
button newbutton(char *text, rect r, actionfn fn)
{
	button obj = newcontrol(text, r);
	if (obj) {
		obj->kind = ButtonObject;
		setredraw(obj, draw_button);
		setmousedown(obj, button_mousedown);
		setmousemove(obj, button_mousemove);
		setmousedrag(obj, button_mousemove);
		setmouseup(obj, button_mouseup);
		setkeydown(obj, button_keydown);
		setaction(obj, fn);
		setbackground(obj, LightGrey);
		settextfont(obj, SystemFont);
		show(obj);
	}
	return obj;
}
Example #10
0
int main(int argc, char *argv[]) {
    screen(width,height);
    screentitle("PlayWave");
    settextfont("FreeMono.ttf",45);
    setonkey(keyfnc);
    run_async(sndPlayer,NULL);
    while(1) {
        fillrect(0,0,width,height,0);
        drawtext( "Press Something",0 ,0,0xf0ffff00);
        if(keystate==1){
            inchz();
        }
        else if(keystate == -1){
            dechz();
        }
        generateWave();
        drawwav();
        drawtext(keymsg_buf ,0,45,0xf0ffff00);        
        flushscreen();
    }
    return 0;
}
Example #11
0
button newimagecheckbox(image img, rect r, actionfn fn)
{
	button obj;

	obj = newdrawing(r, draw_image_button);
	if (! obj)
		return NULL;

	setmousedown(obj, checkbox_mousedown);
	setmousemove(obj, checkbox_mousemove);
	setmousedrag(obj, checkbox_mousemove);
	setmouseup(obj, checkbox_mouseup);
	setkeydown(obj, checkbox_keydown);
	setaction(obj, fn);
	setbackground(obj, LightGrey);
	settextfont(obj, SystemFont);

	setimage(obj, img);

	show(obj);
	return obj;
}
Example #12
0
button newimagebutton(image img, rect r, actionfn fn)
{
	button obj;

	obj = newcontrol(NULL, r);
	if (! obj)
		return NULL;

	setredraw(obj, draw_image_button);
	setmousedown(obj, button_mousedown);
	setmousemove(obj, button_mousemove);
	setmousedrag(obj, button_mousemove);
	setmouseup(obj, button_mouseup);
	setkeydown(obj, button_keydown);
	setaction(obj, fn);
	setbackground(obj, LightGrey);
	settextfont(obj, SystemFont);

	setimage(obj, img);

	show(obj);
	return obj;
}
Example #13
0
static editor neweditor(void)
{
    int x, y, w, h, w0, h0;
    editor c;
    menuitem m;
    textbox t;
    long flags;
    font editorfn = (consolefn ? consolefn : FixedFont);
    EditorData p = neweditordata(0, NULL);
    DWORD rand;

    w = (pagercol + 1)*fontwidth(editorfn);
    h = (pagerrow + 1)*fontheight(editorfn) + 1;
#ifdef USE_MDI
    if(ismdi()) {
	RECT *pR = RgetMDIsize();
	w0 = pR->right;
	h0 = pR->bottom;
    } else {
#endif
	w0 = devicewidth(NULL);
	h0 = deviceheight(NULL);
#ifdef USE_MDI
    }
#endif
    x = (w0 - w) / 2; x = x > 20 ? x : 20;
    y = (h0 - h) / 2; y = y > 20 ? y : 20;
    rand = GetTickCount();
    w0 = 0.4*x; h0 = 0.4*y;
    w0 = w0 > 20 ? w0 : 20;
    h0 = h0 > 20 ? h0 : 20;
    x += (rand % w0) - w0/2;
    y += ((rand/w0) % h0) - h0/2;
    flags = StandardWindow | Menubar;
#ifdef USE_MDI
    if (ismdi()) flags |= Document;
#endif
    c = (editor) newwindow("", rect(x, y, w, h), flags);
    t = newrichtextarea(NULL, rect(0, 0, w, h));
    setdata(c, t);
    setdata(t, p);

    gsetcursor(c, ArrowCursor);
    setforeground(c, guiColors[editorfg]);
    setbackground(c, guiColors[editorbg]);
    setbackground(t, guiColors[editorbg]);
    
#ifdef USE_MDI
    if (ismdi() && (RguiMDI & RW_TOOLBAR)) {
	int btsize = 24;
	rect r = rect(2, 2, btsize, btsize);
	control tb, bt;
	addto(c);
	MCHECK(tb = newtoolbar(btsize + 4));
	addto(tb);
	MCHECK(bt = newtoolbutton(open_image, r, menueditoropen));
	MCHECK(addtooltip(bt, G_("Open script")));
	setdata(bt, c);
	r.x += (btsize + 1) ;
	MCHECK(bt = newtoolbutton(save_image, r, menueditorsave));
	MCHECK(addtooltip(bt,  G_("Save script")));
	setdata(bt, c);
	r.x += (btsize + 6);
	MCHECK(bt = newtoolbutton(copy1_image, r, menueditorrun));
	MCHECK(addtooltip(bt, G_("Run line or selection")));
	setdata(bt, t);
	r.x += (btsize + 6);
	MCHECK(bt = newtoolbutton(console_image, r, editorconsole));
	MCHECK(addtooltip(bt, G_("Return focus to Console")));
	r.x += (btsize + 6);
	MCHECK(bt = newtoolbutton(print_image, r, editorprint));
	MCHECK(addtooltip(bt, G_("Print script")));
	setdata(bt, t);
	MCHECK(addtooltip(bt, G_("Print")));
    }
#endif
    addto(c);
    /* Right-click context menu */
    MCHECK(m = gpopup(editormenuact, EditorPopup));
    setdata(m, t);
    setdata(EditorPopup[0].m, t);
    setdata(EditorPopup[2].m, t);
    setdata(p->mpopcut = EditorPopup[4].m, t);
    setdata(p->mpopcopy = EditorPopup[5].m, t);
    setdata(EditorPopup[6].m, t);
    setdata(p->mpopdelete = EditorPopup[7].m, t);
    setdata(EditorPopup[9].m, t);

    addto(c);
    MCHECK(m = newmenubar(editormenuact));
    setdata(m, t);
    MCHECK(newmenu(G_("File")));
    MCHECK(m = newmenuitem(G_("New script"), 'N', menueditornew));
    setdata(m, c);
    MCHECK(m = newmenuitem(G_("Open script..."), 'O', menueditoropen));
    setdata(m, c);
    MCHECK(m = newmenuitem(G_("Save"), 'S', menueditorsave));
    setdata(m, c);
    MCHECK(m = newmenuitem(G_("Save as..."), 0, menueditorsaveas));
    setdata(m, c);
    MCHECK(m = newmenuitem("-", 0, NULL));
    MCHECK(m = newmenuitem(G_("Print..."), 0, editorprint));
    setdata(m, t);
    MCHECK(m = newmenuitem("-", 0, NULL));
    MCHECK(m = newmenuitem(G_("Close script"), 0, menueditorclose));
    setdata(m, c);
    MCHECK(newmenu(G_("Edit")));
    MCHECK(m = newmenuitem(G_("Undo"), 'Z', editorundo));
    setdata(m, t);
    MCHECK(m = newmenuitem("-", 0, NULL));
    MCHECK(p->mcut = newmenuitem(G_("Cut"), 'X', editorcut));
    setdata(p->mcut, t);
    MCHECK(p->mcopy = newmenuitem(G_("Copy"), 'C', editorcopy));
    setdata(p->mcopy, t);
    MCHECK(m = newmenuitem(G_("Paste"), 'V', editorpaste));
    setdata(m, t);
    MCHECK(p->mdelete = newmenuitem(G_("Delete"), 0, editordelete));
    setdata(p->mdelete, t);
    MCHECK(m = newmenuitem(G_("Select all"), 'A', editorselectall));
    setdata(m, t);
    MCHECK(newmenuitem(G_("Clear console"), 'L', menuclear));
    MCHECK(m = newmenuitem("-", 0, NULL));
    MCHECK(m = newmenuitem(G_("Run line or selection"), 'R', menueditorrun));
    setdata(m, t);
    MCHECK(m = newmenuitem(G_("Run all"), 0, editorrunall));
    setdata(m, t);
    MCHECK(m = newmenuitem("-", 0, NULL));
    MCHECK(p->mfind = newmenuitem(G_("Find..."), 'F', editorfind));
    setdata(p->mfind, t);
    MCHECK(p->mreplace = newmenuitem(G_("Replace..."), 'H', editorreplace));
    setdata(p->mreplace, t);
    MCHECK(m = newmenuitem("-", 0, NULL));
    MCHECK(newmenuitem(G_("GUI preferences..."), 0, menuconfig));

    /* Packages menu should go here */
    p->pmenu = (PkgMenuItems) malloc(sizeof(struct structPkgMenuItems));
    RguiPackageMenu(p->pmenu);

#ifdef USE_MDI
    newmdimenu(); /* Create and fill the 'Window' menu */
#endif

    MCHECK(m = newmenu(G_("Help")));
    MCHECK(newmenuitem(G_("Editor"), 0, menueditorhelp));
    MCHECK(newmenuitem("-", 0, NULL));
    p->hmenu = (HelpMenuItems) malloc(sizeof(struct structHelpMenuItems));
    RguiCommonHelp(m, p->hmenu);

    settextfont(t, editorfn);
    setforeground(t, guiColors[editorfg]);    
    setresize(c, editorresize);
    setclose(c, editorclose);
    setdel(c, editordel);
    setdel(t, textboxdel);
    setonfocus(c, editorfocus);
    setkeyaction(t, editorcontrolkeydown);
    setkeydown(t, editorasciikeydown);

    /* Store pointer to new editor in global array */
    REditors[neditors] = c;
    ++neditors;
    return c;
}