📄 edillo.c
字号:
/* ** $Id: edillo.c,v 1.51 2005/07/01 07:05:28 weiym Exp $**** Copyright (C) 2004 Feynman Software.**** License: GPL*/#include <sys/types.h>#include <sys/stat.h>#include <fcntl.h>#include <errno.h>#include <stdio.h>#include <stdlib.h>#include <unistd.h>#include <minigui/common.h>#include <minigui/minigui.h>#include <minigui/gdi.h>#include <minigui/window.h>#include <minigui/control.h>#include "mgdconfig.h"#include "edillo.h"#include "cache.h"#include "html.h"#include "web.h"#include "prefs.h"#include "history.h"#include "nav.h"#include "dillo.h"#include "dns.h"#include "dicache.h"#include "io/mime.h"#include "io/url_io.h"#include "interface.h"#include "cookies.h"extern gint current_link_number;static void reset_content (BrowserWindow* bw){ DwViewport* viewport = (DwViewport*)bw->viewport; if (viewport == NULL || viewport->child == NULL) { return; } g_signal_emit_by_name (G_OBJECT(viewport->child), "destroy", 0);}int MGD_open_url (HWND hwnd, const char* url_str){ BrowserWindow* bw = (BrowserWindow*) GetWindowAdditionalData2 (hwnd); DwViewport* viewport = (DwViewport*)bw->viewport; if (viewport == NULL) return URL_ERROR; a_Interface_open_url_string ((gchar*)url_str, bw); return 0;}int MGD_open_url_ismap (HWND hwnd, const DilloUrl* url_ismap){ int ret; DilloUrl* url = a_Url_dup (url_ismap); if (url->ismap_url_len) g_string_truncate (url->url_string, url->ismap_url_len); ret = MGD_open_url (hwnd, url->url_string->str); a_Url_free (url); return ret;}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);}#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){ gint32 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; if (viewport == NULL) { return URL_ERROR;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -