File indexing completed on 2024-05-12 05:34:33

0001 #ifndef oxygengroupboxlabeldata_h
0002 #define oxygengroupboxlabeldata_h
0003 /*
0004 * this file is part of the oxygen gtk engine
0005 * SPDX-FileCopyrightText: 2010 Hugo Pereira Da Costa <hugo.pereira@free.fr>
0006 *
0007 * SPDX-License-Identifier: LGPL-2.0-or-later
0008 */
0009 
0010 #include "../oxygengtkutils.h"
0011 
0012 #include <gtk/gtk.h>
0013 
0014 namespace Oxygen
0015 {
0016     // track groupboxlabels
0017     class GroupBoxLabelData
0018     {
0019 
0020         public:
0021 
0022         //! constructor
0023         GroupBoxLabelData( void ):
0024             _resized( false )
0025         {}
0026 
0027         //! destructor
0028         virtual ~GroupBoxLabelData( void )
0029         {}
0030 
0031         //! setup connections
0032         void connect( GtkWidget* )
0033         {}
0034 
0035         //! disconnect
0036         void disconnect( GtkWidget* )
0037         { _resized = false; }
0038 
0039         //! adjust widget size
0040         void adjustSize( GtkWidget* widget )
0041         {
0042             if( _resized ) return;
0043             const GdkRectangle allocation( Gtk::gtk_widget_get_allocation( widget ) );
0044             if( allocation.height > 1 )
0045             {
0046 
0047                 // Save resized state before actually resizing to prevent infinite recursion (bug 305833)
0048                 _resized = true;
0049                 gtk_widget_set_size_request( widget, allocation.width, allocation.height+14 );
0050 
0051             }
0052         }
0053 
0054         private:
0055 
0056         bool _resized;
0057 
0058     };
0059 
0060 }
0061 
0062 #endif