示例#1
0
/* set text to NULL for updating, to a value for new window stuff */
static void updateprogress( TWindow * sliderwin, TWidget * slider,
			    int newVal, char * displayText,
			    char * lineTwo )
{
	ttk_color menu_bg_color = 0;
	ttk_color menu_fg_color = 0;
	int textw;

	if( newVal < 0 ) newVal = 0; /* jsut in case */

	/* if displayText is non-NULL, rerender the whole thing */
	if( displayText || lineTwo ) {
		if( ttk_ap_getx( "menu.bg" ))
			menu_bg_color = ttk_ap_getx("menu.bg")->color;
		if( ttk_ap_getx( "menu.fg" ))
			menu_fg_color = ttk_ap_getx("menu.fg")->color;

		if( menu_fg_color == menu_bg_color ) {
		    if( menu_fg_color == 0 || menu_fg_color == 3 ) { /*why 3?*/
			menu_fg_color = ttk_makecol( BLACK );
			menu_bg_color = ttk_makecol( WHITE );
		    }
		}

		ttk_fillrect(sliderwin->srf,0,0,
				sliderwin->w,sliderwin->h,
				menu_bg_color );

		if( displayText ) {
			textw = ttk_text_width(ttk_textfont,displayText);
			ttk_text(sliderwin->srf,ttk_textfont,
				ttk_screen->w/ 2 - textw/2, ttk_screen->h/2,
				menu_fg_color, displayText);
		}

		if( lineTwo ) {
			textw = ttk_text_width(ttk_textfont, lineTwo);
			ttk_text(sliderwin->srf,ttk_textfont,
				ttk_screen->w/ 2 - textw/2, 
				ttk_screen->h/2 + ttk_textfont->height + 5,
				menu_fg_color, lineTwo);
		}
	}

	ttk_slider_set_val(slider,newVal);
	ttk_slider_draw(slider,sliderwin->srf);
	ttk_draw_window(sliderwin);
	ttk_gfx_update(ttk_screen->srf);
//	ttk_delay(10);  //useful for testing
}
示例#2
0
void draw_mymodule (PzWidget *wid, ttk_surface srf) 
{
    // Draw the message
    char *p = text;
    int y = wid->y + 5;
    while (*p) {
	char svch;
	if (strchr (p, '\n')) {
	    svch = *strchr (p, '\n');
	    *strchr (p, '\n') = 0;
	} else {
	    svch = 0;
	}
	ttk_text (srf, ttk_textfont, wid->x + 5, y, ttk_makecol (BLACK), p);
	p += strlen (p);
	y += ttk_text_height (ttk_textfont) + 1;
	*p = svch;
	if (*p) p++;
    }
    y += 3;
    // Dividing line
    ttk_line (srf, wid->x + 5, y, wid->x + wid->w - 5, y, ttk_makecol (DKGREY));
    
    y += 3;
    // The image
    ttk_blit_image (image, srf, wid->x + (wid->w - imgw) / 2, wid->y + (wid->h - imgh) / 2);
    y += imgh;
    
    // The message
#define MSG "Press a button to quit."
    ttk_text (srf, ttk_menufont, wid->x + (wid->w - ttk_text_width (ttk_menufont, MSG)) / 2,
	      wid->y + wid->h - ttk_text_height (ttk_menufont) - 5, ttk_makecol (BLACK), MSG);
}
示例#3
0
void ti_dial_draw(TWidget * wid, ttk_surface srf)
{
	int sc, n, i, j, ty;
	int m = ti_dial_max()+1;
	uc16 s[2] = {0,0};
	ttk_ap_fillrect(srf, ti_ap_getx(0), wid->x, wid->y, wid->x+wid->w, wid->y+wid->h);
	n = wid->w / CW;
	sc = ti_dial_charlist_pos - n/2;
	ty = 0;
	if (sc > (m-n) ) { sc = (m-n); }
	if (sc < 0) { sc = 0; }
	if (ti_dial_cursormode()) {
		ttk_text(srf, ttk_menufont, wid->x+(wid->w - ttk_text_width(ttk_menufont, ti_dial_cmstring))/2, wid->y+ty, ti_ap_get(1), ti_dial_cmstring);
	} else {
		for (i = sc, j = 0; ((i<m) && (j<n)); i++, j++)
		{
			s[0] = ti_dial_get_char(i);
			if (i == ti_dial_charlist_pos) {
				ttk_ap_fillrect(srf, ti_ap_getx(2), wid->x+j*CW, wid->y, wid->x+j*CW+CW, wid->y+wid->h);
				ttk_text_uc16(srf, ttk_menufont, wid->x+j*CW+(10-ttk_text_width_uc16(ttk_menufont, s))/2, wid->y+ty, ti_ap_get(3), s);
			} else {
				ttk_text_uc16(srf, ttk_menufont, wid->x+j*CW+(10-ttk_text_width_uc16(ttk_menufont, s))/2, wid->y+ty, ti_ap_get(1), s);
			}
		}
	}
}
示例#4
0
/* draws everything else */
void draw_1dtetris (TWidget *wid, ttk_surface srf)
{
	char buffer[8];
	if (score == 0) snprintf(buffer, 8, "%d", score); else	snprintf(buffer, 8, "%d00", score);

	// draw playfield
	ttk_fillrect (srf, 0, 0, w, HWH, ttk_makecol(BLACK));
	ttk_rect (srf, pf_x, 6, pf_x+pf_w, 6+pf_h, ttk_makecol(WHITE));
	ttk_line (srf, pf_x+1, 6, pf_x+pf_w-2, 6, ttk_makecol(BLACK));

	// draw next frame
	ttk_rect (srf, nf_x, nf_y, nf_x+nf_w, nf_y+nf_h, ttk_makecol(WHITE));
	ttk_text (srf, ttk_textfont, nf_x+1, nf_y-ttk_text_height(ttk_textfont), ttk_makecol(WHITE), "next");

	// draw score frame
	ttk_rect (srf, sf_x, nf_y, sf_x+sf_w, nf_y+nf_w, ttk_makecol(WHITE));
	ttk_text (srf, ttk_textfont, sf_x+1, nf_y-ttk_text_height(ttk_textfont), ttk_makecol(WHITE), "score");
	ttk_text (srf, ttk_textfont, sf_x+sf_w-ttk_text_width(ttk_textfont, buffer)-3, nf_y + (nf_w/2 - ttk_text_height(ttk_textfont)/2), ttk_makecol(WHITE), buffer);

	// draw moving brick
	draw_brick(srf, pf_x, 7-(sq_size*brick_length), brick_length, brick_depth);
	// draw next brick
	draw_brick(srf, nf_x+sq_size/2, nf_y+sq_size/2, next_length, 0);

	// hide bad programming skills for users eyes :)
	ttk_fillrect (srf, pf_x, 0, pf_x+pf_w, 6, ttk_makecol(BLACK));
}
示例#5
0
static void pp_place_text(PzWidget *wid, ttk_surface srf, void *text, int num) {
	int w, h;
	w = ttk_text_width(ttk_menufont,  (char *)text); 
	h = ttk_text_height(ttk_menufont);
	
	ttk_text(srf, ttk_menufont, w < wid->w ? (wid->w - w) / 2 : 8,
			h*num - (2*h)/3, ttk_ap_getx("window.fg")->color,
			(char *)text); 
}
示例#6
0
static int draw_duckhunt_highscore (TWidget *wid, ttk_surface srf)
{
    int length;
    char str[30];

    sprintf (str, "High Score = %d", readHighScore("/mnt/aj/duckhunt/hs"));
    length = ttk_text_width (ttk_menufont, str);
    ttk_fillrect (srf, 0, 0, ttk_screen->w, ttk_screen->h, ttk_makecol(WHITE));
    ttk_text (srf, ttk_menufont, (ttk_screen->w/2)-(length/2), (ttk_screen->h-HEADER)/2, ttk_makecol(BLACK), str);
    return 0;
}
示例#7
0
static void main_menu() 
{

	switch(ttk_screen->bpp){
		case 2: texts = ttk_makecol(WHITE); break;
		case 16: texts = ttk_makecol(151, 124, 33); break;
	}
		
	int width;
   	width = ttk_text_width (ttk_menufont, menu_opts[option]);
	 
	ttk_blit_image (menu_bg, iracer_srf, 0, 0);
	ttk_blit_image (menu_wheel, iracer_srf, (bgw/2)-((ipods[191])/2), ipods[44]);
	ttk_text (iracer_srf, ttk_menufont, (bgw/2)-(width/2), ipods[95], texts,menu_opts[option]);
}
示例#8
0
void draw_about_remote_ipod_widget (PzWidget *wid, ttk_surface srf) 
{
    // Draw the message
    int y = wid->y + 5;

	ttk_text (srf, ttk_textfont, wid->x + 5, y, ttk_makecol (BLACK), "Test");
	y += ttk_text_height (ttk_textfont) + 1;

	ttk_text (srf, ttk_textfont, wid->x + 5, y, ttk_makecol (BLACK), "Test2");
	y += ttk_text_height (ttk_textfont) + 1;
	
	if (check_kernel_module("tsb43aa82"))
 	ttk_text (srf, ttk_textfont, wid->x + 5, y, ttk_makecol (BLACK), "tsb43aa82 loaded");
	else
 	ttk_text (srf, ttk_textfont, wid->x + 5, y, ttk_makecol (BLACK), "tsb43aa82 NOT loaded");
	y += ttk_text_height (ttk_textfont) + 1;
	
	if (check_kernel_module("scsi_mod"))
 	ttk_text (srf, ttk_textfont, wid->x + 5, y, ttk_makecol (BLACK), "scsi_mod loaded");
	else
 	ttk_text (srf, ttk_textfont, wid->x + 5, y, ttk_makecol (BLACK), "scsi_mod NOT loaded");
	y += ttk_text_height (ttk_textfont) + 1;

	if (check_kernel_module("sd_mod"))
 	ttk_text (srf, ttk_textfont, wid->x + 5, y, ttk_makecol (BLACK), "sd_mod loaded");
	else
 	ttk_text (srf, ttk_textfont, wid->x + 5, y, ttk_makecol (BLACK), "sd_mod NOT loaded");
	y += ttk_text_height (ttk_textfont) + 1;
	
	if (check_kernel_module("sbp2"))
 	ttk_text (srf, ttk_textfont, wid->x + 5, y, ttk_makecol (BLACK), "sbp2 loaded");
	else
 	ttk_text (srf, ttk_textfont, wid->x + 5, y, ttk_makecol (BLACK), "sbp2 NOT loaded");
	y += ttk_text_height (ttk_textfont) + 1;
	
    y += 3;

    // Dividing line
    ttk_line (srf, wid->x + 5, y, wid->x + wid->w - 5, y, ttk_makecol (DKGREY));
    
    y += 3;
    // The message
#define MSG "Press a button to quit."
    ttk_text (srf, ttk_menufont, wid->x + (wid->w - ttk_text_width (ttk_menufont, MSG)) / 2,
	      wid->y + wid->h - ttk_text_height (ttk_menufont) - 5, ttk_makecol (BLACK), MSG);
}
示例#9
0
 * 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.
 */

#include "pz.h"

void draw_lack_of_text_input_method (TWidget *this, ttk_surface srf) 
{
    ttk_text (srf, ttk_menufont, this->x + 3, this->y + 1, ttk_makecol (BLACK),
              _("No text input method selected."));
    ttk_text (srf, ttk_menufont, this->x + this->w - ttk_text_width (ttk_menufont, _("[press a key]")) - 3,
              this->y + 3 + ttk_text_height (ttk_menufont), ttk_makecol (BLACK), _("[press a key]"));
}

int close_lack_of_text_input_method (TWidget *this, int button, int time) 
{
    ttk_input_end();
    return 0;
}

TWidget *new_lack_of_text_input_method() 
{
    TWidget *ret = ttk_new_widget (0, 0);
    ret->w = ttk_screen->w;
    ret->h = 2 * (ttk_text_height (ttk_menufont) + 2);
    ret->draw = draw_lack_of_text_input_method;