coolwidget.h

来自「具有IDE功能的编辑器」· C头文件 代码 · 共 1,133 行 · 第 1/3 页

H
1,133 行
字号
/* Used internally, or for creating you own widgets, see coolwidget.c */CWidget *CSetupWidget (const char *identifier, Window parent, int x, int y,	    int width, int height, int kindofwidget, unsigned long input,		       unsigned long bgcolor, int takes_focus);/* call before drawing a widget to the root window to stop the window manager    of creating a border for you, */void CSetOverrideRedirect (void);/* then clear after drawing the widget */void CClearOverrideRedirect (void);/* For resizing and reposition a widget */void CSetWidgetSize (const char *ident, int w, int h);void CSetSize (CWidget * wt, int w, int h);void CSetWidgetPosition (const char *ident, int x, int y);/* Forces the a widget to be entirely redrawn */void CExpose (const char *ident);/* Sends an expose event to a window */void CExposeWindowArea (Window win, int count, int x, int y, int w, int h);/* Sends an event to the coolwidget queue. Use instead of XSendEvent */int CSendEvent (XEvent * e);/* add a callback to a widget. Will be called if anything relevent happens   to the widget. callback must return 1 if they handles a key press */void CAddCallback (const char *ident, int (*callback) (CWidget *, XEvent *, CEvent *));void CAddBeforeCallback (const char *ident, int (*callback) (CWidget *, XEvent *, CEvent *));/* send the text box a command (such as XK_Left or XK_Down to scroll) */int CTextboxCursorMove (CWidget * w, KeySym key);/* forces all windows set to CALWAYS_NO_TOP (see above) to be raised */void CRaiseWindows (void);/* same for ALWAYS_ON_BOTTOM, call these after raising or lowering   a window, to keep the "underneath" windows where they should be   (eg the coolwidget logo in the top left of the screen */void CLowerWindows (void);/*   The hinge of this whole library. This handles widget events and calls   the callback routines. It must go in the main loop of a program.   Returns cwevent->handled == 1 if the event was a key event and was   handled, 0 otherwise. */void CNextEvent (XEvent * xevent, CEvent * cwevent);/* Any events left? */int CPending (void);/* key presses waiting ? */int CKeyPending (void);/* Any events left on coolwidgets own event queue? */int CQueueSize (void);/* Do not use the libc sleep command. This sleeps for t seconds,   resolution is 1/50 of a second */void CSleep (double t);/* Do not use the libc system command */int CSystem (const char *string);/* Destroy all widgets */void CDestroyAll (void);/* All widgets may be either enabled or disabled, meaning they either   recieve input from the mouse and keyboard, or not. This backs up the   state of all widgets into the structure CState. See dialog.c for an   example */void CBackupState (CState * s);/* This restore the state from the structure */void CRestoreState (CState * s);/* Disable a widget. ident may be a regular expression. */void CDisable (const char *ident);/* Enable */void CEnable (const char *ident);/* set the focus to a widget */void CFocus (CWidget * w);/* set the focus to a window */void CFocusWindow (Window win);/* get the current focus */Window CGetFocus (void);/* get the current window of the input method */Window CGetICFocus(void);/* pull up or down a menu */void CPullDown (CWidget * button);void CPullUp (CWidget * button);/* set the editor that editmenu will send commands to */void CSetEditMenu (const char *ident);void CEditMenuCommand (int i);CWidget *CGetEditMenu (void);void CEditMenuKey (KeySym i, int state);/* internal */int CSendExpose (Window win, int x, int y, int w, int h);/* cursor blink rate */int CGetCursorBlinkRate (void);void CSetCursorBlinkRate (int times_per_second);/************* the rest is not properly documented **************//* check magic number to detect a memory leak */int widget_check_magic (void);/* convert button press to double click */void resolve_button (XEvent * xevent, CEvent * cwevent);#ifdef DRAWINGS_CCWidget *CDrawTarget;#elseextern CWidget *CDrawTarget;#endif/* Focus ordering */CWidget *CFindFirstDescendent (Window win);int find_next_child_of (Window win, Window child);int find_previous_child_of (Window win, Window child);int find_first_child_of (Window win);int find_last_child_of (Window win);long for_all_widgets (void *call_back, void *data1, void *data2);/* returns the widgets index */int widget_of_window (Window win);/* returns the main window that a widget is a descendent of */Window CFindParentMainWindow (Window win);/* there are two cursor types */#define CURSOR_TYPE_TEXTINPUT 1#define CURSOR_TYPE_EDITOR 2/* set the cursor position (internal) */void set_cursor_position (Window win, int x, int y, int w, int h, int type, wchar_t chr, unsigned long fg, unsigned long bg, int style);/* translates a key press to a keysym */KeySym CKeySym (XEvent * e);/* some by converts to a short with upper bits representing the state */short CKeySymMod (XEvent * e);/* get the current state of the keyboard and mouse */unsigned int CGetKeyBoardState (void);/* match regular expressions */int regexp_match (char *pattern, char *string, int match_type);/* gets a widgets position relative to some ancestor widget */void CGetWindowPosition (Window win, Window ancestor, int *x_return, int *y_return);CWidget *CNextFocus (CWidget * w);CWidget *CPreviousFocus (CWidget * w);CWidget *CChildFocus (CWidget * w);void reset_hint_pos (int x, int y);void set_hint_pos (int x, int y);void CGetHintPos (int *x, int *y);void get_hint_limits (int *max_x, int *max_y);void CSetSizeHintPos (const char *ident);/* disable alarm sets and unsets the signal handler: might   be necesary with some system calls */void CEnableAlarm (void);void CDisableAlarm (void);/* see pipe.c for what these do. triple_pipe_open is very useful for piping processes. *//* set your own SIGCHLD handler though */void set_signal_handlers_to_default (void);char *read_pipe (int fd, int *len);pid_t triple_pipe_open (int *in, int *out, int *err, int mix, const char *file, char *const argv[]);pid_t open_under_pty (int *in, int *out, char *line, const char *file, char *const argv[]);/* see coolnext.c for details */int CCheckWindowEvent (Window w, long event_mask, XEvent ** event_return);double my_log (double x);double my_sqrt (double x);double my_pow (double x, double y);#ifdef HAVE_MAD#define CMalloc(x) mad_alloc(x, __FILE__, __LINE__)#endif#ifdef DEBUG#ifndef HAVE_MAD#define CMalloc(x) CDebugMalloc(x, __LINE__, __FILE__)#endif#endif/* #define FOCUS_DEBUG */#ifdef FOCUS_DEBUG#define CFocus(x) CFocusDebug(x,__LINE__,__FILE__)#define CFocusWindow(x) CFocusWindowDebug(x,__LINE__,__FILE__)#else#define CFocus(x) CFocusNormal(x)#define CFocusWindow(x) CFocusWindowNormal(x)#endifvoid CFocusDebug (CWidget * w, int line, char *file);void CFocusNormal (CWidget * w);void CFocusWindowDebug (Window w, int line, char *file);void CFocusWindowNormal (Window w);void CFocusLast (void);/* get last decendent focussed with the specified main window */Window *CGetLastFocussedInMain (Window main);/* resizing stuff */void CCentre (char *ident);void CSetMovement (const char *ident, unsigned long position);/* send an event to a window with a direct call */int CSendMessage (CWidget * w, int msg);/* set and unset the hourglass for this window */void CHourGlass (Window win);void CUnHourGlass (Window win);void get_home_dir (void);/* drag and drop stuff *//* do a drag */void CDrag (Window from, int data_type, unsigned char *data, int length, unsigned long pointer_state);/* get drop text, type is returned */int CGetDrop (XEvent * xe, unsigned char **data, unsigned long *size, int *x, int *y);/* send a drop ack event */void CDropAcknowledge (XEvent * xe);/* check if event is a drop ack event */int CIsDropAcknowledge (XEvent * xe, unsigned int *state);/* find the pointer x and y position within the window it is over */Window CQueryPointer (int *x, int *y, unsigned int *mask);/* set and get the directory to be prependent onto drags */#ifdef HAVE_DNDchar *CDndDirectory (void);char *CDndFileList (char *t, int *l, int *num_files);#endifvoid CSetDndDirectory (char *d);#define CURSOR_HOUR 0#define CURSOR_LEFT 1#define CURSOR_MENU 2Cursor CGetCursorID (int i);void XDrawVericalString8x16 (Display * display, Drawable d, GC gc,			 int x, int y, char *string, int length);#define DndNotDnd	-1#define DndUnknown	0#define DndRawData	1#define DndFile		2#define DndFiles	3#define DndText		4#define DndDir		5#define DndLink		6#define DndExe		7#define DndURL		8#define DndMIME         9#define DndEND		10#define dnd_null_term_type(d) \	((d) == DndFile || (d) == DndText || (d) == DndDir || \	(d) == DndLink || (d) == DndExe || (d) == DndURL)char *CDndFileList (char *t, int *l, int *num_files);/* dialogs */void CFatalErrorDialog (int x, int y, const char *fmt,...);#define INPUT_DIALOG_BROWSE_MASK	(3<<14)#define INPUT_DIALOG_BROWSE_NONE	(0<<14)#define INPUT_DIALOG_BROWSE_LOAD	(1<<14)#define INPUT_DIALOG_BROWSE_SAVE	(2<<14)#define INPUT_DIALOG_BROWSE_DIR		(3<<14)char *CInputDialog (const char *ident, Window in, int x, int y, int min_width, const char *def, const char *heading, const char *fmt,...);int CQueryDialog (Window in, int x, int y, const char *heading, const char *first,...);void CErrorDialog (Window in, int x, int y, const char *heading, const char *fmt,...);void CMessageDialog (Window in, int x, int y, unsigned long options, const char *heading, const char *fmt,...);void CTextboxMessageDialog (Window in, int x, int y, int width, int height, const char *heading, const char *text, int line);int CListboxDialog (Window in, int x, int y, int columns, int lines,     const char *heading, int start_line, int cursor_line, int num_lines,		    char *(*get_line) (void *data, int line), void *data);char *get_sys_error (const char *s);XEvent *CRawkeyQuery (Window in, int x, int y, const char *heading, const char *fmt,...);char *CTrivialSelectionDialog (Window in, int x, int y, int columns, int lines, const char *text, int line, int cursor_line);struct focus_win {    Window top, bottom, left, right;    Window current;    int width, height;    int border;};int inbounds (int x, int y, int x1, int y1, int x2, int y2);struct look {    int (*get_default_interwidget_spacing) (void);    void (*menu_draw) (Window win, int w, int h, struct menu_item m[], int n, int light);    void (*get_menu_item_extents) (int n, int j, struct menu_item m[], int *border, int *relief,				   int *y1, int *y2);    void (*render_menu_button) (CWidget * wdt);    void (*render_button) (CWidget * wdt);    void (*render_bar) (CWidget * wdt);    void (*render_raised_bevel) (Window win, int x1, int y1, int x2, int y2, int thick, int sunken);    void (*render_sunken_bevel) (Window win, int x1, int y1, int x2, int y2, int thick, int sunken);    void (*draw_hotkey_understroke) (Window win, int x, int y, int hotkey);    char *(*get_default_widget_font) (void);    void (*render_text) (CWidget * wdt);    void (*render_window) (CWidget * wdt);    void (*render_scrollbar) (CWidget * wdt);    int (*get_scrollbar_size) (int type);    void (*init_scrollbar_icons) (CWidget * wdt);    int (*which_scrollbar_button) (int bx, int by, CWidget * wdt);    int (*scrollbar_handler) (CWidget * w, XEvent * xevent, CEvent * cwevent);    void (*get_button_color) (XColor * color, int i);    int (*get_extra_window_spacing) (void);    int (*window_handler) (CWidget * w, XEvent * xevent, CEvent * cwevent);    int (*get_focus_ring_size) (void);    unsigned long (*get_button_flat_color) (void);    int (*get_window_resize_bar_thickness) (void);    void (*render_switch) (CWidget * wdt);    int (*get_switch_size) (void);    void (*draw_browser) (const char *ident, Window parent, int x, int y, const char *dir,			  const char *file, const char *label);    char *(*get_file_or_dir) (Window parent, int x, int y, const char *dir, const char *file,			      const char *label, int options);    CWidget *(*draw_file_list) (const char *identifier, Window parent, int x, int y,				int width, int height, int line, int column,				struct file_entry * directentry, long options);    CWidget *(*redraw_file_list) (const char *identifier, struct file_entry * directentry,				  int preserve);    struct file_entry *(*get_file_list_line) (CWidget * w, int line);    void (*search_replace_dialog) (Window parent, int x, int y, char **search_text,				   char **replace_text, char **arg_order, char *heading,				   int option);    void (*edit_render_tidbits) (CWidget * wdt);    CWidget *(*draw_exclam_cancel_button) (char *ident, Window win, int x, int y);    CWidget *(*draw_tick_cancel_button) (char *ident, Window win, int x, int y);    CWidget *(*draw_cross_cancel_button) (char *ident, Window win, int x, int y);    CWidget *(*draw_tick_ok_button) (char *ident, Window win, int x, int y);    void (*render_fielded_textbox_tidbits) (CWidget * w, int isfocussed);    void (*render_textbox_tidbits) (CWidget * w, int isfocussed);    int (*get_fielded_textbox_hscrollbar_width) (void);    void (*render_textinput_tidbits) (CWidget * wdt, int isfocussed);    void (*render_passwordinput_tidbits) (CWidget * wdt, int isfocussed);    void (*render_focus_border) (Window win);};#include "edit.h"#include "editcmddef.h"#include "imagewidget.h"#endif

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?