diff options
author | Chris Young <chris@unsatisfactorysoftware.co.uk> | 2010-03-23 22:27:33 +0000 |
---|---|---|
committer | Chris Young <chris@unsatisfactorysoftware.co.uk> | 2010-03-23 22:27:33 +0000 |
commit | 861b5b4953541c1a5654bd57e874f68524c3f47a (patch) | |
tree | 889a7942fdac00d663c30c6b853a77616a79c7a7 | |
parent | 5e898e5a922359878d0386b183eb0914e3ae657f (diff) | |
download | netsurf-861b5b4953541c1a5654bd57e874f68524c3f47a.tar.gz |
Factor Amiga theme-related code out to a new file. This includes all throbber and
mouse pointer code (which are "theme modifiable") as well as normal theme reading
code.
svn path=/trunk/netsurf/; revision=10145
-rw-r--r-- | Makefile.sources | 1 | ||||
-rw-r--r-- | amiga/download.c | 5 | ||||
-rwxr-xr-x | amiga/gui.c | 449 | ||||
-rwxr-xr-x | amiga/gui.h | 6 | ||||
-rw-r--r-- | amiga/theme.c | 495 | ||||
-rw-r--r-- | amiga/theme.h | 39 |
6 files changed, 547 insertions, 448 deletions
diff --git a/Makefile.sources b/Makefile.sources index ac2a7c403..ec7edc7a5 100644 --- a/Makefile.sources +++ b/Makefile.sources @@ -95,6 +95,7 @@ S_AMIGA := compat.c gui.c tree.c history.c hotlist.c schedule.c \ cookies.c context_menu.c clipboard.c save_complete.c \ fetch_file.c fetch_mailto.c search.c history_local.c \ download.c iff_dr2d.c sslcert.c gui_options.c print.c \ + theme.c \ stringview/stringview.c stringview/urlhistory.c S_AMIGA := $(addprefix amiga/,$(S_AMIGA)) diff --git a/amiga/download.c b/amiga/download.c index 20647afab..2172fb8cc 100644 --- a/amiga/download.c +++ b/amiga/download.c @@ -16,6 +16,8 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ +#include <string.h> + #include <proto/wb.h> #include <proto/asl.h> #include <proto/exec.h> @@ -33,6 +35,7 @@ #include "amiga/options.h" #include "amiga/bitmap.h" #include "amiga/iff_dr2d.h" +#include "amiga/theme.h" #include "content/fetch.h" @@ -42,8 +45,6 @@ #include "utils/messages.h" #include "utils/utils.h" -#include <string.h> - #include <proto/window.h> #include <proto/layout.h> diff --git a/amiga/gui.c b/amiga/gui.c index d47a7a4b5..22d7064d7 100755 --- a/amiga/gui.c +++ b/amiga/gui.c @@ -55,6 +55,7 @@ #include "amiga/print.h" #include "amiga/schedule.h" #include "amiga/search.h" +#include "amiga/theme.h" #include "amiga/tree.h" #include "amiga/utf8.h" @@ -69,7 +70,6 @@ #include <proto/dos.h> #include <proto/exec.h> #include <proto/graphics.h> -#include <proto/icon.h> #include <proto/intuition.h> #include <proto/keymap.h> #include <proto/locale.h> @@ -81,12 +81,11 @@ /* Other OS includes */ #include <datatypes/pictureclass.h> #include <devices/inputevent.h> +#include <graphics/blitattr.h> #include <libraries/application.h> #include <libraries/gadtools.h> #include <libraries/keymap.h> #include <intuition/icclass.h> -#include <intuition/pointerclass.h> -#include <graphics/blitattr.h> #include <graphics/rpattr.h> #include <workbench/icon.h> #include <workbench/workbench.h> @@ -141,8 +140,6 @@ struct ApplicationIFace *IApplication=NULL; Class *urlStringClass; -struct BitMap *throbber = NULL; -ULONG throbber_width,throbber_height,throbber_frames,throbber_update_interval; BOOL rmbtrapped; BOOL locked_screen = FALSE; BOOL screen_closed = FALSE; @@ -153,62 +150,12 @@ extern colour scroll_widget_fg_colour; extern colour scroll_widget_bg_colour; extern colour scroll_widget_arrow_colour; -static Object *mouseptrobj[AMI_LASTPOINTER+1]; -static struct BitMap *mouseptrbm[AMI_LASTPOINTER+1]; -static int mouseptrcurrent=0; static struct DrawInfo *dri; -char *ptrs[AMI_LASTPOINTER+1] = { - "ptr_default", - "ptr_point", - "ptr_caret", - "ptr_menu", - "ptr_up", - "ptr_down", - "ptr_left", - "ptr_right", - "ptr_rightup", - "ptr_leftdown", - "ptr_leftup", - "ptr_rightdown", - "ptr_cross", - "ptr_move", - "ptr_wait", - "ptr_help", - "ptr_nodrop", - "ptr_notallowed", - "ptr_progress", - "ptr_blank", - "ptr_drag"}; - -char *ptrs32[AMI_LASTPOINTER+1] = { - "ptr32_default", - "ptr32_point", - "ptr32_caret", - "ptr32_menu", - "ptr32_up", - "ptr32_down", - "ptr32_left", - "ptr32_right", - "ptr32_rightup", - "ptr32_leftdown", - "ptr32_leftup", - "ptr32_rightdown", - "ptr32_cross", - "ptr32_move", - "ptr32_wait", - "ptr32_help", - "ptr32_nodrop", - "ptr32_notallowed", - "ptr32_progress", - "ptr32_blank", - "ptr32_drag"}; - -void ami_update_throbber(struct gui_window_2 *g,bool redraw); + void ami_update_buttons(struct gui_window_2 *); void ami_scroller_hook(struct Hook *,Object *,struct IntuiMessage *); uint32 ami_popup_hook(struct Hook *hook,Object *item,APTR reserved); -void ami_init_mouse_pointers(void); void ami_switch_tab(struct gui_window_2 *gwin,bool redraw); void ami_change_tab(struct gui_window_2 *gwin, int direction); static void *myrealloc(void *ptr, size_t len, void *pw); @@ -265,12 +212,11 @@ int main(int argc, char** argv) void gui_init(int argc, char** argv) { struct Locale *locale; - char lang[100],throbberfile[100]; + char lang[100]; STRPTR tempacceptlangs; bool found=FALSE; int i; - BPTR lock=0,amiupdatefh; - Object *dto; + BPTR lock = 0, amiupdatefh = 0; msgport = AllocSysObjectTags(ASOT_PORT, ASO_NoTrack,FALSE, @@ -496,71 +442,9 @@ void gui_init(int argc, char** argv) ami_global_history_initialise(); ami_cookies_initialise(); save_complete_init(); - - strcpy(throbberfile,option_theme); - AddPart(throbberfile,"Theme",100); - - lock = Lock(throbberfile,ACCESS_READ); - - if(!lock) - { - warn_user("ThemeApplyErr",option_theme); - strcpy(throbberfile,"PROGDIR:Resources/Themes/Default/Theme"); - free(option_theme); - option_theme = (char *)strdup("PROGDIR:Resources/Themes/Default"); - } - else - { - UnLock(lock); - } - - messages_load(throbberfile); - + ami_theme_init(); ami_init_mouse_pointers(); - - ami_get_theme_filename(throbberfile,"theme_throbber"); - throbber_frames=atoi(messages_get("theme_throbber_frames")); - throbber_update_interval = atoi(messages_get("theme_throbber_delay")); - if(throbber_update_interval == 0) throbber_update_interval = 100; - - if(dto = NewDTObject(throbberfile, - DTA_GroupID,GID_PICTURE, - PDTA_DestMode,PMODE_V43, - TAG_DONE)) - { - struct BitMapHeader *throbber_bmh; - struct RastPort throbber_rp; - - if(GetDTAttrs(dto,PDTA_BitMapHeader,&throbber_bmh,TAG_DONE)) - { - throbber_width = throbber_bmh->bmh_Width / throbber_frames; - throbber_height = throbber_bmh->bmh_Height; - throbber_bmh->bmh_Masking = mskHasAlpha; - - InitRastPort(&throbber_rp); - - if(throbber = p96AllocBitMap(throbber_bmh->bmh_Width, - throbber_height,32, - BMF_CLEAR | BMF_DISPLAYABLE | BMF_INTERLEAVED, - NULL,RGBFB_A8R8G8B8)) - { - struct RenderInfo ri; - UBYTE *throbber_tempmem = AllocVec(throbber_bmh->bmh_Width*throbber_height*4,MEMF_PRIVATE | MEMF_CLEAR); - throbber_rp.BitMap = throbber; - ri.Memory = throbber_tempmem; - ri.BytesPerRow = 4*throbber_bmh->bmh_Width; - ri.RGBFormat = RGBFB_A8R8G8B8; - - IDoMethod(dto,PDTM_READPIXELARRAY,ri.Memory,PBPAFMT_ARGB,ri.BytesPerRow,0,0,throbber_bmh->bmh_Width,throbber_height); - - p96WritePixelArray((struct RenderInfo *)&ri,0,0,&throbber_rp,0,0,throbber_bmh->bmh_Width,throbber_height); - - FreeVec(throbber_tempmem); - } - } - DisposeDTObject(dto); - } - + ami_theme_throbber_setup(); } void ami_openscreen(void) @@ -1973,7 +1857,7 @@ void gui_quit(void) { int i; - p96FreeBitMap(throbber); + ami_theme_throbber_free(); urldb_save(option_url_file); urldb_save_cookies(option_cookie_file); @@ -2010,16 +1894,7 @@ void gui_quit(void) if(option_context_menu) ami_context_menu_free(); ami_free_menulabs(); - for(i=0;i<=AMI_LASTPOINTER;i++) - { - if(mouseptrbm[i]) - { - FreeRaster(mouseptrbm[i]->Planes[0],16,16); - FreeRaster(mouseptrbm[i]->Planes[1],16,16); - FreeVec(mouseptrbm[i]); - } - } - + ami_mouse_pointers_free(); ami_clipboard_free(); ami_print_free(); @@ -2111,16 +1986,6 @@ void ami_update_buttons(struct gui_window_2 *gwin) } } -void ami_get_theme_filename(char *filename,char *themestring) -{ - if(messages_get(themestring)[0] == '*') strncpy(filename,messages_get(themestring)+1,100); - else - { - strcpy(filename,option_theme); - AddPart(filename,messages_get(themestring),100); - } -} - void ami_toggletabbar(struct gui_window_2 *gwin, bool show) { if(ClickTabBase->lib_Version < 53) return; @@ -3463,191 +3328,6 @@ void gui_window_set_status(struct gui_window *g, const char *text) } } -void gui_window_set_pointer(struct gui_window *g, gui_pointer_shape shape) -{ - ami_update_pointer(g->shared->win,shape); -} - -void ami_update_pointer(struct Window *win, gui_pointer_shape shape) -{ - if(mouseptrcurrent == shape) return; - if(drag_save) return; - - if(option_use_os_pointers) - { - switch(shape) - { - case GUI_POINTER_DEFAULT: - SetWindowPointer(win,TAG_DONE); - break; - - case GUI_POINTER_WAIT: - SetWindowPointer(win, - WA_BusyPointer,TRUE, - WA_PointerDelay,TRUE, - TAG_DONE); - break; - - default: - if(mouseptrobj[shape]) - { - SetWindowPointer(win,WA_Pointer,mouseptrobj[shape],TAG_DONE); - } - else - { - SetWindowPointer(win,TAG_DONE); - } - break; - } - } - else - { - if(mouseptrobj[shape]) - { - SetWindowPointer(win,WA_Pointer,mouseptrobj[shape],TAG_DONE); - } - else - { - if(shape == GUI_POINTER_WAIT) - { - SetWindowPointer(win, - WA_BusyPointer,TRUE, - WA_PointerDelay,TRUE, - TAG_DONE); - } - else - { - SetWindowPointer(win,TAG_DONE); - } - } - } - - mouseptrcurrent = shape; -} - -void gui_window_hide_pointer(struct gui_window *g) -{ - if(mouseptrcurrent != AMI_GUI_POINTER_BLANK) - { - SetWindowPointer(g->shared->win,WA_Pointer,mouseptrobj[AMI_GUI_POINTER_BLANK],TAG_DONE); - mouseptrcurrent = AMI_GUI_POINTER_BLANK; - } -} - -void ami_init_mouse_pointers(void) -{ - int i; - struct RastPort mouseptr; - struct DiskObject *dobj; - uint32 format = IDFMT_BITMAPPED; - int32 mousexpt=0,mouseypt=0; - - InitRastPort(&mouseptr); - - for(i=0;i<=AMI_LASTPOINTER;i++) - { - BPTR ptrfile = 0; - mouseptrbm[i] = NULL; - mouseptrobj[i] = NULL; - char ptrfname[1024]; - - if(option_truecolour_mouse_pointers) - { - ami_get_theme_filename(&ptrfname,ptrs32[i]); - if(dobj = GetIconTags(ptrfname,ICONGETA_UseFriendBitMap,TRUE,TAG_DONE)) - { - if(IconControl(dobj, ICONCTRLA_GetImageDataFormat, &format, TAG_DONE)) - { - if(IDFMT_DIRECTMAPPED == format) - { - int32 width = 0, height = 0; - uint8* data = 0; - IconControl(dobj, - ICONCTRLA_GetWidth, &width, - ICONCTRLA_GetHeight, &height, - ICONCTRLA_GetImageData1, &data, - TAG_DONE); - - if (width > 0 && width <= 64 && height > 0 && height <= 64 && data) - { - STRPTR tooltype; - - if(tooltype = FindToolType(dobj->do_ToolTypes, "XOFFSET")) - mousexpt = atoi(tooltype); - - if(tooltype = FindToolType(dobj->do_ToolTypes, "YOFFSET")) - mouseypt = atoi(tooltype); - - if (mousexpt < 0 || mousexpt >= width) - mousexpt = 0; - if (mouseypt < 0 || mouseypt >= height) - mouseypt = 0; - - static uint8 dummyPlane[64 * 64 / 8]; - static struct BitMap dummyBitMap = { 64 / 8, 64, 0, 2, 0, { dummyPlane, dummyPlane, 0, 0, 0, 0, 0, 0 }, }; - - mouseptrobj[i] = NewObject(NULL, "pointerclass", - POINTERA_BitMap, &dummyBitMap, - POINTERA_XOffset, -mousexpt, - POINTERA_YOffset, -mouseypt, - POINTERA_WordWidth, (width + 15) / 16, - POINTERA_XResolution, POINTERXRESN_SCREENRES, - POINTERA_YResolution, POINTERYRESN_SCREENRESASPECT, - POINTERA_ImageData, data, - POINTERA_Width, width, - POINTERA_Height, height, - TAG_DONE); - } - } - } - } - } - - if(!mouseptrobj[i]) - { - ami_get_theme_filename(ptrfname,ptrs[i]); - if(ptrfile = Open(ptrfname,MODE_OLDFILE)) - { - int mx,my; - UBYTE *pprefsbuf = AllocVec(1061,MEMF_PRIVATE | MEMF_CLEAR); - Read(ptrfile,pprefsbuf,1061); - - mouseptrbm[i]=AllocVec(sizeof(struct BitMap),MEMF_PRIVATE | MEMF_CLEAR); - InitBitMap(mouseptrbm[i],2,32,32); - mouseptrbm[i]->Planes[0] = AllocRaster(32,32); - mouseptrbm[i]->Planes[1] = AllocRaster(32,32); - mouseptr.BitMap = mouseptrbm[i]; - - for(my=0;my<32;my++) - { - for(mx=0;mx<32;mx++) - { - SetAPen(&mouseptr,pprefsbuf[(my*(33))+mx]-'0'); - WritePixel(&mouseptr,mx,my); - } - } - - mousexpt = ((pprefsbuf[1056]-'0')*10)+(pprefsbuf[1057]-'0'); - mouseypt = ((pprefsbuf[1059]-'0')*10)+(pprefsbuf[1060]-'0'); - - mouseptrobj[i] = NewObject(NULL,"pointerclass", - POINTERA_BitMap,mouseptrbm[i], - POINTERA_WordWidth,2, - POINTERA_XOffset,-mousexpt, - POINTERA_YOffset,-mouseypt, - POINTERA_XResolution,POINTERXRESN_SCREENRES, - POINTERA_YResolution,POINTERYRESN_SCREENRESASPECT, - TAG_DONE); - - FreeVec(pprefsbuf); - Close(ptrfile); - } - - } - - } // for -} - void gui_window_set_url(struct gui_window *g, const char *url) { ULONG cur_tab = 0; @@ -3665,64 +3345,6 @@ void gui_window_set_url(struct gui_window *g, const char *url) } } -void gui_window_start_throbber(struct gui_window *g) -{ - struct IBox *bbox; - ULONG cur_tab = 0; - - if(!g) return; - - if(g->tab_node && (g->shared->tabs > 1)) - { - GetAttr(CLICKTAB_Current, g->shared->objects[GID_TABS], - (ULONG *)&cur_tab); - SetClickTabNodeAttrs(g->tab_node, TNA_Flagged, TRUE, TAG_DONE); - RefreshGadgets((APTR)g->shared->objects[GID_TABS], - g->shared->win, NULL); - } - - g->throbbing = true; - - if((cur_tab == g->tab) || (g->shared->tabs <= 1)) - { - GetAttr(SPACE_AreaBox, g->shared->objects[GID_THROBBER], - (ULONG *)&bbox); - - if(g->shared->throbber_frame == 0) g->shared->throbber_frame=1; - - BltBitMapRastPort(throbber,throbber_width,0,g->shared->win->RPort,bbox->Left,bbox->Top,throbber_width,throbber_height,0x0C0); - } -} - -void gui_window_stop_throbber(struct gui_window *g) -{ - struct IBox *bbox; - ULONG cur_tab = 0; - - if(!g) return; - - if(g->tab_node && (g->shared->tabs > 1)) - { - GetAttr(CLICKTAB_Current, g->shared->objects[GID_TABS], - (ULONG *)&cur_tab); - SetClickTabNodeAttrs(g->tab_node, TNA_Flagged, FALSE, TAG_DONE); - RefreshGadgets((APTR)g->shared->objects[GID_TABS], - g->shared->win, NULL); - } - - g->throbbing = false; - - if((cur_tab == g->tab) || (g->shared->tabs <= 1)) - { - GetAttr(SPACE_AreaBox, g->shared->objects[GID_THROBBER], - (ULONG *)&bbox); - - BltBitMapRastPort(throbber, 0, 0, g->shared->win->RPort, bbox->Left, - bbox->Top, throbber_width, throbber_height, 0x0C0); - } -// g->shared->throbber_frame = 0; -} - /** * function to add retrieved favicon to gui */ @@ -3848,59 +3470,6 @@ void gui_window_set_search_ico(struct content *ico) } while(node = nnode); } -void ami_update_throbber(struct gui_window_2 *g,bool redraw) -{ - struct IBox *bbox; - int frame = g->throbber_frame; - - if(!g) return; - if(!g->objects[GID_THROBBER]) return; - - if(g->bw->window->throbbing == false) - { - frame = 0; - g->throbber_frame=1; - } - else - { - if(!redraw) - { - if(g->throbber_update_count < throbber_update_interval) - { - g->throbber_update_count++; - return; - } - - g->throbber_update_count = 0; - - g->throbber_frame++; - if(g->throbber_frame > (throbber_frames-1)) - g->throbber_frame=1; - - } - } - - GetAttr(SPACE_AreaBox,(Object *)g->objects[GID_THROBBER],(ULONG *)&bbox); - -/* - EraseRect(g->win->RPort,bbox->Left,bbox->Top, - bbox->Left+throbber_width,bbox->Top+throbber_height); -*/ - - BltBitMapTags(BLITA_SrcX, throbber_width * frame, - BLITA_SrcY,0, - BLITA_DestX,bbox->Left, - BLITA_DestY,bbox->Top, - BLITA_Width,throbber_width, - BLITA_Height,throbber_height, - BLITA_Source,throbber, - BLITA_Dest,g->win->RPort, - BLITA_SrcType,BLITT_BITMAP, - BLITA_DestType,BLITT_RASTPORT, -// BLITA_UseSrcAlpha,TRUE, - TAG_DONE); -} - void gui_window_place_caret(struct gui_window *g, int x, int y, int height) { struct IBox *bbox; diff --git a/amiga/gui.h b/amiga/gui.h index 14bf794ce..5509c0314 100755 --- a/amiga/gui.h +++ b/amiga/gui.h @@ -74,10 +74,6 @@ enum GID_LAST }; -#define AMI_GUI_POINTER_BLANK GUI_POINTER_PROGRESS+1 -#define AMI_GUI_POINTER_DRAG GUI_POINTER_PROGRESS+2 -#define AMI_LASTPOINTER AMI_GUI_POINTER_DRAG - struct find_window; struct history_window; @@ -127,10 +123,8 @@ struct gui_window }; void ami_get_msg(void); -void ami_update_pointer(struct Window *win, gui_pointer_shape shape); void ami_close_all_tabs(struct gui_window_2 *gwin); void ami_quit_netsurf(void); -void ami_get_theme_filename(char *filename,char *themestring); void ami_do_redraw(struct gui_window_2 *g); STRPTR ami_locale_langs(void); diff --git a/amiga/theme.c b/amiga/theme.c new file mode 100644 index 000000000..f25ba12ba --- /dev/null +++ b/amiga/theme.c @@ -0,0 +1,495 @@ +/* + * Copyright 2010 Chris Young <chris@unsatisfactorysoftware.co.uk> + * + * This file is part of NetSurf, http://www.netsurf-browser.org/ + * + * NetSurf is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * NetSurf is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#include <string.h> + +#include <proto/clicktab.h> +#include <proto/datatypes.h> +#include <proto/dos.h> +#include <proto/exec.h> +#include <proto/graphics.h> +#include <proto/icon.h> +#include <proto/intuition.h> +#include <proto/Picasso96API.h> + +#include <gadgets/clicktab.h> +#include <gadgets/space.h> +#include <graphics/blitattr.h> +#include <intuition/pointerclass.h> +#include <workbench/icon.h> + +#include "amiga/download.h" +#include "amiga/options.h" +#include "amiga/theme.h" +#include "utils/messages.h" +#include "utils/utils.h" + +struct BitMap *throbber = NULL; +ULONG throbber_frames,throbber_update_interval; +static Object *mouseptrobj[AMI_LASTPOINTER+1]; +static struct BitMap *mouseptrbm[AMI_LASTPOINTER+1]; +static int mouseptrcurrent=0; + +char *ptrs[AMI_LASTPOINTER+1] = { + "ptr_default", + "ptr_point", + "ptr_caret", + "ptr_menu", + "ptr_up", + "ptr_down", + "ptr_left", + "ptr_right", + "ptr_rightup", + "ptr_leftdown", + "ptr_leftup", + "ptr_rightdown", + "ptr_cross", + "ptr_move", + "ptr_wait", + "ptr_help", + "ptr_nodrop", + "ptr_notallowed", + "ptr_progress", + "ptr_blank", + "ptr_drag"}; + +char *ptrs32[AMI_LASTPOINTER+1] = { + "ptr32_default", + "ptr32_point", + "ptr32_caret", + "ptr32_menu", + "ptr32_up", + "ptr32_down", + "ptr32_left", + "ptr32_right", + "ptr32_rightup", + "ptr32_leftdown", + "ptr32_leftup", + "ptr32_rightdown", + "ptr32_cross", + "ptr32_move", + "ptr32_wait", + "ptr32_help", + "ptr32_nodrop", + "ptr32_notallowed", + "ptr32_progress", + "ptr32_blank", + "ptr32_drag"}; + +void ami_theme_init(void) +{ + char themefile[1024]; + BPTR lock = 0; + + strcpy(themefile,option_theme); + AddPart(themefile,"Theme",100); + + lock = Lock(themefile,ACCESS_READ); + + if(!lock) + { + warn_user("ThemeApplyErr",option_theme); + strcpy(themefile,"PROGDIR:Resources/Themes/Default/Theme"); + free(option_theme); + option_theme = (char *)strdup("PROGDIR:Resources/Themes/Default"); + } + else + { + UnLock(lock); + } + + messages_load(themefile); +} + +void ami_theme_throbber_setup(void) +{ + char throbberfile[1024]; + Object *dto; + + ami_get_theme_filename(throbberfile,"theme_throbber"); + throbber_frames=atoi(messages_get("theme_throbber_frames")); + throbber_update_interval = atoi(messages_get("theme_throbber_delay")); + if(throbber_update_interval == 0) throbber_update_interval = 100; + + if(dto = NewDTObject(throbberfile, + DTA_GroupID,GID_PICTURE, + PDTA_DestMode,PMODE_V43, + TAG_DONE)) + { + struct BitMapHeader *throbber_bmh; + struct RastPort throbber_rp; + + if(GetDTAttrs(dto,PDTA_BitMapHeader,&throbber_bmh,TAG_DONE)) + { + throbber_width = throbber_bmh->bmh_Width / throbber_frames; + throbber_height = throbber_bmh->bmh_Height; + throbber_bmh->bmh_Masking = mskHasAlpha; + + InitRastPort(&throbber_rp); + + if(throbber = p96AllocBitMap(throbber_bmh->bmh_Width, + throbber_height,32, + BMF_CLEAR | BMF_DISPLAYABLE | BMF_INTERLEAVED, + NULL,RGBFB_A8R8G8B8)) + { + struct RenderInfo ri; + UBYTE *throbber_tempmem = AllocVec(throbber_bmh->bmh_Width*throbber_height*4,MEMF_PRIVATE | MEMF_CLEAR); + throbber_rp.BitMap = throbber; + ri.Memory = throbber_tempmem; + ri.BytesPerRow = 4*throbber_bmh->bmh_Width; + ri.RGBFormat = RGBFB_A8R8G8B8; + + IDoMethod(dto,PDTM_READPIXELARRAY,ri.Memory,PBPAFMT_ARGB,ri.BytesPerRow,0,0,throbber_bmh->bmh_Width,throbber_height); + + p96WritePixelArray((struct RenderInfo *)&ri,0,0,&throbber_rp,0,0,throbber_bmh->bmh_Width,throbber_height); + + FreeVec(throbber_tempmem); + } + } + DisposeDTObject(dto); + } +} + +void ami_theme_throbber_free(void) +{ + p96FreeBitMap(throbber); +} + +void ami_get_theme_filename(char *filename, char *themestring) +{ + if(messages_get(themestring)[0] == '*') + { + strncpy(filename, messages_get(themestring) + 1, 100); + } + else + { + strcpy(filename, option_theme); + AddPart(filename, messages_get(themestring), 100); + } +} + +void gui_window_set_pointer(struct gui_window *g, gui_pointer_shape shape) +{ + ami_update_pointer(g->shared->win,shape); +} + +void ami_update_pointer(struct Window *win, gui_pointer_shape shape) +{ + if(mouseptrcurrent == shape) return; + if(drag_save) return; + + if(option_use_os_pointers) + { + switch(shape) + { + case GUI_POINTER_DEFAULT: + SetWindowPointer(win,TAG_DONE); + break; + + case GUI_POINTER_WAIT: + SetWindowPointer(win, + WA_BusyPointer,TRUE, + WA_PointerDelay,TRUE, + TAG_DONE); + break; + + default: + if(mouseptrobj[shape]) + { + SetWindowPointer(win,WA_Pointer,mouseptrobj[shape],TAG_DONE); + } + else + { + SetWindowPointer(win,TAG_DONE); + } + break; + } + } + else + { + if(mouseptrobj[shape]) + { + SetWindowPointer(win,WA_Pointer,mouseptrobj[shape],TAG_DONE); + } + else + { + if(shape == GUI_POINTER_WAIT) + { + SetWindowPointer(win, + WA_BusyPointer,TRUE, + WA_PointerDelay,TRUE, + TAG_DONE); + } + else + { + SetWindowPointer(win,TAG_DONE); + } + } + } + + mouseptrcurrent = shape; +} + +void gui_window_hide_pointer(struct gui_window *g) +{ + if(mouseptrcurrent != AMI_GUI_POINTER_BLANK) + { + SetWindowPointer(g->shared->win,WA_Pointer,mouseptrobj[AMI_GUI_POINTER_BLANK],TAG_DONE); + mouseptrcurrent = AMI_GUI_POINTER_BLANK; + } +} + +void ami_init_mouse_pointers(void) +{ + int i; + struct RastPort mouseptr; + struct DiskObject *dobj; + uint32 format = IDFMT_BITMAPPED; + int32 mousexpt=0,mouseypt=0; + + InitRastPort(&mouseptr); + + for(i=0;i<=AMI_LASTPOINTER;i++) + { + BPTR ptrfile = 0; + mouseptrbm[i] = NULL; + mouseptrobj[i] = NULL; + char ptrfname[1024]; + + if(option_truecolour_mouse_pointers) + { + ami_get_theme_filename(&ptrfname,ptrs32[i]); + if(dobj = GetIconTags(ptrfname,ICONGETA_UseFriendBitMap,TRUE,TAG_DONE)) + { + if(IconControl(dobj, ICONCTRLA_GetImageDataFormat, &format, TAG_DONE)) + { + if(IDFMT_DIRECTMAPPED == format) + { + int32 width = 0, height = 0; + uint8* data = 0; + IconControl(dobj, + ICONCTRLA_GetWidth, &width, + ICONCTRLA_GetHeight, &height, + ICONCTRLA_GetImageData1, &data, + TAG_DONE); + + if (width > 0 && width <= 64 && height > 0 && height <= 64 && data) + { + STRPTR tooltype; + + if(tooltype = FindToolType(dobj->do_ToolTypes, "XOFFSET")) + mousexpt = atoi(tooltype); + + if(tooltype = FindToolType(dobj->do_ToolTypes, "YOFFSET")) + mouseypt = atoi(tooltype); + + if (mousexpt < 0 || mousexpt >= width) + mousexpt = 0; + if (mouseypt < 0 || mouseypt >= height) + mouseypt = 0; + + static uint8 dummyPlane[64 * 64 / 8]; + static struct BitMap dummyBitMap = { 64 / 8, 64, 0, 2, 0, { dummyPlane, dummyPlane, 0, 0, 0, 0, 0, 0 }, }; + + mouseptrobj[i] = NewObject(NULL, "pointerclass", + POINTERA_BitMap, &dummyBitMap, + POINTERA_XOffset, -mousexpt, + POINTERA_YOffset, -mouseypt, + POINTERA_WordWidth, (width + 15) / 16, + POINTERA_XResolution, POINTERXRESN_SCREENRES, + POINTERA_YResolution, POINTERYRESN_SCREENRESASPECT, + POINTERA_ImageData, data, + POINTERA_Width, width, + POINTERA_Height, height, + TAG_DONE); + } + } + } + } + } + + if(!mouseptrobj[i]) + { + ami_get_theme_filename(ptrfname,ptrs[i]); + if(ptrfile = Open(ptrfname,MODE_OLDFILE)) + { + int mx,my; + UBYTE *pprefsbuf = AllocVec(1061,MEMF_PRIVATE | MEMF_CLEAR); + Read(ptrfile,pprefsbuf,1061); + + mouseptrbm[i]=AllocVec(sizeof(struct BitMap),MEMF_PRIVATE | MEMF_CLEAR); + InitBitMap(mouseptrbm[i],2,32,32); + mouseptrbm[i]->Planes[0] = AllocRaster(32,32); + mouseptrbm[i]->Planes[1] = AllocRaster(32,32); + mouseptr.BitMap = mouseptrbm[i]; + + for(my=0;my<32;my++) + { + for(mx=0;mx<32;mx++) + { + SetAPen(&mouseptr,pprefsbuf[(my*(33))+mx]-'0'); + WritePixel(&mouseptr,mx,my); + } + } + + mousexpt = ((pprefsbuf[1056]-'0')*10)+(pprefsbuf[1057]-'0'); + mouseypt = ((pprefsbuf[1059]-'0')*10)+(pprefsbuf[1060]-'0'); + + mouseptrobj[i] = NewObject(NULL,"pointerclass", + POINTERA_BitMap,mouseptrbm[i], + POINTERA_WordWidth,2, + POINTERA_XOffset,-mousexpt, + POINTERA_YOffset,-mouseypt, + POINTERA_XResolution,POINTERXRESN_SCREENRES, + POINTERA_YResolution,POINTERYRESN_SCREENRESASPECT, + TAG_DONE); + + FreeVec(pprefsbuf); + Close(ptrfile); + } + + } + + } // for +} + +void ami_mouse_pointers_free(void) +{ + int i; + + for(i=0;i<=AMI_LASTPOINTER;i++) + { + if(mouseptrbm[i]) + { + FreeRaster(mouseptrbm[i]->Planes[0],16,16); + FreeRaster(mouseptrbm[i]->Planes[1],16,16); + FreeVec(mouseptrbm[i]); + } + } +} + +void gui_window_start_throbber(struct gui_window *g) +{ + struct IBox *bbox; + ULONG cur_tab = 0; + + if(!g) return; + + if(g->tab_node && (g->shared->tabs > 1)) + { + GetAttr(CLICKTAB_Current, g->shared->objects[GID_TABS], + (ULONG *)&cur_tab); + SetClickTabNodeAttrs(g->tab_node, TNA_Flagged, TRUE, TAG_DONE); + RefreshGadgets((APTR)g->shared->objects[GID_TABS], + g->shared->win, NULL); + } + + g->throbbing = true; + + if((cur_tab == g->tab) || (g->shared->tabs <= 1)) + { + GetAttr(SPACE_AreaBox, g->shared->objects[GID_THROBBER], + (ULONG *)&bbox); + + if(g->shared->throbber_frame == 0) g->shared->throbber_frame=1; + + BltBitMapRastPort(throbber,throbber_width,0,g->shared->win->RPort,bbox->Left,bbox->Top,throbber_width,throbber_height,0x0C0); + } +} + +void gui_window_stop_throbber(struct gui_window *g) +{ + struct IBox *bbox; + ULONG cur_tab = 0; + + if(!g) return; + + if(g->tab_node && (g->shared->tabs > 1)) + { + GetAttr(CLICKTAB_Current, g->shared->objects[GID_TABS], + (ULONG *)&cur_tab); + SetClickTabNodeAttrs(g->tab_node, TNA_Flagged, FALSE, TAG_DONE); + RefreshGadgets((APTR)g->shared->objects[GID_TABS], + g->shared->win, NULL); + } + + g->throbbing = false; + + if((cur_tab == g->tab) || (g->shared->tabs <= 1)) + { + GetAttr(SPACE_AreaBox, g->shared->objects[GID_THROBBER], + (ULONG *)&bbox); + + BltBitMapRastPort(throbber, 0, 0, g->shared->win->RPort, bbox->Left, + bbox->Top, throbber_width, throbber_height, 0x0C0); + } +// g->shared->throbber_frame = 0; +} + +void ami_update_throbber(struct gui_window_2 *g,bool redraw) +{ + struct IBox *bbox; + int frame = g->throbber_frame; + + if(!g) return; + if(!g->objects[GID_THROBBER]) return; + + if(g->bw->window->throbbing == false) + { + frame = 0; + g->throbber_frame=1; + } + else + { + if(!redraw) + { + if(g->throbber_update_count < throbber_update_interval) + { + g->throbber_update_count++; + return; + } + + g->throbber_update_count = 0; + + g->throbber_frame++; + if(g->throbber_frame > (throbber_frames-1)) + g->throbber_frame=1; + + } + } + + GetAttr(SPACE_AreaBox,(Object *)g->objects[GID_THROBBER],(ULONG *)&bbox); + +/* + EraseRect(g->win->RPort,bbox->Left,bbox->Top, + bbox->Left+throbber_width,bbox->Top+throbber_height); +*/ + + BltBitMapTags(BLITA_SrcX, throbber_width * frame, + BLITA_SrcY,0, + BLITA_DestX,bbox->Left, + BLITA_DestY,bbox->Top, + BLITA_Width,throbber_width, + BLITA_Height,throbber_height, + BLITA_Source,throbber, + BLITA_Dest,g->win->RPort, + BLITA_SrcType,BLITT_BITMAP, + BLITA_DestType,BLITT_RASTPORT, +// BLITA_UseSrcAlpha,TRUE, + TAG_DONE); +} diff --git a/amiga/theme.h b/amiga/theme.h new file mode 100644 index 000000000..3a396fdb1 --- /dev/null +++ b/amiga/theme.h @@ -0,0 +1,39 @@ +/* + * Copyright 2010 Chris Young <chris@unsatisfactorysoftware.co.uk> + * + * This file is part of NetSurf, http://www.netsurf-browser.org/ + * + * NetSurf is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * NetSurf is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#ifndef AMIGA_THEME_H +#define AMIGA_THEME_H +#include "amiga/gui.h" + +#define AMI_GUI_POINTER_BLANK GUI_POINTER_PROGRESS+1 +#define AMI_GUI_POINTER_DRAG GUI_POINTER_PROGRESS+2 +#define AMI_LASTPOINTER AMI_GUI_POINTER_DRAG + +ULONG throbber_width, throbber_height; + +void ami_theme_init(void); +void ami_get_theme_filename(char *filename, char *themestring); + +void ami_theme_throbber_setup(void); +void ami_theme_throbber_free(void); +void ami_update_throbber(struct gui_window_2 *g,bool redraw); + +void ami_init_mouse_pointers(void); +void ami_mouse_pointers_free(void); +void ami_update_pointer(struct Window *win, gui_pointer_shape shape); +#endif |