include/OffscreenGecko/browser.h

Go to the documentation of this file.
00001 /* ***** BEGIN LICENSE BLOCK *****
00002  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00003  *
00004  * The contents of this file are subject to the Mozilla Public License Version
00005  * 1.1 (the "License"); you may not use this file except in compliance with
00006  * the License. You may obtain a copy of the License at
00007  * http://www.mozilla.org/MPL/
00008  *
00009  * Software distributed under the License is distributed on an "AS IS" basis,
00010  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00011  * for the specific language governing rights and limitations under the
00012  * License.
00013  *
00014  * The Original Code is OffscreenGecko code.
00015  *
00016  * The Initial Developer of the Original Code is
00017  * Frank Richter <frank.richter@gmail.com>.
00018  * Portions created by the Initial Developer are Copyright (C) 2007
00019  * the Initial Developer. All Rights Reserved.
00020  *
00021  * Contributor(s):
00022  *
00023  * Alternatively, the contents of this file may be used under the terms of
00024  * either the GNU General Public License Version 2 or later (the "GPL"), or
00025  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00026  * in which case the provisions of the GPL or the LGPL are applicable instead
00027  * of those above. If you wish to allow use of your version of this file only
00028  * under the terms of either the GPL or the LGPL, and not to allow others to
00029  * use your version of this file under the terms of the MPL, indicate your
00030  * decision by deleting the provisions above and replace them with the notice
00031  * and other provisions required by the GPL or the LGPL. If you do not delete
00032  * the provisions above, a recipient may use your version of this file under
00033  * the terms of any one of the MPL, the GPL or the LGPL.
00034  *
00035  * ***** END LICENSE BLOCK ***** */
00036 
00037 #ifndef __OFFSCREENGECKO_BROWSER_H__
00038 #define __OFFSCREENGECKO_BROWSER_H__
00039 
00044 #include "embedding.h"
00045 
00049 OSGK_DERIVEDTYPE(OSGK_Browser);
00050 
00057 OSGK_EXTERN_C OSGK_API OSGK_Browser* osgk_browser_create (
00058   OSGK_Embedding* embedding, int width, int height);
00059 
00065 OSGK_EXTERN_C OSGK_API void osgk_browser_navigate (OSGK_Browser* browser,
00066   const char* uri);
00067 
00076 OSGK_EXTERN_C OSGK_API int osgk_browser_query_dirty (OSGK_Browser* browser);
00077 
00094 OSGK_EXTERN_C OSGK_API const unsigned char* osgk_browser_lock_data (
00095   OSGK_Browser* browser, int* isDirty OSGK_DEFAULT_ARG(0));
00096 
00104 OSGK_EXTERN_C OSGK_API void osgk_browser_unlock_data (OSGK_Browser* browser,
00105   const unsigned char* data);
00106 
00112 
00113 typedef enum OSGK_MouseButton
00114 {
00116   mbLeft, 
00118   mbRight, 
00120   mbMiddle
00121 } OSGK_MouseButton;
00122 
00124 typedef enum OSGK_MouseButtonEventType
00125 {
00127   meDown,
00129   meUp,
00131   meDoubleClick
00132 } OSGK_MouseButtonEventType;
00133 
00140 OSGK_EXTERN_C OSGK_API void osgk_browser_event_mouse_move (
00141   OSGK_Browser* browser, int x, int y);
00142 
00149 OSGK_EXTERN_C OSGK_API void osgk_browser_event_mouse_button (
00150   OSGK_Browser* browser, OSGK_MouseButton button, 
00151   OSGK_MouseButtonEventType eventType);
00152 
00154 typedef enum OSGK_WheelAxis
00155 {
00157   waVertical,
00159   waHorizontal
00160 } OSGK_WheelAxis;
00161 
00163 typedef enum OSGK_WheelDirection
00164 {
00166   wdPositive,
00168   wdNegative,
00170   wdPositivePage,
00172   wdNegativePage
00173 } OSGK_WheelDirection;
00174 
00181 OSGK_EXTERN_C OSGK_API void osgk_browser_event_mouse_wheel (
00182   OSGK_Browser* browser, OSGK_WheelAxis axis, 
00183   OSGK_WheelDirection direction);
00184 
00191 
00192 typedef enum OSGK_KeyboardEventType
00193 {
00195   keDown,
00197   keUp,
00199   kePress
00200 } OSGK_KeyboardEventType;
00201 
00203 enum
00204 {
00206   OSGKKey_First = 0x110000,
00207 
00208   OSGKKey_Backspace = OSGKKey_First,
00209   OSGKKey_Tab,
00210   OSGKKey_Return,
00211   OSGKKey_Shift,
00212   OSGKKey_Control,
00213   OSGKKey_Alt,
00214   OSGKKey_CapsLock,
00215   OSGKKey_Escape,
00216   OSGKKey_Space,
00217   OSGKKey_PageUp,
00218   OSGKKey_PageDown,
00219   OSGKKey_End,
00220   OSGKKey_Home,
00221   OSGKKey_Left,
00222   OSGKKey_Up,
00223   OSGKKey_Right,
00224   OSGKKey_Down,
00225   OSGKKey_Insert,
00226   OSGKKey_Delete,
00227   OSGKKey_F1,
00228   OSGKKey_F2,
00229   OSGKKey_F3,
00230   OSGKKey_F4,
00231   OSGKKey_F5,
00232   OSGKKey_F6,
00233   OSGKKey_F7,
00234   OSGKKey_F8,
00235   OSGKKey_F9,
00236   OSGKKey_F10,
00237   OSGKKey_F11,
00238   OSGKKey_F12,
00239   OSGKKey_NumLock,
00240   OSGKKey_ScrollLock,
00241   OSGKKey_Meta
00242 };
00243 
00258 OSGK_EXTERN_C OSGK_API int osgk_browser_event_key (
00259   OSGK_Browser* browser, unsigned int key,
00260   OSGK_KeyboardEventType eventType);
00261 
00264 
00265 typedef enum OSGK_AntiAliasType
00266 {
00268   aaNone,
00270   aaGray,
00271   /* Depends on whether a modification I made to gecko makes it into the source -
00272      see https://bugzilla.mozilla.org/show_bug.cgi?id=407531 */
00278   aaSubpixel
00279 } OSGK_AntiAliasType;
00280 
00286 OSGK_EXTERN_C OSGK_API void osgk_browser_set_antialias (
00287   OSGK_Browser* browser, OSGK_AntiAliasType aaType);
00288 
00294 OSGK_EXTERN_C OSGK_API OSGK_AntiAliasType 
00295   osgk_browser_get_antialias (OSGK_Browser* browser);
00296 
00304 OSGK_EXTERN_C OSGK_API void osgk_browser_focus (OSGK_Browser* browser);
00305 
00312 OSGK_EXTERN_C OSGK_API void osgk_browser_resize (OSGK_Browser* browser,
00313   int width, int height);
00314 
00332 OSGK_EXTERN_C OSGK_API int osgk_browser_set_user_data (OSGK_Browser* browser,
00333   unsigned int key, void* data, int overrideData OSGK_DEFAULT_ARG(0));
00342 OSGK_EXTERN_C OSGK_API int osgk_browser_get_user_data (OSGK_Browser* browser,
00343   unsigned int key, void** data);
00349 
00350 typedef enum OSGK_LoadState
00351 {
00353   loadLoading,
00355   loadFinished
00356 } OSGK_LoadState;
00357 
00363 OSGK_EXTERN_C OSGK_API OSGK_LoadState osgk_browser_query_load_state (
00364   OSGK_Browser* browser);
00365 
00375 OSGK_EXTERN_C OSGK_API float osgk_browser_query_load_progress (
00376   OSGK_Browser* browser);
00377 
00397 OSGK_EXTERN_C OSGK_API int osgk_browser_get_preferred_dimensions (
00398   OSGK_Browser* browser, int* preferredWidth, int* preferredHeight,
00399   int maxWidth OSGK_DEFAULT_ARG(-1));
00400 
00401 #ifdef __cplusplus
00402 namespace OSGK
00403 {
00408   struct Browser : public CXXAPI::Wrap<OSGK_Browser>
00409   {
00416     Browser (Embedding& embedding, int width, int height) : 
00417       WrapperType (osgk_browser_create (embedding.GetObject(),
00418         width, height)) { }
00419 
00420     explicit Browser (WrappedType* obj) : WrapperType (obj) {}
00421     Browser& operator=(const Browser& other)
00422     {
00423       WrapperType::operator=(other);
00424       return *this;
00425     }
00426     
00431     void Navigate (const char* uri)
00432     {
00433       osgk_browser_navigate (GetObject(), uri);
00434     }
00435     
00443     bool IsDirty()
00444     {
00445       return osgk_browser_query_dirty (GetObject()) != 0;
00446     }
00454     const unsigned char* LockData()
00455     {
00456       return osgk_browser_lock_data (GetObject ());
00457     }
00473     const unsigned char* LockData(bool& isDirty)
00474     {
00475       int d;
00476       const unsigned char* p = osgk_browser_lock_data (GetObject (), &d);
00477       isDirty = d != 0;
00478       return p;
00479     }
00486     void UnlockData (const unsigned char* data)
00487     {
00488       osgk_browser_unlock_data (GetObject (), data);
00489     }
00499     void EventMouseMove (int x, int y)
00500     {
00501       osgk_browser_event_mouse_move (GetObject(), x, y);
00502     }
00503 
00509     void EventMouseButton (OSGK_MouseButton button, 
00510       OSGK_MouseButtonEventType eventType)
00511     {
00512       osgk_browser_event_mouse_button (GetObject(), button, eventType);
00513     }
00514 
00520     void EventMouseWheel (OSGK_WheelAxis axis, OSGK_WheelDirection direction)
00521     {
00522       osgk_browser_event_mouse_wheel (GetObject(), axis, direction);
00523     }
00537     bool EventKey (unsigned int key, OSGK_KeyboardEventType eventType)
00538     {
00539       return osgk_browser_event_key (GetObject(), key, eventType) != 0;
00540     }
00547     void SetAntialias (OSGK_AntiAliasType aaType)
00548     {
00549       osgk_browser_set_antialias (GetObject(), aaType);
00550     }
00551 
00556     OSGK_AntiAliasType GetAntialias ()
00557     {
00558       return osgk_browser_get_antialias (GetObject());
00559     }
00560 
00567     void Focus ()
00568     {
00569       osgk_browser_focus (GetObject());
00570     }
00571 
00577     void Resize (int width, int height)
00578     {
00579       osgk_browser_resize (GetObject(), width, height);
00580     }
00581 
00598     bool SetUserData (unsigned int key, void* data, bool overrideData = false)
00599     {
00600       return osgk_browser_set_user_data (GetObject(), key, data, overrideData) != 0;
00601     }
00609     bool GetUserData (unsigned int key, void*& data)
00610     {
00611       return osgk_browser_get_user_data (GetObject(), key, &data) != 0;
00612     }
00622     OSGK_LoadState QueryLoadState ()
00623     {
00624       return osgk_browser_query_load_state (GetObject());
00625     }
00626 
00634     float QueryLoadProgress ()
00635     {
00636       return osgk_browser_query_load_progress (GetObject());
00637     }
00656     bool GetPreferredDimensions (int& preferredWidth, int& preferredHeight,
00657       int maxWidth = -1)
00658     {
00659       return osgk_browser_get_preferred_dimensions (GetObject(),
00660         &preferredWidth, &preferredHeight, maxWidth) != 0;
00661     }
00662   };
00663   
00664 } // namespace OSGK
00665 #endif
00666 
00667 #endif // __OFFSCREENGECKO_BROWSER_H__

Generated on Sun Nov 2 18:15:18 2008 for OffscreenGecko by  doxygen 1.5.4