Changeset 261

Show
Ignore:
Timestamp:
06/11/08 19:50:03 (5 months ago)
Author:
mbensi
Message:

BAL:

2008-06-11 Mario Bensi <mbensi@pleyo.com>

Reviewed by NOBODY (OOPS!).

remove printf, fix drawPattern and add first implementation of popup

  • Base/SDL/BALTypeSDL.h:
  • OWBAL/Concretizations/Types/CMakeLists.txt:
  • OWBAL/Skeletons/Types/StrHash.t: Removed.
  • WKAL/Concretizations/Graphics/SDL/BCImageSDL.cpp:
    (WKAL::Image::drawPattern):
  • WKAL/Concretizations/Graphics/SDL/BCPathSDL.cpp:
    (WKAL::Path::Path):
    (WKAL::Path::~Path):
    (WKAL::Path::operator=):
    (WKAL::Path::clear):
    (WKAL::Path::isEmpty):
    (WKAL::Path::translate):
    (WKAL::Path::moveTo):
    (WKAL::Path::addLineTo):
    (WKAL::Path::addRect):
    (WKAL::Path::addQuadCurveTo):
    (WKAL::Path::addBezierCurveTo):
    (WKAL::Path::addArc):
    (WKAL::Path::addArcTo):
    (WKAL::Path::addEllipse):
    (WKAL::Path::closeSubpath):
    (WKAL::Path::boundingRect):
    (WKAL::Path::contains):
    (WKAL::Path::apply):
    (WKAL::Path::transform):
    (WKAL::Path::debugString):
  • WKAL/Concretizations/Widgets/SDL/BCPopupMenuSDL.cpp:
    (WKAL::isASCIIPrintable):
    (WKAL::PopupMenu::PopupMenu):
    (WKAL::PopupMenu::~PopupMenu):
    (WKAL::PopupMenu::show):
    (WKAL::PopupMenu::focusedIndex):
    (WKAL::PopupMenu::setFocusedIndex):
    (WKAL::PopupMenu::scrollToRevealSelection):
    (WKAL::PopupMenu::itemWritingDirectionIsNatural):
    (WKAL::PopupMenu::calculatePositionAndSize):
    (WKAL::PopupMenu::invalidateItem):
    (WKAL::PopupMenu::clientRect):
    (WKAL::PopupMenu::visibleItems):
    (WKAL::PopupMenu::windowClipRect):
    (WKAL::PopupMenu::valueChanged):
  • WKAL/Concretizations/Widgets/SDL/BCPopupMenuSDL.h:
    (WKAL::PopupMenu::isActive):

WebKit:

2008-06-11 Mario Bensi <mbensi@pleyo.com>

Reviewed by NOBODY (OOPS!).

add custom user agent in webview

  • OrigynWebBrowser/Api/WebView.cpp:
    (WebView::userAgentForKURL):

WebKitTools:

2008-06-11 Mario Bensi <mbensi@pleyo.com>

Reviewed by NOBODY (OOPS!).

