void iupDrawParentBackground(IdrawCanvas* dc) { unsigned char r=0, g=0, b=0; char* color = iupBaseNativeParentGetBgColorAttrib(dc->ih); iupStrToRGB(color, &r, &g, &b); iupDrawRectangle(dc, 0, 0, dc->w-1, dc->h-1, r, g, b, IUP_DRAW_FILL); }
void iupwinDrawParentBackground(Ihandle* ih, HDC hDC, RECT* rect) { unsigned char r=0, g=0, b=0; char* color = iupBaseNativeParentGetBgColorAttrib(ih); iupStrToRGB(color, &r, &g, &b); SetDCBrushColor(hDC, RGB(r,g,b)); FillRect(hDC, rect, (HBRUSH)GetStockObject(DC_BRUSH)); }
static char* iFlatButtonGetBgColorAttrib(Ihandle* ih) { char* value = iupAttribGet(ih, "BGCOLOR"); if (!value) return iupBaseNativeParentGetBgColorAttrib(ih); else return value; }
int iupwinGetParentBgColor(Ihandle* ih, COLORREF* cr) { unsigned char r, g, b; char* color = iupBaseNativeParentGetBgColorAttrib(ih); if (iupStrToRGB(color, &r, &g, &b)) { *cr = RGB(r,g,b); return 1; } return 0; }
static int winTabsCtlColor(Ihandle* ih, HDC hdc, LRESULT *result) { /* works only when NOT winTabsUsingXPStyles */ unsigned char r, g, b; char* color = iupBaseNativeParentGetBgColorAttrib(ih); if (iupStrToRGB(color, &r, &g, &b)) { SetDCBrushColor(hdc, RGB(r,g,b)); *result = (LRESULT)GetStockObject(DC_BRUSH); return 1; } return 0; }
static char* winButtonGetBgColorAttrib(Ihandle* ih) { /* the most important use of this is to provide the correct background for images */ if (iupwin_comctl32ver6 && ih->data->type&IUP_BUTTON_IMAGE && !iupAttribGet(ih, "IMPRESS")) { COLORREF cr; if (iupwinDrawGetThemeButtonBgColor(ih->handle, &cr)) return iupStrReturnStrf("%d %d %d", (int)GetRValue(cr), (int)GetGValue(cr), (int)GetBValue(cr)); } if (iupAttribGet(ih, "IMPRESS")) return iupBaseNativeParentGetBgColorAttrib(ih); else return NULL; }
static char* winToggleGetBgColorAttrib(Ihandle* ih) { /* the most important use of this is to provide the correct background for images */ if (iupwin_comctl32ver6 && ih->data->type==IUP_TOGGLE_IMAGE) { COLORREF cr; if (iupwinDrawGetThemeButtonBgColor(ih->handle, &cr)) return iupStrReturnStrf("%d %d %d", (int)GetRValue(cr), (int)GetGValue(cr), (int)GetBValue(cr)); } if (ih->data->type == IUP_TOGGLE_TEXT) return iupBaseNativeParentGetBgColorAttrib(ih); else return IupGetGlobal("DLGBGCOLOR"); }
static char* winButtonGetBgColorAttrib(Ihandle* ih) { /* the most important use of this is to provide the correct background for images */ if (iupwin_comctl32ver6 && !iupAttribGet(ih, "IMPRESS")) { COLORREF cr; if (iupwinDrawGetThemeButtonBgColor(ih->handle, &cr)) { char* str = iupStrGetMemory(20); sprintf(str, "%d %d %d", (int)GetRValue(cr), (int)GetGValue(cr), (int)GetBValue(cr)); return str; } } if (iupAttribGet(ih, "IMPRESS")) return iupBaseNativeParentGetBgColorAttrib(ih); else return NULL; }
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 iExpanderAction_CB(Ihandle* bar) { Ihandle *ih = bar->parent; IdrawCanvas *dc = iupDrawCreateCanvas(bar); unsigned char r=0, g=0, b=0; unsigned char bg_r=0, bg_g=0, bg_b=0; char* title = iupAttribGetStr(ih, "TITLE"); iupStrToRGB(iupBaseNativeParentGetBgColorAttrib(ih), &bg_r, &bg_g, &bg_b); iupStrToRGB(IupGetAttribute(ih, "FGCOLOR"), &r, &g, &b); iupDrawParentBackground(dc); if (ih->data->position == IEXPANDER_TOP && title) { /* left align everything */ int len; iupStrNextLine(title, &len); /* get the length of the first line */ iupDrawText(dc, title, len, IEXPAND_HANDLE_SIZE, 0, r, g, b, IupGetAttribute(ih, "FONT")); if (ih->data->highlight) iExpanderHighligh(&r, &g, &b); if (ih->data->state == IEXPANDER_CLOSE) iExpanderDrawArrow(dc, 1, 0, r, g, b, bg_r, bg_g, bg_b, IEXPANDER_RIGHT); else iExpanderDrawArrow(dc, 0, 0, r, g, b, bg_r, bg_g, bg_b, IEXPANDER_BOTTOM); } else { /* center align the arrow */ int x, y; if (ih->data->highlight) iExpanderHighligh(&r, &g, &b); switch(ih->data->position) { case IEXPANDER_LEFT: x = 0; y = (bar->currentheight - IEXPAND_HANDLE_SIZE)/2; if (ih->data->state == IEXPANDER_CLOSE) iExpanderDrawArrow(dc, x, y, r, g, b, bg_r, bg_g, bg_b, IEXPANDER_RIGHT); else iExpanderDrawArrow(dc, x, y, r, g, b, bg_r, bg_g, bg_b, IEXPANDER_LEFT); break; case IEXPANDER_TOP: x = (bar->currentwidth - IEXPAND_HANDLE_SIZE)/2; y = 0; if (ih->data->state == IEXPANDER_CLOSE) iExpanderDrawArrow(dc, x, y, r, g, b, bg_r, bg_g, bg_b, IEXPANDER_BOTTOM); else iExpanderDrawArrow(dc, x, y, r, g, b, bg_r, bg_g, bg_b, IEXPANDER_TOP); break; case IEXPANDER_RIGHT: x = 0; y = (bar->currentheight - IEXPAND_HANDLE_SIZE)/2; if (ih->data->state == IEXPANDER_CLOSE) iExpanderDrawArrow(dc, x, y, r, g, b, bg_r, bg_g, bg_b, IEXPANDER_LEFT); else iExpanderDrawArrow(dc, x, y, r, g, b, bg_r, bg_g, bg_b, IEXPANDER_RIGHT); break; case IEXPANDER_BOTTOM: x = (bar->currentwidth - IEXPAND_HANDLE_SIZE)/2; y = 0; if (ih->data->state == IEXPANDER_CLOSE) iExpanderDrawArrow(dc, x, y, r, g, b, bg_r, bg_g, bg_b, IEXPANDER_TOP); else iExpanderDrawArrow(dc, x, y, r, g, b, bg_r, bg_g, bg_b, IEXPANDER_BOTTOM); break; } } iupDrawFlush(dc); iupDrawKillCanvas(dc); return IUP_DEFAULT; }
static int iFlatButtonRedraw_CB(Ihandle* ih) { char *image = iupAttribGet(ih, "IMAGE"); char* title = iupAttribGet(ih, "TITLE"); int active = IupGetInt(ih, "ACTIVE"); /* native implementation */ int selected = iupAttribGetInt(ih, "VALUE"); char* fgcolor = iupAttribGetStr(ih, "FGCOLOR"); char* bgcolor = iupAttribGetStr(ih, "BGCOLOR"); char* bgimage = iupAttribGet(ih, "BACKIMAGE"); char* fgimage = iupAttribGet(ih, "FRONTIMAGE"); int border_width = ih->data->border_width; int draw_border = 0; int old_pressed = ih->data->pressed; IdrawCanvas* dc = iupDrawCreateCanvas(ih); iupDrawParentBackground(dc); if (!bgcolor) bgcolor = iupBaseNativeParentGetBgColorAttrib(ih); if (ih->data->pressed || selected) { char* presscolor = iupAttribGetStr(ih, "PSCOLOR"); if (presscolor) bgcolor = presscolor; draw_border = 1; if (!ih->data->pressed && (bgimage || image)) ih->data->pressed = 1; } else if (ih->data->highlight) { char* hlcolor = iupAttribGetStr(ih, "HLCOLOR"); if (hlcolor) bgcolor = hlcolor; draw_border = 1; } /* draw border - can still be disabled setting border_width=0 */ if (draw_border) { char* bordercolor = iupAttribGetStr(ih, "BORDERCOLOR"); iFlatButtonDrawBorder(dc, 0, ih->currentwidth - 1, 0, ih->currentheight - 1, border_width, bordercolor, bgcolor, active); } /* draw background */ if (bgimage) iFlatButtonDrawImage(ih, dc, border_width, border_width, "BACKIMAGE", bgimage, active); else iFlatButtonDrawBox(dc, border_width, ih->currentwidth - 1 - border_width, border_width, ih->currentheight - 1 - border_width, bgcolor, NULL, 1); /* always active */ iFlatButtonDrawIcon(ih, dc, border_width, border_width, ih->currentwidth - 2 * border_width, ih->currentheight - 2 * border_width, "IMAGE", image, title, fgcolor, bgcolor, active); if (fgimage) iFlatButtonDrawImage(ih, dc, border_width, border_width, "FRONTIMAGE", fgimage, active); else if (!image && !title) { int space = border_width + 2; iFlatButtonDrawBorder(dc, space, ih->currentwidth - 1 - space, space, ih->currentheight - 1 - space, 1, "0 0 0", bgcolor, active); space++; iFlatButtonDrawBox(dc, space, ih->currentwidth - 1 - space, space, ih->currentheight - 1 - space, fgcolor, bgcolor, active); } if (selected && !old_pressed && (bgimage || image)) ih->data->pressed = 0; if (ih->data->has_focus) iupDrawFocusRect(dc, border_width, border_width, ih->currentwidth - 2 * border_width, ih->currentheight - 2 * border_width); iupDrawFlush(dc); iupDrawKillCanvas(dc); return IUP_DEFAULT; }