void cgraphics_listview_widget_create( widget_t *widget ) { object_t *object = (object_t *)widget; widget_t *parent = (widget_t *)object->parent; listview_widget_t *lvw = (listview_widget_t *)widget; HWND hwnd, hwnd_parent = widget_get_container(OBJECT(parent)); if ( !( hwnd = CreateWindowEx( WS_EX_CLIENTEDGE, WC_LISTVIEW, "", WS_CHILD | WS_TABSTOP | LVS_AUTOARRANGE | LVS_OWNERDATA | LVS_REPORT, widget->size_req->x, widget->size_req->y, widget->size_req->w, widget->size_req->h, hwnd_parent, NULL, (HINSTANCE) GetModuleHandle( NULL ), NULL ) ) ) MessageBox( 0, "Could not create listview HWND.", "Claro error", 0 ); widget->native = hwnd; DWORD dw = LVS_EX_FULLROWSELECT; if ( widget->flags & cListViewRowCheckBoxes ) dw |= LVS_EX_CHECKBOXES; SendMessage( hwnd, LVM_SETEXTENDEDLISTVIEWSTYLE, 0, dw ); SetWindowLong( widget->native, GWL_USERDATA, (LONG)widget ); lvw->nativep = (void*)SetWindowLong( widget->native, GWL_WNDPROC, (LONG)cg_listview_intercept_proc ); ShowWindow( hwnd, SW_SHOW ); UpdateWindow( hwnd ); }
void cgraphics_combo_widget_create( widget_t *widget ) { object_t *object = (object_t *)widget; widget_t *parent = (widget_t *)object->parent; HWND hwnd, hwnd_parent = widget_get_container(parent); /* FIXME: bad default */ if ( widget->size_req->h == -1 ) widget->size_req->h = 25; if ( !( hwnd = CreateWindowEx( WS_EX_CLIENTEDGE, "COMBOBOX", "", WS_CHILD | CBS_DROPDOWNLIST | WS_TABSTOP | WS_VSCROLL, widget->size_req->x, widget->size_req->y, widget->size_req->w, 300, /* this is the height of the dropdown itself */ hwnd_parent, NULL, (HINSTANCE) GetModuleHandle( NULL ), NULL ) ) ) MessageBox( 0, "Could not create button HWND.", "Claro error", 0 ); object_addhandler( object, "update", cgraphics_combo_fix_size ); widget->native = hwnd; ShowWindow( hwnd, SW_SHOW ); UpdateWindow( hwnd ); }
void cgraphics_canvas_widget_create( widget_t *widget ) { object_t *object = (object_t *)widget; widget_t *parent = (widget_t *)object->parent; canvas_widget_t *cvsw = (canvas_widget_t *)widget; native_canvas_widget_t *nw = 0;//(native_canvas_widget_t *)&cvsw->ndata; HWND hwnd, hwnd_parent = widget_get_container(parent); WNDCLASSEX wc; char clname[1024]; sprintf( clname, "claro_window_%d", ++curr_classname_id ); wc.cbSize = sizeof(WNDCLASSEX); wc.style = 0; wc.lpfnWndProc = cg_canvas_win32_proc; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = (HINSTANCE) GetModuleHandle( NULL ); wc.hIcon = LoadIcon(NULL, IDI_APPLICATION); wc.hCursor = LoadCursor(NULL, IDC_ARROW); wc.hbrBackground = (HBRUSH)COLOR_APPWORKSPACE + 1; wc.lpszMenuName = NULL; wc.lpszClassName = clname; wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION); if ( !RegisterClassEx( &wc ) ) { MessageBox(NULL, "Window Registration Failed!", "Error!", MB_ICONEXCLAMATION | MB_OK); return; } #ifndef NO_CAIRO cvsw->surface = 0; #endif if ( !( hwnd = CreateWindowEx( 0, clname, 0, WS_CHILD, widget->size_req->x, widget->size_req->y, widget->size_req->w, widget->size_req->h, hwnd_parent, NULL, (HINSTANCE) GetModuleHandle( NULL ), NULL ) ) ) MessageBox( 0, "Could not create canvas HWND.", "Claro error", 0 ); widget->native = hwnd; widget->ndata = (native_canvas_widget_t *)malloc(sizeof(native_canvas_widget_t)); nw = widget->ndata; object_addhandler( widget, "destroy", cgraphics_canvas_cleanup ); nw->bmp = 0; nw->font = 0; ShowWindow( hwnd, SW_SHOW ); UpdateWindow( hwnd ); }
/* Image */ void cgraphics_image_widget_create( widget_t *widget ) { object_t *object = (object_t *)widget; widget_t *parent = (widget_t *)object->parent; HWND hwnd, hwnd_parent = widget_get_container(OBJECT(parent)); WNDCLASSEX wc; char clname[1024]; sprintf( clname, "claro_image_%d", ++curr_classname_id ); wc.cbSize = sizeof(WNDCLASSEX); wc.style = 0; wc.lpfnWndProc = cg_win32_image_proc; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = (HINSTANCE) GetModuleHandle( NULL ); wc.hCursor = LoadCursor(NULL, IDC_ARROW); wc.hbrBackground = NULL; wc.lpszMenuName = NULL; wc.lpszClassName = clname; /* FIXME: use icons when they exist */ wc.hIcon = LoadIcon( NULL, IDI_APPLICATION ); wc.hIconSm = LoadIcon( NULL, IDI_APPLICATION ); if ( !RegisterClassEx( &wc ) ) { MessageBox(NULL, "Window Registration Failed!", "Error!", MB_ICONEXCLAMATION | MB_OK); return; } /* FIXME: bad default */ if ( widget->size_req->h == -1 ) widget->size_req->h = 25; if ( !( hwnd = CreateWindowEx( 0, clname, "", WS_CHILD, widget->size_req->x, widget->size_req->y, widget->size_req->w, widget->size_req->h, hwnd_parent, NULL, (HINSTANCE) GetModuleHandle( NULL ), NULL ) ) ) MessageBox( 0, "Could not create image HWND.", "Claro error", 0 ); widget->native = hwnd; ShowWindow( hwnd, SW_SHOW ); UpdateWindow( hwnd ); }
void cgraphics_radiobutton_widget_create( widget_t *widget ) { object_t *object = (object_t *)widget; widget_t *parent = (widget_t *)object->parent; HWND hwnd, hwnd_parent = widget_get_container(parent); /* FIXME: bad default */ if ( widget->size_req->h == -1 ) widget->size_req->h = 25; if ( !( hwnd = CreateWindowEx( 0, "BUTTON", "", WS_CHILD | WS_TABSTOP | BS_RADIOBUTTON, widget->size_req->x, widget->size_req->y, widget->size_req->w, widget->size_req->h, hwnd_parent, NULL, (HINSTANCE) GetModuleHandle( NULL ), NULL ) ) ) MessageBox( 0, "Could not create button HWND.", "Claro error", 0 ); widget->native = hwnd; ShowWindow( hwnd, SW_SHOW ); UpdateWindow( hwnd ); }
void cgraphics_label_widget_create( widget_t *widget ) { object_t *object = (object_t *)widget; widget_t *parent = (widget_t *)object->parent; HWND hwnd, hwnd_parent = widget_get_container(parent); /* FIXME: bad default */ if ( widget->size_req->h == -1 ) widget->size_req->h = 25; if ( !( hwnd = CreateWindowEx( 0, "STATIC", "", WS_CHILD | SS_LEFTNOWORDWRAP, widget->size_req->x, widget->size_req->y, widget->size_req->w, widget->size_req->h, hwnd_parent, NULL, (HINSTANCE) GetModuleHandle( NULL ), NULL ) ) ) MessageBox( 0, "Could not create label HWND.", "Claro error", 0 ); widget->native = hwnd; ShowWindow( hwnd, SW_SHOW ); UpdateWindow( hwnd ); }
void cgraphics_widget_create( widget_t *widget ) { widget_t *parent; parent = (widget_t *)object_parent(widget); /* check for parent */ if ( parent == NULL ) { clog( CL_ERROR, "Widget requires parent, none given." ); return; } /* FIXME: height should be determined from font height in pixels */ if ( widget->size_req->h == -1 ) widget->size_req->h = 25; gtk_widget_set_size_request( GTK_WIDGET(widget->native), widget->size_req->w, widget->size_req->h ); g_signal_connect( G_OBJECT(widget->native), "configure_event", G_CALLBACK(cgraphics_resized_handler), widget ); g_signal_connect_swapped( G_OBJECT(widget->native), "destroy", G_CALLBACK(cgraphics_destroy_handler), widget ); if ( widget->flags & cWidgetCustomDraw ) { g_signal_connect( G_OBJECT(widget->native), "screen-changed", G_CALLBACK(cgraphics_screen_changed_handler), widget ); g_signal_connect( G_OBJECT(widget->native), "expose-event", G_CALLBACK(cgraphics_cd_expose_handler), widget ); } if ( widget->container != 0 ) g_signal_connect( G_OBJECT(widget->container), "size_allocate", G_CALLBACK(cgraphics_resized2_handler), widget ); else g_signal_connect( G_OBJECT(widget->native), "size_allocate", G_CALLBACK(cgraphics_resized2_handler), widget ); if ( !strcmp( parent->object.type, "claro.graphics.widgets.splitter" ) ) { size_t splitter_num = (size_t)parent->ndata; splitter_widget_t *sw = (splitter_widget_t *)parent; if ( splitter_num == 0 ) gtk_paned_pack1( GTK_PANED(parent->native), widget->native, true, false ); else gtk_paned_pack2( GTK_PANED(parent->native), widget->native, true, false ); sw->children[splitter_num].w = widget; parent->ndata = (void *)(splitter_num+1); } else if ( !strcmp( parent->object.type, "claro.graphics.widgets.workspace" ) ) { gtk_notebook_append_page( widget_get_container(OBJECT(parent)), widget->native, NULL ); } else { gtk_layout_put( GTK_LAYOUT(widget_get_container(OBJECT(parent))), widget->native, widget->size_req->x, widget->size_req->y ); } g_object_set_data( widget->native, "claro_widget", widget ); if ( widget->flags & cWidgetCustomDraw ) cgraphics_screen_changed_handler( widget->native, NULL, widget ); gtk_widget_show( GTK_WIDGET(widget->native) ); }