Ejemplo n.º 1
0
listbox newdropfield(char *list[], rect r, scrollfn fn)
{
	listbox obj;
	int h, i;

	initapp(0,0);
	h = getheight(SystemFont);
	r.height = h+h;
	for (i = 0; list && list[i]; i++)
		r.height += h;

	obj = newchildwin("combobox", NULL,
			  CBS_DROPDOWN |
			  // CBS_DISABLENOSCROLL |
			  WS_BORDER |
			  WS_VSCROLL | WS_HSCROLL,
			  r, NULL);
	if (! obj)
		return obj;
	obj->kind = DroplistObject;
	obj->hit = fn;

	changelistbox(obj, list);

	return obj;
}
Ejemplo n.º 2
0
const char *drawtext(rect r, int alignment, const char *s)
{
    int h;
    int nlines;
    int line_height;
    int u = 0;
    rect clip;
    const char *remains;
    char line[256];

    initapp(0,0);
    if (! s) return (char *) NULL;
    if (! current->fnt)
	current->fnt = SystemFont;

    clip = getcliprect();
    setcliprect(r);

    line_height = getheight(current->fnt);

    if ((alignment & VCenter) == VCenter) {
	h = textheight(r.width, s);
	if (h < r.height)
	    r.y += (r.height-h)/2;
    }
    else if ((alignment & VJustify) == VJustify) {
	h = textheight(r.width, s);
	if (h < r.height) {
	    nlines = h / line_height;
	    if (nlines > 1)
		line_height += ((r.height-h) / (nlines-1));
	}
    }
    else if ((alignment & AlignBottom) == AlignBottom) {
	h = textheight(r.width, s);
	if (h < r.height)
	    r.y += (r.height-h);
    }

    u = (alignment & Underline);

    if ((alignment & Center) == Center)
	remains = draw_text_centered(line, r, line_height, u, s);
    else if ((alignment & Justify) == Justify)
	remains = draw_text_justified(line, r, line_height, u, s);
    else if ((alignment & AlignRight) == AlignRight)
	remains = draw_text_right(line, r, line_height, u, s);
    else
	remains = draw_text_left(line, r, line_height, u, s);

    setcliprect(clip);
    return remains;
}
Ejemplo n.º 3
0
/*
 *  Load a font by name.
 */
