static int motTextSetBgColorAttrib(Ihandle* ih, const char* value) { Widget sb_win = (Widget)iupAttribGet(ih, "_IUP_EXTRAPARENT"); if (sb_win) { Pixel color; /* ignore given value for the scrollbars, must use only from parent */ char* parent_value = iupBaseNativeParentGetBgColor(ih); color = iupmotColorGetPixelStr(parent_value); if (color != (Pixel)-1) { Widget sb = NULL; iupmotSetBgColor(sb_win, color); XtVaGetValues(sb_win, XmNverticalScrollBar, &sb, NULL); if (sb) iupmotSetBgColor(sb, color); XtVaGetValues(sb_win, XmNhorizontalScrollBar, &sb, NULL); if (sb) iupmotSetBgColor(sb, color); } } return iupdrvBaseSetBgColorAttrib(ih, value); /* use given value for contents */ }
static int motFrameSetBgColorAttrib(Ihandle* ih, const char* value) { Pixel color; if (!iupAttribGet(ih, "_IUPFRAME_HAS_BGCOLOR")) { /* ignore given value, must use only from parent */ value = iupBaseNativeParentGetBgColor(ih); } color = iupmotColorGetPixelStr(value); if (color != (Pixel)-1) { Widget child_manager = (Widget)iupAttribGet(ih, "_IUPMOT_FRAMECONTAINER"); if (!iupAttribGet(ih, "_IUPFRAME_HAS_BGCOLOR")) { Widget title_label; iupmotSetBgColor(ih->handle, color); iupmotSetBgColor(child_manager, color); title_label = (Widget)iupAttribGet(ih, "_IUPMOT_FRAMELABEL"); if (title_label) iupmotSetBgColor(title_label, color); } else iupmotSetBgColor(child_manager, color); return 1; } return 0; }
static int motCanvasSetBgColorAttrib(Ihandle* ih, const char* value) { Pixel color; /* ignore given value, must use only from parent for the scrollbars */ char* parent_value = iupBaseNativeParentGetBgColor(ih); color = iupmotColorGetPixelStr(parent_value); if (color != (Pixel)-1) { Widget sb; Widget sb_win = (Widget)iupAttribGet(ih, "_IUP_EXTRAPARENT"); iupmotSetBgColor(sb_win, color); sb = (Widget)iupAttribGet(ih, "_IUPMOT_SBVERT"); if (sb) iupmotSetBgColor(sb, color); sb = (Widget)iupAttribGet(ih, "_IUPMOT_SBHORIZ"); if (sb) iupmotSetBgColor(sb, color); } if (!IupGetCallback(ih, "ACTION")) iupdrvBaseSetBgColorAttrib(ih, value); /* Use the given value only here */ else { XSetWindowAttributes attrs; attrs.background_pixmap = None; XChangeWindowAttributes(iupmot_display, XtWindow(ih->handle), CWBackPixmap, &attrs); iupAttribSet(ih, "_IUPMOT_NO_BGCOLOR", "1"); } return 1; }
static void motTabsUpdatePageBgColor(Ihandle* ih, Pixel color) { Ihandle* child; for (child = ih->firstchild; child; child = child->brother) { Widget child_manager = (Widget)iupAttribGet(child, "_IUPTAB_CONTAINER"); if (child_manager) iupmotSetBgColor(child_manager, color); } }
static void motTabsUpdateButtonsBgColor(Ihandle* ih, Pixel color) { Ihandle* child; for (child = ih->firstchild; child; child = child->brother) { Widget tab_button = (Widget)iupAttribGet(child, "_IUPMOT_TABBUTTON"); if (tab_button) iupmotSetBgColor(tab_button, color); } }
int iupdrvBaseSetBgColorAttrib(Ihandle* ih, const char* value) { Pixel color = iupmotColorGetPixelStr(value); if (color != (Pixel)-1) { iupmotSetBgColor(ih->handle, color); /* update internal image cache for controls that have the IMAGE attribute */ iupImageUpdateParent(ih); } return 1; }
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 motTabsSetBgColorAttrib(Ihandle* ih, const char* value) { Pixel color; /* given value is used only for child, to the Tabs must use only from parent */ char* parent_value = iupBaseNativeParentGetBgColor(ih); color = iupmotColorGetPixelStr(parent_value); if (color != (Pixel)-1) { iupmotSetBgColor(ih->handle, color); motTabsUpdatePageBgColor(ih, color); } color = iupmotColorGetPixelStr(value); if (color != (Pixel)-1) motTabsUpdateButtonsBgColor(ih, color); return 1; }
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 void motTabsChildAddedMethod(Ihandle* ih, Ihandle* child) { if (IupGetName(child) == NULL) iupAttribSetHandleName(child); if (ih->handle) { Widget child_manager; Widget tab_button; int num_args = 0, pos; Arg args[30]; char *tabtitle, *tabimage, *background; Pixel color; /* open space for new tab number */ motTabsUpdatePageNumber(ih); pos = IupGetChildPos(ih, child); /* Create pages */ child_manager = XtVaCreateManagedWidget( "child_manager", xmBulletinBoardWidgetClass, ih->handle, /* Core */ XmNborderWidth, 0, /* Manager */ XmNshadowThickness, 0, XmNnavigationType, XmTAB_GROUP, XmNuserData, child, /* used only in motTabsConfigureNotify */ /* BulletinBoard */ XmNmarginWidth, 0, XmNmarginHeight, 0, XmNresizePolicy, XmRESIZE_NONE, /* no automatic resize of children */ /* Notebook Constraint */ XmNnotebookChildType, XmPAGE, XmNpageNumber, pos, XmNresizable, True, NULL); XtOverrideTranslations(child_manager, XtParseTranslationTable("<Configure>: iupTabsConfigure()")); tabtitle = iupAttribGet(child, "TABTITLE"); if (!tabtitle) tabtitle = iupTabsAttribGetStrId(ih, "TABTITLE", pos); tabimage = iupAttribGet(child, "TABIMAGE"); if (!tabimage) tabimage = iupTabsAttribGetStrId(ih, "TABIMAGE", pos); if (!tabtitle && !tabimage) tabtitle = " "; /* Create tabs */ /* Label */ iupmotSetArg(args[num_args++], XmNlabelType, tabtitle? XmSTRING: XmPIXMAP); iupmotSetArg(args[num_args++], XmNmarginHeight, 0); iupmotSetArg(args[num_args++], XmNmarginWidth, 0); /* Notebook Constraint */ iupmotSetArg(args[num_args++], XmNnotebookChildType, XmMAJOR_TAB); iupmotSetArg(args[num_args++], XmNpageNumber, pos); tab_button = XtCreateManagedWidget("tab_button", xmPushButtonWidgetClass, ih->handle, args, num_args); /* Disable Drag Source */ iupmotDisableDragSource(tab_button); XtAddEventHandler(tab_button, EnterWindowMask, False, (XtEventHandler)iupmotEnterLeaveWindowEvent, (XtPointer)ih); XtAddEventHandler(tab_button, LeaveWindowMask, False, (XtEventHandler)iupmotEnterLeaveWindowEvent, (XtPointer)ih); XtAddEventHandler(tab_button, FocusChangeMask, False, (XtEventHandler)iupmotFocusChangeEvent, (XtPointer)ih); XtAddEventHandler(tab_button, KeyPressMask, False, (XtEventHandler)iupmotKeyPressEvent, (XtPointer)ih); if (tabtitle) iupmotSetString(tab_button, XmNlabelString, tabtitle); else { Pixmap pixmap = (Pixmap)iupImageGetImage(tabimage, ih, 0, "TABIMAGE"); if (pixmap) XtVaSetValues(tab_button, XmNlabelPixmap, pixmap, NULL); } background = iupBaseNativeParentGetBgColorAttrib(ih); color = iupmotColorGetPixelStr(background); if (color != -1) iupmotSetBgColor(child_manager, color); else { Pixmap pixmap = (Pixmap)iupImageGetImage(background, ih, 0, "BACKGROUND"); if (pixmap) { XtVaSetValues(child_manager, XmNbackgroundPixmap, pixmap, NULL); } } background = iupAttribGetStr(ih, "BGCOLOR"); color = iupmotColorGetPixelStr(background); if (color != -1) iupmotSetBgColor(tab_button, color); color = iupmotColorGetPixelStr(IupGetAttribute(ih, "FGCOLOR")); XtVaSetValues(tab_button, XmNforeground, color, NULL); XtRealizeWidget(child_manager); XtRealizeWidget(tab_button); iupAttribSetStr(child, "_IUPTAB_CONTAINER", (char*)child_manager); iupAttribSetStr(child, "_IUPMOT_TABBUTTON", (char*)tab_button); iupAttribSetInt(child, "_IUPMOT_TABNUMBER", pos); } }
static int motListSetBgColorAttrib(Ihandle* ih, const char* value) { Widget sb_win = (Widget)iupAttribGet(ih, "_IUP_EXTRAPARENT"); if (sb_win) { Pixel color; /* ignore given value for the scrollbars, must use only from parent */ char* parent_value = iupBaseNativeParentGetBgColor(ih); color = iupmotColorGetPixelStr(parent_value); if (color != (Pixel)-1) { Widget sb = NULL; iupmotSetBgColor(sb_win, color); XtVaGetValues(sb_win, XmNverticalScrollBar, &sb, NULL); if (sb) iupmotSetBgColor(sb, color); XtVaGetValues(sb_win, XmNhorizontalScrollBar, &sb, NULL); if (sb) iupmotSetBgColor(sb, color); } return iupdrvBaseSetBgColorAttrib(ih, value); /* use given value for contents */ } else { char* parent_value; /* use given value for Edit and List also */ Pixel color = iupmotColorGetPixelStr(value); if (color != (Pixel)-1) { Widget cbedit, cblist, sb; iupmotSetBgColor(ih->handle, color); XtVaGetValues(ih->handle, XmNtextField, &cbedit, NULL); if (cbedit) iupmotSetBgColor(cbedit, color); XtVaGetValues(ih->handle, XmNlist, &cblist, NULL); if (cblist) iupmotSetBgColor(cblist, color); XtVaGetValues(cblist, XmNverticalScrollBar, &sb, NULL); if (sb) iupmotSetBgColor(sb, color); XtVaGetValues(cblist, XmNhorizontalScrollBar, &sb, NULL); if (sb) iupmotSetBgColor(sb, color); } /* but reset just the background, so the combobox will look like a button */ parent_value = iupBaseNativeParentGetBgColor(ih); color = iupmotColorGetPixelStr(parent_value); if (color != (Pixel)-1) XtVaSetValues(ih->handle, XmNbackground, color, NULL); return 1; } }