⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mgdillo.c

📁 飞漫公司的minigui的1.6.8收费增值版本的demon等示例程序
💻 C
📖 第 1 页 / 共 2 页
字号:
static void on_realized (HWND hwnd, const char* url_str){    BrowserWindow* bw = (BrowserWindow*) GetWindowAdditionalData2 (hwnd);    DwViewport* viewport;    viewport = a_Dw_viewport_new (hwnd);    bw->viewport = viewport;    MGD_open_url (hwnd, url_str);}static void on_paint (HWND hwnd, HDC hdc){    RECT rc;    DwRectangle area;    BrowserWindow* bw = (BrowserWindow*) GetWindowAdditionalData2 (hwnd);    DwViewport* viewport = (DwViewport*)bw->viewport;    if (viewport == NULL || viewport->child == NULL) {        return;    }    GetClientRect (hwnd, &rc);    area.x = rc.left;    area.y = rc.top;    area.width = rc.right;    area.height = rc.bottom;    area.x += viewport->world_x;    area.y += viewport->world_y;    a_Dw_widget_draw (viewport->child, hdc, &area);}static void on_destroy (HWND hwnd){    BrowserWindow* bw = (BrowserWindow*) GetWindowAdditionalData2 (hwnd);    DwViewport* viewport = (DwViewport*)bw->viewport;    if (viewport == NULL)        return;    reset_content (bw);    a_Dw_viewport_destroy (viewport);    a_Nav_free (bw);    g_free (bw);    SetWindowAdditionalData2 (hwnd, 0);}#define SCROLL_LINE     10#define SCROLL_PAGE     100static void on_hscrollbar (HWND hwnd, int event, int param){    int scroll = 0;    gint32 world_width;    BrowserWindow* bw = (BrowserWindow*) GetWindowAdditionalData2 (hwnd);    DwViewport* viewport = (DwViewport*)bw->viewport;    if (viewport == NULL || viewport->child == NULL) {        return;    }    world_width = viewport->child->allocation.width;    switch (event) {    case SB_LINERIGHT:        if (viewport->world_x + viewport->allocation.width < world_width) {            scroll = world_width - viewport->world_x - viewport->allocation.width;            if (scroll > SCROLL_LINE) scroll = SCROLL_LINE;        }        break;                    case SB_LINELEFT:        if (viewport->world_x > 0) {            scroll = -viewport->world_x;            if (scroll < -SCROLL_LINE) scroll = -SCROLL_LINE;        }        break;                    case SB_PAGERIGHT:        if (viewport->world_x + viewport->allocation.width < world_width) {            scroll = world_width - viewport->world_x - viewport->allocation.width;            if (scroll > SCROLL_PAGE) scroll = SCROLL_PAGE;        }        break;    case SB_PAGELEFT:        if (viewport->world_x > 0) {            scroll = -viewport->world_x;            if (scroll < -SCROLL_PAGE) scroll = -SCROLL_PAGE;        }        break;    case SB_THUMBPOSITION:        break;    }    if (scroll) {        viewport->world_x = viewport->world_x + scroll;        SetScrollPos (hwnd, SB_HORZ, viewport->world_x);        ScrollWindow (hwnd, -scroll, 0, NULL, NULL);    }}void MGD_scroll_to_x (DwViewport *viewport, int x){    int world_width;    int scroll;    if (viewport == NULL || viewport->child == NULL) {        return;    }    world_width = viewport->child->allocation.width;    if (x < 0)        x = 0;    if (x + viewport->allocation.width > world_width)        x = world_width - viewport->allocation.width;    scroll = x - viewport->world_x;    if (scroll) {        viewport->world_x = x;        SetScrollPos (viewport->hwnd, SB_HORZ, x);        ScrollWindow (viewport->hwnd, -scroll, 0, NULL, NULL);    }}static void on_vscrollbar (HWND hwnd, int event, int param){    int scroll = 0;    gint32 world_height;    BrowserWindow* bw = (BrowserWindow*) GetWindowAdditionalData2 (hwnd);    DwViewport* viewport = (DwViewport*)bw->viewport;    if (viewport == NULL || viewport->child == NULL) {        return;    }    world_height = viewport->child->allocation.ascent + viewport->child->allocation.descent;    switch (event) {    case SB_LINEDOWN:        if (viewport->world_y + viewport->allocation.height < world_height) {            scroll = world_height - viewport->world_y - viewport->allocation.height;            if (scroll > SCROLL_LINE) scroll = SCROLL_LINE;        }        break;                    case SB_LINEUP:        if (viewport->world_y > 0) {            scroll = -viewport->world_y;            if (scroll < -SCROLL_LINE) scroll = -SCROLL_LINE;        }        break;                    case SB_PAGEDOWN:        if (viewport->world_y + viewport->allocation.height < world_height) {            scroll = world_height - viewport->world_y - viewport->allocation.height;            if (scroll > SCROLL_PAGE) scroll = SCROLL_PAGE;        }        break;    case SB_PAGEUP:        if (viewport->world_y > 0) {            scroll = -viewport->world_y;            if (scroll < -SCROLL_PAGE) scroll = -SCROLL_PAGE;        }        break;    case SB_THUMBPOSITION:        break;    }    if (scroll) {        viewport->world_y = viewport->world_y + scroll;        SetScrollPos (hwnd, SB_VERT, viewport->world_y);        ScrollWindow (hwnd, 0, -scroll, NULL, NULL);    }}void MGD_scroll_to_y (DwViewport *viewport, int y){    int world_height;    int scroll;    if (viewport == NULL || viewport->child == NULL) {        return;    }    world_height = viewport->child->allocation.ascent + viewport->child->allocation.descent;    if (y < 0)        y = 0;    if (y + viewport->allocation.height > world_height)        y = world_height - viewport->allocation.height;    scroll = y - viewport->world_y;    if (scroll) {        viewport->world_y = y;        SetScrollPos (viewport->hwnd, SB_VERT, y);        ScrollWindow (viewport->hwnd, 0, -scroll, NULL, NULL);    }}static BOOL on_mouse_event (HWND hwnd, int x, int y, DWORD flags){    DwWidget *dw_widget;    gint32 world_x, world_y;    BrowserWindow* bw = (BrowserWindow*) GetWindowAdditionalData2 (hwnd);    DwViewport* viewport = (DwViewport*)bw->viewport;    if (viewport == NULL || viewport->child == NULL) {        return FALSE;    }    world_x = x + viewport->world_x;    world_y = y + viewport->world_y;    dw_widget = Dw_viewport_widget_at_point (viewport, world_x, world_y);    return Dw_widget_mouse_event (dw_widget, viewport, world_x, world_y, flags);}static int navigation (HWND hwnd, int message){    BrowserWindow* bw = (BrowserWindow*) GetWindowAdditionalData2 (hwnd);    DwViewport* viewport = (DwViewport*)bw->viewport;    DilloUrl* url;    if (viewport == NULL) {        return URL_ERROR;    }    if (message == MGD_NAV_BACKWARD)        url = a_Nav_back (bw);    else        url = a_Nav_forw (bw);    if (url) {        open_url (bw, url);    }    return 0;}static void on_keydown (HWND hwnd, int scancode, DWORD ks){    BrowserWindow* bw = (BrowserWindow*) GetWindowAdditionalData2 (hwnd);    DwViewport* viewport = (DwViewport*)bw->viewport;    int world_height;    if (viewport == NULL) {        return;    }    world_height = viewport->child->allocation.ascent + viewport->child->allocation.descent;    switch (scancode) {    case SCANCODE_HOME:        MGD_scroll_to_x (viewport, 0);        MGD_scroll_to_y (viewport, 0);        break;    case SCANCODE_END:        MGD_scroll_to_y (viewport, world_height);         break;    case SCANCODE_CURSORBLOCKDOWN:        on_vscrollbar (hwnd, SB_LINEDOWN, 0);        break;    case SCANCODE_CURSORBLOCKUP:        on_vscrollbar (hwnd, SB_LINEUP, 0);        break;    case SCANCODE_PAGEDOWN:        if (ks & KS_ALT)            on_hscrollbar (hwnd, SB_PAGERIGHT, 0);        else            on_vscrollbar (hwnd, SB_PAGEDOWN, 0);        break;    case SCANCODE_PAGEUP:        if (ks & KS_ALT)            on_hscrollbar (hwnd, SB_PAGELEFT, 0);        else            on_vscrollbar (hwnd, SB_PAGEUP, 0);        break;    case SCANCODE_CURSORBLOCKRIGHT:        on_hscrollbar (hwnd, SB_LINERIGHT, 0);        break;    case SCANCODE_CURSORBLOCKLEFT:        on_hscrollbar (hwnd, SB_LINELEFT, 0);        break;    case SCANCODE_F:        if (ks & KS_CTRL)            navigation (hwnd, MGD_NAV_FORWARD);        break;    case SCANCODE_B:        if (ks & KS_CTRL)            navigation (hwnd, MGD_NAV_BACKWARD);        break;    }}static int DilloControlProc (HWND hwnd, int message, WPARAM wParam, LPARAM lParam){    HDC hdc;    switch (message) {    case MSG_CREATE:        on_create (hwnd);        return 0;    case MSG_PAINT:        hdc = BeginPaint (hwnd);        on_paint (hwnd, hdc);        EndPaint (hwnd, hdc);        return 0;    case MSG_HSCROLL:        on_hscrollbar (hwnd, wParam, lParam);        break;    case MSG_VSCROLL:        on_vscrollbar (hwnd, wParam, lParam);        break;    case MSG_KEYDOWN:        on_keydown (hwnd, LOWORD (wParam), lParam);        break;    case MSG_MOUSEMOVE:    case MSG_LBUTTONDOWN:    case MSG_LBUTTONUP:        on_mouse_event (hwnd, LOSWORD (lParam), HISWORD (lParam),                     MAKELONG (wParam, message));        break;    case MSG_DESTROY:        on_destroy (hwnd);        break;    case MGD_REALIZED:        on_realized (hwnd, GetWindowCaption (hwnd));        break;    case MGD_OPENURL:        return MGD_open_url (hwnd, (const char*)lParam);    case MGD_NAV_BACKWARD:    case MGD_NAV_FORWARD:        return navigation (hwnd, message);    case MGD_RESETCONTENT:        reset_content ((BrowserWindow*) GetWindowAdditionalData2 (hwnd));        return 0;    }    return DefaultControlProc (hwnd, message, wParam, lParam);}BOOL RegisterDilloControl (void){    WNDCLASS MyClass;    MyClass.spClassName = CTRL_DILLO;    MyClass.dwStyle     = WS_NONE;    MyClass.dwExStyle   = WS_EX_NONE;    MyClass.hCursor     = GetSystemCursor (IDC_ARROW);    MyClass.iBkColor    = COLOR_lightwhite;    MyClass.WinProc     = DilloControlProc;    g_type_init ();    a_Prefs_init ();    a_Dw_style_init ();    return RegisterWindowClass (&MyClass);}void UnregisterDilloControl (void){    UnregisterWindowClass (CTRL_DILLO);    a_Dw_style_freeall ();    a_Prefs_freeall ();    a_History_free ();}

⌨️ 快捷键说明

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