ibrowser.h

Go to the documentation of this file.
00001 /*
00002  * Copyright 2005 Martin Fuchs
00003  *
00004  * This library is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU Lesser General Public
00006  * License as published by the Free Software Foundation; either
00007  * version 2.1 of the License, or (at your option) any later version.
00008  *
00009  * This library is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012  * Lesser General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU Lesser General Public
00015  * License along with this library; if not, write to the Free Software
00016  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00017  */
00018 
00019 
00020  //
00021  // ROS Internet Web Browser
00022  //
00023  // ibrowser.h
00024  //
00025  // Martin Fuchs, 25.01.2005
00026  //
00027 
00028 
00029 #include "utility/window.h"
00030 
00031 
00032 #define IDW_STATUSBAR           0x100
00033 #define IDW_TOOLBAR             0x101
00034 #define IDW_EXTRABAR            0x102
00035 #define IDW_ADDRESSBAR          0x104
00036 #define IDW_SIDEBAR             0x106
00037 #define IDW_FIRST_CHILD         0xC000  /*0x200*/
00038 
00039 
00040 #define PM_GET_FILEWND_PTR      (WM_APP+0x05)
00041 #define PM_GET_SHELLBROWSER_PTR (WM_APP+0x06)
00042 
00043 #define PM_GET_CONTROLWINDOW    (WM_APP+0x16)
00044 
00045 #define PM_RESIZE_CHILDREN      (WM_APP+0x17)
00046 #define PM_GET_WIDTH            (WM_APP+0x18)
00047 
00048 #define PM_REFRESH              (WM_APP+0x1B)
00049 #define PM_REFRESH_CONFIG       (WM_APP+0x1C)
00050 
00051 
00052 #define CLASSNAME_FRAME         TEXT("IBrowserFrameWClass")
00053 
00054 #define CLASSNAME_CHILDWND      TEXT("IBrowserChildWClass")
00055 
00056 
00057 #include "mainframe.h"
00058 
00059 
00060  /// convenient loading of string resources
00061 struct ResString : public String
00062 {
00063     ResString(UINT nid);
00064 };
00065 
00066  /// convenient loading of standard (32x32) icon resources
00067 struct ResIcon
00068 {
00069     ResIcon(UINT nid);
00070 
00071     operator HICON() const {return _hicon;}
00072 
00073 protected:
00074     HICON   _hicon;
00075 };
00076 
00077  /// convenient loading of small (16x16) icon resources
00078 struct SmallIcon
00079 {
00080     SmallIcon(UINT nid);
00081 
00082     operator HICON() const {return _hicon;}
00083 
00084 protected:
00085     HICON   _hicon;
00086 };
00087 
00088  /// convenient loading of icon resources with specified sizes
00089 struct ResIconEx
00090 {
00091     ResIconEx(UINT nid, int w, int h);
00092 
00093     operator HICON() const {return _hicon;}
00094 
00095 protected:
00096     HICON   _hicon;
00097 };
00098 
00099  /// set big and small icons out of the resources for a window
00100 extern void SetWindowIcon(HWND hwnd, UINT nid);
00101 
00102  /// convenient loading of bitmap resources
00103 struct ResBitmap
00104 {
00105     ResBitmap(UINT nid);
00106     ~ResBitmap() {DeleteObject(_hBmp);}
00107 
00108     operator HBITMAP() const {return _hBmp;}
00109 
00110 protected:
00111     HBITMAP _hBmp;
00112 };
00113 
00114 
00115 enum ICON_TYPE {
00116     IT_STATIC,
00117     IT_CACHED,
00118     IT_DYNAMIC,
00119     IT_SYSCACHE
00120 };
00121 
00122 enum ICON_ID {
00123     ICID_UNKNOWN,
00124     ICID_NONE,
00125 
00126     ICID_IBROWSER,
00127     ICID_BOOKMARK,
00128 
00129     ICID_DYNAMIC
00130 };
00131 
00132 struct Icon {
00133     Icon();
00134     Icon(ICON_ID id, UINT nid);
00135     Icon(ICON_TYPE itype, int id, HICON hIcon);
00136     Icon(ICON_TYPE itype, int id, int sys_idx);
00137 
00138     operator ICON_ID() const {return _id;}
00139 
00140     void    draw(HDC hdc, int x, int y, int cx, int cy, COLORREF bk_color, HBRUSH bk_brush) const;
00141     HBITMAP create_bitmap(COLORREF bk_color, HBRUSH hbrBkgnd, HDC hdc_wnd) const;
00142     int     add_to_imagelist(HIMAGELIST himl, HDC hdc_wnd, COLORREF bk_color=GetSysColor(COLOR_WINDOW), HBRUSH bk_brush=GetSysColorBrush(COLOR_WINDOW)) const;
00143 
00144     int     get_sysiml_idx() const {return _itype==IT_SYSCACHE? _sys_idx: -1;}
00145 
00146     bool    destroy() {if (_itype == IT_DYNAMIC) {DestroyIcon(_hicon); return true;} else return false;}
00147 
00148 protected:
00149     ICON_ID _id;
00150     ICON_TYPE _itype;
00151     HICON   _hicon;
00152     int     _sys_idx;
00153 };
00154 
00155 struct SysCacheIcon : public Icon {
00156     SysCacheIcon(int id, int sys_idx)
00157      :  Icon(IT_SYSCACHE, id, sys_idx) {}
00158 };
00159 
00160 struct IconCache {
00161     IconCache() : _himlSys(0) {}
00162 
00163     void    init();
00164 
00165     const Icon& extract(const String& path);
00166     const Icon& extract(LPCTSTR path, int idx);
00167     const Icon& extract(IExtractIcon* pExtract, LPCTSTR path, int idx);
00168 
00169     const Icon& add(HICON hIcon, ICON_TYPE type=IT_DYNAMIC);
00170     const Icon& add(int sys_idx/*, ICON_TYPE type=IT_SYSCACHE*/);
00171 
00172     const Icon& get_icon(int icon_id);
00173     HIMAGELIST get_sys_imagelist() const {return _himlSys;}
00174 
00175     void    free_icon(int icon_id);
00176 
00177 protected:
00178     static int s_next_id;
00179 
00180     typedef map<int, Icon> IconMap;
00181     IconMap _icons;
00182 
00183     typedef map<String, ICON_ID> PathMap;
00184     PathMap _pathMap;
00185 
00186     typedef pair<String, int> CachePair;
00187     typedef map<CachePair, ICON_ID> PathIdxMap;
00188     PathIdxMap _pathIdxMap;
00189 
00190     HIMAGELIST _himlSys;
00191 };
00192 
00193 
00194  /// create a bitmap from an icon
00195 extern HBITMAP create_bitmap_from_icon(HICON hIcon, HBRUSH hbrush_bkgnd, HDC hdc_wnd);
00196 
00197  /// add icon with alpha channel to imagelist using the specified background color
00198 extern int ImageList_AddAlphaIcon(HIMAGELIST himl, HICON hIcon, HBRUSH hbrush_bkgnd, HDC hdc_wnd);
00199 
00200 
00201 #include "utility/xmlstorage.h"
00202 
00203 using namespace XMLStorage;
00204 
00205 #include "favorites.h"
00206 
00207 
00208  // globals
00209 extern HINSTANCE g_hInstance;
00210 extern IconCache g_icon_cache;
00211 extern ATOM g_hframeClass;
00212 
00213 
00214  // display explorer "About" dialog
00215 extern void ibrowser_about(HWND hwndParent);
00216 
00217  // display explorer "open" dialog
00218 extern void ibrowser_open(HWND hwndParent);
00219 
00220  // declare shell32's "Run..." dialog export function
00221 typedef void (WINAPI* RUNFILEDLG)(HWND hwndOwner, HICON hIcon, LPCSTR lpstrDirectory, LPCSTR lpstrTitle, LPCSTR lpstrDescription, UINT uFlags);
00222 
00223  //
00224  // Flags for RunFileDlg
00225  //
00226 
00227 #define RFF_NOBROWSE        0x01    // Removes the browse button.
00228 #define RFF_NODEFAULT       0x02    // No default item selected.
00229 #define RFF_CALCDIRECTORY   0x04    // Calculates the working directory from the file name.
00230 #define RFF_NOLABEL         0x08    // Removes the edit box label.
00231 #define RFF_NOSEPARATEMEM   0x20    // Removes the Separate Memory Space check box (Windows NT only).

IBrowser Source Code Documentation
generated on 18.09.2008 by doxygen

Homepage