[haiku-webkit-commits] r483 - in webkit/trunk/WebKit: . haiku/WebPositive haiku/WebPositive/support

  • From: webkit@xxxxxxxxxxxxxxx
  • To: haiku-webkit-commits@xxxxxxxxxxxxx
  • Date: Tue, 04 May 2010 16:10:40 +0000

Author: stippi
Date: Tue May  4 16:10:39 2010
New Revision: 483
URL: http://mmlr.dyndns.org/changeset/483

Log:
Moved BitmapButton into it's own file.

Added:
   webkit/trunk/WebKit/haiku/WebPositive/support/BitmapButton.cpp
   webkit/trunk/WebKit/haiku/WebPositive/support/BitmapButton.h
Modified:
   webkit/trunk/WebKit/Jamfile
   webkit/trunk/WebKit/haiku/WebPositive/URLInputGroup.cpp

Modified: webkit/trunk/WebKit/Jamfile
==============================================================================
--- webkit/trunk/WebKit/Jamfile Tue May  4 12:23:56 2010        (r482)
+++ webkit/trunk/WebKit/Jamfile Tue May  4 16:10:39 2010        (r483)
@@ -134,6 +134,7 @@
        TextViewCompleter.cpp
        # support
        BaseURL.cpp
+    BitmapButton.cpp
     DateTime.cpp
     FontSelectionView.cpp
     IconButton.cpp

Modified: webkit/trunk/WebKit/haiku/WebPositive/URLInputGroup.cpp
==============================================================================
--- webkit/trunk/WebKit/haiku/WebPositive/URLInputGroup.cpp     Tue May  4 
12:23:56 2010        (r482)
+++ webkit/trunk/WebKit/haiku/WebPositive/URLInputGroup.cpp     Tue May  4 
16:10:39 2010        (r483)
@@ -16,13 +16,13 @@
 #include <PopUpMenu.h>
 #include <SeparatorView.h>
 #include <TextView.h>
-#include <TranslationUtils.h>
 #include <Window.h>
 
 #include <stdio.h>
 #include <stdlib.h>
 
 #include "BaseURL.h"
+#include "BitmapButton.h"
 #include "BrowsingHistory.h"
 #include "IconButton.h"
 #include "TextViewCompleter.h"
@@ -382,9 +382,6 @@
 }
 
 
-// #pragma mark - GoButton
-
-
 const uint32 kGoBitmapWidth = 14;
 const uint32 kGoBitmapHeight = 14;
 const color_space kGoBitmapFormat = B_RGBA32;
@@ -442,87 +439,7 @@
 };
 
 
-class BitmapButton : public BButton {
-       static const float kFrameInset = 2;
-
-public:
-       BitmapButton(const char* resourceName, BMessage* message)
-               :
-               BButton("", message),
-               fBitmap(BTranslationUtils::GetBitmap(resourceName))
-       {
-       }
-
-       BitmapButton(const uint8* bits, uint32 width, uint32 height,
-                       color_space format, BMessage* message)
-               :
-               BButton("", message),
-               fBitmap(new BBitmap(BRect(0, 0, width - 1, height - 1), 0, 
format))
-       {
-               memcpy(fBitmap->Bits(), bits, fBitmap->BitsLength());
-       }
-
-       ~BitmapButton()
-       {
-               delete fBitmap;
-       }
-
-       virtual BSize MinSize()
-       {
-               BSize min(0, 0);
-               if (fBitmap) {
-                       min.width = fBitmap->Bounds().Width();
-                       min.height = fBitmap->Bounds().Height();
-               }
-               min.width += kFrameInset * 2;
-               min.height += kFrameInset * 2;
-               return min;
-       }
-
-       virtual BSize MaxSize()
-       {
-               return BSize(B_SIZE_UNLIMITED, B_SIZE_UNLIMITED);
-       }
-
-       virtual BSize PreferredSize()
-       {
-               return MinSize();
-       }
-
-       virtual void Draw(BRect updateRect)
-       {
-               BRect bounds(Bounds());
-               rgb_color base = ui_color(B_PANEL_BACKGROUND_COLOR);
-               uint32 flags = be_control_look->Flags(this);
-
-               be_control_look->DrawButtonBackground(this, bounds, updateRect, 
base,
-                       flags);
-
-               SetDrawingMode(B_OP_ALPHA);
-
-               if (!IsEnabled()) {
-                       SetBlendingMode(B_CONSTANT_ALPHA, B_ALPHA_OVERLAY);
-                       SetHighColor(0, 0, 0, 120);
-               }
-
-               if (fBitmap == NULL)
-                       return;
-               BRect bitmapBounds(fBitmap->Bounds());
-               BPoint bitmapLocation(
-                       floorf((bounds.left + bounds.right
-                               - (bitmapBounds.left + bitmapBounds.right)) / 2 
+ 0.5f),
-                       floorf((bounds.top + bounds.bottom
-                               - (bitmapBounds.top + bitmapBounds.bottom)) / 2 
+ 0.5f));
-
-               DrawBitmap(fBitmap, bitmapLocation);
-       }
-
-private:
-       BBitmap* fBitmap;
-};
-
-
-// #pragma mark - IconView
+// #pragma mark - PageIconView
 
 
 class URLInputGroup::PageIconView : public BView {

Added: webkit/trunk/WebKit/haiku/WebPositive/support/BitmapButton.cpp
==============================================================================
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ webkit/trunk/WebKit/haiku/WebPositive/support/BitmapButton.cpp      Tue May 
 4 16:10:39 2010        (r483)
@@ -0,0 +1,116 @@
+/*
+ * Copyright 2010 Stephan Aßmus <superstippi@xxxxxx>. All rights reserved.
+ * Distributed under the terms of the MIT License.
+ */
+
+#include "BitmapButton.h"
+
+#include <string.h>
+
+#include <Bitmap.h>
+#include <ControlLook.h>
+#include <TranslationUtils.h>
+
+
+static const float kFrameInset = 2;
+
+
+BitmapButton::BitmapButton(const char* resourceName, BMessage* message)
+       :
+       BButton("", message),
+       fBitmap(BTranslationUtils::GetBitmap(resourceName)),
+       fBackgroundMode(BUTTON_BACKGROUND)
+{
+}
+
+
+BitmapButton::BitmapButton(const uint8* bits, uint32 width, uint32 height,
+               color_space format, BMessage* message)
+       :
+       BButton("", message),
+       fBitmap(new BBitmap(BRect(0, 0, width - 1, height - 1), 0, format)),
+       fBackgroundMode(BUTTON_BACKGROUND)
+{
+       memcpy(fBitmap->Bits(), bits, fBitmap->BitsLength());
+}
+
+
+BitmapButton::~BitmapButton()
+{
+       delete fBitmap;
+}
+
+
+BSize
+BitmapButton::MinSize()
+{
+       BSize min(0, 0);
+       if (fBitmap) {
+               min.width = fBitmap->Bounds().Width();
+               min.height = fBitmap->Bounds().Height();
+       }
+       min.width += kFrameInset * 2;
+       min.height += kFrameInset * 2;
+       return min;
+}
+
+
+BSize
+BitmapButton::MaxSize()
+{
+       return BSize(B_SIZE_UNLIMITED, B_SIZE_UNLIMITED);
+}
+
+
+BSize
+BitmapButton::PreferredSize()
+{
+       return MinSize();
+}
+
+
+void
+BitmapButton::Draw(BRect updateRect)
+{
+       BRect bounds(Bounds());
+       rgb_color base = ui_color(B_PANEL_BACKGROUND_COLOR);
+       uint32 flags = be_control_look->Flags(this);
+
+       if (fBackgroundMode == BUTTON_BACKGROUND || Value() == B_CONTROL_ON) {
+               be_control_look->DrawButtonBackground(this, bounds, updateRect, 
base,
+                       flags);
+       } else {
+               be_control_look->DrawMenuBarBackground(this, bounds, 
updateRect, base,
+                       flags);
+       }
+
+       if (fBitmap == NULL)
+               return;
+
+       SetDrawingMode(B_OP_ALPHA);
+
+       if (!IsEnabled()) {
+               SetBlendingMode(B_CONSTANT_ALPHA, B_ALPHA_OVERLAY);
+               SetHighColor(0, 0, 0, 120);
+       }
+
+       BRect bitmapBounds(fBitmap->Bounds());
+       BPoint bitmapLocation(
+               floorf((bounds.left + bounds.right
+                       - (bitmapBounds.left + bitmapBounds.right)) / 2 + 0.5f),
+               floorf((bounds.top + bounds.bottom
+                       - (bitmapBounds.top + bitmapBounds.bottom)) / 2 + 
0.5f));
+
+       DrawBitmap(fBitmap, bitmapLocation);
+}
+
+
+void
+BitmapButton::SetBackgroundMode(uint32 mode)
+{
+       if (fBackgroundMode != mode) {
+               fBackgroundMode = mode;
+               Invalidate();
+       }
+}
+

Added: webkit/trunk/WebKit/haiku/WebPositive/support/BitmapButton.h
==============================================================================
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ webkit/trunk/WebKit/haiku/WebPositive/support/BitmapButton.h        Tue May 
 4 16:10:39 2010        (r483)
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2010 Stephan Aßmus <superstippi@xxxxxx>. All rights reserved.
+ * Distributed under the terms of the MIT License.
+ */
+#ifndef BITMAP_BUTTON_H
+#define BITMAP_BUTTON_H
+
+#include <Button.h>
+
+
+class BBitmap;
+
+
+class BitmapButton : public BButton {
+public:
+       enum {
+               BUTTON_BACKGROUND = 0,
+               MENUBAR_BACKGROUND,
+       };
+
+                                                               
BitmapButton(const char* resourceName,
+                                                                       
BMessage* message);
+
+                                                               
BitmapButton(const uint8* bits, uint32 width,
+                                                                       uint32 
height, color_space format,
+                                                                       
BMessage* message);
+
+       virtual                                         ~BitmapButton();
+
+       virtual BSize                           MinSize();
+       virtual BSize                           MaxSize();
+       virtual BSize                           PreferredSize();
+
+       virtual void                            Draw(BRect updateRect);
+
+                       void                            
SetBackgroundMode(uint32 mode);
+
+private:
+                       BBitmap*                        fBitmap;
+                       uint32                          fBackgroundMode;
+};
+
+
+#endif // BITMAP_BUTTON_H

Other related posts:

  • » [haiku-webkit-commits] r483 - in webkit/trunk/WebKit: . haiku/WebPositive haiku/WebPositive/support - webkit