Another patch by Vasilis Kaoutsis: Replaced pointer use with a

BMessenger


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20238 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stefano Ceccherini
2007-02-26 16:18:44 +00:00
parent 1546cbf149
commit 3834597b97
4 changed files with 75 additions and 107 deletions
+13 -10
View File
@@ -1,15 +1,14 @@
/*
* Copyright (c) 2003-4 Kian Duffy <[email protected]>
* Copyright (c) 1998,99 Kazuho Okui and Takashi Murai.
*
* Distributed unter the terms of the MIT License.
* Copyright 2001-2007, Haiku, Inc.
* Copyright 2003-2004 Kian Duffy, [email protected]
* Parts Copyright 1998-1999 Kazuho Okui and Takashi Murai.
* All rights reserved. Distributed under the terms of the MIT license.
*/
#include "AppearPrefView.h"
#include "MenuUtil.h"
#include "PrefHandler.h"
#include "TermWindow.h"
#include "TermConst.h"
#include <View.h>
@@ -23,9 +22,9 @@
AppearancePrefView::AppearancePrefView(BRect frame, const char *name,
TermWindow *window)
BMessenger messenger)
: PrefView(frame, name),
fTermWindow(window)
fAppearancePrefViewMessenger(messenger)
{
const char *color_tbl[] = {
PREF_TEXT_FORE_COLOR,
@@ -134,8 +133,13 @@ AppearancePrefView::MessageReceived(BMessage *msg)
}
if (modified) {
fTermWindow->PostMessage(msg);
Window()->PostMessage(MSG_PREF_MODIFIED);
fAppearancePrefViewMessenger.SendMessage(msg);
// send message to fTermWindow
// send the MSG_PREF_MODIFIED message
// to fPrefWindow
BMessenger messenger(this);
messenger.SendMessage(MSG_PREF_MODIFIED);
}
}
@@ -182,4 +186,3 @@ AppearancePrefView::_MakeSizeMenu(uint32 command, uint8 defaultSize)
return menu;
}
+6 -7
View File
@@ -1,8 +1,8 @@
/*
* Copyright (c) 2003-4 Kian Duffy <[email protected]>
* Copyright (c) 1998,99 Kazuho Okui and Takashi Murai.
*
* Distributed unter the terms of the MIT License.
* Copyright 2001-2007, Haiku, Inc.
* Copyright 2003-2004 Kian Duffy, [email protected]
* Parts Copyright 1998-1999 Kazuho Okui and Takashi Murai.
* All rights reserved. Distributed under the terms of the MIT license.
*/
#ifndef APPEARANCE_PREF_VIEW_H
#define APPEARANCE_PREF_VIEW_H
@@ -14,14 +14,13 @@ class BColorControl;
class BMenu;
class BMenuField;
class TermWindow;
class TTextControl;
class AppearancePrefView : public PrefView {
public:
AppearancePrefView(BRect frame, const char *name,
TermWindow *window);
BMessenger messenger);
virtual void Revert();
virtual void MessageReceived(BMessage *message);
@@ -39,7 +38,7 @@ class AppearancePrefView : public PrefView {
BMenuField *fColorField;
BColorControl *fColorControl;
TermWindow *fTermWindow;
BMessenger fAppearancePrefViewMessenger;
};
#endif // APPEARANCE_PREF_VIEW_H
+27 -38
View File
@@ -1,8 +1,8 @@
/*
* Copyright (c) 2003-4 Kian Duffy <[email protected]>
* Copyright (C) 1998,99 Kazuho Okui and Takashi Murai.
*
* Distributed unter the terms of the MIT License.
* Copyright 2001-2007, Haiku, Inc.
* Copyright 2003-2004 Kian Duffy, [email protected]
* Parts Copyright 1998-1999 Kazuho Okui and Takashi Murai.
* All rights reserved. Distributed under the terms of the MIT license.
*/
@@ -17,8 +17,6 @@
#include "PrefHandler.h"
#include "PrefDlg.h"
#include "TermConst.h"
#include "TermView.h"
#include "TermWindow.h"
#include "MenuUtil.h"
#include "AppearPrefView.h"
@@ -29,12 +27,12 @@
// Global Preference Handler
extern PrefHandler *gTermPref;
PrefDlg::PrefDlg(TermWindow *inWindow)
PrefDlg::PrefDlg(BMessenger messenger)
: BWindow(CenteredRect(BRect(0, 0, 350, 215)), "Terminal Settings",
B_TITLED_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL,
B_NOT_RESIZABLE|B_NOT_ZOOMABLE)
B_NOT_RESIZABLE|B_NOT_ZOOMABLE),
fPrefDlgMessenger(messenger)
{
fTermWindow = inWindow;
fPrefTemp = new PrefHandler(gTermPref);
fDirty = false;
fSavePanel = NULL;
@@ -48,7 +46,7 @@ PrefDlg::PrefDlg(TermWindow *inWindow)
r=top->Bounds();
r.bottom *= .75;
AppearancePrefView *prefView= new AppearancePrefView(r, "Appearance",
fTermWindow);
fPrefDlgMessenger);
top->AddChild(prefView);
fSaveAsFileButton = new BButton(BRect(0,0,1,1), "savebutton",
@@ -95,7 +93,7 @@ PrefDlg::~PrefDlg()
void
PrefDlg::Quit()
{
fTermWindow->PostMessage(MSG_PREF_CLOSED);
fPrefDlgMessenger.SendMessage(MSG_PREF_CLOSED);
delete fPrefTemp;
delete fSavePanel;
BWindow::Quit();
@@ -121,14 +119,14 @@ PrefDlg::QuitRequested()
return false;
if (index == 2)
doSave();
_Save();
return true;
}
void
PrefDlg::doSaveAs()
PrefDlg::_SaveAs()
{
if (!fSavePanel)
fSavePanel = new BFilePanel(B_SAVE_PANEL, new BMessenger(this));
@@ -138,7 +136,7 @@ PrefDlg::doSaveAs()
void
PrefDlg::SaveRequested(BMessage *msg)
PrefDlg::_SaveRequested(BMessage *msg)
{
entry_ref dirref;
const char *filename;
@@ -154,7 +152,7 @@ PrefDlg::SaveRequested(BMessage *msg)
void
PrefDlg::doSave()
PrefDlg::_Save()
{
delete fPrefTemp;
fPrefTemp = new PrefHandler(gTermPref);
@@ -168,16 +166,14 @@ PrefDlg::doSave()
void
PrefDlg::doRevert()
PrefDlg::_Revert()
{
BMessenger messenger (fTermWindow);
delete gTermPref;
gTermPref = new PrefHandler(fPrefTemp);
messenger.SendMessage(MSG_HALF_FONT_CHANGED);
messenger.SendMessage(MSG_COLOR_CHANGED);
messenger.SendMessage(MSG_INPUT_METHOD_CHANGED);
fPrefDlgMessenger.SendMessage(MSG_HALF_FONT_CHANGED);
fPrefDlgMessenger.SendMessage(MSG_COLOR_CHANGED);
fPrefDlgMessenger.SendMessage(MSG_INPUT_METHOD_CHANGED);
fDirty = false;
}
@@ -188,37 +184,30 @@ PrefDlg::MessageReceived(BMessage *msg)
{
switch (msg->what) {
case MSG_SAVE_PRESSED:
{
doSave();
_Save();
PostMessage(B_QUIT_REQUESTED);
break;
}
case MSG_SAVEAS_PRESSED:
{
doSaveAs();
_SaveAs();
break;
}
case MSG_REVERT_PRESSED:
{
doRevert();
_Revert();
PostMessage(B_QUIT_REQUESTED);
break;
}
case MSG_PREF_MODIFIED:
{
fDirty = true;
break;
}
case B_SAVE_REQUESTED:
{
SaveRequested(msg);
_SaveRequested(msg);
break;
}
default:
{
BWindow::MessageReceived(msg);
break;
}
break;
}
}
+29 -52
View File
@@ -1,31 +1,8 @@
/*
* Copyright (c) 2003-4 Kian Duffy <[email protected]>
* Parts Copyright (C) 1998,99 Kazuho Okui and Takashi Murai.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files or portions
* thereof (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:
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice
* in the binary, as well as this list of conditions and the following
* disclaimer in the documentation and/or other materials provided with
* the distribution.
*
* 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.
*
* Copyright 2001-2007, Haiku, Inc.
* Copyright 2003-2004 Kian Duffy, [email protected]
* Parts Copyright 1998-1999 Kazuho Okui and Takashi Murai.
* All rights reserved. Distributed under the terms of the MIT license.
*/
#ifndef PREFDLG_H_INCLUDED
#define PREFDLG_H_INCLUDED
@@ -46,38 +23,38 @@ const ulong MSG_PREF_CLOSED = 'mspc';
class BRect;
class BMessage;
class BTextControl;
class TermWindow;
class PrefView;
class BButton;
class PrefHandler;
class BFilePanel;
class PrefDlg : public BWindow
{
public:
PrefDlg(TermWindow *inWindow);
~PrefDlg();
void Quit();
private:
void doSave (void);
void doSaveAs (void);
void doRevert (void);
void SaveRequested(BMessage *msg);
bool QuitRequested();
void MessageReceived (BMessage *msg);
public:
PrefDlg(BMessenger messenger);
virtual ~PrefDlg();
virtual void Quit();
virtual bool QuitRequested();
virtual void MessageReceived(BMessage *msg);
private:
void _Save();
void _SaveAs();
void _Revert();
void _SaveRequested(BMessage *msg);
static BRect CenteredRect(BRect r);
PrefHandler *fPrefTemp;
BFilePanel *fSavePanel;
static BRect CenteredRect(BRect r);
TermWindow *fTermWindow;
PrefHandler *fPrefTemp;
BFilePanel *fSavePanel;
BButton *fSaveAsFileButton,
*fRevertButton,
*fSaveButton;
bool fDirty;
BButton *fSaveAsFileButton,
*fRevertButton,
*fSaveButton;
bool fDirty;
BMessenger fPrefDlgMessenger;
};
#endif //PREFDLG_H_INCLUDED