mirror of
https://github.com/yann64/haikuports.git
synced 2026-04-22 19:50:05 +02:00
Use graphical buttons in the toolbar in Haiku. Could be done in BeOS as well but I'm too lazy to convert buttons to BBitmaps.
This commit is contained in:
@@ -220,21 +220,91 @@ index 32860de..90cadde 100644
|
||||
// asynchronously
|
||||
a->Go(NULL);
|
||||
|
||||
diff --git a/beos/res.rdef b/beos/res.rdef
|
||||
index b047bd0..b9aa589 100644
|
||||
--- a/beos/res.rdef
|
||||
+++ b/beos/res.rdef
|
||||
@@ -397,3 +397,43 @@ resource(101, "BEOS:V:STD_ICON") #'zICO' array {
|
||||
$"7F793EDCE3F417BB10DA0B"
|
||||
};
|
||||
|
||||
+resource(102, "forward_button") #'VICN' array {
|
||||
+ $"6E6369660304006603005900020006020000003C6000C000000000004C000048"
|
||||
+ $"A0000080FF80FF00B300010A0748353448343E223E222C342C3422030A000100"
|
||||
+ $"30222201178322040A0101001001178322040A02010000"
|
||||
+};
|
||||
+
|
||||
+resource(103, "back_button") #'VICN' array {
|
||||
+ $"6E6369660304006603005900020006020000003C6000C000000000004C000048"
|
||||
+ $"A0000080FF80FF00B300010A0722353622362C482C483E363E3648030A000100"
|
||||
+ $"30222201178322040A0101001001178322040A02010000"
|
||||
+};
|
||||
+
|
||||
+resource(104, "stop_button") #'VICN' array {
|
||||
+ $"6E6369660304006603800000020006020000003C6000C000000000004C000048"
|
||||
+ $"A00000FFABABFFD900000208022A40402A02043525BEE325B7D825253525B7D8"
|
||||
+ $"25BEE33545B7D845BEE345453545BEE345B7D8030A0002000130222201178900"
|
||||
+ $"040A010200011001178900040A02020100100117850004"
|
||||
+};
|
||||
+
|
||||
+resource(105, "reload_button") #'VICN' array {
|
||||
+ $"6E6369660404006603004080020006020000003A0000C000000000004C000046"
|
||||
+ $"7FFF00ABD5FFFF006CD9020006020000003A0000C000000000004C0000467FFF"
|
||||
+ $"FFAAD4FF00006CD9010606C60F482232383D2D3D2D3826222A2B2329224327BC"
|
||||
+ $"B7B25A4327060A00010030222201178322040A0101001001178322040A020100"
|
||||
+ $"000A00010012C00000000000000000C000004AC0004AC00001178422040A0101"
|
||||
+ $"0012C00000000000000000C000004AA0004AA00001178422040A03010002C000"
|
||||
+ $"00000000000000C000004AA0004AA000"
|
||||
+};
|
||||
+
|
||||
+resource(106, "home_button") #'VICN' array {
|
||||
+ $"6E6369660804006603800000020006020000003A8000C000000000004C000047"
|
||||
+ $"000000FFABABFFD900000554020016020000003AC000C000000000004BE00048"
|
||||
+ $"A00000FFFFE50300590002000602000000370000C000000000004C00004A5000"
|
||||
+ $"0080FF80FF00B20003806040040A064836483035222230223635280A04484848"
|
||||
+ $"42224222480A0542404234352A283428400A042C342C4032403234080A030102"
|
||||
+ $"1001178400040A040102000A0101001001178402040A020100000A0501011001"
|
||||
+ $"178402040A060101000A070103000A0701030240AAAA0000000000003E000045"
|
||||
+ $"0000468000"
|
||||
+};
|
||||
+
|
||||
diff --git a/beos/scaffolding.cpp b/beos/scaffolding.cpp
|
||||
index 4003b09..3455baf 100644
|
||||
index 4003b09..c9a9d15 100644
|
||||
--- a/beos/scaffolding.cpp
|
||||
+++ b/beos/scaffolding.cpp
|
||||
@@ -38,6 +38,9 @@
|
||||
@@ -22,7 +22,9 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
+
|
||||
#include <BeBuild.h>
|
||||
+#include <Box.h>
|
||||
#include <Button.h>
|
||||
#include <Dragger.h>
|
||||
#include <Menu.h>
|
||||
@@ -31,6 +33,8 @@
|
||||
#include <Node.h>
|
||||
#include <Path.h>
|
||||
#include <PopUpMenu.h>
|
||||
+#include <Resources.h>
|
||||
+#include <Roster.h>
|
||||
#include <Screen.h>
|
||||
#include <ScrollView.h>
|
||||
#include <String.h>
|
||||
@@ -38,6 +42,12 @@
|
||||
#include <TextControl.h>
|
||||
#include <View.h>
|
||||
#include <Window.h>
|
||||
+
|
||||
+#if defined(__HAIKU__)
|
||||
+#include <IconUtils.h>
|
||||
+#include "WindowStack.h"
|
||||
+#endif
|
||||
+
|
||||
#include <fs_attr.h>
|
||||
extern "C" {
|
||||
#include "content/content.h"
|
||||
@@ -571,6 +574,12 @@ NSBrowserWindow::NSBrowserWindow(BRect frame, struct beos_scaffolding *scaf)
|
||||
@@ -571,6 +581,12 @@ NSBrowserWindow::NSBrowserWindow(BRect frame, struct beos_scaffolding *scaf)
|
||||
: BWindow(frame, "NetSurf", B_DOCUMENT_WINDOW, 0),
|
||||
fScaffolding(scaf)
|
||||
{
|
||||
@@ -247,7 +317,7 @@ index 4003b09..3455baf 100644
|
||||
}
|
||||
|
||||
|
||||
@@ -621,6 +630,8 @@ NSBrowserWindow::QuitRequested(void)
|
||||
@@ -621,6 +637,8 @@ NSBrowserWindow::QuitRequested(void)
|
||||
}
|
||||
|
||||
|
||||
@@ -256,7 +326,155 @@ index 4003b09..3455baf 100644
|
||||
// #pragma mark - implementation
|
||||
|
||||
int32 nsbeos_replicant_main_thread(void *_arg)
|
||||
@@ -2407,3 +2418,4 @@ void nsbeos_scaffolding_popup_menu(nsbeos_scaffolding *g, BPoint where)
|
||||
@@ -1659,6 +1677,90 @@ static BMenuItem *make_menu_item(const char *name, BMessage *message)
|
||||
return item;
|
||||
}
|
||||
|
||||
+
|
||||
+class BBitmapButton: public BButton
|
||||
+{
|
||||
+ public:
|
||||
+ BBitmapButton(BRect rect, const char* name, const char* label,
|
||||
+ BMessage* message);
|
||||
+ ~BBitmapButton();
|
||||
+
|
||||
+ void Draw(BRect updateRect);
|
||||
+ void SetBitmap(const char* attrName);
|
||||
+ private:
|
||||
+ BBitmap* fBitmap;
|
||||
+};
|
||||
+
|
||||
+
|
||||
+BBitmapButton::BBitmapButton(BRect rect, const char* name, const char* label,
|
||||
+ BMessage* message)
|
||||
+ : BButton(rect, name, label, message)
|
||||
+{
|
||||
+ SetBitmap(name);
|
||||
+}
|
||||
+
|
||||
+
|
||||
+BBitmapButton::~BBitmapButton()
|
||||
+{
|
||||
+ delete fBitmap;
|
||||
+}
|
||||
+
|
||||
+
|
||||
+void BBitmapButton::Draw(BRect updateRect)
|
||||
+{
|
||||
+ if(fBitmap == NULL) {
|
||||
+ BButton::Draw(updateRect);
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ SetDrawingMode(B_OP_COPY);
|
||||
+ FillRect(updateRect, B_SOLID_LOW);
|
||||
+ rgb_color color = LowColor();
|
||||
+
|
||||
+ SetDrawingMode(B_OP_ALPHA);
|
||||
+ if(Value() != 0) {
|
||||
+ // button is clicked
|
||||
+ DrawBitmap(fBitmap, BPoint(1, 1));
|
||||
+ } else {
|
||||
+ // button is released
|
||||
+ DrawBitmap(fBitmap, BPoint(0, 0));
|
||||
+ }
|
||||
+
|
||||
+ if(!IsEnabled())
|
||||
+ {
|
||||
+ color.alpha = 127;
|
||||
+ SetLowColor(color);
|
||||
+ FillRect(updateRect, B_SOLID_LOW);
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+
|
||||
+void BBitmapButton::SetBitmap(const char* attrname)
|
||||
+{
|
||||
+#ifdef __HAIKU__
|
||||
+ size_t size = 0;
|
||||
+ const void* data = BApplication::AppResources()->LoadResource('VICN', attrname, &size);
|
||||
+
|
||||
+ if (!data) {
|
||||
+ printf("CANT LOAD RESOURCE %s\n", attrname);
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ fBitmap = new BBitmap(BRect(0, 0, 32, 32), B_RGB32);
|
||||
+ status_t status = BIconUtils::GetVectorIcon((const uint8*)data, size, fBitmap);
|
||||
+
|
||||
+ if(status != B_OK) {
|
||||
+ fprintf(stderr, "%s > oops %s\n", attrname, strerror(status));
|
||||
+ delete fBitmap;
|
||||
+ fBitmap = NULL;
|
||||
+ }
|
||||
+#else
|
||||
+ // No vector icon support on BeOS. We could try to load a bitmap one
|
||||
+ fBitmap = NULL;
|
||||
+#endif
|
||||
+}
|
||||
+
|
||||
+
|
||||
nsbeos_scaffolding *nsbeos_new_scaffolding(struct gui_window *toplevel)
|
||||
{
|
||||
struct beos_scaffolding *g = (struct beos_scaffolding *)malloc(sizeof(*g));
|
||||
@@ -2038,14 +2140,13 @@ nsbeos_scaffolding *nsbeos_new_scaffolding(struct gui_window *toplevel)
|
||||
rect = g->top_view->Bounds();
|
||||
rect.bottom = rect.top + TOOLBAR_HEIGHT - 1;
|
||||
rect.right = rect.right - DRAGGER_WIDTH;
|
||||
- g->tool_bar = new BView(rect, "Toolbar",
|
||||
+ g->tool_bar = new BBox(rect, "Toolbar",
|
||||
B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP, B_WILL_DRAW);
|
||||
g->top_view->AddChild(g->tool_bar);
|
||||
g->tool_bar->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
||||
g->tool_bar->SetLowColor(ui_color(B_PANEL_BACKGROUND_COLOR)) ;
|
||||
|
||||
// buttons
|
||||
-#warning use BPictureButton
|
||||
rect = g->tool_bar->Bounds();
|
||||
rect.right = TOOLBAR_HEIGHT;
|
||||
rect.InsetBySelf(5, 5);
|
||||
@@ -2054,35 +2155,35 @@ nsbeos_scaffolding *nsbeos_new_scaffolding(struct gui_window *toplevel)
|
||||
|
||||
message = new BMessage('back');
|
||||
message->AddPointer("scaffolding", g);
|
||||
- g->back_button = new BButton(rect, "back_button", "<", message);
|
||||
+ g->back_button = new BBitmapButton(rect, "back_button", "<", message);
|
||||
g->tool_bar->AddChild(g->back_button);
|
||||
nButtons++;
|
||||
|
||||
rect.OffsetBySelf(TOOLBAR_HEIGHT, 0);
|
||||
message = new BMessage('forw');
|
||||
message->AddPointer("scaffolding", g);
|
||||
- g->forward_button = new BButton(rect, "forward_button", ">", message);
|
||||
+ g->forward_button = new BBitmapButton(rect, "forward_button", ">", message);
|
||||
g->tool_bar->AddChild(g->forward_button);
|
||||
nButtons++;
|
||||
|
||||
rect.OffsetBySelf(TOOLBAR_HEIGHT, 0);
|
||||
message = new BMessage('stop');
|
||||
message->AddPointer("scaffolding", g);
|
||||
- g->stop_button = new BButton(rect, "stop_button", "S", message);
|
||||
+ g->stop_button = new BBitmapButton(rect, "stop_button", "S", message);
|
||||
g->tool_bar->AddChild(g->stop_button);
|
||||
nButtons++;
|
||||
|
||||
rect.OffsetBySelf(TOOLBAR_HEIGHT, 0);
|
||||
message = new BMessage('relo');
|
||||
message->AddPointer("scaffolding", g);
|
||||
- g->reload_button = new BButton(rect, "reload_button", "R", message);
|
||||
+ g->reload_button = new BBitmapButton(rect, "reload_button", "R", message);
|
||||
g->tool_bar->AddChild(g->reload_button);
|
||||
nButtons++;
|
||||
|
||||
rect.OffsetBySelf(TOOLBAR_HEIGHT, 0);
|
||||
message = new BMessage('home');
|
||||
message->AddPointer("scaffolding", g);
|
||||
- g->home_button = new BButton(rect, "home_button", "H", message);
|
||||
+ g->home_button = new BBitmapButton(rect, "home_button", "H", message);
|
||||
g->tool_bar->AddChild(g->home_button);
|
||||
nButtons++;
|
||||
|
||||
@@ -2407,3 +2508,4 @@ void nsbeos_scaffolding_popup_menu(nsbeos_scaffolding *g, BPoint where)
|
||||
{
|
||||
g->popup_menu->Go(where);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user