📄 dw_widget.h
字号:
#ifndef __DW_WIDGET_H__#define __DW_WIDGET_H__#include <minigui/common.h>#include <minigui/minigui.h>#include <minigui/gdi.h>#include <minigui/window.h>#include <minigui/control.h>#include <glib.h>#include <glib-object.h>#include "dw_style.h"#include "dw.h"#ifdef __cplusplusextern "C" {#endif /* __cplusplus */#define DW_TYPE_WIDGET (a_Dw_widget_get_type())#define DW_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DW_TYPE_WIDGET, DwWidget))#define DW_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DW_TYPE_WIDGET, DwWidgetClass))#define DW_WIDGET_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DW_TYPE_WIDGET, DwWidgetClass))#define DW_IS_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DW_TYPE_WIDGET))#define DW_WIDGET_SET_FLAGS(wid, flag) (DW_WIDGET(wid)->flags |= (flag))#define DW_WIDGET_UNSET_FLAGS(wid, flag) (DW_WIDGET(wid)->flags &= ~(flag))#define DW_WIDGET_NEEDS_RESIZE(wid) (DW_WIDGET(wid)->flags & \ DW_NEEDS_RESIZE)#define DW_WIDGET_NEEDS_ALLOCATE(wid) (DW_WIDGET(wid)->flags & \ DW_NEEDS_ALLOCATE)#define DW_WIDGET_EXTREMES_CHANGED(wid) (DW_WIDGET(wid)->flags & \ DW_EXTREMES_CHANGED)#define DW_WIDGET_REALIZED(wid) (DW_WIDGET(wid)->flags & DW_REALIZED)#define DW_WIDGET_USES_HINTS(wid) (DW_WIDGET(wid)->flags & \ DW_USES_HINTS)#define DW_WIDGET_HAS_CONTENT(wid) (DW_WIDGET(wid)->flags & \ DW_HAS_CONTENT)#define DW_WIDGET_HEIGHT(wid) ((wid)->allocation.ascent + \ (wid)->allocation.descent)#define DW_WIDGET_CONTENT_HEIGHT(wid) \ ((wid)->allocation.ascent + (wid)->allocation.descent - \ p_Dw_style_box_diff_height((wid)->style))#define DW_WIDGET_CONTENT_WIDTH(wid) ((wid)->allocation.width - \ p_Dw_style_box_diff_width((wid)->style))typedef enum { DW_NEEDS_RESIZE = 1 << 0, DW_NEEDS_ALLOCATE = 1 << 1, DW_EXTREMES_CHANGED = 1 << 2, DW_REALIZED = 1 << 3, DW_USES_HINTS = 1 << 4, DW_HAS_CONTENT = 1 << 5,} DwWidgetFlags;typedef enum{ DW_HPOS_LEFT, DW_HPOS_CENTER, DW_HPOS_RIGHT, DW_HPOS_INTO_VIEW, /* scroll only, until the content in question comes * into view */ DW_HPOS_NO_CHANGE} DwHPosition;typedef enum{ DW_VPOS_TOP, DW_VPOS_CENTER, DW_VPOS_BOTTOM, DW_VPOS_INTO_VIEW, /* scroll only, until the content in question comes * into view */ DW_VPOS_NO_CHANGE} DwVPosition;/* content types for iterator data */typedef enum{ DW_CONTENT_START = 1 << 0, DW_CONTENT_END = 1 << 1, DW_CONTENT_TEXT = 1 << 2, DW_CONTENT_WIDGET = 1 << 3, DW_CONTENT_ANCHOR = 1 << 4, DW_CONTENT_BREAK = 1 << 5, DW_CONTENT_ALL = 0xff} DwContentType;/* Different "layers" may be highlighted in a widget. */typedef enum{ DW_HIGHLIGHT_SELECTION, DW_HIGHLIGHT_FINDTEXT, DW_HIGHLIGHT_NUM_LAYERS} DwHighlightLayer;#if 0#define DW_WIDGET_WINDOW(widget) \ ((widget)->clip_pixmap ? (widget)->clip_pixmap : \ ((GtkDwViewport*)(widget)->viewport)->back_pixmap)#else#define DW_WIDGET_WINDOW(widget) HDC_SCREEN#endiftypedef struct _DwAllocation DwAllocation;typedef struct _DwRequisition DwRequisition;typedef struct _DwExtremes DwExtremes;typedef struct _DwRectPosition DwRectPosition;typedef struct _DwContent DwContent;typedef struct _DwIterator DwIterator;typedef struct _DwIteratorInt DwIteratorInt;typedef struct _DwIteratorText DwIteratorText;typedef struct _DwWidget DwWidget;typedef struct _DwWidgetClass DwWidgetClass;#define DW_PAINT_DEFAULT_BGND 0xd6d6c0struct _DwAllocation{ gint32 x; gint32 y; gint32 width; gint32 ascent; gint32 descent;};struct _DwRequisition{ gint32 width; gint32 ascent; gint32 descent;};struct _DwExtremes{ gint32 min_width; gint32 max_width;};struct _DwRectPosition{ gint32 x, y, width, height; DwHPosition hpos; DwVPosition vpos;};struct _DwContent{ DwContentType type; gboolean space; union { char *text; DwWidget *widget; char *anchor; gint break_space; } data;};struct _DwIterator{ DwWidget *widget; gint mask; /* the current data, after first call of next */ DwContent content; /* For simplicity, static stuff is put into the structure. */ /* * Move iterator forward and store content it. Returns TRUE on * success. */ gboolean (*next) (DwIterator*); /* * Move iterator backward and store content it. Returns TRUE on * success. */ gboolean (*prev) (DwIterator*); /* * Highlight a part of the current content. Unhighlight the current * content by passing -1 as start. For text, start and end define the * characters, otherwise, the region is defined as [0, 1], i.e. for * highlighting a whole DwContent, pass 0 and >= 1. */ void (*highlight) (DwIterator*, gint start, gint end, DwHighlightLayer layer); /* * Return the region, which a part of the item, the iterator points on, * allocates. The parameters start and end have the same meaning as in * DwIterator::highlight(). */ void (*get_allocation) (DwIterator*, gint start, gint end, DwAllocation*); /* * Create an exact copy of the iterator, which then can be used * independantly of the original one. */ DwIterator* (*clone) (DwIterator*); /* * Return a value < 0, if first iterator is smaller, > 0, if it is * greater, or 0 for equal iterators. The implementation may assume * that both iterators belong to the same widget. */ gint (*compare) (DwIterator*, DwIterator*); /* * Free memory of iterator. */ void (*free) (DwIterator*);};/* This iterator type is quite commonly used. */struct _DwIteratorInt{ DwIterator it; int pos;};struct _DwIteratorText{ DwIterator it; gchar *text;};struct _DwViewport;struct _DwWidget{ GObject object; /* the parent widget, NULL for top-level widgets */ DwWidget *parent;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -