示例#1
0
static void zbar_gtk_size_allocate (GtkWidget *widget,
                                    GtkAllocation *allocation)
{
    ZBarGtk *self = ZBAR_GTK(widget);
    if(!self->_private)
        return;
    ZBarGtkPrivate *zbar = ZBAR_GTK_PRIVATE(self->_private);

    (*GTK_WIDGET_CLASS(zbar_gtk_parent_class)->size_allocate)
        (widget, allocation);
    if(zbar->window)
        zbar_window_resize(zbar->window,
                            allocation->width, allocation->height);
}
示例#2
0
static LRESULT CALLBACK win_handle_event (HWND hwnd,
                                          UINT message,
                                          WPARAM wparam,
                                          LPARAM lparam)
{
    zbar_processor_t *proc =
        (zbar_processor_t*)GetWindowLongPtr(hwnd, GWL_USERDATA);
    /* initialized during window creation */
    if(message == WM_NCCREATE) {
        proc = ((LPCREATESTRUCT)lparam)->lpCreateParams;
        assert(proc);
        SetWindowLongPtr(hwnd, GWL_USERDATA, (LONG_PTR)proc);
        proc->display = hwnd;

        zbar_window_attach(proc->window, proc->display, proc->xwin);
    }
    else if(!proc)
        return(DefWindowProc(hwnd, message, wparam, lparam));

    switch(message) {

    case WM_SIZE: {
        RECT r;
        GetClientRect(hwnd, &r);
        zprintf(3, "WM_SIZE %ldx%ld\n", r.right, r.bottom);
        assert(proc);
        zbar_window_resize(proc->window, r.right, r.bottom);
        InvalidateRect(hwnd, NULL, 0);
        return(0);
    }

    case WM_PAINT: {
        PAINTSTRUCT ps;
        BeginPaint(hwnd, &ps);
        if(zbar_window_redraw(proc->window)) {
            HDC hdc = GetDC(hwnd);
            RECT r;
            GetClientRect(hwnd, &r);
            FillRect(hdc, &r, GetStockObject(BLACK_BRUSH));
            ReleaseDC(hwnd, hdc);
        }
        EndPaint(hwnd, &ps);
        return(0);
    }

    case WM_CHAR: {
        _zbar_processor_handle_input(proc, wparam);
        return(0);
    }

    case WM_LBUTTONDOWN: {
        _zbar_processor_handle_input(proc, 1);
        return(0);
    }

    case WM_MBUTTONDOWN: {
        _zbar_processor_handle_input(proc, 2);
        return(0);
    }

    case WM_RBUTTONDOWN: {
        _zbar_processor_handle_input(proc, 3);
        return(0);
    }

    case WM_CLOSE: {
        zprintf(3, "WM_CLOSE\n");
        _zbar_processor_handle_input(proc, -1);
        return(1);
    }

    case WM_DESTROY: {
        zprintf(3, "WM_DESTROY\n");
        proc->display = NULL;
        zbar_window_attach(proc->window, NULL, 0);
        return(0);
    }
    }
    return(DefWindowProc(hwnd, message, wparam, lparam));
}