Rewrote BAlert button layout routine. Made it much simpler, and it's now

also font sensitive (really, it wasn't before).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17861 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2006-06-16 16:22:53 +00:00
parent 60d1530802
commit 9a3c8b14fd
2 changed files with 214 additions and 306 deletions
+67 -115
View File
@@ -1,52 +1,24 @@
//------------------------------------------------------------------------------
// 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: Alert.h
// Author: Erik Jaesler ([email protected])
// Description: BAlert displays a modal alert window.
//------------------------------------------------------------------------------
/*
* Copyright 2001-2006, Haiku.
* Distributed under the terms of the MIT License.
*
* Authors:
* Erik Jaesler ([email protected])
*/
#ifndef _ALERT_H
#define _ALERT_H
// Standard Includes -----------------------------------------------------------
// System Includes -------------------------------------------------------------
#include <BeBuild.h>
#include <Window.h>
// Project Includes ------------------------------------------------------------
// Local Includes --------------------------------------------------------------
// Local Defines ---------------------------------------------------------------
// Globals ---------------------------------------------------------------------
class BBitmap;
class BButton;
class BInvoker;
class BTextView;
// enum for flavors of alert ---------------------------------------------------
// enum for flavors of alert
enum alert_type {
B_EMPTY_ALERT = 0,
B_INFO_ALERT,
@@ -55,101 +27,81 @@ enum alert_type {
B_STOP_ALERT
};
enum button_spacing {
B_EVEN_SPACING = 0,
B_OFFSET_SPACING
};
// BAlert class ----------------------------------------------------------------
class BAlert : public BWindow
{
public:
BAlert( const char *title,
const char *text,
const char *button1,
const char *button2 = NULL,
const char *button3 = NULL,
button_width width = B_WIDTH_AS_USUAL,
alert_type type = B_INFO_ALERT);
BAlert( const char *title,
const char *text,
const char *button1,
const char *button2,
const char *button3,
button_width width,
button_spacing spacing,
alert_type type = B_INFO_ALERT);
virtual ~BAlert();
// Archiving
BAlert(BMessage *data);
static BArchivable *Instantiate(BMessage *data);
virtual status_t Archive(BMessage *data, bool deep = true) const;
// BAlert guts
void SetShortcut(int32 button_index, char key);
char Shortcut(int32 button_index) const;
class BAlert : public BWindow {
public:
BAlert(const char* title, const char* text,
const char* button1, const char* button2 = NULL,
const char* button3 = NULL,
button_width width = B_WIDTH_AS_USUAL,
alert_type type = B_INFO_ALERT);
BAlert(const char *title, const char *text,
const char *button1, const char *button2,
const char *button3, button_width width,
button_spacing spacing,
alert_type type = B_INFO_ALERT);
virtual ~BAlert();
int32 Go();
status_t Go(BInvoker *invoker);
// Archiving
BAlert(BMessage *data);
static BArchivable *Instantiate(BMessage *data);
virtual status_t Archive(BMessage *data, bool deep = true) const;
virtual void MessageReceived(BMessage *an_event);
virtual void FrameResized(float new_width, float new_height);
BButton *ButtonAt(int32 index) const;
BTextView *TextView() const;
// BAlert guts
void SetShortcut(int32 button_index, char key);
char Shortcut(int32 button_index) const;
virtual BHandler *ResolveSpecifier(BMessage *msg,
int32 index,
BMessage *specifier,
int32 form,
const char *property);
virtual status_t GetSupportedSuites(BMessage *data);
int32 Go();
status_t Go(BInvoker *invoker);
virtual void DispatchMessage(BMessage *msg, BHandler *handler);
virtual void Quit();
virtual bool QuitRequested();
virtual void MessageReceived(BMessage *an_event);
virtual void FrameResized(float new_width, float new_height);
BButton* ButtonAt(int32 index) const;
BTextView* TextView() const;
static BPoint AlertPosition(float width, float height);
virtual BHandler* ResolveSpecifier(BMessage* message, int32 index,
BMessage* specifier, int32 form,
const char* property);
virtual status_t GetSupportedSuites(BMessage *data);
// Private or reserved ---------------------------------------------------------
virtual status_t Perform(perform_code d, void *arg);
virtual void DispatchMessage(BMessage* message, BHandler* handler);
virtual void Quit();
virtual bool QuitRequested();
private:
friend class _BAlertFilter_;
static BPoint AlertPosition(float width, float height);
virtual void _ReservedAlert1();
virtual void _ReservedAlert2();
virtual void _ReservedAlert3();
virtual status_t Perform(perform_code d, void *arg);
void InitObject(const char *text,
const char *button1,
const char *button2 = NULL,
const char *button3 = NULL,
button_width width = B_WIDTH_AS_USUAL,
button_spacing spacing = B_EVEN_SPACING,
alert_type type = B_INFO_ALERT);
BBitmap *InitIcon();
private:
friend class _BAlertFilter_;
sem_id fAlertSem;
int32 fAlertVal;
BButton *fButtons[3];
BTextView *fTextView;
char fKeys[3];
alert_type fMsgType;
button_width fButtonWidth;
BInvoker *fInvoker;
uint32 _reserved[4];
virtual void _ReservedAlert1();
virtual void _ReservedAlert2();
virtual void _ReservedAlert3();
void _InitObject(const char* text, const char* button1,
const char* button2 = NULL,
const char* button3 = NULL,
button_width width = B_WIDTH_AS_USUAL,
button_spacing spacing = B_EVEN_SPACING,
alert_type type = B_INFO_ALERT);
BBitmap* _InitIcon();
BButton* _CreateButton(int32 which, const char* label);
sem_id fAlertSem;
int32 fAlertValue;
BButton* fButtons[3];
BTextView* fTextView;
char fKeys[3];
alert_type fMsgType;
button_width fButtonWidth;
BInvoker* fInvoker;
uint32 _reserved[4];
};
//------------------------------------------------------------------------------
#endif // _ALERT_H
/*
* $Log $
*
* $Id $
*
*/