pref/appearence: Remove old cursor code
Change-Id: I4b88e582f1241e99e3fcfdbf4242f9524309682b Reviewed-on: https://review.haiku-os.org/c/haiku/+/8869 Reviewed-by: nephele nephele <[email protected]>
This commit is contained in:
committed by
nephele nephele
parent
d836d5447a
commit
3d1f0f31ec
@@ -8,13 +8,12 @@
|
|||||||
#include "APRMain.h"
|
#include "APRMain.h"
|
||||||
#include "APRWindow.h"
|
#include "APRWindow.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include "defs.h"
|
|
||||||
|
|
||||||
#include <Catalog.h>
|
#include <Catalog.h>
|
||||||
#include <Locale.h>
|
#include <Locale.h>
|
||||||
|
|
||||||
APRApplication::APRApplication(void)
|
APRApplication::APRApplication(void)
|
||||||
: BApplication(APPEARANCE_APP_SIGNATURE)
|
: BApplication("application/x-vnd.Haiku-Appearance")
|
||||||
{
|
{
|
||||||
fWindow = new APRWindow(BRect(100, 100, 550, 420));
|
fWindow = new APRWindow(BRect(100, 100, 550, 420));
|
||||||
fWindow->Show();
|
fWindow->Show();
|
||||||
|
|||||||
@@ -30,7 +30,6 @@
|
|||||||
#include <SpaceLayoutItem.h>
|
#include <SpaceLayoutItem.h>
|
||||||
|
|
||||||
#include "APRWindow.h"
|
#include "APRWindow.h"
|
||||||
#include "defs.h"
|
|
||||||
#include "Colors.h"
|
#include "Colors.h"
|
||||||
|
|
||||||
|
|
||||||
@@ -40,7 +39,8 @@
|
|||||||
|
|
||||||
#define COLOR_DROPPED 'cldp'
|
#define COLOR_DROPPED 'cldp'
|
||||||
#define AUTO_ADJUST_CHANGED 'madj'
|
#define AUTO_ADJUST_CHANGED 'madj'
|
||||||
|
#define UPDATE_COLOR 'upcl'
|
||||||
|
#define ATTRIBUTE_CHOSEN 'atch'
|
||||||
|
|
||||||
using BPrivate::BColorItem;
|
using BPrivate::BColorItem;
|
||||||
using BPrivate::BColorListView;
|
using BPrivate::BColorListView;
|
||||||
|
|||||||
@@ -21,7 +21,6 @@
|
|||||||
|
|
||||||
#include "AntialiasingSettingsView.h"
|
#include "AntialiasingSettingsView.h"
|
||||||
#include "APRView.h"
|
#include "APRView.h"
|
||||||
#include "defs.h"
|
|
||||||
#include "FontView.h"
|
#include "FontView.h"
|
||||||
#include "LookAndFeelSettingsView.h"
|
#include "LookAndFeelSettingsView.h"
|
||||||
|
|
||||||
|
|||||||
@@ -1,492 +0,0 @@
|
|||||||
//------------------------------------------------------------------------------
|
|
||||||
// Copyright (c) 2001-2002, Haiku
|
|
||||||
//
|
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
|
||||||
// copy of this software and associated documentation files (the "Software"),
|
|
||||||
// to deal in the Software without restriction, including without limitation
|
|
||||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
||||||
// and/or sell copies of the Software, and to permit persons to whom the
|
|
||||||
// Software is furnished to do so, subject to the following conditions:
|
|
||||||
//
|
|
||||||
// The above copyright notice and this permission notice shall be included in
|
|
||||||
// all copies or substantial portions of the Software.
|
|
||||||
//
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
||||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
||||||
// DEALINGS IN THE SOFTWARE.
|
|
||||||
//
|
|
||||||
// File Name: CurView.cpp
|
|
||||||
// Author: DarkWyrm <[email protected]>
|
|
||||||
// Description: cursor handler for the app
|
|
||||||
//
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
#include <OS.h>
|
|
||||||
#include <Directory.h>
|
|
||||||
#include <Alert.h>
|
|
||||||
#include <storage/Path.h>
|
|
||||||
#include <Entry.h>
|
|
||||||
#include <File.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include "CursorWhichItem.h"
|
|
||||||
#include "CurView.h"
|
|
||||||
#include <PortLink.h>
|
|
||||||
#include "defs.h"
|
|
||||||
#include "ServerConfig.h"
|
|
||||||
#include <ServerProtocol.h>
|
|
||||||
#include <PortMessage.h>
|
|
||||||
#include <InterfaceDefs.h>
|
|
||||||
#include <TranslationUtils.h>
|
|
||||||
|
|
||||||
//#define DEBUG_CURSORSET
|
|
||||||
|
|
||||||
#define SAVE_CURSORSET 'svcu'
|
|
||||||
#define DELETE_CURSORSET 'dlcu'
|
|
||||||
#define LOAD_CURSORSET 'ldcu'
|
|
||||||
#define CURSOR_UPDATED 'csru'
|
|
||||||
|
|
||||||
CurView::CurView(const BRect &frame, const char *name, int32 resize, int32 flags)
|
|
||||||
:BView(frame,name,resize,flags), settings(B_SIMPLE_DATA)
|
|
||||||
{
|
|
||||||
SetViewUIColor(B_PANEL_BACKGROUND_COLOR);
|
|
||||||
|
|
||||||
|
|
||||||
cursorset=new CursorSet("Default");
|
|
||||||
|
|
||||||
/*
|
|
||||||
// Code disabled -- cursor set management belongs in another app
|
|
||||||
BMenuBar *mb=new BMenuBar(BRect(0,0,Bounds().Width(),16),"menubar");
|
|
||||||
|
|
||||||
settings_menu=new BMenu("Settings");
|
|
||||||
settings_menu->AddItem(new BMenuItem("Save Cursor Set",new BMessage(SAVE_CURSORSET),'S'));
|
|
||||||
settings_menu->AddSeparatorItem();
|
|
||||||
settings_menu->AddItem(new BMenuItem("Delete Cursor Set",new BMessage(DELETE_CURSORSET)));
|
|
||||||
mb->AddItem(settings_menu);
|
|
||||||
|
|
||||||
cursorset_menu=LoadCursorSets();
|
|
||||||
if(cursorset_menu)
|
|
||||||
mb->AddItem(cursorset_menu);
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// We should *never* be here, but just in case....
|
|
||||||
cursorset_menu=new BMenu("Cursor Sets");
|
|
||||||
mb->AddItem(cursorset_menu);
|
|
||||||
}
|
|
||||||
AddChild(mb);
|
|
||||||
*/
|
|
||||||
BRect wellrect(0,0,20,20);
|
|
||||||
wellrect.OffsetTo(10,25);
|
|
||||||
wellrect.right=wellrect.left+50;
|
|
||||||
|
|
||||||
/*
|
|
||||||
// Code disabled -- cursor set management belongs in another app
|
|
||||||
cursorset_label=new BStringView(wellrect,"cursorset_label","Cursor Set: ");
|
|
||||||
AddChild(cursorset_label);
|
|
||||||
cursorset_label->ResizeToPreferred();
|
|
||||||
cursorset_name="<untitled>";
|
|
||||||
*/
|
|
||||||
|
|
||||||
// Set up list of cursor attributes
|
|
||||||
BRect cvrect;
|
|
||||||
BRect rect;
|
|
||||||
|
|
||||||
cvrect.Set(0,0,75,75);
|
|
||||||
|
|
||||||
bmpview=new BitmapView(BPoint(10,10),new BMessage(CURSOR_UPDATED),this);
|
|
||||||
bmpview->MoveTo( (Bounds().Width()-bmpview->Bounds().Width())/2,30);
|
|
||||||
AddChild(bmpview);
|
|
||||||
|
|
||||||
|
|
||||||
rect.left=(Bounds().Width()-200)/2;
|
|
||||||
rect.right=rect.left+190;
|
|
||||||
rect.top=bmpview->Frame().bottom+30;
|
|
||||||
rect.bottom=rect.top+100;
|
|
||||||
|
|
||||||
attrlist=new BListView(rect,"AttributeList");
|
|
||||||
|
|
||||||
scrollview=new BScrollView("ScrollView",attrlist, B_FOLLOW_LEFT |
|
|
||||||
B_FOLLOW_TOP, 0, false, true);
|
|
||||||
AddChild(scrollview);
|
|
||||||
scrollview->SetViewUIColor(B_PANEL_BACKGROUND_COLOR);
|
|
||||||
|
|
||||||
attrlist->SetSelectionMessage(new BMessage(ATTRIBUTE_CHOSEN));
|
|
||||||
|
|
||||||
attrlist->AddItem(new CursorWhichItem(B_CURSOR_DEFAULT));
|
|
||||||
attrlist->AddItem(new CursorWhichItem(B_CURSOR_TEXT));
|
|
||||||
attrlist->AddItem(new CursorWhichItem(B_CURSOR_MOVE));
|
|
||||||
attrlist->AddItem(new CursorWhichItem(B_CURSOR_DRAG));
|
|
||||||
attrlist->AddItem(new CursorWhichItem(B_CURSOR_RESIZE));
|
|
||||||
attrlist->AddItem(new CursorWhichItem(B_CURSOR_RESIZE_NWSE));
|
|
||||||
attrlist->AddItem(new CursorWhichItem(B_CURSOR_RESIZE_NESW));
|
|
||||||
attrlist->AddItem(new CursorWhichItem(B_CURSOR_RESIZE_NS));
|
|
||||||
attrlist->AddItem(new CursorWhichItem(B_CURSOR_RESIZE_EW));
|
|
||||||
|
|
||||||
|
|
||||||
cvrect.Set(0,0,60,30);
|
|
||||||
cvrect.OffsetTo( (Bounds().Width()-200)/2,scrollview->Frame().bottom+20);
|
|
||||||
|
|
||||||
defaults=new BButton(cvrect,"DefaultsButton","Defaults",
|
|
||||||
new BMessage(DEFAULT_SETTINGS),B_FOLLOW_LEFT |B_FOLLOW_TOP,
|
|
||||||
B_WILL_DRAW | B_NAVIGABLE);
|
|
||||||
AddChild(defaults);
|
|
||||||
|
|
||||||
cvrect.OffsetBy(70,0);
|
|
||||||
revert=new BButton(cvrect,"RevertButton","Revert",
|
|
||||||
new BMessage(REVERT_SETTINGS),B_FOLLOW_LEFT |B_FOLLOW_TOP,
|
|
||||||
B_WILL_DRAW | B_NAVIGABLE);
|
|
||||||
AddChild(revert);
|
|
||||||
revert->SetEnabled(false);
|
|
||||||
|
|
||||||
cvrect.OffsetBy(70,0);
|
|
||||||
apply=new BButton(cvrect,"ApplyButton","Apply",
|
|
||||||
new BMessage(APPLY_SETTINGS),B_FOLLOW_LEFT |B_FOLLOW_TOP,
|
|
||||||
B_WILL_DRAW | B_NAVIGABLE);
|
|
||||||
AddChild(apply);
|
|
||||||
apply->SetEnabled(false);
|
|
||||||
|
|
||||||
BEntry entry(COLOR_SET_DIR);
|
|
||||||
entry_ref ref;
|
|
||||||
entry.GetRef(&ref);
|
|
||||||
|
|
||||||
attribute=B_PANEL_BACKGROUND_COLOR;
|
|
||||||
attrstring="Background";
|
|
||||||
LoadSettings();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
CurView::~CurView(void)
|
|
||||||
{
|
|
||||||
delete cursorset;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CurView::AllAttached(void)
|
|
||||||
{
|
|
||||||
attrlist->Select(0);
|
|
||||||
attrlist->SetTarget(this);
|
|
||||||
apply->SetTarget(this);
|
|
||||||
defaults->SetTarget(this);
|
|
||||||
revert->SetTarget(this);
|
|
||||||
bmpview->SetTarget(this);
|
|
||||||
BMessenger msgr(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CurView::MessageReceived(BMessage *msg)
|
|
||||||
{
|
|
||||||
if(msg->WasDropped())
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
switch(msg->what)
|
|
||||||
{
|
|
||||||
case CURSOR_UPDATED:
|
|
||||||
{
|
|
||||||
CursorWhichItem *cwi=(CursorWhichItem*)attrlist->ItemAt(attrlist->CurrentSelection());
|
|
||||||
if(cwi)
|
|
||||||
cwi->SetBitmap(bmpview->GetBitmap());
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case ATTRIBUTE_CHOSEN:
|
|
||||||
{
|
|
||||||
CursorWhichItem *cwi=(CursorWhichItem*)attrlist->ItemAt(attrlist->CurrentSelection());
|
|
||||||
if(cwi)
|
|
||||||
{
|
|
||||||
bmpview->SetBitmap(cwi->GetBitmap());
|
|
||||||
bmpview->Invalidate();
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
BView::MessageReceived(msg);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
// Code disabled -- cursor set management belongs in another app
|
|
||||||
BMenu *CurView::LoadCursorSets(void)
|
|
||||||
{
|
|
||||||
#ifdef DEBUG_CURSORSET
|
|
||||||
printf("Loading cursor sets from disk\n");
|
|
||||||
#endif
|
|
||||||
// This function populates the member menu *cursorset_menu with the cursor
|
|
||||||
// set files located in the cursor set directory. To ensure that there are
|
|
||||||
// no entries pointing to invalid cursor sets, they are validated before
|
|
||||||
// a menu item is added.
|
|
||||||
BDirectory dir;
|
|
||||||
BEntry entry;
|
|
||||||
BPath path;
|
|
||||||
BString name;
|
|
||||||
|
|
||||||
BMenu *menu=new BMenu("Cursor Sets");
|
|
||||||
|
|
||||||
status_t dirstat=dir.SetTo(COLOR_SET_DIR);
|
|
||||||
if(dirstat!=B_OK)
|
|
||||||
{
|
|
||||||
// We couldn't set the directory, so more than likely it just
|
|
||||||
// doesn't exist. Create it and return an empty menu.
|
|
||||||
switch(dirstat)
|
|
||||||
{
|
|
||||||
case B_NAME_TOO_LONG:
|
|
||||||
{
|
|
||||||
BAlert *a=new BAlert("Haiku","Couldn't open the folder for cursor sets. "
|
|
||||||
"You will be able to change system cursors, but be unable to save them to a cursor set. "
|
|
||||||
"Please contact Haiku about Appearance Preferences::CurView::"
|
|
||||||
"LoadCursorSets::B_NAME_TOO_LONG for a bugfix", "OK",
|
|
||||||
NULL, NULL, B_WIDTH_AS_USUAL, B_WARNING_ALERT);
|
|
||||||
a->SetFlags(a->Flags() | B_CLOSE_ON_ESCAPE);
|
|
||||||
a->Go();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case B_ENTRY_NOT_FOUND:
|
|
||||||
{
|
|
||||||
create_directory(COLOR_SET_DIR,0777);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case B_BAD_VALUE:
|
|
||||||
{
|
|
||||||
printf("CurView::LoadCursorSets(): Invalid cursorset folder path.\n");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case B_NO_MEMORY:
|
|
||||||
{
|
|
||||||
printf("CurView::LoadCursorSets(): No memory left. We're probably going to crash now. \n");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case B_BUSY:
|
|
||||||
{
|
|
||||||
printf("CurView::LoadCursorSets(): Busy node " CURSOR_SET_DIR "\n");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case B_FILE_ERROR:
|
|
||||||
{
|
|
||||||
BAlert *a=new BAlert("Haiku","Couldn't open the folder for cursor sets "
|
|
||||||
"because of a file error. Perhaps there is a file (instead of a folder) at " COLOR_SET_DIR
|
|
||||||
"? You will be able to change system cursors, but be unable to save them to a cursor set. ",
|
|
||||||
"OK", NULL, NULL, B_WIDTH_AS_USUAL, B_WARNING_ALERT);
|
|
||||||
a->SetFlags(a->Flags() | B_CLOSE_ON_ESCAPE);
|
|
||||||
a->Go();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case B_NO_MORE_FDS:
|
|
||||||
{
|
|
||||||
BAlert *a=new BAlert("Haiku","Couldn't open the folder for cursor sets "
|
|
||||||
"because there are too many open files. Please close some files and restart "
|
|
||||||
" this application.", "OK",
|
|
||||||
NULL, NULL, B_WIDTH_AS_USUAL, B_WARNING_ALERT);
|
|
||||||
a->SetFlags(a->Flags() | B_CLOSE_ON_ESCAPE);
|
|
||||||
a->Go();
|
|
||||||
if(Window())
|
|
||||||
Window()->PostMessage(B_QUIT_REQUESTED);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return menu;
|
|
||||||
}
|
|
||||||
|
|
||||||
int32 count=dir.CountEntries();
|
|
||||||
|
|
||||||
|
|
||||||
BMessage *msg;
|
|
||||||
CursorSet cs(NULL);
|
|
||||||
|
|
||||||
for(int32 i=0;i<count;i++)
|
|
||||||
{
|
|
||||||
dir.GetNextEntry(&entry);
|
|
||||||
entry.GetPath(&path);
|
|
||||||
|
|
||||||
if(cs.Load(path.Path())!=B_OK)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
// Don't include the default set in the menu
|
|
||||||
name=path.Leaf();
|
|
||||||
if(name.Compare("Default")==0)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
name=path.Path();
|
|
||||||
|
|
||||||
name.Remove(0,name.FindLast('/')+1);
|
|
||||||
|
|
||||||
msg=new BMessage(LOAD_CURSORSET);
|
|
||||||
msg->AddString("name",name);
|
|
||||||
menu->AddItem(new BMenuItem(name.String(),msg));
|
|
||||||
}
|
|
||||||
|
|
||||||
return menu;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CurView::SetCursorSetName(const char *name)
|
|
||||||
{
|
|
||||||
if(!name)
|
|
||||||
return;
|
|
||||||
BString namestr("Cursor Set: ");
|
|
||||||
cursorset_name=name;
|
|
||||||
namestr+=name;
|
|
||||||
cursorset_label->SetText(namestr.String());
|
|
||||||
cursorset_label->ResizeToPreferred();
|
|
||||||
cursorset_label->Invalidate();
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
void CurView::SaveSettings(void)
|
|
||||||
{
|
|
||||||
// Save the current GUI cursor settings to the GUI cursors file in the
|
|
||||||
// path specified in defs.h
|
|
||||||
|
|
||||||
BString path(SERVER_SETTINGS_DIR);
|
|
||||||
path+=CURSOR_SETTINGS_NAME;
|
|
||||||
#ifdef DEBUG_CURSORSET
|
|
||||||
printf("SaveSettings: %s\n",path.String());
|
|
||||||
#endif
|
|
||||||
cursorset->Save(path.String(),B_CREATE_FILE|B_ERASE_FILE);
|
|
||||||
|
|
||||||
// prev_set_name=cursorset_name;
|
|
||||||
revert->SetEnabled(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CurView::LoadSettings(void)
|
|
||||||
{
|
|
||||||
// Load the current GUI cursor settings from disk. This is done instead of
|
|
||||||
// getting them from the server at this point for testing purposes. Comment
|
|
||||||
// out the #define LOAD_SETTINGS_FROM_DISK line to use the server query code
|
|
||||||
#ifdef DEBUG_CURSORSET
|
|
||||||
printf("Loading settings from disk\n");
|
|
||||||
#endif
|
|
||||||
settings.MakeEmpty();
|
|
||||||
|
|
||||||
BDirectory dir,newdir;
|
|
||||||
if(dir.SetTo(SERVER_SETTINGS_DIR)==B_ENTRY_NOT_FOUND)
|
|
||||||
{
|
|
||||||
#ifdef DEBUG_CURSORSET
|
|
||||||
printf("Cursor set folder not found. Creating %s\n",SERVER_SETTINGS_DIR);
|
|
||||||
#endif
|
|
||||||
create_directory(SERVER_SETTINGS_DIR,0777);
|
|
||||||
}
|
|
||||||
|
|
||||||
BString path(SERVER_SETTINGS_DIR);
|
|
||||||
path+=CURSOR_SETTINGS_NAME;
|
|
||||||
|
|
||||||
status_t stat=cursorset->Load(path.String());
|
|
||||||
|
|
||||||
if(stat!=B_OK)
|
|
||||||
{
|
|
||||||
#ifdef DEBUG_CURSORSET
|
|
||||||
printf("Couldn't open file %s for read\n",path.String());
|
|
||||||
#endif
|
|
||||||
SetDefaults();
|
|
||||||
SaveSettings();
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CurView::SetDefaults(void)
|
|
||||||
{
|
|
||||||
// The server will perform the necessary work to set defaults, so just ask it to do the
|
|
||||||
// work for us. It is a synchronous procedure, so we will notify the server and load the cursor
|
|
||||||
// set 'Default'.
|
|
||||||
BString string(CURSOR_SET_DIR);
|
|
||||||
string+="Default";
|
|
||||||
|
|
||||||
cursorset->Load(string.String());
|
|
||||||
|
|
||||||
port_id port=find_port(SERVER_PORT_NAME);
|
|
||||||
if(port==B_NAME_NOT_FOUND)
|
|
||||||
return;
|
|
||||||
|
|
||||||
BPrivate::PortLink link(port);
|
|
||||||
int32 code;
|
|
||||||
|
|
||||||
link.StartMessage(AS_SET_SYSCURSOR_DEFAULTS);
|
|
||||||
link.Flush();
|
|
||||||
link.GetNextMessage(code);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
BitmapView::BitmapView(const BPoint &pt,BMessage *message, const BHandler *handler, const BLooper *looper=NULL)
|
|
||||||
: BBox(BRect(0,0,75,75).OffsetToCopy(pt),"bitmapview",B_FOLLOW_NONE,B_WILL_DRAW, B_PLAIN_BORDER),
|
|
||||||
BInvoker(message,handler,looper)
|
|
||||||
{
|
|
||||||
SetFont(be_plain_font);
|
|
||||||
bitmap=NULL;
|
|
||||||
SetViewUIColor(B_PANEL_BACKGROUND_COLOR);
|
|
||||||
SetDrawingMode(B_OP_ALPHA);
|
|
||||||
drawrect=Bounds().InsetByCopy(5,5);
|
|
||||||
}
|
|
||||||
|
|
||||||
BitmapView::~BitmapView(void)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void BitmapView::SetBitmap(BBitmap *bmp)
|
|
||||||
{
|
|
||||||
bitmap=bmp;
|
|
||||||
}
|
|
||||||
|
|
||||||
void BitmapView::Draw(BRect r)
|
|
||||||
{
|
|
||||||
BBox::Draw(r);
|
|
||||||
|
|
||||||
if(bitmap)
|
|
||||||
DrawBitmap(bitmap, drawrect);
|
|
||||||
}
|
|
||||||
|
|
||||||
void BitmapView::MessageReceived(BMessage *msg)
|
|
||||||
{
|
|
||||||
if(msg->WasDropped())
|
|
||||||
{
|
|
||||||
entry_ref ref;
|
|
||||||
if(msg->FindRef("refs",&ref)!=B_OK)
|
|
||||||
return;
|
|
||||||
|
|
||||||
BBitmap *tmp=BTranslationUtils::GetBitmap(&ref);
|
|
||||||
if(tmp)
|
|
||||||
{
|
|
||||||
delete bitmap;
|
|
||||||
bitmap=tmp;
|
|
||||||
|
|
||||||
int32 offset;
|
|
||||||
BRect r(Bounds());
|
|
||||||
r.right-=10;
|
|
||||||
r.bottom-=10;
|
|
||||||
|
|
||||||
drawrect=bitmap->Bounds();
|
|
||||||
if(r.Contains(bitmap->Bounds()))
|
|
||||||
{
|
|
||||||
// calculate a centered rect for direct display
|
|
||||||
offset=((r.IntegerWidth()-bitmap->Bounds().IntegerWidth()) >> 1)+5;
|
|
||||||
drawrect.OffsetBy(offset,offset);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// calculate a scaled-down rectangle for display
|
|
||||||
drawrect.left=drawrect.top=0;
|
|
||||||
|
|
||||||
if(bitmap->Bounds().Height() > bitmap->Bounds().Width())
|
|
||||||
{
|
|
||||||
drawrect.right=(r.Height()*bitmap->Bounds().Width())/bitmap->Bounds().Height();
|
|
||||||
drawrect.bottom=r.Height();
|
|
||||||
offset=((r.IntegerWidth()-drawrect.IntegerWidth()) >> 1)+5;
|
|
||||||
drawrect.OffsetBy(offset,5);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
drawrect.bottom=(r.Width()*bitmap->Bounds().Height())/bitmap->Bounds().Width();
|
|
||||||
drawrect.right=r.Width();
|
|
||||||
offset=((r.IntegerHeight()-drawrect.IntegerHeight()) >> 1)+5;
|
|
||||||
drawrect.OffsetBy(5,offset);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Invoke();
|
|
||||||
Invalidate();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
BBox::MessageReceived(msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,95 +0,0 @@
|
|||||||
//------------------------------------------------------------------------------
|
|
||||||
// Copyright (c) 2001-2002, Haiku
|
|
||||||
//
|
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
|
||||||
// copy of this software and associated documentation files (the "Software"),
|
|
||||||
// to deal in the Software without restriction, including without limitation
|
|
||||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
||||||
// and/or sell copies of the Software, and to permit persons to whom the
|
|
||||||
// Software is furnished to do so, subject to the following conditions:
|
|
||||||
//
|
|
||||||
// The above copyright notice and this permission notice shall be included in
|
|
||||||
// all copies or substantial portions of the Software.
|
|
||||||
//
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
||||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
||||||
// DEALINGS IN THE SOFTWARE.
|
|
||||||
//
|
|
||||||
// File Name: CurView.cpp
|
|
||||||
// Author: DarkWyrm <[email protected]>
|
|
||||||
// Description: System cursor handler
|
|
||||||
//
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
#ifndef CUR_VIEW_H_
|
|
||||||
#define CUR_VIEW_H_
|
|
||||||
|
|
||||||
#include <View.h>
|
|
||||||
#include <Message.h>
|
|
||||||
#include <ListItem.h>
|
|
||||||
#include <ListView.h>
|
|
||||||
#include <Button.h>
|
|
||||||
#include <ScrollView.h>
|
|
||||||
#include <ScrollBar.h>
|
|
||||||
#include <String.h>
|
|
||||||
#include <Menu.h>
|
|
||||||
#include <MenuBar.h>
|
|
||||||
#include <MenuItem.h>
|
|
||||||
#include <StringView.h>
|
|
||||||
#include <Invoker.h>
|
|
||||||
#include <CursorSet.h>
|
|
||||||
#include <Bitmap.h>
|
|
||||||
#include <Box.h>
|
|
||||||
#include <Invoker.h>
|
|
||||||
|
|
||||||
class APRWindow;
|
|
||||||
|
|
||||||
class BitmapView : public BBox, public BInvoker
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
BitmapView(const BPoint &pt,BMessage *message,
|
|
||||||
const BHandler *handler, const BLooper *looper=NULL);
|
|
||||||
~BitmapView(void);
|
|
||||||
void SetBitmap(BBitmap *bmp);
|
|
||||||
BBitmap *GetBitmap(void) const { return bitmap; }
|
|
||||||
void Draw(BRect r);
|
|
||||||
void MessageReceived(BMessage *msg);
|
|
||||||
protected:
|
|
||||||
BBitmap *bitmap;
|
|
||||||
BRect drawrect;
|
|
||||||
};
|
|
||||||
|
|
||||||
class CurView : public BView
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
CurView(const BRect &frame, const char *name, int32 resize, int32 flags);
|
|
||||||
~CurView(void);
|
|
||||||
void AllAttached(void);
|
|
||||||
void MessageReceived(BMessage *msg);
|
|
||||||
void SaveSettings(void);
|
|
||||||
void LoadSettings(void);
|
|
||||||
void SetDefaults(void);
|
|
||||||
protected:
|
|
||||||
friend APRWindow;
|
|
||||||
// BMenu *LoadCursorSets(void);
|
|
||||||
// void SetCursorSetName(const char *name);
|
|
||||||
|
|
||||||
BButton *apply,*revert,*defaults;
|
|
||||||
BListView *attrlist;
|
|
||||||
color_which attribute;
|
|
||||||
BMessage settings;
|
|
||||||
BString attrstring;
|
|
||||||
BScrollView *scrollview;
|
|
||||||
// BStringView *cursorset_label;
|
|
||||||
// BMenu *cursorset_menu,*settings_menu;
|
|
||||||
// BFilePanel *savepanel;
|
|
||||||
// BString cursorset_name;
|
|
||||||
// BString prev_set_name;
|
|
||||||
CursorSet *cursorset;
|
|
||||||
BitmapView *bmpview;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,128 +0,0 @@
|
|||||||
//------------------------------------------------------------------------------
|
|
||||||
// Copyright (c) 2001-2002, Haiku
|
|
||||||
//
|
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
|
||||||
// copy of this software and associated documentation files (the "Software"),
|
|
||||||
// to deal in the Software without restriction, including without limitation
|
|
||||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
||||||
// and/or sell copies of the Software, and to permit persons to whom the
|
|
||||||
// Software is furnished to do so, subject to the following conditions:
|
|
||||||
//
|
|
||||||
// The above copyright notice and this permission notice shall be included in
|
|
||||||
// all copies or substantial portions of the Software.
|
|
||||||
//
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
||||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
||||||
// DEALINGS IN THE SOFTWARE.
|
|
||||||
//
|
|
||||||
// File Name: CursorWhichItem.cpp
|
|
||||||
// Author: DarkWyrm <[email protected]>
|
|
||||||
// Description: ListItem class for managing cursor_which specifiers
|
|
||||||
//
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
#include "CursorWhichItem.h"
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
CursorWhichItem::CursorWhichItem(cursor_which which)
|
|
||||||
: BStringItem(NULL,0,false)
|
|
||||||
{
|
|
||||||
SetAttribute(which);
|
|
||||||
image=NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
CursorWhichItem::~CursorWhichItem(void)
|
|
||||||
{
|
|
||||||
// Empty, but exists for just-in-case
|
|
||||||
if(image)
|
|
||||||
delete image;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CursorWhichItem::SetAttribute(cursor_which which)
|
|
||||||
{
|
|
||||||
switch(which)
|
|
||||||
{
|
|
||||||
// cases not existing in R5 which exist in Haiku
|
|
||||||
case B_CURSOR_DEFAULT:
|
|
||||||
{
|
|
||||||
attribute=which;
|
|
||||||
SetText("Default");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case B_CURSOR_TEXT:
|
|
||||||
{
|
|
||||||
attribute=which;
|
|
||||||
SetText("Text");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case B_CURSOR_MOVE:
|
|
||||||
{
|
|
||||||
attribute=which;
|
|
||||||
SetText("Move");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case B_CURSOR_DRAG:
|
|
||||||
{
|
|
||||||
attribute=which;
|
|
||||||
SetText("Drag");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case B_CURSOR_RESIZE:
|
|
||||||
{
|
|
||||||
attribute=which;
|
|
||||||
SetText("Resize");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case B_CURSOR_RESIZE_NWSE:
|
|
||||||
{
|
|
||||||
attribute=which;
|
|
||||||
SetText("Diagonal Resize NW-SE");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case B_CURSOR_RESIZE_NESW:
|
|
||||||
{
|
|
||||||
attribute=which;
|
|
||||||
SetText("Diagonal Resize NE-SW");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case B_CURSOR_RESIZE_NS:
|
|
||||||
{
|
|
||||||
attribute=which;
|
|
||||||
SetText("Vertical Resize");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case B_CURSOR_RESIZE_EW:
|
|
||||||
{
|
|
||||||
attribute=which;
|
|
||||||
SetText("Horizontal Resize");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case B_CURSOR_OTHER:
|
|
||||||
{
|
|
||||||
attribute=which;
|
|
||||||
SetText("Other");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case B_CURSOR_INVALID:
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
{
|
|
||||||
printf("unknown code '%c%c%c%c'\n",(char)((which & 0xFF000000) >> 24),
|
|
||||||
(char)((which & 0x00FF0000) >> 16),
|
|
||||||
(char)((which & 0x0000FF00) >> 8),
|
|
||||||
(char)((which & 0x000000FF)) );
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
cursor_which CursorWhichItem::GetAttribute(void)
|
|
||||||
{
|
|
||||||
return attribute;
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,49 +0,0 @@
|
|||||||
//------------------------------------------------------------------------------
|
|
||||||
// Copyright (c) 2001-2002, Haiku
|
|
||||||
//
|
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
|
||||||
// copy of this software and associated documentation files (the "Software"),
|
|
||||||
// to deal in the Software without restriction, including without limitation
|
|
||||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
||||||
// and/or sell copies of the Software, and to permit persons to whom the
|
|
||||||
// Software is furnished to do so, subject to the following conditions:
|
|
||||||
//
|
|
||||||
// The above copyright notice and this permission notice shall be included in
|
|
||||||
// all copies or substantial portions of the Software.
|
|
||||||
//
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
||||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
||||||
// DEALINGS IN THE SOFTWARE.
|
|
||||||
//
|
|
||||||
// File Name: CursorWhichItem.h
|
|
||||||
// Author: DarkWyrm <[email protected]>
|
|
||||||
// Description: ListItem class for managing cursor_which specifiers
|
|
||||||
//
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
#ifndef COLORWHICH_ITEM_H
|
|
||||||
#define COLORWHICH_ITEM_H
|
|
||||||
|
|
||||||
#include <InterfaceDefs.h>
|
|
||||||
#include <ListItem.h>
|
|
||||||
#include <Bitmap.h>
|
|
||||||
#include <SysCursor.h>
|
|
||||||
|
|
||||||
class CursorWhichItem : public BStringItem
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
CursorWhichItem(cursor_which which);
|
|
||||||
~CursorWhichItem(void);
|
|
||||||
void SetAttribute(cursor_which which);
|
|
||||||
cursor_which GetAttribute(void);
|
|
||||||
void SetBitmap(BBitmap *bmp) { if(image) delete image; image=bmp; }
|
|
||||||
BBitmap *GetBitmap(void) const { return image; }
|
|
||||||
private:
|
|
||||||
cursor_which attribute;
|
|
||||||
BBitmap *image;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,66 +0,0 @@
|
|||||||
#include <PortLink.h>
|
|
||||||
#include <ServerProtocol.h>
|
|
||||||
#include <OS.h>
|
|
||||||
#include "SysCursorAPI.h"
|
|
||||||
|
|
||||||
// TODO R2: tweak the BBitmap and BCursor headers
|
|
||||||
|
|
||||||
void set_syscursor(cursor_which which, const BCursor *cursor)
|
|
||||||
{
|
|
||||||
/* port_id server=find_port(SERVER_PORT_NAME);
|
|
||||||
if(fServerFrom!=B_NAME_NOT_FOUND)
|
|
||||||
{
|
|
||||||
PortLink link(server);
|
|
||||||
link.SetOpCode(AS_SET_SYSCURSOR_BCURSOR);
|
|
||||||
link.Attach<cursor_which>(which);
|
|
||||||
link.Attach<int32>(cursor->m_serverToken);
|
|
||||||
link.Flush();
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
|
|
||||||
void set_syscursor(cursor_which which, const BBitmap *bitmap)
|
|
||||||
{
|
|
||||||
/* port_id server=find_port(SERVER_PORT_NAME);
|
|
||||||
if(fServerFrom!=B_NAME_NOT_FOUND)
|
|
||||||
{
|
|
||||||
PortLink link(server);
|
|
||||||
link.SetOpCode(AS_SET_SYSCURSOR_BBITMAP);
|
|
||||||
link.Attach<cursor_which>(which);
|
|
||||||
link.Attach<int32>(cursor->fToken);
|
|
||||||
link.Flush();
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
|
|
||||||
cursor_which get_syscursor(void)
|
|
||||||
{
|
|
||||||
port_id server=find_port(SERVER_PORT_NAME);
|
|
||||||
if(server!=B_NAME_NOT_FOUND)
|
|
||||||
{
|
|
||||||
int32 code;
|
|
||||||
BPrivate::PortLink link(server);
|
|
||||||
|
|
||||||
link.StartMessage(AS_GET_SYSCURSOR);
|
|
||||||
link.GetNextMessage(code);
|
|
||||||
|
|
||||||
if(code==SERVER_TRUE)
|
|
||||||
{
|
|
||||||
cursor_which which;
|
|
||||||
link.Read<cursor_which>(&which);
|
|
||||||
return which;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return B_CURSOR_INVALID;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setcursor(cursor_which which)
|
|
||||||
{
|
|
||||||
port_id server=find_port(SERVER_PORT_NAME);
|
|
||||||
if(server!=B_NAME_NOT_FOUND)
|
|
||||||
{
|
|
||||||
BPrivate::PortLink link(server);
|
|
||||||
link.StartMessage(AS_SET_CURSOR_SYSTEM);
|
|
||||||
link.Flush();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
#ifndef SYSCURSOR_API_H_
|
|
||||||
#define SYSCURSOR_API_H_
|
|
||||||
|
|
||||||
#include <SysCursor.h>
|
|
||||||
#include <Bitmap.h>
|
|
||||||
#include <Cursor.h>
|
|
||||||
|
|
||||||
void set_syscursor(cursor_which which, const BCursor *cursor);
|
|
||||||
void set_syscursor(cursor_which which, const BBitmap *bitmap);
|
|
||||||
|
|
||||||
cursor_which get_syscursor(void);
|
|
||||||
|
|
||||||
void setcursor(cursor_which which);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,44 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2002-2006, Haiku. All rights reserved.
|
|
||||||
* Distributed under the terms of the MIT License.
|
|
||||||
*
|
|
||||||
* Authors:
|
|
||||||
* DarkWyrm ([email protected])
|
|
||||||
*/
|
|
||||||
#ifndef DEFS_H_
|
|
||||||
#define DEFS_H_
|
|
||||||
|
|
||||||
// If these paths are changed, ensure that they all end in a '/' character
|
|
||||||
/*
|
|
||||||
#define SETTINGS_DIR "/boot/home/config/settings/app_server/"
|
|
||||||
#define COLOR_SET_DIR "/boot/home/config/settings/color_sets/"
|
|
||||||
#define CURSOR_SET_DIR "/boot/home/config/settings/cursor_sets/"
|
|
||||||
#define DECORATORS_DIR "/boot/home/config/add-ons/decorators/"
|
|
||||||
#define COLOR_SETTINGS_NAME "system_colors"
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define APPEARANCE_APP_SIGNATURE "application/x-vnd.Haiku-Appearance"
|
|
||||||
|
|
||||||
// message commands
|
|
||||||
#define APPLY_SETTINGS 'aply'
|
|
||||||
#define TRY_SETTINGS 'trys'
|
|
||||||
|
|
||||||
#define ATTRIBUTE_CHOSEN 'atch'
|
|
||||||
#define SET_COLOR 'sclr'
|
|
||||||
#define SET_CURRENT_COLOR 'sccl'
|
|
||||||
#define UPDATE_COLOR 'upcl'
|
|
||||||
#define DECORATOR_CHOSEN 'dcch'
|
|
||||||
#define UPDATE_DECORATOR 'updc'
|
|
||||||
#define UPDATE_COLOR_SET 'upcs'
|
|
||||||
|
|
||||||
#define SET_DECORATOR 'sdec'
|
|
||||||
#define GET_DECORATOR 'gdec'
|
|
||||||
|
|
||||||
#define SET_UI_COLORS 'suic'
|
|
||||||
#define PREFS_CHOSEN 'prch'
|
|
||||||
|
|
||||||
// user interface
|
|
||||||
const uint32 kBorderSpace = 10;
|
|
||||||
const uint32 kItemSpace = 7;
|
|
||||||
|
|
||||||
#endif
|
|
||||||
Reference in New Issue
Block a user