[Cin] How to add correctly BC_TumbleTextBox ?

Phyllis Smith phylsmith2017 at gmail.com
Mon Mar 16 17:01:27 CET 2020

Turns out there are widgets and gadgets (old school parlance).  Widgets
usually involve a window base class, and gadgets usually involve a set of
widgets or gadgets.  A BC_TumbleTextBox is a gadget, which has a textbox
widget and a tumbler widget.  The "create_objects()" call is mandatory for
gadgets. A gadget tries to create an organized set of widgets as a
graphical component.   It may have a window base class, and may need an
add_subwindow... or (as with most of them) it may just be a group of
objects, usually with a common x,y,w,h base class definition.  For a
BC_TumbleTextBox, just call create objects, and do not add_subwindow.   The
exact initialization order determines this, and can be variable.  For
instance, a popup menu, or a list box may need add_window, and also a
create_objects to load the widget content prior to invoking the draw.

It is frequently attractive (from a programming perspective) to add a
pointer to the widgets and gadgets in the gui base class so that you can
easily access them from the debugger.  add_subwindow adds the subwindow to
the gui subwindow list, and makes it part of the window hierarchy.
Anything created and added with add_subwindow should probably not be
deleted in the destructor.  The destruction of the gui will delete it
normally.   You can delete a subwindow (lock the gui), and it is ok to do
that if your intent to to re-factor the gui appearance after construction.
Gadgets usually need to be deleted in the gui destructor since the object
is not in the gui subwindow set.  If you dont delete it, it wont cause an
error, but it will be a memory leak.

I tweaked/attached the patch for your review.  It is not tested,

On Mon, Mar 16, 2020 at 5:29 AM Andrew Randrianasulu <
randrianasulu at gmail.com> wrote:

> I tried to add png compression level into filepng.c
> But I did something stupid, and whole thing doesn't compile:
> root at slax:/dev/shm/tmp/cinelerra-goodguy-20200316/cinelerra-5.1/cinelerra#
> LANG=C make
> g++ `cat i686/c_flags`  -DMSGQUAL=filepng -c filepng.C -o i686/filepng.o
> filepng.C: In member function 'virtual void
> PNGConfigVideo::create_objects()':
> filepng.C:370:49: error: no matching function for call to
> 'PNGConfigVideo::add_subwindow(PNGCompression*)'
>   add_subwindow(new PNGCompression(this, x+50, y));
>                                                  ^
> In file included from
> /dev/shm/tmp/cinelerra-goodguy-20200316/cinelerra-5.1/cinelerra/../guicast/bcsubwindow.h:26:0,
>                  from
> /dev/shm/tmp/cinelerra-goodguy-20200316/cinelerra-5.1/cinelerra/../guicast/bcbar.h:26,
>                  from
> /dev/shm/tmp/cinelerra-goodguy-20200316/cinelerra-5.1/cinelerra/../guicast/guicast.h:27,
>                  from edit.h:30,
>                  from filepng.C:23:
> /dev/shm/tmp/cinelerra-goodguy-20200316/cinelerra-5.1/cinelerra/../guicast/bcwindowbase.h:276:17:
> note: candidate: BC_WindowBase* BC_WindowBase::add_subwindow(BC_WindowBase*)
>   BC_WindowBase* add_subwindow(BC_WindowBase *subwindow);
>                  ^
> /dev/shm/tmp/cinelerra-goodguy-20200316/cinelerra-5.1/cinelerra/../guicast/bcwindowbase.h:276:17:
> note:   no known conversion for argument 1 from 'PNGCompression*' to
> 'BC_WindowBase*'
> At global scope:
> cc1plus: warning: unrecognized command line option
> '-Wno-stringop-truncation'
> cc1plus: warning: unrecognized command line option '-Wno-format-overflow'
> cc1plus: warning: unrecognized command line option '-Wno-format-truncation'
> cc1plus: warning: unrecognized command line option '-Wno-stringop-overflow'
> cc1plus: warning: unrecognized command line option
> '-Wno-unknown-warning-option'
> make: *** [i686/filepng.o] Error 1
> patch attached ....
> --
> Cin mailing list
> Cin at lists.cinelerra-gg.org
> https://lists.cinelerra-gg.org/mailman/listinfo/cin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.cinelerra-gg.org/pipermail/cin/attachments/20200316/6780f83f/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: filepng.patch1
Type: application/octet-stream
Size: 4876 bytes
Desc: not available
URL: <https://lists.cinelerra-gg.org/pipermail/cin/attachments/20200316/6780f83f/attachment.obj>

More information about the Cin mailing list