Commit de5809b7 authored by Monty Montgomery's avatar Monty Montgomery

add bounded trough to multibar


git-svn-id: https://svn.xiph.org/trunk/postfish@5831 0101bb08-14d6-0310-b084-bc0e0c8e3800
parent e28a9f3b
......@@ -10,10 +10,12 @@ BINDIR=$PREFIX/bin
ETCDIR=/etc
MANDIR=$PREFIX/man
SRC = main.c mainpanel.c multibar.c readout.c input.c output.c clippanel.c declip.c \
reconstruct.c smallft.c windowbutton.c subpanel.c feedback.c
OBJ = main.o mainpanel.o multibar.o readout.o input.o output.o clippanel.o declip.o \
reconstruct.o smallft.o windowbutton.o subpanel.o feedback.o
SRC = main.c mainpanel.c multibar.c readout.c input.c output.c clippanel.c \
declip.c reconstruct.c smallft.c windowbutton.c subpanel.c \
feedback.c freq.c eq.c eqpanel.c
OBJ = main.o mainpanel.o multibar.o readout.o input.o output.o clippanel.o \
declip.o reconstruct.o smallft.o windowbutton.o subpanel.o \
feedback.o freq.o eq.o eqpanel.o
GCF = `pkg-config --cflags gtk+-2.0` -DG_DISABLE_DEPRECATED -DGDK_DISABLE_DEPRECATED -DGTK_DISABLE_DEPRECATED -DGDK_PIXBUF_DISABLE_DEPRECATED
all:
......
/*
*
* postfish
*
* Copyright (C) 2002-2004 Monty
*
* Postfish 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, or (at your option)
* any later version.
*
* Postfish 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 Postfish; see the file COPYING. If not, write to the
* Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
*
*
*/
#include "postfish.h"
extern void clippanel_create(postfish_mainpanel *mp,
......
/*
*
* postfish
*
* Copyright (C) 2002-2004 Monty and Xiph.Org
*
* Postfish 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, or (at your option)
* any later version.
*
* Postfish 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 Postfish; see the file COPYING. If not, write to the
* Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
*
*
*/
#include "postfish.h"
#include "feedback.h"
#include "freq.h"
#include "eq.h"
extern int input_size;
sig_atomic_t eq_active;
freq_state eq;
int pull_eq_feedback(double **peak,double **rms){
return pull_freq_feedback(&eq,peak,rms);
}
/* called only by initial setup */
int eq_load(void){
return freq_load(&eq,input_size);
}
/* called only in playback thread */
int eq_reset(){
return freq_reset(&eq);
}
static void workfunc(double *data,freq_state *f,
double *peak, double *rms){
return;
}
/* called only by playback thread */
time_linkage *eq_read(time_linkage *in){
return freq_read(in,&eq,workfunc);
}
/*
*
* postfish
*
* Copyright (C) 2002-2004 Monty and Xiph.Org
*
* Postfish 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, or (at your option)
* any later version.
*
* Postfish 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 Postfish; see the file COPYING. If not, write to the
* Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
*
*
*/
#include "postfish.h"
extern int pull_eq_feedback(double **peak,double **rms);
extern int eq_load(void);
extern int eq_reset();
extern time_linkage *eq_read(time_linkage *in);
/*
*
* postfish
*
* Copyright (C) 2002-2004 Monty
*
* Postfish 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, or (at your option)
* any later version.
*
* Postfish 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 Postfish; see the file COPYING. If not, write to the
* Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
*
*
*/
#include "postfish.h"
#include <gtk/gtk.h>
#include <gdk/gdkkeysyms.h>
#include "readout.h"
#include "multibar.h"
#include "mainpanel.h"
#include "subpanel.h"
#include "feedback.h"
#include "freq.h"
#include "eq.h"
extern sig_atomic_t eq_active;
extern int input_ch;
extern int input_size;
extern int input_rate;
typedef struct {
GtkWidget *slider;
GtkWidget *readout;
int number;
} bar;
bar bars[freqs];
static void slider_change(GtkWidget *w,gpointer in){
char buffer[80];
bar *b=(bar *)in;
gdouble val=multibar_get_value(MULTIBAR(b->slider),0);
sprintf(buffer,"%+5.1f dB",val);
readout_set(READOUT(b->readout),buffer);
//eq_setlevel(val,p->number);
}
void eqpanel_create(postfish_mainpanel *mp,
GtkWidget *windowbutton,
GtkWidget *activebutton){
int i;
char *labels[15]={"-110","-100","-90","-80","-70","-60","-50","-40",
"-30","-20","-10","0","+10","+20","+30"};
double levels[16]={-120,-110,-100,-90,-80,-70,-60,-50,-40,
-30,-20,-10,0,10,20,30};
subpanel_generic *panel=subpanel_create(mp,windowbutton,activebutton,
&eq_active,
"_Equalization filter"," [e] ");
GtkWidget *slidertable=gtk_table_new(freqs,3,0);
for(i=0;i<freqs;i++){
const char *labeltext="";
if((i&1)==0)labeltext=freq_frequency_label(i);
GtkWidget *label=gtk_label_new(labeltext);
bars[i].readout=readout_new("+00.0 dB");
bars[i].slider=multibar_new(15,labels,levels,1,
LO_ATTACK|LO_DECAY|HI_DECAY);
bars[i].number=i;
multibar_callback(MULTIBAR(bars[i].slider),slider_change,bars+i);
multibar_thumb_set(MULTIBAR(bars[i].slider),0.,0);
multibar_thumb_bounds(MULTIBAR(bars[i].slider),-60,30);
gtk_misc_set_alignment(GTK_MISC(label),1,.5);
gtk_table_attach(GTK_TABLE(slidertable),label,0,1,i,i+1,
GTK_FILL,0,10,0);
gtk_table_attach(GTK_TABLE(slidertable),bars[i].readout,1,2,i,i+1,
GTK_FILL,0,0,0);
gtk_table_attach(GTK_TABLE(slidertable),bars[i].slider,2,3,i,i+1,
GTK_FILL|GTK_EXPAND,GTK_FILL|GTK_EXPAND,0,0);
}
gtk_box_pack_start(GTK_BOX(panel->subpanel_box),slidertable,1,1,4);
}
void eqpanel_feedback(void){
#if 0
int clip[input_ch],count;
double peak[input_ch];
if(pull_declip_feedback(clip,peak,&count)){
int i;
for(i=0;i<input_ch;i++){
double val[2],zero[2];
val[0]=-1.,zero[0]=-1.;
val[1]=(count?clip[i]*100./count-.1:-1);
zero[1]=-1.;
multibar_set(MULTIBAR(feedback_bars[i]),zero,val,2);
val[1]=(count?peak[i]:-1);
multibar_set(MULTIBAR(trigger_bars[i]),zero,val,2);
if(clip[i]){
multibar_setwarn(MULTIBAR(mainpanel_inbar));
multibar_setwarn(MULTIBAR(feedback_bars[i]));
multibar_setwarn(MULTIBAR(trigger_bars[i]));
}
}
}
#endif
}
void eqpanel_reset(void){
int i;
for(i=0;i<freqs;i++)
multibar_reset(MULTIBAR(bars[i].slider));
}
/*
*
* postfish
*
* Copyright (C) 2002-2004 Monty
*
* Postfish 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, or (at your option)
* any later version.
*
* Postfish 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 Postfish; see the file COPYING. If not, write to the
* Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
*
*
*/
#include "postfish.h"
extern void eqpanel_create(postfish_mainpanel *mp,
GtkWidget *windowbutton,
GtkWidget *activebutton);
extern void eqpanel_feedback(void);
extern void eqpanel_reset(void);
This diff is collapsed.
/*
*
* postfish
*
* Copyright (C) 2002-2004 Monty and Xiph.Org
*
* Postfish 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, or (at your option)
* any later version.
*
* Postfish 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 Postfish; see the file COPYING. If not, write to the
* Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
*
*
*/
#include "postfish.h"
#include "smallft.h"
#define freqs 39
typedef struct {
drft_lookup fft;
time_linkage out;
feedback_generic_pool feedpool;
int blocksize;
double **ho_window;
double ho_area[freqs];
int ho_bin_lo[freqs];
int ho_bin_hi[freqs];
double *window;
double **lap;
double **cache;
int cache_samples;
int fillstate; /* 0: uninitialized
1: normal
2: eof processed */
} freq_state;
extern int pull_freq_feedback(freq_state *ff,double **peak,double **rms);
extern int freq_load(freq_state *f,int blocksize);
extern int freq_reset(freq_state *f);
extern const char *freq_frequency_label(int n);
extern time_linkage *freq_read(time_linkage *in, freq_state *f,
void (*func)(double *data,freq_state *f,
double *peak, double *rms));
......@@ -43,6 +43,7 @@ int main(int argc, char **argv){
if(input_load(argc-1,argv+1))exit(1);
/* set up filter chains */
if(declip_load())exit(1);
if(eq_load())exit(1);
/* look at stdout... do we have a file or device? */
if(!isatty(STDOUT_FILENO)){
......
/*
*
* postfish
*
* Copyright (C) 2002-2004 Monty
*
* Postfish 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, or (at your option)
* any later version.
*
* Postfish 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 Postfish; see the file COPYING. If not, write to the
* Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
*
*
*/
#include "postfish.h"
#include <gtk/gtk.h>
......@@ -61,6 +83,7 @@ static void action_zero(GtkWidget *widget,postfish_mainpanel *p){
multibar_reset(MULTIBAR(p->inbar));
multibar_reset(MULTIBAR(p->outbar));
clippanel_reset();
eqpanel_reset();
}
static void action_end(GtkWidget *widget,postfish_mainpanel *p){
......@@ -74,6 +97,7 @@ static void action_end(GtkWidget *widget,postfish_mainpanel *p){
multibar_reset(MULTIBAR(p->inbar));
multibar_reset(MULTIBAR(p->outbar));
clippanel_reset();
eqpanel_reset();
}
static void action_bb(GtkWidget *widget,postfish_mainpanel *p){
......@@ -631,16 +655,20 @@ void mainpanel_create(postfish_mainpanel *panel,char **chlabels){
{
GtkWidget *box=gtk_hbox_new(0,0);
panel->masterdB_a=gtk_toggle_button_new_with_label("[m]aster");
GtkWidget *masterlabel=gtk_label_new("master:");
panel->masterdB_a=gtk_toggle_button_new_with_label("[m] active");
panel->masterdB_r=readout_new(" 0.0 dB");
panel->masterdB_s=gtk_hscale_new_with_range(-50,50,.1);
gtk_misc_set_alignment(GTK_MISC(masterlabel),1,.5);
gtk_range_set_value(GTK_RANGE(panel->masterdB_s),0);
gtk_scale_set_draw_value(GTK_SCALE(panel->masterdB_s),FALSE);
gtk_table_attach(GTK_TABLE(ttable),panel->masterdB_a,0,1,3,4,
gtk_table_attach(GTK_TABLE(ttable),masterlabel,0,1,3,4,
GTK_FILL,GTK_FILL,0,0);
gtk_box_pack_start(GTK_BOX(box),panel->masterdB_a,0,0,2);
gtk_box_pack_start(GTK_BOX(box),panel->masterdB_r,0,0,0);
gtk_box_pack_start(GTK_BOX(box),panel->masterdB_s,1,1,0);
......@@ -826,7 +854,7 @@ void mainpanel_create(postfish_mainpanel *panel,char **chlabels){
mainpanel_panelentry(panel,"_Declip ","[d]",0,clippanel_create);
mainpanel_panelentry(panel,"Cross_Talk ","[t]",1,0);
mainpanel_panelentry(panel,"_Noise Filter ","[n]",2,0);
mainpanel_panelentry(panel,"_Equalizer ","[e]",3,0);
mainpanel_panelentry(panel,"_Equalizer ","[e]",3,eqpanel_create);
mainpanel_panelentry(panel,"_Compander ","[c]",4,0);
mainpanel_panelentry(panel,"_Limiter ","[l]",5,0);
mainpanel_panelentry(panel,"_Output Cal. ","[o]",6,0);
......@@ -896,6 +924,7 @@ static gboolean feedback_process(postfish_mainpanel *panel){
}
clippanel_feedback();
eqpanel_feedback();
}
}
......
/*
*
* postfish
*
* Copyright (C) 2002-2004 Monty
*
* Postfish 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, or (at your option)
* any later version.
*
* Postfish 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 Postfish; see the file COPYING. If not, write to the
* Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
*
*
*/
#include "postfish.h"
struct postfish_mainpanel;
typedef struct postfish_mainpanel postfish_mainpanel;
#include "clippanel.h"
#include "eqpanel.h"
struct postfish_mainpanel{
GtkWidget *topframe;
......
/*
*
* postfish
*
* Copyright (C) 2002-2004 Monty
*
* Postfish 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, or (at your option)
* any later version.
*
* Postfish 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 Postfish; see the file COPYING. If not, write to the
* Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
*
*
*/
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
......@@ -352,27 +375,55 @@ static void draw(GtkWidget *widget,int n){
/* blank side padding to bg of parent */
gdk_draw_rectangle(m->backing,gc,1,0,0,xpad,height);
gdk_draw_rectangle(m->backing,gc,1,width,0,xpad,height);
/* dark trough */
gdk_draw_rectangle(m->backing,mid_gc,1,
xpad,height-lpad,width-xpad,lpad);
/* blank sides of trough */
gdk_draw_rectangle(m->backing,gc,1,
0,height-lpad,
m->thumblo_x+xpad,lpad);
gdk_draw_rectangle(m->backing,gc,1,
m->thumbhi_x+xpad,height-lpad,
width-m->thumbhi_x,lpad);
/* frame */
gdk_draw_line(m->backing,dark_gc,xpad-1,0,width,0);
gdk_draw_line(m->backing,dark_gc,xpad-1,0,xpad-1,height-2);
gdk_draw_line(m->backing,light_gc,xpad-1,height-1,width+1,height-1);
gdk_draw_line(m->backing,light_gc,width+1,0,width+1,height-1);
gdk_draw_line(m->backing,dark_gc,xpad-1,0,xpad-1,height-lpad);
gdk_draw_line(m->backing,dark_gc,xpad,height-lpad,width,height-lpad);
gdk_draw_line(m->backing,dark_gc,width,height-lpad,width,1);
gdk_draw_line(m->backing,light_gc,xpad-1,height-lpad+1,
width+1,height-lpad+1);
gdk_draw_line(m->backing,light_gc,width+1,0,width+1,height-lpad+1);
gdk_draw_line(m->backing,light_gc,xpad,1,width-1,1);
if(lpad>2)
gdk_draw_line(m->backing,light_gc,xpad,1,xpad,height-lpad);
else
gdk_draw_line(m->backing,light_gc,xpad,1,xpad,height-lpad-1);
gdk_draw_line(m->backing,light_gc,xpad,1,xpad,height-lpad-1);
/* dark trough */
if(lpad>2){
gdk_draw_rectangle(m->backing,mid_gc,1,
xpad+m->thumblo_x,height-lpad+1,
m->thumbhi_x-m->thumblo_x+1,lpad-1);
gdk_draw_line(m->backing,dark_gc,
m->thumblo_x+xpad-1,height-lpad+1,
m->thumblo_x+xpad-1,height-1);
gdk_draw_line(m->backing,light_gc,
m->thumblo_x+xpad-1,height-1,
m->thumbhi_x+xpad+1,height-1);
gdk_draw_line(m->backing,light_gc,
m->thumbhi_x+xpad+1,height-1,
m->thumbhi_x+xpad+1,height-lpad+1);
dark_gc=widget->style->dark_gc[GTK_STATE_ACTIVE];
gdk_draw_line(m->backing,dark_gc,
m->thumblo_x+xpad,height-lpad,
m->thumbhi_x+xpad,height-lpad);
}
}
......@@ -718,6 +769,9 @@ static gboolean configure(GtkWidget *widget, GdkEventConfigure *event){
compute(widget,0,0,0);
for(i=0;i<m->thumbs;i++)
m->thumbpixel[i]=val_to_pixel(widget,m->thumbval[i]);
m->thumblo_x=val_to_pixel(widget,m->thumblo);
m->thumbhi_x=val_to_pixel(widget,m->thumbhi);
draw_and_expose(widget);
return TRUE;
......@@ -914,9 +968,7 @@ gboolean key_press(GtkWidget *w,GdkEventKey *event){
static GtkDrawingAreaClass *parent_class = NULL;
static void multibar_class_init (MultibarClass *class){
GObjectClass *gobject_class = G_OBJECT_CLASS (class);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class);
GdkWindow *root=gdk_get_default_root_window();
parent_class = g_type_class_peek_parent (class);
widget_class->expose_event = expose;
......@@ -985,6 +1037,8 @@ GtkWidget* multibar_new (int n, char **labels, double *levels, int thumbs,
m->thumbgrab=-1;
m->thumblo=levels[0];
m->thumbhi=levels[n];
m->thumblo_x=val_to_pixel(ret,m->thumblo);
m->thumbhi_x=val_to_pixel(ret,m->thumbhi);
if(thumbs<0)thumbs=0;
if(thumbs>3)thumbs=3;
......@@ -1094,12 +1148,22 @@ double multibar_get_value(Multibar *m,int n){
void multibar_thumb_bounds(Multibar *m,double lo, double hi){
GtkWidget *w=GTK_WIDGET(m);
if(lo>hi)return;
if(lo<m->levels[0])lo=m->levels[0];
if(hi<m->levels[0])hi=m->levels[0];
if(lo>m->levels[m->labels])lo=m->levels[m->labels];
if(hi>m->levels[m->labels])hi=m->levels[m->labels];
m->thumblo=lo;
m->thumbhi=hi;
m->thumblo_x=val_to_pixel(w,lo);
m->thumbhi_x=val_to_pixel(w,hi);
vals_bound(m);
if(m->callback)m->callback(GTK_WIDGET(m),m->callbackp);
draw_and_expose(w);
}
/*
*
* postfish
*
* Copyright (C) 2002-2004 Monty
*
* Postfish 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, or (at your option)
* any later version.
*
* Postfish 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 Postfish; see the file COPYING. If not, write to the
* Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
*
*
*/
#ifndef __MULTIBAR_H__
#define __MULTIBAR_H__
......@@ -66,6 +89,9 @@ struct _Multibar{
double thumblo;
double thumbhi;
int thumblo_x;
int thumbhi_x;
int xpad;
void (*callback)(GtkWidget *,gpointer);
......
......@@ -50,7 +50,7 @@ style "multibar" {
text[NORMAL]="#c0c0d0"
text[ACTIVE]="#ffb0b0"
font_name = "sans 8"
font_name = "sans 6"
}
style "clipbar" {
......@@ -67,11 +67,7 @@ style "readout" {
bg[NORMAL]="#ffffff"
bg[ACTIVE]="#ffffff"
font_name = "fixed 8"
GtkMisc::xpad = 10
GtkMisc::xalign = 1.0
GtkWidget::width-request=100
GtkLabel::justify = right
font_name = "Nimbus Mono L, Courier New, Monospace 8"
}
style "darkpanel" {
......
......@@ -53,6 +53,7 @@
#define todB(x) ((x)==0?-400.f:log((x)*(x))*4.34294480f)
#define fromdB(x) (exp((x)*.11512925f))
#define toOC(n) (log(n)*1.442695f-5.965784f)
#define fromOC(o) (exp(((o)+5.965784f)*.693147f))
#define toBark(n) (13.1f*atan(.00074f*(n))+2.24f*atan((n)*(n)*1.85e-8f)+1e-4f*(n))
#define fromBark(z) (102.f*(z)-2.f*pow(z,2.f)+.4f*pow(z,3.f)+pow(1.46f,z)-1.f)
......
/*
*
* postfish
*
* Copyright (C) 2002-2004 Monty
*
* Postfish 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, or (at your option)
* any later version.
*
* Postfish 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 Postfish; see the file COPYING. If not, write to the
* Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
*
*
*/
#include <stdlib.h>
#include "readout.h"
static GtkFrameClass *parent_class = NULL;
static GtkDrawingAreaClass *parent_class = NULL;
static void readout_class_init (ReadoutClass *class){
GtkWidgetClass *widget_class = (GtkWidgetClass*) class;
parent_class = g_type_class_peek_parent (class);
static void draw(GtkWidget *widget){
Readout *r=READOUT(widget);
int width=widget->allocation.width;
int height=widget->allocation.height;
int px,py;
GdkGC *gc=widget->style->bg_gc[0];
GdkGC *text_gc=widget->style->text_gc[0];
GdkGC *light_gc=widget->style->light_gc[0];
GdkGC *dark_gc=widget->style->dark_gc[0];
/* blank pane */
gdk_draw_rectangle(r->backing,gc,1,
0,0,width,height);
/* draw layout */
pango_layout_get_pixel_size(r->layout,&px,&py);
gdk_draw_layout (r->backing,text_gc,
width-2-px-(py/2),(height-py)/2,
r->layout);
/* draw frame */
gdk_draw_rectangle(r->backing,dark_gc,0,
0,0,width-2,height-2);
gdk_draw_line(r->backing,light_gc,1,1,width-3,1);
gdk_draw_line(r->backing,light_gc,1,1,1,height-3);
gdk_draw_line(r->backing,light_gc,width-1,0,width-1,height-1);
gdk_draw_line(r->backing,light_gc,0,height-1,width-1,height-1);