char* iupBaseNativeParentGetBgColorAttrib(Ihandle* ih) { /* Used only by those who need a transparent background */ char* color = iupAttribGetInheritNativeParent(ih, "BGCOLOR"); if (!color) color = iupAttribGetInheritNativeParent(ih, "BACKGROUND"); if (!color) color = IupGetGlobal("DLGBGCOLOR"); return color; }
static void winTabsDrawPageBackground(Ihandle* ih, HDC hDC, RECT* rect) { unsigned char r=0, g=0, b=0; char* color = iupAttribGetInheritNativeParent(ih, "BGCOLOR"); if (!color) color = iupAttribGetInheritNativeParent(ih, "BACKGROUND"); if (!color) color = iupAttribGet(ih, "BACKGROUND"); if (!color) color = IupGetGlobal("DLGBGCOLOR"); iupStrToRGB(color, &r, &g, &b); SetDCBrushColor(hDC, RGB(r,g,b)); FillRect(hDC, rect, (HBRUSH)GetStockObject(DC_BRUSH)); }
char* iupBaseNativeParentGetBgColor(Ihandle* ih) { /* Used in SetBgColorAttrib */ char* color = iupAttribGetInheritNativeParent(ih, "BGCOLOR"); if (!color) color = IupGetGlobal("DLGBGCOLOR"); return color; }
static int motToggleSetBackgroundAttrib(Ihandle* ih, const char* value) { if (ih->data->type == IUP_TOGGLE_TEXT) { Pixel color; /* ignore given value, must use only from parent */ value = iupAttribGetInheritNativeParent(ih, "BACKGROUND"); color = iupmotColorGetPixelStr(value); if (color != (Pixel)-1) { XtVaSetValues(ih->handle, XmNbackground, color, NULL); return 1; } else { Pixmap pixmap = (Pixmap)iupImageGetImage(value, ih, 0, "BACKGROUND"); if (pixmap) { XtVaSetValues(ih->handle, XmNbackgroundPixmap, pixmap, NULL); return 1; } } } return 0; }
static int motToggleSetBgColorAttrib(Ihandle* ih, const char* value) { if (ih->data->type == IUP_TOGGLE_TEXT) { char* parent_value = iupAttribGetInheritNativeParent(ih, "BGCOLOR"); if (!parent_value) { /* if not defined at a native parent, then change the toggle button color to the given color instead using the default */ if (iupdrvBaseSetBgColorAttrib(ih, value)) /* let XmChangeColor do its job */ { parent_value = IupGetGlobal("DLGBGCOLOR"); XtVaSetValues(ih->handle, XmNbackground, iupmotColorGetPixelStr(parent_value), NULL); /* reset just the background */ if (ih->data->is_radio) XtVaSetValues(ih->handle, XmNselectColor, iupmotColorGetPixel(0, 0, 0), NULL); XtVaSetValues(ih->handle, XmNunselectColor, iupmotColorGetPixelStr(value), NULL); return 1; } } else { /* ignore given value, must use only from parent */ if (iupdrvBaseSetBgColorAttrib(ih, parent_value)) { if (ih->data->is_radio) XtVaSetValues(ih->handle, XmNselectColor, iupmotColorGetPixel(0, 0, 0), NULL); XtVaSetValues(ih->handle, XmNunselectColor, iupmotColorGetPixelStr(parent_value), NULL); return 1; } } return 0; } else { if (ih->data->flat) { /* ignore given value, must use only from parent */ value = iupBaseNativeParentGetBgColor(ih); if (iupdrvBaseSetBgColorAttrib(ih, value)) return 1; } return iupdrvBaseSetBgColorAttrib(ih, value); } }
static int motLabelSetBackgroundAttrib(Ihandle* ih, const char* value) { /* ignore given value, must use only from parent */ value = iupAttribGetInheritNativeParent(ih, "BACKGROUND"); if (iupdrvBaseSetBgColorAttrib(ih, value)) return 1; else { Pixmap pixmap = (Pixmap)iupImageGetImage(value, ih, 0); if (pixmap) { XtVaSetValues(ih->handle, XmNbackgroundPixmap, pixmap, NULL); return 1; } } return 0; }
static int motFrameSetBackgroundAttrib(Ihandle* ih, const char* value) { Pixel color; /* ignore given value, must use only from parent */ value = iupAttribGetInheritNativeParent(ih, "BACKGROUND"); color = iupmotColorGetPixelStr(value); if (color != (Pixel)-1) { Widget title_label, child_manager; iupmotSetBgColor(ih->handle, color); child_manager = (Widget)iupAttribGet(ih, "_IUPMOT_FRAMECONTAINER"); iupmotSetBgColor(child_manager, color); title_label = (Widget)iupAttribGet(ih, "_IUPMOT_FRAMELABEL"); if (!title_label) return 1; iupmotSetBgColor(title_label, color); return 1; } else { Pixmap pixmap = (Pixmap)iupImageGetImage(value, ih, 0); if (pixmap) { Widget child_manager = (Widget)iupAttribGet(ih, "_IUPMOT_FRAMECONTAINER"); Widget title_label = (Widget)iupAttribGet(ih, "_IUPMOT_FRAMELABEL"); XtVaSetValues(child_manager, XmNbackgroundPixmap, pixmap, NULL); if (title_label) XtVaSetValues(title_label, XmNbackgroundPixmap, pixmap, NULL); return 1; } } return 0; }
static int motTabsSetBackgroundAttrib(Ihandle* ih, const char* value) { /* given value is used only for child, to the Tabs must use only from parent */ char* parent_value = iupAttribGetInheritNativeParent(ih, "BACKGROUND"); Pixel color = iupmotColorGetPixelStr(parent_value); if (color != (Pixel)-1) { iupmotSetBgColor(ih->handle, color); motTabsUpdatePageBgColor(ih, color); } else { Pixmap pixmap = (Pixmap)iupImageGetImage(parent_value, ih, 0, "BACKGROUND"); if (pixmap) { XtVaSetValues(ih->handle, XmNbackgroundPixmap, pixmap, NULL); motTabsUpdatePageBgPixmap(ih, pixmap); } } (void)value; return 1; }
static int winTabsMapMethod(Ihandle* ih) { DWORD dwStyle = WS_CHILD | WS_CLIPSIBLINGS | TCS_HOTTRACK | WS_TABSTOP, dwExStyle = 0; if (!ih->parent) return IUP_ERROR; if (ih->data->type == ITABS_BOTTOM) dwStyle |= TCS_BOTTOM; else if (ih->data->type == ITABS_RIGHT) dwStyle |= TCS_VERTICAL|TCS_RIGHT; else if (ih->data->type == ITABS_LEFT) dwStyle |= TCS_VERTICAL; if (ih->data->is_multiline) dwStyle |= TCS_MULTILINE; iupwinGetNativeParentStyle(ih, &dwExStyle, &dwStyle); if (dwExStyle & WS_EX_COMPOSITED && !ih->data->is_multiline && iupwinIsVista()) { /* workaround for composite bug in Vista */ ih->data->is_multiline = 1; dwStyle |= TCS_MULTILINE; } if (!iupwinCreateWindowEx(ih, WC_TABCONTROL, dwExStyle, dwStyle)) return IUP_ERROR; /* replace the WinProc to handle other messages */ IupSetCallback(ih, "_IUPWIN_CTRLPROC_CB", (Icallback)winTabsProc); /* Process WM_NOTIFY */ IupSetCallback(ih, "_IUPWIN_NOTIFY_CB", (Icallback)winTabsWmNotify); /* Process background color */ IupSetCallback(ih, "_IUPWIN_CTLCOLOR_CB", (Icallback)winTabsCtlColor); if (iupwin_comctl32ver6 && ih->data->type != ITABS_TOP) { /* XP Styles support only TABTYPE=TOP */ iupwinDrawRemoveTheme(ih->handle); } /* Change children background */ if (winTabsUsingXPStyles(ih)) { char* color = iupAttribGetInheritNativeParent(ih, "BGCOLOR"); if (!color) color = iupAttribGetInheritNativeParent(ih, "BACKGROUND"); if (!color) { COLORREF cr; if (iupwinDrawGetThemeTabsBgColor(ih->handle, &cr)) iupAttribSetStrf(ih, "BACKGROUND", "%d %d %d", (int)GetRValue(cr), (int)GetGValue(cr), (int)GetBValue(cr)); } } /* Create pages and tabs */ if (ih->firstchild) { Ihandle* child; for (child = ih->firstchild; child; child = child->brother) winTabsChildAddedMethod(ih, child); } return IUP_NOERROR; }