#include <fspanel.h>

applet_info_t info_g;

applet_info_t get_applet_info( void )
{
    return info_g;
}

set_applet_info( applet_info_t inf )
{
    info_g = inf;
    if( info_g.width == -1 )
    {
        info_g.width = 100;
    }
    
}

// NOTE to me ... consider passing in the display, root window, etc ...
int gui_draw( int x, void *token ) 
{
    char *wspace;
    int offset;
    int winheight;
    
    int width = info_g.width;
    
    winheight = panel_get_winheight();
    wspace = wm_get_current_workspace_name();
    if( wspace )
    {
        offset = XTextWidth ( x_get_fontstruct(), wspace, strlen(wspace)); 
        offset = (width - offset) / 2;

//        draw_line (tb, x + 1, 0, x + width, 0);
        
        set_foreground (1);
        // draw_line (tb, x + 1, winheight - 1, x + width, winheight - 1);
        
        //x++;
		/*set_foreground (1);*/		  /* mid gray */
		fill_rect ( x + 3, 3, width - 5, winheight - 6);
		set_foreground (3);		  /* white */
		draw_line ( x + 2, winheight - 2, x + width - 2, winheight - 2);
		draw_line ( x + width - 2, 2, x + width - 2, winheight - 2);
		set_foreground (0);
		draw_line ( x + 1, 2, x + 1, winheight - 2);
		set_foreground (4);		  /* darkest gray */
		draw_line ( x + 2, 2, x + width - 2, 2);
		draw_line ( x + 2, 2, x + 2, winheight - 3);
        
        set_foreground (5);	/* black */                   
        XDrawString( x_get_display(),
                     x_get_window(),
                     x_get_foregroundGC(),
                     x + offset,
                     panel_get_y_text_origin(),
                     wspace,
                     strlen(wspace) );
        free( wspace );

//        x--;
    }
    
    return x + width;
}


int gui_button_press ( int x, int y, int button, void *token )
{
    // nothing
    return 1;
}

int event_notification( void *token )
{

}

int gui_button_release ( int x, int y, int button, void *token )
{

}
