/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#+
#+     Internet Radio Automation & Encoding Toolkit
#+
#+     Copyright (C) 2018 - 2025 by Kevin C. O'Kane
#+
#+     Kevin C. O'Kane
#+     kc.okane@gmail.com
#+     https://www.cs.uni.edu/~okane
#+     https://threadsafebooks.com/
#+
#+ This program is free software; you can redistribute it and/or modify
#+ it under the terms of the GNU General Public License as published by
#+ the Free Software Foundation; either version 2 of the License, or
#+ (at your option) any later version.
#+
#+ This program is distributed in the hope that it will be useful,
#+ but WITHOUT ANY WARRANTY; without even the implied warranty of
#+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#+ GNU General Public License for more details.
#+
#+ You should have received a copy of the GNU General Public License
#+ along with this program; if not, write to the Free Software
#+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
#+
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/

//	Sept 17, 2025

#include "includes.h"
#include "common-externs.h"

#define SLASH '/'

//--------------------------------------------------------------------------------
//      on_p1_scroll_event  on_p2_scroll_event  on_p3_scroll_event
//      on_p4_scroll_event on_p5_scroll_event on_p6_scroll_event
//      on_p7scroll_event on_p8_scroll_event  on_p9_scroll_event
//      on_p10_scroll_event  on_p11_scroll_event on_p12_scroll_event
//--------------------------------------------------------------------------------

#define P_BUTTON_SCROLL(NBR) \
        gboolean on_p## NBR ##_scroll_event(GtkEntry *b, GdkEventScroll *e) { \
                return scroll_event(e); }

P_BUTTON_SCROLL(1) P_BUTTON_SCROLL(2) P_BUTTON_SCROLL(3)   P_BUTTON_SCROLL(4)
P_BUTTON_SCROLL(5) P_BUTTON_SCROLL(6) P_BUTTON_SCROLL(7)   P_BUTTON_SCROLL(8)
P_BUTTON_SCROLL(9) P_BUTTON_SCROLL(10) P_BUTTON_SCROLL(11) P_BUTTON_SCROLL(12)


//---------------------------------------------------------------------------------------
//      on_p1_button_press_event  on_p2_button_press_event  on_p3_button_press_event
//      on_p4_button_press_event  on_p5_button_press_event  on_p6_button_press_event
//      on_p7_button_press_event  on_p8_button_press_event  on_p9_button_press_event
//      on_p10_button_press_event on_p11_button_press_event on_p12_button_press_event
//---------------------------------------------------------------------------------------

#define P_BUTTON_PRESS(NBR) \
        gboolean on_p## NBR ##_button_press_event \
                (GtkButton *btn, GdkEventButton *event, gpointer user_data) {  \
                if (event->state & GDK_CONTROL_MASK)  \
                        if (drag_source == -1) { \
                                gtkSetCursor(GDK_HAND1); \
                                drag_source =  SP->begin + NBR - 1;  \
                                return TRUE; /*no further processing*/ }  \
                        else { \
                                drag_target = SP->begin + NBR - 1; \
                                gtkSetCursor(GDK_TOP_LEFT_ARROW); \
                                on_p## NBR ##_drag_end (GTK_WIDGET(btn), NULL); \
                                return TRUE; } \
                drag_source = drag_target = -1;  \
                gtkSetCursor(GDK_TOP_LEFT_ARROW); \
                if (event->button == 1 ) return FALSE; /* left click */  \
                Message(mediaProbe(SP->begin + NBR - 1)); \
                return TRUE; \
                }

P_BUTTON_PRESS(1) P_BUTTON_PRESS(2)  P_BUTTON_PRESS(3)  P_BUTTON_PRESS(4)
P_BUTTON_PRESS(5) P_BUTTON_PRESS(6)  P_BUTTON_PRESS(7)  P_BUTTON_PRESS(8)
P_BUTTON_PRESS(9) P_BUTTON_PRESS(10) P_BUTTON_PRESS(11) P_BUTTON_PRESS(12)



//-----------------------------------------------------------------------------------------------
//      on_p1_clicked on_p2_clicked on_p3_clicked on_p4_clicked  on_p5_clicked on_p6_clicked
//      on_p7_clicked on_p8_clicked on_p9_clicked on_p10_clicked on_p11_clicked on_p12_clicked
//-----------------------------------------------------------------------------------------------

#define P_BUTTON_CLICKED(NBR1,NBR2) \
        void on_p## NBR1 ##_clicked(GtkWidget *b) { \
                on_button## NBR2 ##_clicked(NULL, NULL); }

P_BUTTON_CLICKED(1,3)  P_BUTTON_CLICKED(2,8)  P_BUTTON_CLICKED(3,9)  P_BUTTON_CLICKED(4,10)
P_BUTTON_CLICKED(5,11) P_BUTTON_CLICKED(6,12) P_BUTTON_CLICKED(7,13) P_BUTTON_CLICKED(8,14)
P_BUTTON_CLICKED(9,2)  P_BUTTON_CLICKED(10,5) P_BUTTON_CLICKED(11,6) P_BUTTON_CLICKED(12,15)

