Ejemplo n.º 1
0
/*#DOC*/
int view_resize(View v, int w, int h)
{
	w = viewP_posrelat(w, TERM_W);
	h = viewP_posrelat(h, TERM_H);
	if (ERR == wresize(view_win(v), h, w)) return ERR;
	return replace_panel(view_pan(v), view_win(v));
}
Ejemplo n.º 2
0
static int lcp_replace_panel(lua_State *L)
{
    PANEL *p = lcp_check(L, 1);
    WINDOW *w = lcw_check(L, 2);
    WINDOW *oldw = panel_window(p);

    if (replace_panel(p, w) == ERR)
    {
        lua_pushboolean(L, 0);
        return 1;
    }

    /* remove entry of old window */
    lua_pushlightuserdata(L, oldw);
    lua_pushnil(L);
    lua_rawset(L, UPINDEX);

    /* and save new window */
    lua_pushlightuserdata(L, oldw);
    lua_pushvalue(L, 2);
    lua_rawset(L, UPINDEX);

    lua_pushboolean(L, 1);
    return 1;
}
Ejemplo n.º 3
0
//--------------------------------------------------------------------
void ConWindow::resize(short width, short height)
{
    if (wresize(win, height, width) != OK)
        exitMsg(99, "Internal error: Failed to resize window");

    replace_panel(pan, win);

    clear();
} // end ConWindow::resize
Ejemplo n.º 4
0
void CTabWidget::setSize(uint width, uint height)
{
	_size.set(width, height);

	wresize(_window, height, width);
	replace_panel(_panel, _window);

	for(vector<CWidget *>::const_iterator i = _widgets.begin(); i != _widgets.end(); ++i)
		(*i)->setSize(width, height - 1);

	_changed = true;
}
Ejemplo n.º 5
0
void CWidget::setSize(uint width, uint height)
{
	DEBUG_ui("CWidget::setSize [" + _name + "]");
	_size.set(width, height);

	wresize(_window, height, width);
	replace_panel(_panel, _window);

	if(_layout)
		_layout->setSize(width, height);

	_changed = true;
}
Ejemplo n.º 6
0
void value_list_resize(struct value_list *vl, int nlines, int ncols,
		       int begin_y, int begin_x)
{
	WINDOW *nwin, *nsub;

	nwin = newwin(nlines, ncols, begin_y, begin_x);
	if (nwin == NULL) {
		return;
	}
	nsub = subwin(nwin, nlines - 2, ncols - 2, begin_y + 1, begin_x + 1);
	if (nsub == NULL) {
		delwin(nwin);
		return;
	}
	replace_panel(vl->panel, nwin);
	delwin(vl->sub);
	delwin(vl->window);
	vl->window = nwin;
	vl->sub = nsub;
	box(vl->window, 0, 0);
	mvwprintw(vl->window, 0, HEADING_X, "Value");
	multilist_set_window(vl->list, vl->sub);
	value_list_show(vl);
}
Ejemplo n.º 7
0
static void
my_resize_panel(PANEL ** pans, int which, FillPanel myFill)
{
    if (pans[which] != 0) {
	int code;
	int y0, x0;
	int y1, x1;
	WINDOW *win = panel_window(pans[which]);
	char also[80];

	getbegyx(win, y0, x0);
	sprintf(also, " (start %d,%d)", y0, x0);
	wmove(stdscr, y0, x0);
	while ((code = get_position("Resize panel",
				    also, which, &x1, &y1)) == 0) {
	    ;
	}
	if (code > 0) {
	    WINDOW *next = newwin(ABS(y1 - y0) + 1,
				  ABS(x1 - x0) + 1,
				  MIN(y0, y1),
				  MIN(x0, x1));
	    if (next != 0) {
		keypad(next, TRUE);
		if (use_colors) {
		    wbkgdset(next, (chtype) (COLOR_PAIR(which) | ' '));
		} else if (!unboxed) {
		    wbkgdset(next, A_BOLD | ' ');
		}
		replace_panel(pans[which], next);
		myFill(pans[which]);
		delwin(win);
	    }
	}
    }
}
Ejemplo n.º 8
0
int main()
{   WINDOW *my_wins[3];
    PANEL  *my_panels[3];
    PANEL_DATA  *top;
    PANEL *stack_top;
    WINDOW *temp_win, *old_win;
    int ch;
    int newx, newy, neww, newh;
    int size = FALSE, move = FALSE;

    /* Initialize curses */
    initscr();
    start_color();
    cbreak();
    noecho();
    keypad(stdscr, TRUE);

    /* Initialize all the colors */
    init_pair(1, COLOR_RED, COLOR_BLACK);
    init_pair(2, COLOR_GREEN, COLOR_BLACK);
    init_pair(3, COLOR_BLUE, COLOR_BLACK);
    init_pair(4, COLOR_CYAN, COLOR_BLACK);

    init_wins(my_wins, 3);
 
    /* Attach a panel to each window */     /* Order is bottom up */
    my_panels[0] = new_panel(my_wins[0]);   /* Push 0, order: stdscr-0 */
    my_panels[1] = new_panel(my_wins[1]);   /* Push 1, order: stdscr-0-1 */
    my_panels[2] = new_panel(my_wins[2]);   /* Push 2, order: stdscr-0-1-2 */

    set_user_ptrs(my_panels, 3);
    /* Update the stacking order. 2nd panel will be on top */
    update_panels();

    /* Show it on the screen */
    attron(COLOR_PAIR(4));
    mvprintw(LINES - 3, 0, "Use 'm' for moving, 'r' for resizing");
    mvprintw(LINES - 2, 0, "Use tab to browse through the windows (F1 to Exit)");
    attroff(COLOR_PAIR(4));
    doupdate();

    stack_top = my_panels[2];
    top = (PANEL_DATA *)panel_userptr(stack_top);
    newx = top->x;
    newy = top->y;
    neww = top->w;
    newh = top->h;
    while((ch = getch()) != KEY_F(1))
    {   switch(ch)
        {   case 9:     /* Tab */
                top = (PANEL_DATA *)panel_userptr(stack_top);
                top_panel(top->next);
                stack_top = top->next;
                top = (PANEL_DATA *)panel_userptr(stack_top);
                newx = top->x;
                newy = top->y;
                neww = top->w;
                newh = top->h;
                break;
            case 'r':   /* Re-Size*/
                size = TRUE;
                attron(COLOR_PAIR(4));
                mvprintw(LINES - 4, 0, "Entered Resizing :Use Arrow Keys to resize and press <ENTER> to end resizing");
                refresh();
                attroff(COLOR_PAIR(4));
                break;
            case 'm':   /* Move */
                attron(COLOR_PAIR(4));
                mvprintw(LINES - 4, 0, "Entered Moving: Use Arrow Keys to Move and press <ENTER> to end moving");
                refresh();
                attroff(COLOR_PAIR(4));
                move = TRUE;
                break;
            case KEY_LEFT:
                if(size == TRUE)
                {   --newx;
                    ++neww;
                }
                if(move == TRUE)
                    --newx;
                break;
            case KEY_RIGHT:
                if(size == TRUE)
                {   ++newx;
                    --neww;
                }
                if(move == TRUE)
                    ++newx;
                break;
            case KEY_UP:
                if(size == TRUE)
                {   --newy;
                    ++newh;
                }
                if(move == TRUE)
                    --newy;
                break;
            case KEY_DOWN:
                if(size == TRUE)
                {   ++newy;
                    --newh;
                }
                if(move == TRUE)
                    ++newy;
                break;
            case 10:    /* Enter */
                move(LINES - 4, 0);
                clrtoeol();
                refresh();
                if(size == TRUE)
                {   old_win = panel_window(stack_top);
                    temp_win = newwin(newh, neww, newy, newx);
                    replace_panel(stack_top, temp_win);
                    win_show(temp_win, top->label, top->label_color); 
                    delwin(old_win);
                    size = FALSE;
                }
                if(move == TRUE)
                {   move_panel(stack_top, newy, newx);
                    move = FALSE;
                }
                break;
            
        }
        attron(COLOR_PAIR(4));
        mvprintw(LINES - 3, 0, "Use 'm' for moving, 'r' for resizing");
            mvprintw(LINES - 2, 0, "Use tab to browse through the windows (F1 to Exit)");
            attroff(COLOR_PAIR(4));
            refresh();  
        update_panels();
        doupdate();
    }
    endwin();
    return 0;
}
Ejemplo n.º 9
0
static VALUE rbncurs_c_replace_panel(VALUE rb_panel, VALUE rb_window)
{ return INT2NUM(replace_panel(get_panel(rb_panel), get_window(rb_window))); }