font newfont(char *name, int style, int size)
{
	font obj;
	HFONT hf;
	LOGFONT lf;

	initapp(0,NULL);

	/* This next calculation should convert from point size to
	   pixels.  We use this since we always use the MM_TEXT mode,
	   which is in pixels. */
	/* Windows requires the lfHeight field must be negative
	   to specify point size, positive to specify pixel size. */

	if (size < 0) /* negative size indicates this is a point size */
		lf.lfHeight = ((screen_dpiy * size)/72);
	else /* positive size indicates a pixel height for the font */
		lf.lfHeight = size;

	lf.lfWidth = lf.lfEscapement = lf.lfOrientation = 0;
	lf.lfWeight = FW_NORMAL;
	lf.lfItalic = lf.lfUnderline = lf.lfStrikeOut = 0;
	lf.lfCharSet = ANSI_CHARSET;
	if ((! string_diff(name, "Symbol"))
		|| (! string_diff(name, "Wingdings")))
			lf.lfCharSet = SYMBOL_CHARSET;
	lf.lfOutPrecision = OUT_DEFAULT_PRECIS;
	lf.lfClipPrecision = CLIP_DEFAULT_PRECIS;
	lf.lfQuality = DEFAULT_QUALITY;
	lf.lfPitchAndFamily = DEFAULT_PITCH | FF_DONTCARE;
	if ((name != 0) && (*name != '\0'))
		strncpy(lf.lfFaceName, name, LF_FACESIZE-1);

	if (style & Italic)
		lf.lfItalic = 1;
	if (style & Bold)
		lf.lfWeight = FW_BOLD;
	if (style & FixedWidth)
		lf.lfPitchAndFamily |= FIXED_PITCH;
	if (style & SansSerif)
		lf.lfPitchAndFamily |= FF_SWISS;

	if ((hf = CreateFontIndirect(&lf)) == 0)
		return NULL;

	obj = new_font_object(hf);
	if (obj)
		obj->text = new_string(name);

	return (font) obj;
}
Ejemplo n.º 4
0
int gprintf(const char *fmt, ...)
{
    static point p = {0,0};
    int count;
    int line_height;
    char *s, *t;
    va_list argptr;
    char str[256];

    va_start(argptr, fmt);
    count = vsprintf(str, fmt, argptr);

    initapp(0,0);
    if (! current->fnt)
	current->fnt = SystemFont;
    line_height = getheight(current->fnt);

    for (s=t=str; *s!='\0'; t++) {
	if (current->p.y != p.y) {
	    /* typewriter ping! */
	    p = current->p;
	}
	if (*t == '\n') {
	    /* print everything from s to t and move point down */
	    *t = '\0';
	    drawstr(p, s);
	    current->p.y += line_height;
	    /* go past the substring just printed */
	    s = t+1;
	}
	else if (*t == '\0') {
	    /* print final string without newline */
	    p.x += drawstr(p, s);
	    /* go to end of string, signal termination */
	    s = t;
	}
    }

    va_end(argptr);

    return count;
}
Ejemplo n.º 5
0
static void
GeanyPy_start_interpreter(void)
{
    gchar *init_code;
    gchar *py_dir = NULL;


#ifndef GEANYPY_WINDOWS
    {   /* Prevents a crash in the dynload thingy
         TODO: is this or the old dlopen version even needed? */
        GModule *mod = g_module_open(GEANYPY_PYTHON_LIBRARY, G_MODULE_BIND_LAZY);
        if (!mod) {
            g_warning(_("Unable to pre-load Python library: %s."), g_module_error());
            return;
        }
        g_module_close(mod);
    }
#endif

    Py_Initialize();

    /* Import the C modules */
    initapp();
    initdialogs();
    initdocument();
    initeditor();
    initencoding();
    initfiletypes();
    inithighlighting();
    initmain();
    initmsgwin();
    initnavqueue();
    initprefs();
    initproject();
    initscintilla();
    initsearch();
    inittemplates();
    initui_utils();

#ifdef GEANYPY_WINDOWS
    {   /* On windows, get path at runtime since we don't really know where
         * Geany is installed ahead of time. */
        gchar *geany_base_dir;
        geany_base_dir = g_win32_get_package_installation_directory_of_module(NULL);
        if (geany_base_dir)
        {
            py_dir = g_build_filename(geany_base_dir, "lib", "geanypy", NULL);
            g_free(geany_base_dir);
        }
        if (!g_file_test(py_dir, G_FILE_TEST_EXISTS))
        {
            g_critical("The path to the `geany' module was not found: %s", py_dir);
            g_free(py_dir);
            py_dir = g_strdup(""); /* will put current dir on path? */
        }
    }
#else
    py_dir = g_strdup(GEANYPY_PYTHON_DIR);
#endif

    /* Adjust Python path to find wrapper package (geany) */
    init_code = g_strdup_printf(
                    "import os, sys\n"
                    "path = '%s'.replace('~', os.path.expanduser('~'))\n"
                    "sys.path.append(path)\n"
                    "import geany\n", py_dir);
    g_free(py_dir);

    PyRun_SimpleString(init_code);
    g_free(init_code);

}
Ejemplo n.º 6
0
static void Init(int hwnd)
{
	ghwnd = (HWND)hwnd;
	initapp(0,NULL);
}
Ejemplo n.º 7
0
Archivo: rui.c Proyecto: Maxsl/r-source
int setupui(void)
{
    char *p, *ctype, Rlocale[1000] = ""; /* Windows' locales can be very long */

    initapp(0, 0);

    /* set locale before doing anything with menus */
    setlocale(LC_CTYPE, ""); /* necessary in case next fails to set
				a valid locale */
    if((p = getenv("LC_ALL"))) strcpy(Rlocale, p);
    if((p = getenv("LC_CTYPE"))) strcpy(Rlocale, p);
    if (strcmp(Rlocale, "C") == 0) strcpy(Rlocale, "en");
    setlocale(LC_CTYPE, Rlocale);
    mbcslocale = MB_CUR_MAX > 1;
    ctype = setlocale(LC_CTYPE, NULL);
    p = strrchr(ctype, '.');
    if(p && isdigit(p[1])) localeCP = atoi(p+1); else localeCP = 1252;

    readconsolecfg();
    int flags = StandardWindow | Document | Menubar;
    if(mbcslocale) flags |= UseUnicode;
    if (RguiMDI & RW_MDI) {
	TRACERUI("Rgui");
	RFrame = newwindow(
#ifdef _WIN64
	    "RGui (64-bit)",
#else
	    "RGui (32-bit)",
#endif
	    MDIsize,
	    StandardWindow | Menubar | Workspace);
	setclose(RFrame, closeconsole);
	show(RFrame);
	TRACERUI("Rgui done");
	TRACERUI("Console");
	if (!(RConsole = newconsole("R Console", flags ))) return 0;
	TRACERUI("Console done");
    } else {
	TRACERUI("Console");
#ifdef _WIN64
	if (!(RConsole = newconsole("R Console (64-bit)", flags ))) return 0;
#else
	if (!(RConsole = newconsole("R Console (32-bit)", flags ))) return 0;
#endif
	TRACERUI("Console done");
    }
    
    if (ismdi()) {
	  int btsize = 24;
	  rect r = rect(2, 2, btsize, btsize);
	  control tb, bt;

	  MCHECK(tb = newtoolbar(btsize + 4));
	  addto(tb);

	  MCHECK(bt = newtoolbutton(open_image, r, menueditoropen));
	  MCHECK(addtooltip(bt, G_("Open script")));
	  r.x += (btsize + 1) ;

	  MCHECK(bt = newtoolbutton(open1_image, r, menuloadimage));
	  MCHECK(addtooltip(bt, G_("Load workspace")));
	  r.x += (btsize + 1) ;

	  MCHECK(bt = newtoolbutton(save_image, r, menusaveimage));
	  MCHECK(addtooltip(bt, G_("Save workspace")));
	  r.x += (btsize + 6);

	  MCHECK(bt = newtoolbutton(copy_image, r, buttoncopy));
	  MCHECK(addtooltip(bt, G_("Copy")));
	  r.x += (btsize + 1);

	  MCHECK(bt = newtoolbutton(paste_image, r, buttonpaste));
	  MCHECK(addtooltip(bt, G_("Paste")));
	  r.x += (btsize + 1);

	  MCHECK(bt = newtoolbutton(copypaste_image, r, buttoncopypaste));
	  MCHECK(addtooltip(bt, G_("Copy and paste")));
	  r.x += (btsize + 6);

	  MCHECK(bt = newtoolbutton(stop_image, r, buttonkill));
	  MCHECK(addtooltip(bt, G_("Stop current computation")));
	  r.x += (btsize + 6) ;

	  MCHECK(bt = newtoolbutton(print_image, r, menuprint));
	  MCHECK(addtooltip(bt, G_("Print")));
    }
    if (ismdi() && (RguiMDI & RW_STATUSBAR)) {
	TRACERUI("status bar");
	addstatusbar();
	addto(RConsole);
	TRACERUI("status bar done");
    }
    if (ismdi()) {
	char s[256];
	PrintVersionString(s, 256);
	setstatus(s);
    }
    addto(RConsole);
    setclose(RConsole, closeconsole);
    setdrop(RConsole, dropconsole);
    MCHECK(RConsolePopup = gpopup(popupact, ConsolePopup));
    MCHECK(RMenuBar = newmenubar(menuact));
    MCHECK(newmenu(G_("File")));
    MCHECK(msource = newmenuitem(G_("Source R code..."), 0, menusource));
    MCHECK(newmenuitem(G_("New script"), 0, menueditornew));
    MCHECK(newmenuitem(G_("Open script..."), 0, menueditoropen));
    MCHECK(mdisplay = newmenuitem(G_("Display file(s)..."), 0, menudisplay));
    MCHECK(newmenuitem("-", 0, NULL));
    MCHECK(mload = newmenuitem(G_("Load Workspace..."), 0, menuloadimage));
    MCHECK(msave = newmenuitem(G_("Save Workspace..."), 'S', menusaveimage));
    MCHECK(newmenuitem("-", 0, NULL));
    MCHECK(mloadhistory = newmenuitem(G_("Load History..."), 0,
				      menuloadhistory));
    MCHECK(msavehistory = newmenuitem(G_("Save History..."), 0,
				      menusavehistory));
    MCHECK(newmenuitem("-", 0, NULL));
    MCHECK(newmenuitem(G_("Change dir..."), 0, menuchangedir));
    MCHECK(newmenuitem("-", 0, NULL));
    MCHECK(newmenuitem(G_("Print..."), 'P', menuprint));
    MCHECK(newmenuitem(G_("Save to File..."), 0, menusavefile));
    MCHECK(newmenuitem("-", 0, NULL));
    MCHECK(newmenuitem(G_("Exit"), 0, menuexit));

    MCHECK(newmenu(G_("Edit")));
    MCHECK(mcopy = newmenuitem(G_("Copy"), 'C', menucopy));
    MCHECK(mpaste = newmenuitem(G_("Paste"), 'V', menupaste));
    MCHECK(mpastecmds = newmenuitem(G_("Paste commands only"), 0,
				    menupastecmds));
    MCHECK(mcopypaste = newmenuitem(G_("Copy and Paste"), 'X', menucopypaste));
    MCHECK(newmenuitem(G_("Select all"), 0, menuselectall));
    MCHECK(newmenuitem(G_("Clear console"), 'L', menuclear));
    MCHECK(newmenuitem("-", 0, NULL));
    MCHECK(mde = newmenuitem(G_("Data editor..."), 0, menude));
    MCHECK(newmenuitem("-", 0, NULL));
    MCHECK(mconfig = newmenuitem(G_("GUI preferences..."), 0, menuconfig));
    if (ismdi()) {
	MCHECK(newmenu(G_("View")));
	MCHECK(mtools = newmenuitem(G_("Toolbar"), 0, menutools));
	MCHECK(mstatus = newmenuitem(G_("Statusbar"), 0, menustatus));
	if(RguiMDI & RW_TOOLBAR) check(mtools);
	if(RguiMDI & RW_STATUSBAR) check(mstatus);
    }
    MCHECK(newmenu(G_("Misc")));
    MCHECK(newmenuitem(G_("Stop current computation           \tESC"), 0,
		       menukill));
    MCHECK(newmenuitem(G_("Stop all computations"), 0, menukillall));
    if (DebugMenuitem || isdebuggerpresent())
	MCHECK(newmenuitem(G_("Break to debugger"), 0, menudebug));
    MCHECK(newmenuitem("-", 0, NULL));
    MCHECK(mlazy = newmenuitem(G_("Buffered output"), 'W', menulazy));
    MCHECK(mcomplete = newmenuitem(G_("Word completion"), 0, menucomplete));
    check(mcomplete);
    MCHECK(mfncomplete = newmenuitem(G_("Filename completion"), 0,
				     menufncomplete));
    if(check_file_completion())
	check(mfncomplete);
    else
	uncheck(mfncomplete);
    MCHECK(newmenuitem("-", 0, NULL));
    MCHECK(mls = newmenuitem(G_("List objects"), 0, menuls));
    MCHECK(mrm = newmenuitem(G_("Remove all objects"), 0, menurm));
    MCHECK(msearch = newmenuitem(G_("List search &path"), 0, menusearch));

    pmenu = (PkgMenuItems) malloc(sizeof(struct structPkgMenuItems));
    RguiPackageMenu(pmenu);
    RguiWindowMenu();
    MCHECK(m = newmenu(G_("Help")));
    MCHECK(newmenuitem(G_("Console"), 0, menuconsolehelp));
    MCHECK(newmenuitem("-", 0, NULL));
    CheckForManuals();
    hmenu = (HelpMenuItems) malloc(sizeof(struct structHelpMenuItems));
    RguiCommonHelp(m, hmenu);
    consolesetbrk(RConsole, menukill, ESC, 0);
    wgl_hist_init(R_HistorySize, 0);
    if (R_RestoreHistory) wgl_loadhistory(R_HistoryFile);
    if (ismdi() && !(RguiMDI & RW_TOOLBAR)) toolbar_hide();
    show(RConsole);
    return 1;
}