* GetPreferredSize() now accepts NULL arguments for "width" and "height"

* use GetFontHeight() instead of: BFont font; GetFont(&font); font.GetHeight(...)
* fixed odd unarchiving of the alignment.
* cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15090 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2005-11-23 17:28:18 +00:00
parent a8c4b88de4
commit f97761575a
2 changed files with 206 additions and 232 deletions
+49 -87
View File
@@ -1,107 +1,69 @@
//------------------------------------------------------------------------------
// Copyright (c) 2001-2002, OpenBeOS
//
// 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: StringView.h
// Author: Frans van Nispen ([email protected])
// Description: BStringView draw a non-editable text string
//------------------------------------------------------------------------------
/*
* Copyright 2001-2005, Haiku Inc.
* Distributed under the terms of the MIT License.
*
* Authors:
* Frans van Nispen ([email protected])
*/
#ifndef _STRING_VIEW_H
#define _STRING_VIEW_H
// Standard Includes -----------------------------------------------------------
// System Includes -------------------------------------------------------------
#include <BeBuild.h>
#include <View.h>
// Project Includes ------------------------------------------------------------
// Local Includes --------------------------------------------------------------
// Local Defines ---------------------------------------------------------------
// Globals ---------------------------------------------------------------------
// BStringView class -----------------------------------------------------------
class BStringView : public BView{
public:
BStringView(BRect bounds, const char* name, const char* text,
uint32 resizeFlags = B_FOLLOW_LEFT | B_FOLLOW_TOP,
uint32 flags = B_WILL_DRAW);
BStringView(BMessage* data);
virtual ~BStringView();
static BArchivable *Instantiate(BMessage* data);
virtual status_t Archive(BMessage* data, bool deep = true) const;
public:
BStringView(BRect bounds, const char* name,
const char* text,
uint32 resizeFlags = B_FOLLOW_LEFT | B_FOLLOW_TOP,
uint32 flags = B_WILL_DRAW);
BStringView(BMessage* data);
virtual ~BStringView();
void SetText(const char* text);
const char *Text() const;
void SetAlignment(alignment flag);
alignment Alignment() const;
static BArchivable* Instantiate(BMessage* data);
virtual status_t Archive(BMessage* data, bool deep = true) const;
virtual void AttachedToWindow();
virtual void Draw(BRect bounds);
void SetText(const char* text);
const char* Text() const;
void SetAlignment(alignment flag);
alignment Alignment() const;
virtual void MessageReceived(BMessage* msg);
virtual void MouseDown(BPoint pt);
virtual void MouseUp(BPoint pt);
virtual void MouseMoved(BPoint pt, uint32 code, const BMessage* msg);
virtual void DetachedFromWindow();
virtual void FrameMoved(BPoint new_position);
virtual void FrameResized(float new_width, float new_height);
virtual void AttachedToWindow();
virtual void Draw(BRect bounds);
virtual BHandler *ResolveSpecifier( BMessage* msg, int32 index, BMessage* specifier,
int32 form, const char* property);
virtual void MessageReceived(BMessage* message);
virtual void MouseDown(BPoint point);
virtual void MouseUp(BPoint point);
virtual void MouseMoved(BPoint point, uint32 transit,
const BMessage* dragMessage);
virtual void DetachedFromWindow();
virtual void FrameMoved(BPoint newPosition);
virtual void FrameResized(float newWidth, float newHeight);
virtual void ResizeToPreferred();
virtual void GetPreferredSize(float* width, float* height);
virtual void MakeFocus(bool state = true);
virtual void AllAttached();
virtual void AllDetached();
virtual status_t GetSupportedSuites(BMessage* data);
virtual BHandler* ResolveSpecifier(BMessage* msg, int32 index,
BMessage* specifier, int32 form,
const char* property);
virtual void ResizeToPreferred();
virtual void GetPreferredSize(float* _width, float* _height);
virtual void MakeFocus(bool state = true);
virtual void AllAttached();
virtual void AllDetached();
virtual status_t GetSupportedSuites(BMessage* data);
// Private or reserved ---------------------------------------------------------
virtual status_t Perform(perform_code d, void* arg);
private:
virtual status_t Perform(perform_code d, void* arg);
virtual void _ReservedStringView1();
virtual void _ReservedStringView2();
virtual void _ReservedStringView3();
private:
virtual void _ReservedStringView1();
virtual void _ReservedStringView2();
virtual void _ReservedStringView3();
BStringView &operator=(const BStringView&);
BStringView &operator=(const BStringView&);
char* fText;
alignment fAlign;
uint32 _reserved[3];
char* fText;
alignment fAlign;
uint32 _reserved[3];
};
//------------------------------------------------------------------------------
#endif // _STRINGVIEW_H
/*
* $Log $
*
* $Id $
*
*/
#endif // _STRING_VIEW_H