Exemplo n.º 1
0
bool Viewer::checkEvents()
{
    // check events from any attached sources
    for(Devices::iterator eitr = _eventSources.begin();
        eitr != _eventSources.end();
        ++eitr)
    {
        osgGA::Device* es = eitr->get();
        if (es->getCapabilities() & osgGA::Device::RECEIVE_EVENTS)
        {
            if (es->checkEvents()) return true;
        }

    }

    // get events from all windows attached to Viewer.
    Windows windows;
    getWindows(windows);
    for(Windows::iterator witr = windows.begin();
        witr != windows.end();
        ++witr)
    {
        if ((*witr)->checkEvents()) return true;
    }

    return false;
}
Exemplo n.º 2
0
Win *get_win(const char *name)
{
    Win *win = NULL;
    Windows::iterator iter;

    iter = windows.find(name);
    if (iter == windows.end()) {
        return NULL;
    }
    win = &iter->second;
   
    return win;
}
Exemplo n.º 3
0
int main(int argc, char *argv[])
{
    int ret = 0;

    setlocale(LC_ALL,"");

    init_keyboard();
    initscr();

    init_allwin();
    resize_allwin();

    signal(SIGWINCH, sig_winch);

    work_thread_start();
    main_loop();

    close_keyboard();
    cleanup();

    for (int i = 30; i<129;i++) {
        printf("%d %c\t", i, i);
    }
    printf("\n");

    struct winsize size;
    Win *win = NULL;
    ioctl(STDIN_FILENO,TIOCGWINSZ,&size);
    Windows::iterator iter;
    for (iter=windows.begin(); iter!=windows.end(); iter++) {
        win = &iter->second;
        printf("%s @(%d,%d), (%dx%d) %s\n", win->name,
                win->locate.x, win->locate.y,
                win->locate.w, win->locate.h,
                win->title);
    }
    printf("SCREEN: %d x %d\n", size.ws_col, size.ws_row);

    return ret;
}
bool CompositeViewer::checkEvents()
{
    for(RefViews::iterator itr = _views.begin();
            itr != _views.end();
            ++itr)
    {
        osgViewer::View* view = itr->get();
        if (view)
        {
            // check events from any attached sources
            for(View::Devices::iterator eitr = view->getDevices().begin();
                    eitr != view->getDevices().end();
                    ++eitr)
            {
                osgGA::Device* es = eitr->get();
                if (es->getCapabilities() & osgGA::Device::RECEIVE_EVENTS)
                {
                    if (es->checkEvents()) return true;
                }

            }
        }
    }

    // get events from all windows attached to Viewer.
    Windows windows;
    getWindows(windows);
    for(Windows::iterator witr = windows.begin();
            witr != windows.end();
            ++witr)
    {
        if ((*witr)->checkEvents()) return true;
    }

    return false;
}
Exemplo n.º 5
0
void resize_allwin()
{
    Win *win = NULL;
    Win *frame = NULL;
    Windows::iterator iter;
    struct winsize size;
    // char msg[64] = {0};
    int ret = 0;

    ioctl(STDIN_FILENO,TIOCGWINSZ,&size);

    for (iter=windows.begin(); iter!=windows.end(); iter++) {
        win = &iter->second;
        frame = get_frame(win->name);
        if (NULL == frame) {
            cleanup();
            exit(0);
        }
        // set new size
        frame->locate.x = size.ws_col * frame->scale.x;
        frame->locate.y = size.ws_row * frame->scale.y;
        frame->locate.w = size.ws_col * frame->scale.w;
        frame->locate.h = size.ws_row * frame->scale.h;

        win->locate.x = frame->locate.x + 1;
        win->locate.y = frame->locate.y + 1;
        win->locate.w = frame->locate.w - 2;
        win->locate.h = frame->locate.h - 2;

        if (iter->first.compare("RCMD") == 0) {
            win->locate.h = 4;
        }

        // resize 
        ret = wresize(frame->win, frame->locate.h, frame->locate.w);
        ret = wresize(win->win, win->locate.h, win->locate.w);
        if (ERR == ret) {
            printf("wresize failed:%s %d,%d\n", win->name, win->locate.x, win->locate.y);
        }

        // move
        ret = mvwin(frame->win, frame->locate.y, frame->locate.x);
        if (ERR == ret) {
            cleanup();
            printf("mvwin frame failed:%s %d,%d\n", frame->name, frame->locate.y, frame->locate.x);
            printf("\t %d x %d\n", frame->locate.w, frame->locate.h);
            exit(0);
        }
        ret = mvwin(win->win, win->locate.y, win->locate.x);
        if (ERR == ret) {
            cleanup();
            printf("SCREEN=%d x %d\n", COLS, LINES);
            printf("mvwin failed:%s %d,%d\n", win->name, win->locate.x, win->locate.y);
            printf("\t %d x %d\n", win->locate.w, win->locate.h);
            printf("frame %d,%d %d x %d\n", frame->locate.x, frame->locate.y, frame->locate.w, frame->locate.h);
            exit(0);
        }

        //echo();
        //touchwin(win->win);
        //attron(A_REVERSE);
        box(frame->win, '|', '-');
        //mvaddstr(2, 2,win->name);
        // mvwaddstr(win->win, 1, 1, win->name);
        //sprintf(msg, "%d,%d", win->locate.y, win->locate.x);
        //mvwaddstr(win->win, 2, 1, msg);
        //attroff(A_REVERSE);
        //move(1, 1);
        //waddstr(win->win, win->name);
        wrefresh(frame->win);
        wrefresh(win->win);
  //      }
    }
}