1 /*
2  * ui_skinned_window.h
3  * Copyright 2011 John Lindgren
4  *
5  * This file is part of Audacious.
6  *
7  * Audacious is free software: you can redistribute it and/or modify it under
8  * the terms of the GNU General Public License as published by the Free Software
9  * Foundation, version 2 or version 3 of the License.
10  *
11  * Audacious is distributed in the hope that it will be useful, but WITHOUT ANY
12  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
13  * A PARTICULAR PURPOSE. See the GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License along with
16  * Audacious. If not, see <http://www.gnu.org/licenses/>.
17  *
18  * The Audacious team does not consider modular code linking to Audacious or
19  * using our public API to be a derived work.
20  */
21 
22 #ifndef SKINS_UI_SKINNED_WINDOW_H
23 #define SKINS_UI_SKINNED_WINDOW_H
24 
25 #include "widget.h"
26 
27 #include <libaudcore/objects.h>
28 
29 enum {
30     WINDOW_MAIN,
31     WINDOW_EQ,
32     WINDOW_PLAYLIST,
33     N_WINDOWS
34 };
35 
36 class Window : public Widget
37 {
38 public:
39     Window (int id, int * x, int * y, int w, int h, bool shaded);
40     ~Window ();
41 
42     void resize (int w, int h);
43     void set_shapes (GdkRegion * shape, GdkRegion * sshape);
is_shaded()44     bool is_shaded () { return m_is_shaded; }
45     void set_shaded (bool shaded);
46     void put_widget (bool shaded, Widget * widget, int x, int y);
47     void move_widget (bool shaded, Widget * widget, int x, int y);
48 
setWindowTitle(const char * title)49     void setWindowTitle (const char * title)
50         { gtk_window_set_title ((GtkWindow *) gtk (), title); }
getPosition(int * x,int * y)51     void getPosition (int * x, int * y)
52         { gtk_window_get_position ((GtkWindow *) gtk (), x, y); }
move(int x,int y)53     void move (int x, int y)
54         { gtk_window_move ((GtkWindow *) gtk (), x, y); }
55 
56 protected:
57     void realize ();
58     bool keypress (GdkEventKey * event);  // in main.cc
59     bool button_press (GdkEventButton * event);
60     bool button_release (GdkEventButton * event);
61     bool motion (GdkEventMotion * event);
62     bool close ();
63 
64 private:
65     void apply_shape ();
66 
67     const int m_id;
68     bool m_is_shaded = false;
69     bool m_is_moving = false;
70     GtkWidget * m_normal = nullptr, * m_shaded = nullptr;
71     SmartPtr<GdkRegion, gdk_region_destroy> m_shape, m_sshape;
72 };
73 
74 void dock_add_window (int id, Window * window, int * x, int * y, int w, int h);
75 void dock_remove_window (int id);
76 void dock_set_size (int id, int w, int h);
77 void dock_move_start (int id, int x, int y);
78 void dock_move (int x, int y);
79 void dock_change_scale (int old_scale, int new_scale);
80 
81 #endif
82