📄 dialogs.h
字号:
/* get number of caharcters to the first/end of text line box. if the (plus) is -1,
it counts from char (from) to first visible char in textline. if the (plus) is +1,
it counts from char (from) to last visible char in textline
*/
l_int (*charsin) ( p_textline o, l_int from, l_int plus );
/* same as charsin, but it not use width of textline box, but (size) as width.
*/
l_int (*charsin_size) ( p_textline o, l_int size, l_int from, l_int plus );
/*
return (char), where mouse is over it. (p) is the local point of mouse->where.
*/
l_int (*get_pos_from_xy) ( p_textline o, t_point p );
/*
set text to newone (text). this function allocate the new memory for the new text
and free the old one. it also set all to initial values.
*/
l_bool (*set_text) ( p_textline o, l_text text );
} t_textline;
#define TEXTLINE(o) ((p_textline)(o))
/* clear textline text-selection */
#define sel_clear(o) (o)->sel_from = (o)->sel_to = (o)->sel_first_from = (o)->sel_first_to = (o)->sel_ok = 0
/* return true if text is rewrite able, otherwise it returns false */
#define is_wable(o) (!((o)->flags & TF_REWRITEUNABLE))
/* return true if text is selected */
#define is_sel(o) ((o)->sel_from != (o)->sel_to)
/* t_history */
/*
object t_history is used as combination of t_listbox and t_textline.
it shows the t_textline with button, that shows the listbox when it's pressed.
*/
typedef struct t_history *p_history;
typedef struct t_history {
/* inherited functions / variabes from t_textline, t_view and t_object objects */
struct t_textline obclass;
/* current position of the selected item in the list */
l_long current;
/* list of items, see t_listbox_item. you can add to the list by function
new_history_item, what is same to new_listbox_item for now.
*/
p_list list;
/* list box, that's showed whenever is button pressed
*/
p_listbox listbox;
/* button that show the listbox
*/
p_button button;
l_dword message;
/*
execute process in selected listbox. the process is halt, whenever mouse is pressed
outside from the listbox or the ESC is pressed. in this case it returns MSG_CANCEL.
if the item is choosed or ENTER is pressed it returns MSG_OK.
*/
l_dword (*listbox_execute) ( p_object o );
/*
show listbox box and run listbox_execute. it also redraw the selected item and set
t_textline (TEXTLINE(&t_history)->text) to text of selected item. return the same values as
the listbox_execute.
*/
l_dword (*show_box) ( p_history o );
/*
move the item of the t_listbox->current to ( item ) and set text
(TEXTLINE(&t_history)->text) to the current item.
USE THIS FUNCTION FOR MOVING BETWEEN ITEMS.
*/
void (*rewrite_item) ( p_history o, l_long item );
/*
set the list and all set to initial values and redraw the textline. If you are
going to set the new list, you should free the old one by using function
dispose_list(...) as :
dispose_list(t_listbox.list, true);
*/
l_bool (*set_list) ( p_history o, p_list p );
} t_history;
#define HISTORY(o) ((p_history)(o))
/* t_stattext */
/*
object t_stattext is used drawing formated text and placed it to the other object.
*/
/*typedef struct t_stattext *p_stattext;
typedef struct t_stattext {
struct t_view obclass;
l_char text[256];
l_int align;
} t_stattext;
#define STATTEXT(o) ((p_stattext)(o))
*/
/* t_process */
/*
create object t_process to area (r). (size) is the end of (*where).
For example you can use this argument for size of file.
(where) is pointer from 0 to (size). This may be position in file as is copying.
example :
---------
l_dword size = 100000;
l_dword pos = 0;
p_process x = process_init(_malloc(sizeof(t_process)), r, size, &pos);
OBJECT(desktop)->insert(OBJECT(desktop), OBJECT(x));
_while ( pos++ < size );
*/
extern p_process (*process_init) ( p_process o, t_rect r, l_dword size, l_dword *where );
p_process _process_init ( p_process o, t_rect r, l_dword size, l_dword *where );
void process_translate_event ( p_object o, t_event *event );
void process_func_callback ( p_object o );
void process_draw ( p_view o );
t_rect process_size_limits ( p_view o );
void process_rewrite_promile ( p_process o, l_dword where );
void process_draw_process ( p_process o );
/* t_history */
/*
create new history object. (r) is rectangular area of the object,
(list) is list of pulldown box. (limit) is a limit of maximum characters
that can be write in case of writeable history.
(flags) may be one or combination HF_XXXXX ( see above )
example :
---------
p_list get_list ( void )
{
p_list list = list_init(_malloc(sizeof(t_list)), &free_history_item, DAT_LIST);
list's items->rec will be freed by function free_history_item
if ( list ) {
list->insert(list, new_listbox_item("Name", NULL, true, LIF_NONE));
list->insert(list, new_listbox_item("New Name", NULL, true, LIF_NONE));
};
return list;
};
t_rect r = rect_assign(100, 100, 120, 200);
p_history his = history_init(_malloc(sizeof(t_history)), r,
get_list(),
100, max number of chars in line
HF_REWRITEUNABLE); readonly !
OBJECT(desktop)->insert(OBJECT(desktop), OBJECT(his));
r = rect_assign(100, 130, 200, 150);
his = history_init(_malloc(sizeof(t_history)), r,
get_list(),
60, max number of chars in line
HF_NONE); read/write
OBJECT(desktop)->insert(OBJECT(desktop), OBJECT(his));
*/
extern p_history (*history_init) ( p_history o, t_rect r, p_list list, l_int limit, l_int flags );
p_history _history_init ( p_history o, t_rect r, p_list list, l_int limit, l_int flags );
void history_translate_event ( p_object o, t_event *event );
void history_setup ( p_object o );
void history_change_bounds ( p_view o, t_rect nr );
l_dword history_listbox_execute ( p_object o );
l_dword history_show_box ( p_history o );
void history_rewrite_item ( p_history o, l_long item );
l_bool history_set_list ( p_history o, p_list p );
#define new_history_item new_listbox_item
#define free_history_item free_listbox_item
/* listbox item functions */
/* t_listbox */
/*
create new object t_listbox, where (r) is area of listbox, where will be placed,
(list) is list of items that will be shown, (rows) is number of rows.
when <=1, it will scroll down and up, otherwise left and right.
(flags) can be combination of LF_XXXXX (see above) :
p_list must contains compatible record items with t_listbox_item
typedef struct t_listbox_item {
l_text name;
BITMAP *icon;
l_bool sel;
l_int flags;
l_char reserved[12];
} t_listbox_item;
*/
extern p_listbox (*listbox_init) ( p_listbox o, t_rect r, p_list list, l_byte rows, l_int flags );
p_listbox _listbox_init ( p_listbox o, t_rect r, p_list list, l_byte rows, l_int flags );
/*
make new item. insert name (name) by function _strdup, icon (icon),
sel if it's selected, (flags) - combination of LIF_XXXX ( see above ).
example :
---------
p_list get_list ( void )
{
p_list list = list_init(_malloc(sizeof(t_list)), &free_listbox_item, DAT_LIST);
list's items->rec will be freed by function free_listbox_item
if ( list ) {
list->insert(list, new_listbox_item("Name", NULL, true, LIF_NONE));
list->insert(list, new_listbox_item("New Name", NULL, true, LIF_NONE));
};
return list;
};
t_rect r = rect_assign(100, 100, 200, 200);
p_listbox box = listbox_init(_malloc(sizeof(t_listbox)), r, get_list(), 1, 0);
OBJECT(desktop)->insert(OBJECT(desktop), OBJECT(box));
*/
p_listbox_item new_listbox_item ( l_text name, BITMAP *icon, l_bool sel, l_int flags );
void free_listbox_item ( void* t );
void listbox_translate_event ( p_object o, t_event *event );
void listbox_set_state ( p_object o, l_dword st, l_bool set );
void listbox_set_options ( p_object o, l_dword op, l_bool set );
l_bool listbox_done ( p_object o );
l_bool listbox_get_data ( p_object o, t_data *rec );
l_bool listbox_set_data ( p_object o, t_data *rec );
void listbox_draw ( p_view o );
t_rect listbox_size_limits ( p_view o );
void listbox_scroll_size ( p_scroller o, l_long *x, l_long *y );
t_rect listbox_scroll_limits ( p_scroller o );
void listbox_recalc_positions ( p_scroller o, l_long x, l_long y );
l_bool listbox_set_list ( p_listbox o, p_list p );
l_long listbox_get_pos_from_xy ( p_listbox o, t_point where );
void listbox_draw_item_ptr ( p_listbox o, l_long item, void *recitem, l_bool set );
void listbox_draw_item ( p_listbox o, l_long item, l_bool set );
void listbox_draw_box ( p_listbox o );
void listbox_rewrite_item ( p_listbox o, l_long item );
l_int listbox_get_max_in_box ( p_listbox o );
l_long listbox_get_max ( p_listbox o );
l_int listbox_get_rows ( p_listbox o );
t_point listbox_get_item_size ( p_listbox o );
t_rect listbox_get_item_rect ( p_listbox o, l_long item );
p_list listbox_get_selected_items ( p_listbox o, l_bool sel );
/* t_worklistbox */
extern p_listbox (*worklistbox_init) ( p_listbox o, t_rect r, p_list list, l_byte cells, l_int flags );
p_listbox _worklistbox_init ( p_listbox o, t_rect r, p_list list, l_byte cells, l_int flags );
t_rect worklistbox_size_limits ( p_view o );
void worklistbox_draw ( p_view o );
/* t_textline */
/*
create new textline to rect (r).
(limit) is maximum number of characters, that can be displayed in the
current textline. (flags) are settings for the textline,
you can use as combination of the TF_XXXX ( see above ).
example :
---------
t_rect r = rect_assign(100, 100, 300, 120);
p_textline o = textline_init ( _malloc(sizeof(t_textline)),
r,
100, limit of text
0); rewrite able
OBJECT(desktop)->insert(OBJECT(desktop), OBJECT(o));
o->set_text("Hello world"); set text to "Hello world"
if ( !strcmp(o->text, "Hello world") ) text is "Hello world" ?
o->set_text("Hello Mr. Michal Stencl");
*/
p_textline _textline_init ( p_textline o, t_rect r, l_int limit, l_int flags );
extern p_textline (*textline_init) ( p_textline o, t_rect r, l_int limit, l_int flags );
void textline_ins_text ( p_textline o, l_int pos, l_text text );
void textline_ins_char ( p_textline o, l_int pos, l_char chr );
void textline_del_text ( p_textline o, l_int pos, l_int size );
void textline_del_char ( p_textline o, l_int pos );
l_bool textline_done ( p_object o );
void textline_set_state ( p_object o, l_dword st, l_bool set );
void textline_set_options ( p_object o, l_dword op, l_bool set );
void textline_draw ( p_view o );
l_dword textline_execute ( p_object o );
void textline_translate_event ( p_object o, t_event *event );
t_rect textline_size_limits ( p_view o );
void textline_draw_cursor_ex ( p_textline o, l_int line, l_int pos, l_int active );
void textline_draw_cursor ( p_textline o, l_int oldline, l_int oldpos );
void textline_show_cursor ( p_textline o, l_bool show );
void textline_draw_text ( p_textline o );
void textline_redraw_text ( p_textline o, l_int newpos, l_int keycode );
void textline_sel_all ( p_textline o, l_int selfrom, l_int selto );
l_int textline_charsin ( p_textline o, l_int from, l_int plus );
l_int textline_charsin_size ( p_textline o, l_int size, l_int from, l_int plus );
l_int textline_get_pos_from_xy ( p_textline o, t_point p );
l_bool textline_select_data ( p_object o, l_int data_style, l_bool set );
l_bool textline_get_data ( p_object o, t_data *rec );
l_bool textline_set_data ( p_object o, t_data *rec );
l_bool textline_set_text ( p_textline o, l_text text );
l_bool textline_drag_where ( p_view o, t_data *rec, t_point where );
p_textline _dyntext_init ( p_textline o, t_rect r, l_int limit );
extern p_textline (*dyntext_init) ( p_textline o, t_rect r, l_int limit );
void dyntext_draw ( p_view o );
/* t_workline */
/*
create new textline, that is not pushed down, but only arrounded
by the black rectangle.
*/
p_textline _worktextline_init ( p_textline o, t_rect r, l_int limit );
extern p_textline (*worktextline_init) ( p_textline o, t_rect r, l_int limit );
t_rect worktextline_size_limits ( p_view o );
void worktextline_draw ( p_view o );
p_menuitem get_edit_menuitem ( p_object o, l_bool selection );
void show_edit_menu ( p_object o, l_bool selection );
void listbox_change_bounds ( p_view o, t_rect nr );
#ifdef __cplusplus
}
#endif
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -