[Iup-users] Use IupBackgroundBox with CD?

2021-06-21 Thread Isaac Raway
Is there any way to use IupBackgroundBox with CD?

I am currently using an IupCanvas and drawing into it successfully using CD. I 
would like to parent other controls onto this surface (such as IupMultitext, 
IupButton), but retain the ability to draw using CD since I have a lot of code 
written using that.

So if there was a way to copy the result from CD into IupBackgroundBox using 
IupDraw that would seem to do the job, but I can't quite seem to get it to 
work. The only way I could figure out to create a cdCanvas was to use 
CD_NATIVEWINDOW with a new Win32 HWND. The graphics are drawn into the HWND but 
then I can't get it copied out there into the BackgroundBox.

Here's what I have:

void win_create()
{

win->notes_graph= IupBackgroundBox();

IupSetCallback(win->notes_graph, "MAP_CB", (Icallback)graph_mapcb);
IupSetCallback(win->notes_graph, "UNMAP_CB", (Icallback)graph_unmapcb);
IupSetCallback(win->notes_graph, "RESIZE_CB", (Icallback)graph_resize);
IupSetCallback(win->notes_graph, "BUTTON_CB", (Icallback)graph_button);
IupSetCallback(win->notes_graph, "MOTION_CB", (Icallback)graph_motion);
IupSetCallback(win->notes_graph, "KEYPRESS_CB", (Icallback)graph_keypress);
IupSetCallback(win->notes_graph, "WHEEL_CB", (Icallback)graph_wheel);

IupSetCallback(win->notes_graph, "ACTION", 
(Icallback)graph_draw_backbuffer_to_container);

}

int graph_mapcb(_HANDLE_PTR self)
{
tWIN *win = (tWIN *)IupGetAttribute(self, "WIND");


   const wchar_t CLASS_NAME[] = L"BACKBUFFER";
WNDCLASS wc = { 0 };
wc.lpfnWndProc = DefWindowProc;
wc.hInstance = 0;
wc.lpszClassName = CLASS_NAME;
RegisterClass(&wc);
HWND hwnd = CreateWindowEx(
0,  // Optional window styles.
CLASS_NAME, // Window class
L"Learn to Program Windows",// Window text
WS_OVERLAPPEDWINDOW,// Window style

// Size and position
CW_USEDEFAULT, CW_USEDEFAULT, win->screenWidth, win->screenHeight,

NULL,   // Parent window   
NULL,   // Menu
0,  // Instance handle
NULL// Additional application data
);

  
  win->notes_cdGraph = cdCreateCanvas(CD_NATIVEWINDOW, hwnd);
return IUP_DEFAULT;
}

// I had to provide this signature for some reason even though I include cdim.h
void cdCanvasGetImImage(cdCanvas* canvas, imImage* image, int x, int y);

int graph_draw_backbuffer_to_container(_HANDLE_PTR self)
{
tWIN* win = (tWIN*)IupGetAttribute(self, "WIND");
cdCanvasGetImImage(win->cdGraph, win->backbuffer, 0, 0);
Ihandle *iupImage = IupImageFromImImage(win->backbuffer);
IupSetHandle("BACKBUFFER", iupImage);
IupDrawImage(win->notes_graph, "BACKBUFFER", 0, 0, win->graphWidth, 
win->graphHeight);
IupSetHandle("BACKBUFFER", NULL);
IupDestroy(iupImage);
}
___
Iup-users mailing list
Iup-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/iup-users


Re: [Iup-users] Theming

2021-06-21 Thread Antonio Scuri
I just saw you question at Stack Overflow:

https://stackoverflow.com/questions/67803879/how-do-i-use-the-iup-theme-attribute-defaulttheme-global-attribute

I will try to answer that later today.

Sorry for the delay.

Best,
Scuri


Em seg., 21 de jun. de 2021 às 15:58, Antonio Scuri 
escreveu:

>   No, you are not doing something stupid.
>
>   No it does not.
>
>   If an attribute is defined at the element, the dialog inheritance will
> not affect that element.
>
> Best,
> Scuri
>
>
> Em ter., 1 de jun. de 2021 às 13:51, colevalleyg...@colevalleygirl.co.uk <
> colevalleyg...@colevalleygirl.co.uk> escreveu:
>
>> Is there an order of precedence when theming a UI?
>>
>>
>>
>> If I have the following code:
>>
>>
>>
>>   iup.SetGlobal("DLGBGCOLOR","255 255 255") --default background colour
>>
>>   iup.SetGlobal("DLGFGCOLOR", "255,255,255") --default text color
>>
>>   myLabelTheme = iup.user{ fgcolor = "255 0 255"}
>>
>>   myTheme = iup.user{ IUPLABEL = myLabelTheme, }
>>
>>
>>
>> does the global default override the specific theme for labels? Or am I
>> doing something stupid?
>>
>>
>>
>>
>>
>>
>> ___
>> Iup-users mailing list
>> Iup-users@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/iup-users
>>
>
___
Iup-users mailing list
Iup-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/iup-users


Re: [Iup-users] Theming

2021-06-21 Thread Antonio Scuri
  No, you are not doing something stupid.

  No it does not.

  If an attribute is defined at the element, the dialog inheritance will
not affect that element.

Best,
Scuri


Em ter., 1 de jun. de 2021 às 13:51, colevalleyg...@colevalleygirl.co.uk <
colevalleyg...@colevalleygirl.co.uk> escreveu:

> Is there an order of precedence when theming a UI?
>
>
>
> If I have the following code:
>
>
>
>   iup.SetGlobal("DLGBGCOLOR","255 255 255") --default background colour
>
>   iup.SetGlobal("DLGFGCOLOR", "255,255,255") --default text color
>
>   myLabelTheme = iup.user{ fgcolor = "255 0 255"}
>
>   myTheme = iup.user{ IUPLABEL = myLabelTheme, }
>
>
>
> does the global default override the specific theme for labels? Or am I
> doing something stupid?
>
>
>
>
>
>
> ___
> Iup-users mailing list
> Iup-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/iup-users
>
___
Iup-users mailing list
Iup-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/iup-users