add return 0 to finish the main

  • OWBLauncher/SDL/main.cpp:
    (main):
  • OWBLauncher/gtk/main.cpp:
    (main):
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/Doduo/BAL/Base/SDL/BALTypeSDL.h

    r243 r261  
    6565typedef SDL_Rect BalRectangle; 
    6666typedef void BalMenuItem; 
    67 typedef void BalMenu; 
     67typedef SDL_Surface BalMenu; 
    6868typedef void BalClipboard; 
    6969typedef void BalTargetList; 
     
    8585    typedef void* DragImageRef; 
    8686    typedef void* DragDataRef; 
    87     typedef void* PlatformMenuDescription; 
    8887    typedef unsigned short GlyphBufferGlyph; 
    8988    typedef WKAL::FloatSize GlyphBufferAdvance; 
  • branches/Doduo/BAL/ChangeLogOWB

    r259 r261  
     12008-06-11  Mario Bensi  <mbensi@pleyo.com> 
     2 
     3        Reviewed by NOBODY (OOPS!). 
     4 
     5        remove printf, fix drawPattern and add first implementation of popup 
     6 
     7        * Base/SDL/BALTypeSDL.h: 
     8        * OWBAL/Concretizations/Types/CMakeLists.txt: 
     9        * OWBAL/Skeletons/Types/StrHash.t: Removed. 
     10        * WKAL/Concretizations/Graphics/SDL/BCImageSDL.cpp: 
     11        (WKAL::Image::drawPattern): 
     12        * WKAL/Concretizations/Graphics/SDL/BCPathSDL.cpp: 
     13        (WKAL::Path::Path): 
     14        (WKAL::Path::~Path): 
     15        (WKAL::Path::operator=): 
     16        (WKAL::Path::clear): 
     17        (WKAL::Path::isEmpty): 
     18        (WKAL::Path::translate): 
     19        (WKAL::Path::moveTo): 
     20        (WKAL::Path::addLineTo): 
     21        (WKAL::Path::addRect): 
     22        (WKAL::Path::addQuadCurveTo): 
     23        (WKAL::Path::addBezierCurveTo): 
     24        (WKAL::Path::addArc): 
     25        (WKAL::Path::addArcTo): 
     26        (WKAL::Path::addEllipse): 
     27        (WKAL::Path::closeSubpath): 
     28        (WKAL::Path::boundingRect): 
     29        (WKAL::Path::contains): 
     30        (WKAL::Path::apply): 
     31        (WKAL::Path::transform): 
     32        (WKAL::Path::debugString): 
     33        * WKAL/Concretizations/Widgets/SDL/BCPopupMenuSDL.cpp: 
     34        (WKAL::isASCIIPrintable): 
     35        (WKAL::PopupMenu::PopupMenu): 
     36        (WKAL::PopupMenu::~PopupMenu): 
     37        (WKAL::PopupMenu::show): 
     38        (WKAL::PopupMenu::focusedIndex): 
     39        (WKAL::PopupMenu::setFocusedIndex): 
     40        (WKAL::PopupMenu::scrollToRevealSelection): 
     41        (WKAL::PopupMenu::itemWritingDirectionIsNatural): 
     42        (WKAL::PopupMenu::calculatePositionAndSize): 
     43        (WKAL::PopupMenu::invalidateItem): 
     44        (WKAL::PopupMenu::clientRect): 
     45        (WKAL::PopupMenu::visibleItems): 
     46        (WKAL::PopupMenu::windowClipRect): 
     47        (WKAL::PopupMenu::valueChanged): 
     48        * WKAL/Concretizations/Widgets/SDL/BCPopupMenuSDL.h: 
     49        (WKAL::PopupMenu::isActive): 
     50 
    1512008-06-11  Fred  <fmarmond@pleyo.com> 
    252 
  • branches/Doduo/BAL/OWBAL/Concretizations/Types/CMakeLists.txt

    r243 r261  
    7171OWBLN (WK/BCVectorTraitsWK.h OWBAL/wtf 0 0) 
    7272OWBLN (WK/BCbalValuePrivateWK.h OWBAL 0 0) 
    73 OWBLN (WK/BCStrHashWK.h OWBAL/wtf 0 0) 
    7473OWBLN (WK/BCAVLTreeWK.h OWBAL/wtf 0 0) 
    7574 
  • branches/Doduo/BAL/WKAL/Concretizations/Graphics/SDL/BCImageSDL.cpp

    r243 r261  
    201201} 
    202202 
     203 
     204 
     205 
    203206void Image::drawPattern(GraphicsContext* context, const FloatRect& tileRect, const AffineTransform& patternTransform, 
    204207                        const FloatPoint& phase, CompositeOperator op, const FloatRect& destRect) 
    205208{ 
    206 //     printf("BitmapImage::drawPattern tileRect %f %f %f %f\n", tileRect.x(), tileRect.y(), tileRect.width(), tileRect.height()); 
    207 //     printf("BitmapImage::drawPattern destRect %f %f %f %f\n", destRect.x(), destRect.y(), destRect.width(), destRect.height()); 
    208 //     printf("BitmapImage::drawPattern phase %f %f\n", phase.x(), phase.y()); 
    209 //     printf("patternTransform a=%f b=%f c=%f d=%f dx=%f dy=%f \n", patternTransform.a(), patternTransform.b() , patternTransform.c(), patternTransform.d(), patternTransform.e(), patternTransform.f()); 
    210  
    211209    if (destRect.isEmpty()) 
    212210        return; 
     
    216214        return; 
    217215 
    218     //printf("image %d %d\n", image->w, image->h); 
    219216    SDL_Surface* cr = context->platformContext(); 
    220217    context->save(); 
     
    222219    context->setCompositeOperation(op); 
    223220 
     221    printf("CompositeOperator = %d\n", op); 
    224222    // Check and see if a single draw of the image can cover the entire area we are supposed to tile. 
    225223    // save context info 
    226224    context->clip(IntRect(destRect)); // don't draw outside this 
    227225 
    228     /*float scaleX = image->w / tileRect.width(); 
    229     float scaleY = image->h / tileRect.height(); 
    230  
    231     SDL_Surface *surface; 
    232     surface = zoomSurface(image, scaleX, scaleY, SMOOTHING_OFF); 
    233  
    234     SDL_Rect d = {static_cast<Sint16>(destRect.x() + context->origin().width()), 
    235                   static_cast<Sint16>(destRect.y() + context->origin().height()), 
    236                   0, 
    237                   0}; 
    238     SDL_Rect s = {static_cast<Sint16>(tileRect.x()), 
    239                       static_cast<Sint16>(tileRect.y() - phase.y()), 
    240                       static_cast<Sint16>(tileRect.width()), 
    241                       static_cast<Sint16>(destRect.height())}; 
    242  
    243     for (; d.x < static_cast<int>(destRect.right()); d.x += s.w) 
    244         SDL_BlitSurface(surface, &s, cr, &d); 
    245  
    246     SDL_FreeSurface(surface);*/ 
    247  
    248     //IntRect dest(destRect); 
    249     //IntRect src(static_cast<int>(phase.x()), static_cast<int>(phase.y()), static_cast<int>(tileRect.width()), static_cast<int>(tileRect.height())); 
     226 
     227    IntRect dest(IntPoint(), IntSize(image->w, image->h)); 
     228    IntRect src(static_cast<int>(phase.x()), static_cast<int>(phase.y()), static_cast<int>(tileRect.size().width()), static_cast<int>(tileRect.size().height())); 
    250229 
    251230    int xMax = static_cast<int>(destRect.x() + destRect.width()); 
    252231    int yMax = static_cast<int>(destRect.y() + destRect.height()); 
    253232 
    254     SDL_Rect s = {static_cast<Sint16>(phase.x()), 
    255                   static_cast<Sint16>(phase.y()), 
    256                   static_cast<Sint16>(tileRect.width()), 
    257                   static_cast<Sint16>(tileRect.height())}; 
     233 
     234    SDL_Rect srcRect, dstRect; 
     235 
     236    srcRect.x = 0; 
     237    srcRect.y = 0; 
     238    if (0 == src.width()) 
     239        srcRect.w = image->w; 
     240    else 
     241        srcRect.w = static_cast<Uint16>(src.width()); 
     242    if (0 == src.height()) 
     243        srcRect.h = image->h; 
     244    else 
     245        srcRect.h = static_cast<Uint16>(src.height()); 
     246 
     247    dstRect.x = static_cast<Sint16>(dest.x()); 
     248    dstRect.y = static_cast<Sint16>(dest.y()); 
     249    dstRect.w = static_cast<Sint16>(dest.width()); 
     250    dstRect.h = static_cast<Sint16>(dest.height()); 
     251 
     252    //compute ratio of the zoomed part: 
     253    double  ratioW=(((double)dest.width()/(double)srcRect.w)); 
     254    double  ratioH=((double)dest.height()/((double)srcRect.h)); 
     255 
     256    SDL_Surface *surface = NULL; 
     257    if ((ratioW!=1.0)||(ratioH!=1.0)) { 
     258        surface = zoomSurface(image, 
     259                        ratioW, 
     260                        ratioH, 
     261                        SMOOTHING_OFF); 
     262        //adjust offset to the new referentiel (zoomed) 
     263        srcRect.x=(Sint16)(src.x()*ratioW); 
     264        srcRect.y=(Sint16)(src.y()*ratioH); 
     265    } 
    258266     
    259     float scaleX = destRect.width() / tileRect.width(); 
    260     float scaleY = destRect.height() / tileRect.height(); 
    261  
    262     //printf( "scaleX = %f scaleY = %f\n", scaleX,scaleY ); 
    263  
    264     //SDL_Surface *surface; 
    265     //surface = zoomSurface(image, scaleX, scaleY, SMOOTHING_OFF); 
    266  
    267     //printf("surface %d %d\n", surface->w, surface->h); 
    268  
    269     for(int x = 0; x < destRect.width(); x+= static_cast<int>(tileRect.width())) { 
    270         for(int y = 0; y < destRect.height(); y+= static_cast<int>(tileRect.height())) { 
    271             //dest.setLocation(IntPoint(x, y) + context->origin()); 
    272             SDL_Rect d = {static_cast<Sint16>(x + static_cast<int>(destRect.x()) + context->origin().width()), 
    273                           static_cast<Sint16>(y + static_cast<int>(destRect.y()) + context->origin().height()), 
    274                           static_cast<Sint16>(tileRect.width()), 
    275                           static_cast<Sint16>(tileRect.height())}; 
    276             //printf("d = %d %d %d %d\n", d.x, d.y, d.w, d.h); 
    277             SDL_BlitSurface(image, &s, cr, &d); 
    278         } 
    279     } 
    280     //SDL_FreeSurface(surface); 
    281     //int xMax = static_cast<int>(destRect.x() + destRect.width()); 
    282     //int yMax = static_cast<int>(destRect.y() + destRect.height()); 
    283  
    284     /*float scaleX = image->w / tileRect.width(); 
    285     float scaleY = image->h / tileRect.height(); 
    286  
    287     SDL_Surface *surface; 
    288     surface = zoomSurface(image, scaleX, scaleY, SMOOTHING_OFF); 
    289     SDL_Rect s = {static_cast<Sint16>(tileRect.x()), 
    290                     static_cast<Sint16>(tileRect.y() + phase.y()), 
    291                     static_cast<Sint16>(image->w), 
    292                     static_cast<Sint16>(image->h)}; 
    293  
    294     for (int i = static_cast<int>(destRect.x()); i < static_cast<int>(destRect.right()); i += static_cast<int>(tileRect.width())) { 
    295         for (int j = static_cast<int>(destRect.y()); j < static_cast<int>(destRect.bottom()); j += static_cast<int>(tileRect.height())) { 
    296             SDL_Rect d = {static_cast<Sint16>(i + context->origin().width() + phase.x()),  
    297                             static_cast<Sint16>(j + context->origin().height()), 
    298                             static_cast<Sint16>(tileRect.width()), 
    299                             static_cast<Sint16>(tileRect.height())}; 
    300             printf("d = %d %d %d %d\n", d.x, d.y, d.w, d.h); 
    301             SDL_BlitSurface(surface, &s, cr, &d); 
    302         } 
    303     } 
    304  
    305     SDL_FreeSurface(surface);*/ 
    306      
    307      
     267 
     268    for(int x = static_cast<int>(phase.x()); x <= xMax; x+= image->w) { 
     269        for(int y = static_cast<int>(phase.y()); y <= yMax; y+=image->h) { 
     270            dest.setLocation(IntPoint(x, y) + context->origin()); 
     271             
     272            dstRect.x = static_cast<Sint16>(dest.x()); 
     273            dstRect.y = static_cast<Sint16>(dest.y()); 
     274 
     275            if (surface) { 
     276                if (context->transparencyLayer() == 1.0) { 
     277                    SDL_BlitSurface(surface, &srcRect, cr, &dstRect); 
     278                } 
     279                else { 
     280                    SDL_Surface *surfaceWithAlpha = applyTransparency(surface, static_cast<int> (context->transparencyLayer() * 255)); 
     281                    SDL_BlitSurface(surfaceWithAlpha, &srcRect, cr, &dstRect); 
     282                    SDL_FreeSurface(surfaceWithAlpha); 
     283                } 
     284            } 
     285            else { 
     286                if (context->transparencyLayer() == 1.0) { 
     287                    SDL_BlitSurface(image, &srcRect, cr, &dstRect); 
     288                } 
     289                else { 
     290                    SDL_Surface *surfaceWithAlpha = applyTransparency(image, static_cast<int> (context->transparencyLayer() * 255)); 
     291                    SDL_BlitSurface(surfaceWithAlpha, &srcRect, cr, &dstRect); 
     292                    SDL_FreeSurface(surfaceWithAlpha); 
     293                } 
     294            } 
     295        } 
     296    } 
     297 
     298    if(surface) 
     299        SDL_FreeSurface(surface); 
    308300 
    309301    context->restore(); 
  • branches/Doduo/BAL/WKAL/Concretizations/Graphics/SDL/BCPathSDL.cpp

    r243 r261  
    4242//    : m_path(new CairoPath()) 
    4343{ 
    44     printf("Path::Path\n"); 
     44    //printf("Path::Path\n"); 
    4545} 
    4646 
    4747Path::~Path() 
    4848{ 
    49     printf("Path::~Path\n"); 
     49    //printf("Path::~Path\n"); 
    5050    //delete m_path; 
    5151} 
     
    5454//    : m_path(new CairoPath()) 
    5555{ 
    56     printf("Path::Path copy\n"); 
     56    //printf("Path::Path copy\n"); 
    5757} 
    5858 
    5959Path& Path::operator=(const Path& other) 
    6060{ 
    61     printf("Path::operator=\n"); 
     61    //printf("Path::operator=\n"); 
    6262    if (&other == this) 
    6363        return *this; 
     
    7070void Path::clear() 
    7171{ 
    72     printf("Path::clear\n"); 
     72    //printf("Path::clear\n"); 
    7373} 
    7474 
    7575bool Path::isEmpty() const 
    7676{ 
    77     printf("Path::isEmpty\n"); 
     77    //printf("Path::isEmpty\n"); 
    7878    return true; 
    7979} 
     
    8181void Path::translate(const FloatSize& p) 
    8282{ 
    83     printf("Path::translate\n"); 
     83    //printf("Path::translate\n"); 
    8484} 
    8585 
    8686void Path::moveTo(const FloatPoint& p) 
    8787{ 
    88     printf("Path::moveTo\n"); 
     88    //printf("Path::moveTo\n"); 
    8989} 
    9090 
    9191void Path::addLineTo(const FloatPoint& p) 
    9292{ 
    93     printf("Path::addLineTo\n"); 
     93    //printf("Path::addLineTo\n"); 
    9494} 
    9595 
    9696void Path::addRect(const FloatRect& rect) 
    9797{ 
    98     printf("Path::addRect\n"); 
     98    //printf("Path::addRect\n"); 
    9999} 
    100100 
     
    104104void Path::addQuadCurveTo(const FloatPoint& controlPoint, const FloatPoint& point) 
    105105{ 
    106     printf("Path::addQuadCurveTo\n"); 
     106    //printf("Path::addQuadCurveTo\n"); 
    107107} 
    108108 
    109109void Path::addBezierCurveTo(const FloatPoint& controlPoint1, const FloatPoint& controlPoint2, const FloatPoint& controlPoint3) 
    110110{ 
    111     printf("Path::addBezierCurveTo\n"); 
     111    //printf("Path::addBezierCurveTo\n"); 
    112112 
    113113} 
     
    115115void Path::addArc(const FloatPoint& p, float r, float sa, float ea, bool anticlockwise) 
    116116{ 
    117     printf("Path::addArc\n"); 
     117    //printf("Path::addArc\n"); 
    118118} 
    119119 
    120120void Path::addArcTo(const FloatPoint& p1, const FloatPoint& p2, float radius) 
    121121{ 
    122     printf("Path::addArcTo\n"); 
     122    //printf("Path::addArcTo\n"); 
    123123    // FIXME: cairo_arc_to not yet in cairo see cairo.h 
    124124    // cairo_arc_to(m_cr, p1.x(), p1.y(), p2.x(), p2.y()); 
     
    128128void Path::addEllipse(const FloatRect& rect) 
    129129{ 
    130     printf("Path::addEllipse\n"); 
     130    //printf("Path::addEllipse\n"); 
    131131} 
    132132 
    133133void Path::closeSubpath() 
    134134{ 
    135     printf("Path::closeSubpath\n"); 
     135    //printf("Path::closeSubpath\n"); 
    136136} 
    137137 
    138138FloatRect Path::boundingRect() const 
    139139{ 
    140     printf("Path::boundingRect\n"); 
     140    //printf("Path::boundingRect\n"); 
    141141    return FloatRect(); 
    142142} 
     
    144144bool Path::contains(const FloatPoint& point, WindRule rule) const 
    145145{ 
    146     printf("Path::contains\n"); 
     146    //printf("Path::contains\n"); 
    147147    return false; 
    148148} 
     
    150150void Path::apply(void* info, PathApplierFunction function) const 
    151151{ 
    152     printf("Path::apply\n"); 
     152    //printf("Path::apply\n"); 
    153153} 
    154154 
    155155void Path::transform(const AffineTransform& trans) 
    156156{ 
    157     printf("Path::transform\n"); 
     157    //printf("Path::transform\n"); 
    158158} 
    159159 
    160160String Path::debugString() const 
    161161{ 
    162     printf("Path::debugString\n"); 
     162    //printf("Path::debugString\n"); 
    163163    String string = ""; 
    164164     
  • branches/Doduo/BAL/WKAL/Concretizations/Widgets/SDL/BCPopupMenuSDL.cpp

    r248 r261  
    3333#include "CString.h" 
    3434#include "FrameView.h" 
     35#include "Font.h" 
     36#include "FontDescription.h" 
     37#include "FloatRect.h" 
     38#include "FontSelector.h" 
     39#include "PlatformScrollBar.h" 
     40#include "PlatformScreen.h" 
    3541#include "PlatformString.h" 
     42#include "RenderStyle.h" 
     43#include "SDL.h" 
     44 
     45using std::min; 
    3646 
    3747namespace WKAL { 
     48 
     49// Default Window animation duration in milliseconds 
     50static const int defaultAnimationDuration = 200; 
     51// Maximum height of a popup window 
     52static const int maxPopupHeight = 320; 
     53 
     54static const int popupWindowAlphaPercent = 95; 
     55 
     56const int optionSpacingMiddle = 1; 
     57const int popupWindowBorderWidth = 1; 
     58 
     59// FIXME: Remove this as soon as practical. 
     60static inline bool isASCIIPrintable(unsigned c) 
     61{ 
     62    return c >= 0x20 && c <= 0x7E; 
     63} 
    3864 
    3965PopupMenu::PopupMenu(PopupMenuClient* client) 
     
    4167    , m_popupClient(client) 
    4268    , m_popup(0) 
    43 
    44     printf("PopupMenu::PopupMenu\n"); 
     69    , m_scrollBar(0) 
     70    , m_wasClicked(false) 
     71    , m_itemHeight(0) 
     72    , m_scrollOffset(0) 
     73    , m_wheelDelta(0) 
     74    , m_focusedIndex(0) 
     75    , m_scrollbarCapturingMouse(false) 
     76
    4577} 
    4678 
     
    4880{ 
    4981    printf("PopupMenu::~PopupMenu\n"); 
    50 
    51  
    52 void PopupMenu::show(const IntRect& rect, FrameView* view, int index) 
     82    if (m_popup) 
     83        SDL_FreeSurface(m_popup); 
     84
     85 
     86void PopupMenu::show(const IntRect& r, FrameView* v, int index) 
    5387{ 
    5488    ASSERT(client()); 
     89     
     90    calculatePositionAndSize(r, v); 
     91    if (clientRect().isEmpty()) 
     92        return; 
     93 
    5594    printf("PopupMenu::show\n"); 
    56  
     95    if (!m_popup) { 
     96        printf("PopupMenu::show create popup\n"); 
     97        // Even though we already know our size and location at this point, we pass (0,0,0,0) as our size/location here. 
     98        // We need to wait until after the call to ::SetWindowLongPtr to set our size so that in our WM_SIZE handler we can get access to the PopupMenu object 
     99        SDL_Surface* surface; 
     100        Uint32 rmask, gmask, bmask, amask; 
     101        /* SDL interprets each pixel as a 32-bit number, so our masks must depend 
     102        on the endianness (byte order) of the machine */ 
     103        rmask = 0x00ff0000; 
     104        gmask = 0x0000ff00; 
     105        bmask = 0x000000ff; 
     106        amask = 0xff000000; 
     107        m_popup = SDL_CreateRGBSurface(SDL_HWSURFACE | SDL_SRCALPHA, r.width(), r.height(), 32, 
     108                                       rmask, gmask, bmask, amask); 
     109 
     110        if (!m_popup) 
     111            return; 
     112    } 
     113 
     114    if (!m_scrollBar) 
     115        if (visibleItems() < client()->listSize()) { 
     116            // We need a scroll bar 
     117            m_scrollBar = new PlatformScrollbar(this, VerticalScrollbar, SmallScrollbar); 
     118            m_scrollBar->setContainingWindow(m_popup); 
     119        } 
     120 
     121    SDL_Rect srcRect, dstRect; 
     122 
     123    srcRect.x = 0;//static_cast<Sint16>(r.x()); 
     124    srcRect.y = 0;//static_cast<Sint16>(r.y()); 
     125//     if (0 == r.width()) 
     126//         srcRect.w = m_popup->w; 
     127//     else 
     128//         srcRect.w = static_cast<Uint16>(r.width()); 
     129//     if (0 == r.height()) 
     130//         srcRect.h = m_popup->h; 
     131//     else 
     132//         srcRect.h = static_cast<Uint16>(r.height()); 
     133 
     134    dstRect.x = static_cast<Sint16>(m_windowRect.x()); 
     135    dstRect.y = static_cast<Sint16>(m_windowRect.y()); 
     136    dstRect.w = static_cast<Sint16>(m_windowRect.width()); 
     137    dstRect.h = static_cast<Sint16>(m_windowRect.height()); 
     138 
     139    printf("srcRect %d %d %d %d\n", srcRect.x, srcRect.y, srcRect.h, srcRect.w); 
     140    printf("dstRect %d %d %d %d\n", dstRect.x, dstRect.y, dstRect.h, dstRect.w); 
     141    WebCore::Color c(255, 0, 0); 
     142    SDL_FillRect(m_popup, &srcRect, c.rgb()); 
     143    SDL_BlitSurface(m_popup, &srcRect, v->containingWindow(), &dstRect); 
     144 
     145    if (client()) { 
     146        int index = client()->selectedIndex(); 
     147        if (index >= 0) 
     148            setFocusedIndex(index); 
     149    } 
     150
     151 
     152int PopupMenu::focusedIndex() const 
     153
     154    return m_focusedIndex; 
     155
     156 
     157bool PopupMenu::setFocusedIndex(int i, bool hotTracking) 
     158
     159    if (i < 0 || i >= client()->listSize() || i == focusedIndex()) 
     160        return false; 
     161 
     162    if (!client()->itemIsEnabled(i)) 
     163        return false; 
     164 
     165    invalidateItem(focusedIndex()); 
     166    invalidateItem(i); 
     167 
     168    m_focusedIndex = i; 
     169 
     170    if (!hotTracking) 
     171        client()->setTextFromItem(i); 
     172 
     173    if (!scrollToRevealSelection()) 
     174        SDL_UpdateRect(m_popup, 0, 0, m_popup->w, m_popup->h); 
     175 
     176    return true; 
     177
     178 
     179bool PopupMenu::scrollToRevealSelection() 
     180
     181    if (!m_scrollBar) 
     182        return false; 
     183 
     184    int index = focusedIndex(); 
     185 
     186    if (index < m_scrollOffset) { 
     187        m_scrollBar->setValue(index); 
     188        return true; 
     189    } 
     190 
     191    if (index >= m_scrollOffset + visibleItems()) { 
     192        m_scrollBar->setValue(index - visibleItems() + 1); 
     193        return true; 
     194    } 
     195 
     196    return false; 
    57197} 
    58198 
     
    71211{ 
    72212    //printf("PopupMenu::itemWritingDirectionIsNatural\n"); 
    73     return true; 
     213    return false; 
    74214} 
    75215 
     
    103243} 
    104244 
    105 
     245const int endOfLinePadding = 2; 
     246void PopupMenu::calculatePositionAndSize(const IntRect& r, FrameView* v) 
     247
     248    // r is in absolute document coordinates, but we want to be in screen coordinates 
     249 
     250    // First, move to WebView coordinates 
     251    IntRect rScreenCoords(v->contentsToWindow(r.location()), r.size()); 
     252 
     253    // Then, translate to screen coordinates 
     254    //IntRect location(rScreenCoords.location()); 
     255    //if (!::ClientToScreen(v->containingWindow(), &location)) 
     256    //    return; 
     257 
     258    //rScreenCoords.setLocation(location); 
     259 
     260    // First, determine the popup's height 
     261    int itemCount = client()->listSize(); 
     262    m_itemHeight = client()->clientStyle()->font().height() + optionSpacingMiddle; 
     263    int naturalHeight = m_itemHeight * itemCount; 
     264    int popupHeight = min(maxPopupHeight, naturalHeight); 
     265    // The popup should show an integral number of items (i.e. no partial items should be visible) 
     266    popupHeight -= popupHeight % m_itemHeight; 
     267     
     268    // Next determine its width 
     269    int popupWidth = 0; 
     270    for (int i = 0; i < itemCount; ++i) { 
     271        String text = client()->itemText(i); 
     272        if (text.isEmpty()) 
     273            continue; 
     274 
     275        Font itemFont = client()->clientStyle()->font(); 
     276        if (client()->itemIsLabel(i)) { 
     277            FontDescription d = itemFont.fontDescription(); 
     278            d.setWeight(d.bolderWeight()); 
     279            itemFont = Font(d, itemFont.letterSpacing(), itemFont.wordSpacing()); 
     280            itemFont.update(m_popupClient->fontSelector()); 
     281        } 
     282 
     283        popupWidth = max(popupWidth, itemFont.width(TextRun(text.characters(), text.length()))); 
     284    } 
     285 
     286    if (naturalHeight > maxPopupHeight) 
     287        // We need room for a scrollbar 
     288        popupWidth += PlatformScrollbar::verticalScrollbarWidth(); 
     289 
     290    // Add padding to align the popup text with the <select> text 
     291    // Note: We can't add paddingRight() because that value includes the width 
     292    // of the dropdown button, so we must use our own endOfLinePadding constant. 
     293    popupWidth += max(0, endOfLinePadding - client()->clientInsetRight()) + max(0, client()->clientPaddingLeft() - client()->clientInsetLeft()); 
     294 
     295    // Leave room for the border 
     296    popupWidth += 2 * popupWindowBorderWidth; 
     297    popupHeight += 2 * popupWindowBorderWidth; 
     298 
     299    // The popup should be at least as wide as the control on the page 
     300    popupWidth = max(rScreenCoords.width() - client()->clientInsetLeft() - client()->clientInsetRight(), popupWidth); 
     301 
     302    // Always left-align items in the popup.  This matches popup menus on the mac. 
     303    int popupX = rScreenCoords.x() + client()->clientInsetLeft(); 
     304 
     305    IntRect popupRect(popupX, rScreenCoords.bottom(), popupWidth, popupHeight); 
     306 
     307    // The popup needs to stay within the bounds of the screen and not overlap any toolbars 
     308    FloatRect screen = screenAvailableRect(v); 
     309 
     310    // Check that we don't go off the screen vertically 
     311    if (popupRect.bottom() > screen.height()) { 
     312        // The popup will go off the screen, so try placing it above the client 
     313        if (rScreenCoords.y() - popupRect.height() < 0) { 
     314            // The popup won't fit above, either, so place it whereever's bigger and resize it to fit 
     315            if ((rScreenCoords.y() + rScreenCoords.height() / 2) < (screen.height() / 2)) { 
     316                // Below is bigger 
     317                popupRect.setHeight(static_cast<int>(screen.height() - popupRect.y())); 
     318            } else { 
     319                // Above is bigger 
     320                popupRect.setY(0); 
     321                popupRect.setHeight(rScreenCoords.y()); 
     322            } 
     323        } else { 
     324            // The popup fits above, so reposition it 
     325            popupRect.setY(rScreenCoords.y() - popupRect.height()); 
     326        } 
     327    } 
     328 
     329    // Check that we don't go off the screen horizontally 
     330    if (popupRect.x() < screen.x()) { 
     331        popupRect.setWidth(static_cast<int>(popupRect.width() - (screen.x() - popupRect.x()))); 
     332        popupRect.setX(static_cast<int>(screen.x())); 
     333    } 
     334 
     335    m_windowRect = popupRect; 
     336        printf("m_windowRect %d %d %d %d\n", m_windowRect.x(), m_windowRect.y(), m_windowRect.width(), m_windowRect.height()); 
     337    return; 
     338
     339 
     340void PopupMenu::invalidateItem(int index) 
     341
     342    if (!m_popup) 
     343        return; 
     344 
     345    IntRect damageRect(clientRect()); 
     346    damageRect.setY(m_itemHeight * (index - m_scrollOffset)); 
     347    damageRect.setHeight(m_itemHeight); 
     348    if (m_scrollBar) 
     349        damageRect.setWidth(damageRect.width() - m_scrollBar->frameGeometry().width()); 
     350 
     351    IntRect r = damageRect; 
     352    //::InvalidateRect(m_popup, &r, TRUE); 
     353
     354 
     355IntRect PopupMenu::clientRect() const 
     356
     357    IntRect clientRect = m_windowRect; 
     358    clientRect.inflate(-popupWindowBorderWidth); 
     359    clientRect.setLocation(IntPoint(0, 0)); 
     360    return clientRect; 
     361
     362 
     363int PopupMenu::visibleItems() const 
     364
     365    return clientRect().height() / m_itemHeight; 
     366
     367 
     368IntRect PopupMenu::windowClipRect() const 
     369
     370    return m_windowRect; 
     371
     372 
     373void PopupMenu::valueChanged(Scrollbar* scrollBar) 
     374
     375    printf("PopupMenu::valueChanged\n"); 
     376
     377 
     378
  • branches/Doduo/BAL/WKAL/Concretizations/Widgets/SDL/BCPopupMenuSDL.h

    r243 r261  
    3535#include "IntRect.h" 
    3636#include "PopupMenuClient.h" 
     37#include "ScrollBar.h" 
    3738#include <wtf/PassRefPtr.h> 
    3839#include "BALBase.h" 
     
    4546class PlatformScrollbar; 
    4647 
    47 class PopupMenu : public RefCounted<PopupMenu> 
     48class PopupMenu : public RefCounted<PopupMenu>, private ScrollbarClient 
    4849{ 
    4950public: 
     
    6667    PopupMenu(PopupMenuClient* client); 
    6768 
     69    //ScrollBarClient 
     70    virtual void valueChanged(Scrollbar*); 
     71    virtual IntRect windowClipRect() const; 
     72    virtual bool isActive() const { return true; } 
    6873private: 
    6974    PopupMenuClient* m_popupClient; 
     
    7681    static void menuPositionFunction(BalMenu*, int*, int*, bool*, PopupMenu*); 
    7782    static void menuRemoveItem(BalWidget*, PopupMenu*); 
     83    void calculatePositionAndSize(const IntRect&, FrameView*); 
     84    void invalidateItem(int index); 
     85    bool setFocusedIndex(int i, bool hotTracking = false); 
     86    int focusedIndex() const; 
     87    IntRect clientRect() const; 
     88    int visibleItems() const; 
     89    bool scrollToRevealSelection(); 
    7890 
     91    RefPtr<PlatformScrollbar> m_scrollBar; 
     92    bool m_wasClicked; 
     93    IntRect m_windowRect; 
     94    int m_itemHeight; 
     95    int m_scrollOffset; 
     96    int m_wheelDelta; 
     97    int m_focusedIndex; 
     98    bool m_scrollbarCapturingMouse; 
    7999}; 
    80100 
  • branches/Doduo/WebKit/ChangeLogOWB

    r260 r261  
     12008-06-11  Mario Bensi  <mbensi@pleyo.com> 
     2 
     3        Reviewed by NOBODY (OOPS!). 
     4 
     5        add custom user agent in webview 
     6 
     7        * OrigynWebBrowser/Api/WebView.cpp: 
     8        (WebView::userAgentForKURL): 
     9 
    1102008-06-11  Olivier DOLE  <odole@pleyo.com> 
    211 
  • branches/Doduo/WebKit/OrigynWebBrowser/Api/WebView.cpp

    r243 r261  
    826826        return m_userAgentCustom; 
    827827 
     828    m_userAgentStandard = getenv("OWB_USER_AGENT"); 
     829 
    828830    if (!m_userAgentStandard.length()) 
    829831#ifdef __OWBAL_PLATFORM_MACPORT__ 
  • branches/Doduo/WebKitTools/ChangeLogOWB

    r245 r261  
     12008-06-11  Mario Bensi  <mbensi@pleyo.com> 
     2 
     3        Reviewed by NOBODY (OOPS!). 
     4 
     5        add return 0 to finish the main 
     6 
     7        * OWBLauncher/SDL/main.cpp: 
     8        (main): 
     9        * OWBLauncher/gtk/main.cpp: 
     10        (main): 
     11 
    1122008-06-09  Olivier DOLE  <odole@pleyo.com> 
    213 
  • branches/Doduo/WebKitTools/OWBLauncher/SDL/main.cpp

    r243 r261  
    208208    DS_INST_DUMP_CURRENT(IOcout); 
    209209    DS_CLEAN_DEEPSEE_FRAMEWORK(); 
     210    return 0; 
    210211} 
  • branches/Doduo/WebKitTools/OWBLauncher/gtk/main.cpp

    r243 r261  
    100100    DS_INST_DUMP_CURRENT(IOcout); 
    101101    DS_CLEAN_DEEPSEE_FRAMEWORK(); 
     102    return 0; 
    102103}