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:
@@ -1,15 +1,14 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2003-4 Kian Duffy <[email protected]>
|
* Copyright 2001-2007, Haiku, Inc.
|
||||||
* Copyright (c) 1998,99 Kazuho Okui and Takashi Murai.
|
* Copyright 2003-2004 Kian Duffy, [email protected]
|
||||||
*
|
* Parts Copyright 1998-1999 Kazuho Okui and Takashi Murai.
|
||||||
* Distributed unter the terms of the MIT License.
|
* All rights reserved. Distributed under the terms of the MIT license.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include "AppearPrefView.h"
|
#include "AppearPrefView.h"
|
||||||
#include "MenuUtil.h"
|
#include "MenuUtil.h"
|
||||||
#include "PrefHandler.h"
|
#include "PrefHandler.h"
|
||||||
#include "TermWindow.h"
|
|
||||||
#include "TermConst.h"
|
#include "TermConst.h"
|
||||||
|
|
||||||
#include <View.h>
|
#include <View.h>
|
||||||
@@ -23,9 +22,9 @@
|
|||||||
|
|
||||||
|
|
||||||
AppearancePrefView::AppearancePrefView(BRect frame, const char *name,
|
AppearancePrefView::AppearancePrefView(BRect frame, const char *name,
|
||||||
TermWindow *window)
|
BMessenger messenger)
|
||||||
: PrefView(frame, name),
|
: PrefView(frame, name),
|
||||||
fTermWindow(window)
|
fAppearancePrefViewMessenger(messenger)
|
||||||
{
|
{
|
||||||
const char *color_tbl[] = {
|
const char *color_tbl[] = {
|
||||||
PREF_TEXT_FORE_COLOR,
|
PREF_TEXT_FORE_COLOR,
|
||||||
@@ -134,8 +133,13 @@ AppearancePrefView::MessageReceived(BMessage *msg)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (modified) {
|
if (modified) {
|
||||||
fTermWindow->PostMessage(msg);
|
fAppearancePrefViewMessenger.SendMessage(msg);
|
||||||
Window()->PostMessage(MSG_PREF_MODIFIED);
|
// 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;
|
return menu;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2003-4 Kian Duffy <[email protected]>
|
* Copyright 2001-2007, Haiku, Inc.
|
||||||
* Copyright (c) 1998,99 Kazuho Okui and Takashi Murai.
|
* Copyright 2003-2004 Kian Duffy, [email protected]
|
||||||
*
|
* Parts Copyright 1998-1999 Kazuho Okui and Takashi Murai.
|
||||||
* Distributed unter the terms of the MIT License.
|
* All rights reserved. Distributed under the terms of the MIT license.
|
||||||
*/
|
*/
|
||||||
#ifndef APPEARANCE_PREF_VIEW_H
|
#ifndef APPEARANCE_PREF_VIEW_H
|
||||||
#define APPEARANCE_PREF_VIEW_H
|
#define APPEARANCE_PREF_VIEW_H
|
||||||
@@ -14,14 +14,13 @@ class BColorControl;
|
|||||||
class BMenu;
|
class BMenu;
|
||||||
class BMenuField;
|
class BMenuField;
|
||||||
|
|
||||||
class TermWindow;
|
|
||||||
class TTextControl;
|
class TTextControl;
|
||||||
|
|
||||||
|
|
||||||
class AppearancePrefView : public PrefView {
|
class AppearancePrefView : public PrefView {
|
||||||
public:
|
public:
|
||||||
AppearancePrefView(BRect frame, const char *name,
|
AppearancePrefView(BRect frame, const char *name,
|
||||||
TermWindow *window);
|
BMessenger messenger);
|
||||||
|
|
||||||
virtual void Revert();
|
virtual void Revert();
|
||||||
virtual void MessageReceived(BMessage *message);
|
virtual void MessageReceived(BMessage *message);
|
||||||
@@ -39,7 +38,7 @@ class AppearancePrefView : public PrefView {
|
|||||||
BMenuField *fColorField;
|
BMenuField *fColorField;
|
||||||
BColorControl *fColorControl;
|
BColorControl *fColorControl;
|
||||||
|
|
||||||
TermWindow *fTermWindow;
|
BMessenger fAppearancePrefViewMessenger;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // APPEARANCE_PREF_VIEW_H
|
#endif // APPEARANCE_PREF_VIEW_H
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2003-4 Kian Duffy <[email protected]>
|
* Copyright 2001-2007, Haiku, Inc.
|
||||||
* Copyright (C) 1998,99 Kazuho Okui and Takashi Murai.
|
* Copyright 2003-2004 Kian Duffy, [email protected]
|
||||||
*
|
* Parts Copyright 1998-1999 Kazuho Okui and Takashi Murai.
|
||||||
* Distributed unter the terms of the MIT License.
|
* All rights reserved. Distributed under the terms of the MIT license.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
@@ -17,8 +17,6 @@
|
|||||||
#include "PrefHandler.h"
|
#include "PrefHandler.h"
|
||||||
#include "PrefDlg.h"
|
#include "PrefDlg.h"
|
||||||
#include "TermConst.h"
|
#include "TermConst.h"
|
||||||
#include "TermView.h"
|
|
||||||
#include "TermWindow.h"
|
|
||||||
#include "MenuUtil.h"
|
#include "MenuUtil.h"
|
||||||
|
|
||||||
#include "AppearPrefView.h"
|
#include "AppearPrefView.h"
|
||||||
@@ -29,12 +27,12 @@
|
|||||||
// Global Preference Handler
|
// Global Preference Handler
|
||||||
extern PrefHandler *gTermPref;
|
extern PrefHandler *gTermPref;
|
||||||
|
|
||||||
PrefDlg::PrefDlg(TermWindow *inWindow)
|
PrefDlg::PrefDlg(BMessenger messenger)
|
||||||
: BWindow(CenteredRect(BRect(0, 0, 350, 215)), "Terminal Settings",
|
: BWindow(CenteredRect(BRect(0, 0, 350, 215)), "Terminal Settings",
|
||||||
B_TITLED_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL,
|
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);
|
fPrefTemp = new PrefHandler(gTermPref);
|
||||||
fDirty = false;
|
fDirty = false;
|
||||||
fSavePanel = NULL;
|
fSavePanel = NULL;
|
||||||
@@ -48,7 +46,7 @@ PrefDlg::PrefDlg(TermWindow *inWindow)
|
|||||||
r=top->Bounds();
|
r=top->Bounds();
|
||||||
r.bottom *= .75;
|
r.bottom *= .75;
|
||||||
AppearancePrefView *prefView= new AppearancePrefView(r, "Appearance",
|
AppearancePrefView *prefView= new AppearancePrefView(r, "Appearance",
|
||||||
fTermWindow);
|
fPrefDlgMessenger);
|
||||||
top->AddChild(prefView);
|
top->AddChild(prefView);
|
||||||
|
|
||||||
fSaveAsFileButton = new BButton(BRect(0,0,1,1), "savebutton",
|
fSaveAsFileButton = new BButton(BRect(0,0,1,1), "savebutton",
|
||||||
@@ -95,7 +93,7 @@ PrefDlg::~PrefDlg()
|
|||||||
void
|
void
|
||||||
PrefDlg::Quit()
|
PrefDlg::Quit()
|
||||||
{
|
{
|
||||||
fTermWindow->PostMessage(MSG_PREF_CLOSED);
|
fPrefDlgMessenger.SendMessage(MSG_PREF_CLOSED);
|
||||||
delete fPrefTemp;
|
delete fPrefTemp;
|
||||||
delete fSavePanel;
|
delete fSavePanel;
|
||||||
BWindow::Quit();
|
BWindow::Quit();
|
||||||
@@ -121,14 +119,14 @@ PrefDlg::QuitRequested()
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (index == 2)
|
if (index == 2)
|
||||||
doSave();
|
_Save();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PrefDlg::doSaveAs()
|
PrefDlg::_SaveAs()
|
||||||
{
|
{
|
||||||
if (!fSavePanel)
|
if (!fSavePanel)
|
||||||
fSavePanel = new BFilePanel(B_SAVE_PANEL, new BMessenger(this));
|
fSavePanel = new BFilePanel(B_SAVE_PANEL, new BMessenger(this));
|
||||||
@@ -138,7 +136,7 @@ PrefDlg::doSaveAs()
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PrefDlg::SaveRequested(BMessage *msg)
|
PrefDlg::_SaveRequested(BMessage *msg)
|
||||||
{
|
{
|
||||||
entry_ref dirref;
|
entry_ref dirref;
|
||||||
const char *filename;
|
const char *filename;
|
||||||
@@ -154,7 +152,7 @@ PrefDlg::SaveRequested(BMessage *msg)
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PrefDlg::doSave()
|
PrefDlg::_Save()
|
||||||
{
|
{
|
||||||
delete fPrefTemp;
|
delete fPrefTemp;
|
||||||
fPrefTemp = new PrefHandler(gTermPref);
|
fPrefTemp = new PrefHandler(gTermPref);
|
||||||
@@ -168,16 +166,14 @@ PrefDlg::doSave()
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PrefDlg::doRevert()
|
PrefDlg::_Revert()
|
||||||
{
|
{
|
||||||
BMessenger messenger (fTermWindow);
|
|
||||||
|
|
||||||
delete gTermPref;
|
delete gTermPref;
|
||||||
gTermPref = new PrefHandler(fPrefTemp);
|
gTermPref = new PrefHandler(fPrefTemp);
|
||||||
|
|
||||||
messenger.SendMessage(MSG_HALF_FONT_CHANGED);
|
fPrefDlgMessenger.SendMessage(MSG_HALF_FONT_CHANGED);
|
||||||
messenger.SendMessage(MSG_COLOR_CHANGED);
|
fPrefDlgMessenger.SendMessage(MSG_COLOR_CHANGED);
|
||||||
messenger.SendMessage(MSG_INPUT_METHOD_CHANGED);
|
fPrefDlgMessenger.SendMessage(MSG_INPUT_METHOD_CHANGED);
|
||||||
|
|
||||||
fDirty = false;
|
fDirty = false;
|
||||||
}
|
}
|
||||||
@@ -188,37 +184,30 @@ PrefDlg::MessageReceived(BMessage *msg)
|
|||||||
{
|
{
|
||||||
switch (msg->what) {
|
switch (msg->what) {
|
||||||
case MSG_SAVE_PRESSED:
|
case MSG_SAVE_PRESSED:
|
||||||
{
|
_Save();
|
||||||
doSave();
|
|
||||||
PostMessage(B_QUIT_REQUESTED);
|
PostMessage(B_QUIT_REQUESTED);
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
case MSG_SAVEAS_PRESSED:
|
case MSG_SAVEAS_PRESSED:
|
||||||
{
|
_SaveAs();
|
||||||
doSaveAs();
|
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
case MSG_REVERT_PRESSED:
|
case MSG_REVERT_PRESSED:
|
||||||
{
|
_Revert();
|
||||||
doRevert();
|
|
||||||
PostMessage(B_QUIT_REQUESTED);
|
PostMessage(B_QUIT_REQUESTED);
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
case MSG_PREF_MODIFIED:
|
case MSG_PREF_MODIFIED:
|
||||||
{
|
|
||||||
fDirty = true;
|
fDirty = true;
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
case B_SAVE_REQUESTED:
|
case B_SAVE_REQUESTED:
|
||||||
{
|
_SaveRequested(msg);
|
||||||
SaveRequested(msg);
|
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
default:
|
default:
|
||||||
{
|
|
||||||
BWindow::MessageReceived(msg);
|
BWindow::MessageReceived(msg);
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+29
-52
@@ -1,31 +1,8 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2003-4 Kian Duffy <[email protected]>
|
* Copyright 2001-2007, Haiku, Inc.
|
||||||
* Parts Copyright (C) 1998,99 Kazuho Okui and Takashi Murai.
|
* Copyright 2003-2004 Kian Duffy, [email protected]
|
||||||
*
|
* Parts Copyright 1998-1999 Kazuho Okui and Takashi Murai.
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining
|
* All rights reserved. Distributed under the terms of the MIT license.
|
||||||
* 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.
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
#ifndef PREFDLG_H_INCLUDED
|
#ifndef PREFDLG_H_INCLUDED
|
||||||
#define PREFDLG_H_INCLUDED
|
#define PREFDLG_H_INCLUDED
|
||||||
@@ -46,38 +23,38 @@ const ulong MSG_PREF_CLOSED = 'mspc';
|
|||||||
class BRect;
|
class BRect;
|
||||||
class BMessage;
|
class BMessage;
|
||||||
class BTextControl;
|
class BTextControl;
|
||||||
class TermWindow;
|
|
||||||
class PrefView;
|
|
||||||
class BButton;
|
class BButton;
|
||||||
class PrefHandler;
|
class PrefHandler;
|
||||||
class BFilePanel;
|
class BFilePanel;
|
||||||
|
|
||||||
class PrefDlg : public BWindow
|
class PrefDlg : public BWindow
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
PrefDlg(TermWindow *inWindow);
|
PrefDlg(BMessenger messenger);
|
||||||
~PrefDlg();
|
virtual ~PrefDlg();
|
||||||
void Quit();
|
|
||||||
private:
|
virtual void Quit();
|
||||||
void doSave (void);
|
virtual bool QuitRequested();
|
||||||
void doSaveAs (void);
|
virtual void MessageReceived(BMessage *msg);
|
||||||
void doRevert (void);
|
|
||||||
void SaveRequested(BMessage *msg);
|
private:
|
||||||
|
void _Save();
|
||||||
bool QuitRequested();
|
void _SaveAs();
|
||||||
void MessageReceived (BMessage *msg);
|
void _Revert();
|
||||||
|
void _SaveRequested(BMessage *msg);
|
||||||
|
|
||||||
|
static BRect CenteredRect(BRect r);
|
||||||
|
|
||||||
|
PrefHandler *fPrefTemp;
|
||||||
|
BFilePanel *fSavePanel;
|
||||||
|
|
||||||
static BRect CenteredRect(BRect r);
|
BButton *fSaveAsFileButton,
|
||||||
|
*fRevertButton,
|
||||||
TermWindow *fTermWindow;
|
*fSaveButton;
|
||||||
PrefHandler *fPrefTemp;
|
|
||||||
BFilePanel *fSavePanel;
|
bool fDirty;
|
||||||
|
|
||||||
BButton *fSaveAsFileButton,
|
BMessenger fPrefDlgMessenger;
|
||||||
*fRevertButton,
|
|
||||||
*fSaveButton;
|
|
||||||
|
|
||||||
bool fDirty;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif //PREFDLG_H_INCLUDED
|
#endif //PREFDLG_H_INCLUDED
|
||||||
|
|||||||
Reference in New Issue
Block a user