Changeset 261
- Timestamp:
- 06/11/08 19:50:03 (5 months ago)
- Files:
-
- branches/Doduo/BAL/Base/SDL/BALTypeSDL.h (modified) (2 diffs)
- branches/Doduo/BAL/ChangeLogOWB (modified) (1 diff)
- branches/Doduo/BAL/OWBAL/Concretizations/Types/CMakeLists.txt (modified) (1 diff)
- branches/Doduo/BAL/OWBAL/Skeletons/Types/StrHash.t (deleted)
- branches/Doduo/BAL/WKAL/Concretizations/Graphics/SDL/BCImageSDL.cpp (modified) (3 diffs)
- branches/Doduo/BAL/WKAL/Concretizations/Graphics/SDL/BCPathSDL.cpp (modified) (9 diffs)
- branches/Doduo/BAL/WKAL/Concretizations/Widgets/SDL/BCPopupMenuSDL.cpp (modified) (5 diffs)
- branches/Doduo/BAL/WKAL/Concretizations/Widgets/SDL/BCPopupMenuSDL.h (modified) (4 diffs)
- branches/Doduo/WebKit/ChangeLogOWB (modified) (1 diff)
- branches/Doduo/WebKit/OrigynWebBrowser/Api/WebView.cpp (modified) (1 diff)
- branches/Doduo/WebKitTools/ChangeLogOWB (modified) (1 diff)
- branches/Doduo/WebKitTools/OWBLauncher/SDL/main.cpp (modified) (1 diff)
- branches/Doduo/WebKitTools/OWBLauncher/gtk/main.cpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/Doduo/BAL/Base/SDL/BALTypeSDL.h
r243 r261 65 65 typedef SDL_Rect BalRectangle; 66 66 typedef void BalMenuItem; 67 typedef voidBalMenu;67 typedef SDL_Surface BalMenu; 68 68 typedef void BalClipboard; 69 69 typedef void BalTargetList; … … 85 85 typedef void* DragImageRef; 86 86 typedef void* DragDataRef; 87 typedef void* PlatformMenuDescription;88 87 typedef unsigned short GlyphBufferGlyph; 89 88 typedef WKAL::FloatSize GlyphBufferAdvance; branches/Doduo/BAL/ChangeLogOWB
r259 r261 1 2008-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 1 51 2008-06-11 Fred <fmarmond@pleyo.com> 2 52 branches/Doduo/BAL/OWBAL/Concretizations/Types/CMakeLists.txt
r243 r261 71 71 OWBLN (WK/BCVectorTraitsWK.h OWBAL/wtf 0 0) 72 72 OWBLN (WK/BCbalValuePrivateWK.h OWBAL 0 0) 73 OWBLN (WK/BCStrHashWK.h OWBAL/wtf 0 0)74 73 OWBLN (WK/BCAVLTreeWK.h OWBAL/wtf 0 0) 75 74 branches/Doduo/BAL/WKAL/Concretizations/Graphics/SDL/BCImageSDL.cpp
r243 r261 201 201 } 202 202 203 204 205 203 206 void Image::drawPattern(GraphicsContext* context, const FloatRect& tileRect, const AffineTransform& patternTransform, 204 207 const FloatPoint& phase, CompositeOperator op, const FloatRect& destRect) 205 208 { 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 211 209 if (destRect.isEmpty()) 212 210 return; … … 216 214 return; 217 215 218 //printf("image %d %d\n", image->w, image->h);219 216 SDL_Surface* cr = context->platformContext(); 220 217 context->save(); … … 222 219 context->setCompositeOperation(op); 223 220 221 printf("CompositeOperator = %d\n", op); 224 222 // Check and see if a single draw of the image can cover the entire area we are supposed to tile. 225 223 // save context info 226 224 context->clip(IntRect(destRect)); // don't draw outside this 227 225 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())); 250 229 251 230 int xMax = static_cast<int>(destRect.x() + destRect.width()); 252 231 int yMax = static_cast<int>(destRect.y() + destRect.height()); 253 232 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 } 258 266 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); 308 300 309 301 context->restore(); branches/Doduo/BAL/WKAL/Concretizations/Graphics/SDL/BCPathSDL.cpp
r243 r261 42 42 // : m_path(new CairoPath()) 43 43 { 44 printf("Path::Path\n");44 //printf("Path::Path\n"); 45 45 } 46 46 47 47 Path::~Path() 48 48 { 49 printf("Path::~Path\n");49 //printf("Path::~Path\n"); 50 50 //delete m_path; 51 51 } … … 54 54 // : m_path(new CairoPath()) 55 55 { 56 printf("Path::Path copy\n");56 //printf("Path::Path copy\n"); 57 57 } 58 58 59 59 Path& Path::operator=(const Path& other) 60 60 { 61 printf("Path::operator=\n");61 //printf("Path::operator=\n"); 62 62 if (&other == this) 63 63 return *this; … … 70 70 void Path::clear() 71 71 { 72 printf("Path::clear\n");72 //printf("Path::clear\n"); 73 73 } 74 74 75 75 bool Path::isEmpty() const 76 76 { 77 printf("Path::isEmpty\n");77 //printf("Path::isEmpty\n"); 78 78 return true; 79 79 } … … 81 81 void Path::translate(const FloatSize& p) 82 82 { 83 printf("Path::translate\n");83 //printf("Path::translate\n"); 84 84 } 85 85 86 86 void Path::moveTo(const FloatPoint& p) 87 87 { 88 printf("Path::moveTo\n");88 //printf("Path::moveTo\n"); 89 89 } 90 90 91 91 void Path::addLineTo(const FloatPoint& p) 92 92 { 93 printf("Path::addLineTo\n");93 //printf("Path::addLineTo\n"); 94 94 } 95 95 96 96 void Path::addRect(const FloatRect& rect) 97 97 { 98 printf("Path::addRect\n");98 //printf("Path::addRect\n"); 99 99 } 100 100 … … 104 104 void Path::addQuadCurveTo(const FloatPoint& controlPoint, const FloatPoint& point) 105 105 { 106 printf("Path::addQuadCurveTo\n");106 //printf("Path::addQuadCurveTo\n"); 107 107 } 108 108 109 109 void Path::addBezierCurveTo(const FloatPoint& controlPoint1, const FloatPoint& controlPoint2, const FloatPoint& controlPoint3) 110 110 { 111 printf("Path::addBezierCurveTo\n");111 //printf("Path::addBezierCurveTo\n"); 112 112 113 113 } … … 115 115 void Path::addArc(const FloatPoint& p, float r, float sa, float ea, bool anticlockwise) 116 116 { 117 printf("Path::addArc\n");117 //printf("Path::addArc\n"); 118 118 } 119 119 120 120 void Path::addArcTo(const FloatPoint& p1, const FloatPoint& p2, float radius) 121 121 { 122 printf("Path::addArcTo\n");122 //printf("Path::addArcTo\n"); 123 123 // FIXME: cairo_arc_to not yet in cairo see cairo.h 124 124 // cairo_arc_to(m_cr, p1.x(), p1.y(), p2.x(), p2.y()); … … 128 128 void Path::addEllipse(const FloatRect& rect) 129 129 { 130 printf("Path::addEllipse\n");130 //printf("Path::addEllipse\n"); 131 131 } 132 132 133 133 void Path::closeSubpath() 134 134 { 135 printf("Path::closeSubpath\n");135 //printf("Path::closeSubpath\n"); 136 136 } 137 137 138 138 FloatRect Path::boundingRect() const 139 139 { 140 printf("Path::boundingRect\n");140 //printf("Path::boundingRect\n"); 141 141 return FloatRect(); 142 142 } … … 144 144 bool Path::contains(const FloatPoint& point, WindRule rule) const 145 145 { 146 printf("Path::contains\n");146 //printf("Path::contains\n"); 147 147 return false; 148 148 } … … 150 150 void Path::apply(void* info, PathApplierFunction function) const 151 151 { 152 printf("Path::apply\n");152 //printf("Path::apply\n"); 153 153 } 154 154 155 155 void Path::transform(const AffineTransform& trans) 156 156 { 157 printf("Path::transform\n");157 //printf("Path::transform\n"); 158 158 } 159 159 160 160 String Path::debugString() const 161 161 { 162 printf("Path::debugString\n");162 //printf("Path::debugString\n"); 163 163 String string = ""; 164 164 branches/Doduo/BAL/WKAL/Concretizations/Widgets/SDL/BCPopupMenuSDL.cpp
r248 r261 33 33 #include "CString.h" 34 34 #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" 35 41 #include "PlatformString.h" 42 #include "RenderStyle.h" 43 #include "SDL.h" 44 45 using std::min; 36 46 37 47 namespace WKAL { 48 49 // Default Window animation duration in milliseconds 50 static const int defaultAnimationDuration = 200; 51 // Maximum height of a popup window 52 static const int maxPopupHeight = 320; 53 54 static const int popupWindowAlphaPercent = 95; 55 56 const int optionSpacingMiddle = 1; 57 const int popupWindowBorderWidth = 1; 58 59 // FIXME: Remove this as soon as practical. 60 static inline bool isASCIIPrintable(unsigned c) 61 { 62 return c >= 0x20 && c <= 0x7E; 63 } 38 64 39 65 PopupMenu::PopupMenu(PopupMenuClient* client) … … 41 67 , m_popupClient(client) 42 68 , 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 { 45 77 } 46 78 … … 48 80 { 49 81 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 86 void PopupMenu::show(const IntRect& r, FrameView* v, int index) 53 87 { 54 88 ASSERT(client()); 89 90 calculatePositionAndSize(r, v); 91 if (clientRect().isEmpty()) 92 return; 93 55 94 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 152 int PopupMenu::focusedIndex() const 153 { 154 return m_focusedIndex; 155 } 156 157 bool 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 179 bool 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; 57 197 } 58 198 … … 71 211 { 72 212 //printf("PopupMenu::itemWritingDirectionIsNatural\n"); 73 return true;213 return false; 74 214 } 75 215 … … 103 243 } 104 244 105 } 245 const int endOfLinePadding = 2; 246 void 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 340 void 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 355 IntRect PopupMenu::clientRect() const 356 { 357 IntRect clientRect = m_windowRect; 358 clientRect.inflate(-popupWindowBorderWidth); 359 clientRect.setLocation(IntPoint(0, 0)); 360 return clientRect; 361 } 362 363 int PopupMenu::visibleItems() const 364 { 365 return clientRect().height() / m_itemHeight; 366 } 367 368 IntRect PopupMenu::windowClipRect() const 369 { 370 return m_windowRect; 371 } 372 373 void PopupMenu::valueChanged(Scrollbar* scrollBar) 374 { 375 printf("PopupMenu::valueChanged\n"); 376 } 377 378 } branches/Doduo/BAL/WKAL/Concretizations/Widgets/SDL/BCPopupMenuSDL.h
r243 r261 35 35 #include "IntRect.h" 36 36 #include "PopupMenuClient.h" 37 #include "ScrollBar.h" 37 38 #include <wtf/PassRefPtr.h> 38 39 #include "BALBase.h" … … 45 46 class PlatformScrollbar; 46 47 47 class PopupMenu : public RefCounted<PopupMenu> 48 class PopupMenu : public RefCounted<PopupMenu>, private ScrollbarClient 48 49 { 49 50 public: … … 66 67 PopupMenu(PopupMenuClient* client); 67 68 69 //ScrollBarClient 70 virtual void valueChanged(Scrollbar*); 71 virtual IntRect windowClipRect() const; 72 virtual bool isActive() const { return true; } 68 73 private: 69 74 PopupMenuClient* m_popupClient; … … 76 81 static void menuPositionFunction(BalMenu*, int*, int*, bool*, PopupMenu*); 77 82 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(); 78 90 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; 79 99 }; 80 100 branches/Doduo/WebKit/ChangeLogOWB
r260 r261 1 2008-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 1 10 2008-06-11 Olivier DOLE <odole@pleyo.com> 2 11 branches/Doduo/WebKit/OrigynWebBrowser/Api/WebView.cpp
r243 r261 826 826 return m_userAgentCustom; 827 827 828 m_userAgentStandard = getenv("OWB_USER_AGENT"); 829 828 830 if (!m_userAgentStandard.length()) 829 831 #ifdef __OWBAL_PLATFORM_MACPORT__ branches/Doduo/WebKitTools/ChangeLogOWB
r245 r261 1 2008-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 1 12 2008-06-09 Olivier DOLE <odole@pleyo.com> 2 13 branches/Doduo/WebKitTools/OWBLauncher/SDL/main.cpp
r243 r261 208 208 DS_INST_DUMP_CURRENT(IOcout); 209 209 DS_CLEAN_DEEPSEE_FRAMEWORK(); 210 return 0; 210 211 } branches/Doduo/WebKitTools/OWBLauncher/gtk/main.cpp
r243 r261 100 100 DS_INST_DUMP_CURRENT(IOcout); 101 101 DS_CLEAN_DEEPSEE_FRAMEWORK(); 102 return 0; 102 103 }
