1a45f75e0SStephan Aßmus/* 2a45f75e0SStephan Aßmus * Copyright 2014, Stephan A��mus <superstippi@gmx.de>. 3a45f75e0SStephan Aßmus * All rights reserved. Distributed under the terms of the MIT License. 4a45f75e0SStephan Aßmus */ 5a45f75e0SStephan Aßmus 6a45f75e0SStephan Aßmus 7a45f75e0SStephan Aßmus#include "LinkedBitmapView.h" 8a45f75e0SStephan Aßmus 9a45f75e0SStephan Aßmus#include <Cursor.h> 10a45f75e0SStephan Aßmus 11a45f75e0SStephan Aßmus 12a45f75e0SStephan AßmusLinkedBitmapView::LinkedBitmapView(const char* name, BMessage* message) 13a45f75e0SStephan Aßmus : 14a45f75e0SStephan Aßmus BitmapView(name), 15a45f75e0SStephan Aßmus BInvoker(message, NULL), 16a45f75e0SStephan Aßmus fEnabled(true), 17a45f75e0SStephan Aßmus fMouseInside(false) 18a45f75e0SStephan Aßmus{ 19a45f75e0SStephan Aßmus} 20a45f75e0SStephan Aßmus 21a45f75e0SStephan Aßmus 22fa19dd44Slooncrazvoid 23fa19dd44SlooncrazLinkedBitmapView::AllAttached() 24fa19dd44Slooncraz{ 25fa19dd44Slooncraz // We don't want to use BitmapView's default behavior here. 26fa19dd44Slooncraz} 27fa19dd44Slooncraz 28fa19dd44Slooncraz 29a45f75e0SStephan Aßmusvoid 30a45f75e0SStephan AßmusLinkedBitmapView::MouseMoved(BPoint where, uint32 transit, 31a45f75e0SStephan Aßmus const BMessage* dragMessage) 32a45f75e0SStephan Aßmus{ 33a45f75e0SStephan Aßmus // TODO: Check that no buttons are pressed, don't indicate clickable 34a45f75e0SStephan Aßmus // link if a button is held. 35a45f75e0SStephan Aßmus if (transit == B_ENTERED_VIEW) { 36a45f75e0SStephan Aßmus fMouseInside = true; 37a45f75e0SStephan Aßmus _UpdateViewCursor(); 38a45f75e0SStephan Aßmus } else if (transit == B_EXITED_VIEW) { 39a45f75e0SStephan Aßmus fMouseInside = false; 40a45f75e0SStephan Aßmus _UpdateViewCursor(); 41a45f75e0SStephan Aßmus } 42a45f75e0SStephan Aßmus} 43a45f75e0SStephan Aßmus 44a45f75e0SStephan Aßmus 45a45f75e0SStephan Aßmusvoid 46a45f75e0SStephan AßmusLinkedBitmapView::MouseDown(BPoint where) 47a45f75e0SStephan Aßmus{ 48a45f75e0SStephan Aßmus if (fEnabled) 49a45f75e0SStephan Aßmus Invoke(Message()); 50a45f75e0SStephan Aßmus} 51a45f75e0SStephan Aßmus 52a45f75e0SStephan Aßmus 53a45f75e0SStephan Aßmusvoid 54a45f75e0SStephan AßmusLinkedBitmapView::SetEnabled(bool enabled) 55a45f75e0SStephan Aßmus{ 56a45f75e0SStephan Aßmus if (fEnabled != enabled) { 57a45f75e0SStephan Aßmus fEnabled = enabled; 58a45f75e0SStephan Aßmus _UpdateViewCursor(); 59a45f75e0SStephan Aßmus } 60a45f75e0SStephan Aßmus} 61a45f75e0SStephan Aßmus 62a45f75e0SStephan Aßmus 63a45f75e0SStephan Aßmusvoid 64a45f75e0SStephan AßmusLinkedBitmapView::_UpdateViewCursor() 65a45f75e0SStephan Aßmus{ 66a45f75e0SStephan Aßmus if (fEnabled && fMouseInside) { 67a45f75e0SStephan Aßmus BCursor cursor(B_CURSOR_ID_FOLLOW_LINK); 68a45f75e0SStephan Aßmus SetViewCursor(&cursor, true); 69a45f75e0SStephan Aßmus } else { 70a45f75e0SStephan Aßmus BCursor cursor(B_CURSOR_SYSTEM_DEFAULT); 71a45f75e0SStephan Aßmus SetViewCursor(&cursor, true); 72a45f75e0SStephan Aßmus } 73a45f75e0SStephan Aßmus} 74