add utility functions to create new schematic window
This commit is contained in:
parent
2f3025cf3f
commit
2b7e31e0d6
|
|
@ -193,7 +193,7 @@ int callback(int event, int mx, int my, KeySym key,
|
|||
#ifndef __unix__
|
||||
if ((xctx->ui_state & STARTWIRE) || (xctx->ui_state & STARTARC) ||
|
||||
(xctx->ui_state & STARTLINE) || (xctx->ui_state & STARTMOVE) ||
|
||||
(xctx->ui_state & STARTCOPY) || (xctx->ui_state & STARTRECT) ||i
|
||||
(xctx->ui_state & STARTCOPY) || (xctx->ui_state & STARTRECT) ||
|
||||
(xctx->ui_state & STARTPOLYGON) || (xctx->ui_state & STARTPAN2) ||
|
||||
(xctx->ui_state & STARTPAN) || (xctx->ui_state & STARTSELECT)) {
|
||||
XCopyArea(display, xctx->save_pixmap, xctx->window, gctiled, xctx->xrect[0].x, xctx->xrect[0].y,
|
||||
|
|
|
|||
|
|
@ -1777,7 +1777,7 @@ int XSetClipRectangles(register Display* dpy, GC gc, int clip_x_origin, int clip
|
|||
{
|
||||
return 0;
|
||||
}
|
||||
int XSetTile(Display* display, GC gc, Pixmap xctx->save_pixmap)
|
||||
int XSetTile(Display* display, GC gc, Pixmap save_pixmap)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -169,6 +169,14 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
|
|||
windowid();
|
||||
}
|
||||
|
||||
else if(!strcmp(argv[1],"new_schematic"))
|
||||
{
|
||||
if(argc == 3) new_schematic(argv[2], "{}","{}");
|
||||
else if(argc == 4) new_schematic(argv[2], argv[3], "{}");
|
||||
else if(argc == 5) new_schematic(argv[2], argv[3], argv[4]);
|
||||
Tcl_ResetResult(interp);
|
||||
}
|
||||
|
||||
else if(!strcmp(argv[1],"preview_window"))
|
||||
{
|
||||
if(argc == 3) preview_window(argv[2], "{}","{}");
|
||||
|
|
|
|||
64
src/xinit.c
64
src/xinit.c
|
|
@ -28,7 +28,7 @@
|
|||
static int init_done=0; /* 20150409 to avoid double call by Xwindows close and TclExitHandler */
|
||||
static XSetWindowAttributes winattr;
|
||||
static int screen_number;
|
||||
static Tk_Window tkwindow, mainwindow, tkpre_window;
|
||||
static Tk_Window tkwindow, mainwindow;
|
||||
static XWMHints *hints_ptr;
|
||||
static Window topwindow;
|
||||
static XColor xcolor_exact,xcolor;
|
||||
|
|
@ -848,6 +848,8 @@ void preview_window(const char *what, const char *tk_win_path, const char *filen
|
|||
static char *current_file = NULL;
|
||||
static Xschem_ctx *save_xctx = NULL; /* save pointer to current schematic context structure */
|
||||
static Xschem_ctx *preview_xctx = NULL; /* save pointer to current schematic context structure */
|
||||
static Window pre_window;
|
||||
static Tk_Window tkpre_window;
|
||||
|
||||
dbg(1, "------\n");
|
||||
if(!strcmp(what, "create")) {
|
||||
|
|
@ -876,7 +878,6 @@ void preview_window(const char *what, const char *tk_win_path, const char *filen
|
|||
resetwin(1, 0, 1); /* create preview pixmap. resetwin(create_pixmap, clear_pixmap, force) */
|
||||
}
|
||||
resetwin(1, 1, 0); /* handle resize. resetwin(create_pixmap, clear_pixmap, force) */
|
||||
XSetTile(display,gctiled, xctx->save_pixmap);
|
||||
zoom_full(1, 0); /* draw */
|
||||
xctx = save_xctx;
|
||||
XSetTile(display,gctiled, xctx->save_pixmap);
|
||||
|
|
@ -897,6 +898,65 @@ void preview_window(const char *what, const char *tk_win_path, const char *filen
|
|||
}
|
||||
}
|
||||
|
||||
void new_schematic(const char *what, const char *tk_win_path, const char *filename)
|
||||
{
|
||||
static int n = 0, cnt = 0;
|
||||
static Xschem_ctx *save_xctx[20]; /* save pointer to current schematic context structure */
|
||||
static Window new_window;
|
||||
static Tk_Window tknew_window[20];
|
||||
|
||||
dbg(1, "------\n");
|
||||
if(!strcmp(what, "create")) {
|
||||
dbg(1, "new_schematic() create, save ctx\n");
|
||||
if(cnt == 0) save_xctx[0] = xctx; /* save current schematic */
|
||||
cnt++;
|
||||
n = cnt;
|
||||
tknew_window[cnt] = Tk_NameToWindow(interp, tk_win_path, mainwindow);
|
||||
Tk_MakeWindowExist(tknew_window[cnt]);
|
||||
new_window = Tk_WindowId(tknew_window[cnt]);
|
||||
dbg(1, "new_schematic() draw\n");
|
||||
xctx = NULL; /* reset for preview */
|
||||
alloc_xschem_data(); /* alloc data into xctx */
|
||||
save_xctx[cnt] = xctx;
|
||||
dbg(1, "new_schematic() draw, load schematic\n");
|
||||
load_schematic(1,filename, 0);
|
||||
xctx->window = new_window;
|
||||
resetwin(1, 0, 1); /* create preview pixmap. resetwin(create_pixmap, clear_pixmap, force) */
|
||||
zoom_full(1, 0); /* draw */
|
||||
} else if(!strcmp(what, "redraw")) {
|
||||
Xschem_ctx *save;
|
||||
save = xctx;
|
||||
n = atoi(tk_win_path);
|
||||
if(n <0) n = 0;
|
||||
if(n > cnt) n = cnt;
|
||||
xctx = save_xctx[n];
|
||||
resetwin(1, 1, 0); /* create preview pixmap. resetwin(create_pixmap, clear_pixmap, force) */
|
||||
draw();
|
||||
xctx = save;
|
||||
set_modify(xctx->modified);
|
||||
} else if(!strcmp(what, "destroy")) {
|
||||
if(cnt > 0) {
|
||||
dbg(1, "new_schematic() destroy\n");
|
||||
xctx = save_xctx[cnt];
|
||||
preview_clear();
|
||||
save_xctx[cnt] = NULL;
|
||||
Tk_DestroyWindow(tknew_window[cnt]);
|
||||
cnt--;
|
||||
n = 0;
|
||||
xctx = save_xctx[0]; /* restore schematic */
|
||||
resetwin(1, 1, 0); /* create preview pixmap. resetwin(create_pixmap, clear_pixmap, force) */
|
||||
set_modify(xctx->modified);
|
||||
}
|
||||
} else if(!strcmp(what, "switch")) {
|
||||
n = atoi(tk_win_path);
|
||||
if(n <0) n = 0;
|
||||
if(n > cnt) n = cnt;
|
||||
xctx = save_xctx[n];
|
||||
resetwin(1, 1, 0); /* create preview pixmap. resetwin(create_pixmap, clear_pixmap, force) */
|
||||
set_modify(xctx->modified);
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef __unix__
|
||||
/* Source: https://www.tcl.tk/man/tcl8.7/TclCmd/glob.htm */
|
||||
/* backslash character has a special meaning to glob command,
|
||||
|
|
|
|||
|
|
@ -3146,6 +3146,25 @@ proc raise_dialog {window_path } {
|
|||
}
|
||||
}
|
||||
|
||||
#### TEST MODE #####
|
||||
proc new_window {what {path {}} {filename {}}} {
|
||||
if { $what eq {create}} {
|
||||
toplevel $path -bg {}
|
||||
update
|
||||
xschem new_schematic create $path $filename
|
||||
set_bindings $path
|
||||
} elseif { $what eq {destroy}} {
|
||||
xschem new_schematic destroy $path {}
|
||||
} elseif { $what eq {switch}} {
|
||||
xschem new_schematic switch $path {}
|
||||
} elseif { $what eq {redraw}} {
|
||||
xschem new_schematic redraw $path {}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
proc set_bindings {window_path} {
|
||||
global env no_x
|
||||
|
|
|
|||
Loading…
Reference in New Issue