コード例 #1
0
TWindow * podwrite_mh_return(ttk_menu_item * item)
{
	podwrite_mode = 0;
	pz_close_window(podwrite_menu->win);
	ti_widget_start(podwrite_wid);
	return TTK_MENU_DONOTHING;
}
コード例 #2
0
TWindow * new_podwrite_window_with_text(char * dt)
{
	TWindow * ret;
	TWidget * wid;
	
	/* set podwrite's state */
	podwrite_mode = 0;
	podwrite_linecount = 0;
	podwrite_screenlines = 0;
	podwrite_scroll = 0;
	podwrite_cursor_out_of_bounds = 0;
	podwrite_filename = 0;
	
	/* create the window, widget, and buffer */
	podwrite_win = ret = ttk_new_window(_("PodWrite"));
	podwrite_wid = wid = ti_new_text_widget(0, 0, ret->w, ret->h, 1, dt, podwrite_callback, podwrite_widget_draw, podwrite_widget_input, 0);
	podwrite_buf = (TiBuffer *)wid->data;
	wid->scroll = podwrite_widget_scroll;
	wid->button = podwrite_widget_button;
	
	/* move cursor to beginning */
	ti_buffer_cset(podwrite_buf, 0);
	
	/* set up window */
	ttk_add_widget(ret, wid);
//	ret = pz_finish_window(ret);
	ttk_show_window(ret);
	ti_widget_start(wid);
	
	/* return */
	return ret;
}
コード例 #3
0
TWindow * podwrite_mh_save(ttk_menu_item * item)
{
	TWindow * ret;
	TWidget * wid;
	ret = ttk_new_window(_("Save to..."));
	wid = ti_new_standard_text_widget(10, 40, ret->w-20, 10+ttk_text_height(ttk_textfont), 0, (podwrite_filename?podwrite_filename:"/mnt/Notes/"), podwrite_save_callback);
	ttk_add_widget(ret, wid);
//	ret = pz_finish_window(ret);
ttk_show_window(ret);
	ti_widget_start(wid);
	return ret;
}
コード例 #4
0
static int piezomaker_save()
{
    {
        TWindow *ret;
        TWidget *wid;

        ret = ttk_new_window(_("Save to..."));
        wid = ti_new_standard_text_widget(10, 40, ret->w-20, 10+ttk_text_height(ttk_textfont), 0, "/untitled.pzm", piezomaker_save_callback);
        ttk_add_widget(ret, wid);
        ttk_show_window(ret);
        ti_widget_start(wid);
    }

    return 0;
}
コード例 #5
0
TWindow * new_mkdir_window(ttk_menu_item * item)
{
	TWindow * ret;
	TWidget * wid;
	TWidget * wid2;
	ret = ttk_new_window(_("Make Directory"));
	wid = ti_new_standard_text_widget(10, 10+ttk_text_height(ttk_textfont)*2, ret->w-20, 10+ttk_text_height(ttk_textfont), 0, "", tix_mkdir_callback);
	ttk_add_widget(ret, wid);
	wid2 = ttk_new_widget(10, 10);
	wid2->w = ret->w-20;
	wid2->h = ttk_text_height(ttk_menufont);
	wid2->draw = tix_mkdir_draw;
	ttk_add_widget(ret, wid2);
	ttk_show_window(ret);
	ti_widget_start(wid);
	return 0;
}
コード例 #6
0
int podwrite_save_callback(TWidget * wid, char * fn)
{
	FILE * f;
	pz_close_window(wid->win);
	if (fn[0]) {
		f = fopen(fn, "wb");
		if (!f) {
			pz_error(_("Could not open file for saving."));
			return 0;
		}
		fwrite(podwrite_buf->text, 1, podwrite_buf->usize, f);
		fclose(f);
	}
	podwrite_mode = 0;
	pz_close_window(podwrite_menu->win);
	ti_widget_start(podwrite_wid);
	return 0;
}
コード例 #7
0
TWindow * new_rename_window(ttk_menu_item * item)
{
	TWindow * ret;
	TWidget * wid;
	TWidget * wid2;
	tix_rename_oldname = strdup(item->data);
	ret = ttk_new_window(_("Rename"));
	wid = ti_new_standard_text_widget(10, 10+ttk_text_height(ttk_textfont)*2, ret->w-20, 10+ttk_text_height(ttk_textfont), 0, tix_rename_oldname, tix_rename_callback);
	ttk_add_widget(ret, wid);
	wid2 = ttk_new_widget(10, 10);
	wid2->w = ret->w-20;
	wid2->h = ttk_text_height(ttk_menufont);
	wid2->draw = tix_rename_draw;
	ttk_add_widget(ret, wid2);
	
	ti_widget_start(wid);
	ttk_show_window(ret);
	return 0;
}
コード例 #8
0
int podwrite_widget_button(TWidget * wid, int btn, int t)
{
	if (btn == TTK_BUTTON_MENU ||
		btn == TTK_BUTTON_PLAY ||
		btn == TTK_BUTTON_ACTION ||
		podwrite_mode == 0) { return ti_widget_start(wid); }
	
	switch (podwrite_mode) {
	case 1:
		if (btn == TTK_BUTTON_PREVIOUS) {
			((TiBuffer *)wid->data)->cpos = 0;
			podwrite_scroll = 0;
			wid->dirty = 1;
		} else if (btn == TTK_BUTTON_NEXT) {
			((TiBuffer *)wid->data)->cpos = ((TiBuffer *)wid->data)->usize;
			podwrite_scroll = (podwrite_linecount - podwrite_screenlines);
			wid->dirty = 1;
		} else {
			return TTK_EV_UNUSED;
		}
		break;
	case 2:
		if (btn == TTK_BUTTON_PREVIOUS) {
			podwrite_scroll = 0;
			wid->dirty = 1;
		} else if (btn == TTK_BUTTON_NEXT) {
			podwrite_scroll = (podwrite_linecount - podwrite_screenlines);
			wid->dirty = 1;
		} else {
			return TTK_EV_UNUSED;
		}
		break;
	default:
		return TTK_EV_UNUSED;
		break;
	}
	return TTK_EV_CLICK;
}
コード例 #9
0
int podwrite_widget_scroll(TWidget * wid, int dir)
{
	if (podwrite_mode == 0) { return ti_widget_start(wid); }
	
	TTK_SCROLLMOD (dir,4);
	switch (podwrite_mode) {
	case 1:
		ti_buffer_cmove((TiBuffer *)wid->data, dir);
		podwrite_check_bounds();
		wid->dirty = 1;
		break;
	case 2:
		podwrite_scroll += dir;
		if (podwrite_scroll < 0) podwrite_scroll = 0;
		if (podwrite_scroll > (podwrite_linecount - podwrite_screenlines)) podwrite_scroll = (podwrite_linecount - podwrite_screenlines);
		wid->dirty = 1;
		break;
	default:
		return TTK_EV_UNUSED;
		break;
	}
	return TTK_EV_CLICK;
}