Cleanup.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@40985 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -15,9 +15,11 @@
|
||||
|
||||
#include "DataTranslationsSettings.h"
|
||||
|
||||
|
||||
class BDirectory;
|
||||
class BEntry;
|
||||
|
||||
|
||||
class DataTranslationsApplication : public BApplication {
|
||||
public:
|
||||
DataTranslationsApplication();
|
||||
@@ -40,4 +42,5 @@ private:
|
||||
DataTranslationsSettings fSettings;
|
||||
};
|
||||
|
||||
|
||||
#endif // DATA_TRANSLATIONS_H
|
||||
|
||||
@@ -10,14 +10,14 @@
|
||||
|
||||
#include "DataTranslationsSettings.h"
|
||||
|
||||
#include <Application.h>
|
||||
#include <FindDirectory.h>
|
||||
#include <File.h>
|
||||
#include <Path.h>
|
||||
#include <Message.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include <Application.h>
|
||||
#include <File.h>
|
||||
#include <FindDirectory.h>
|
||||
#include <Message.h>
|
||||
#include <Path.h>
|
||||
|
||||
|
||||
DataTranslationsSettings::DataTranslationsSettings()
|
||||
{
|
||||
|
||||
@@ -13,15 +13,16 @@
|
||||
|
||||
|
||||
class DataTranslationsSettings {
|
||||
public:
|
||||
DataTranslationsSettings();
|
||||
~DataTranslationsSettings();
|
||||
public:
|
||||
DataTranslationsSettings();
|
||||
~DataTranslationsSettings();
|
||||
|
||||
BPoint WindowCorner() const { return fCorner; }
|
||||
void SetWindowCorner(BPoint corner);
|
||||
BPoint WindowCorner() const { return fCorner; }
|
||||
void SetWindowCorner(BPoint corner);
|
||||
|
||||
private:
|
||||
BPoint fCorner;
|
||||
private:
|
||||
BPoint fCorner;
|
||||
};
|
||||
|
||||
|
||||
#endif // DATA_TRANSLATIONS_SETTINGS_H
|
||||
|
||||
@@ -10,10 +10,7 @@
|
||||
*/
|
||||
|
||||
|
||||
#include "DataTranslations.h"
|
||||
#include "DataTranslationsWindow.h"
|
||||
#include "IconView.h"
|
||||
#include "TranslatorListView.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
@@ -36,6 +33,10 @@
|
||||
#include <TranslationDefs.h>
|
||||
#include <TranslatorRoster.h>
|
||||
|
||||
#include "DataTranslations.h"
|
||||
#include "IconView.h"
|
||||
#include "TranslatorListView.h"
|
||||
|
||||
|
||||
#undef B_TRANSLATE_CONTEXT
|
||||
#define B_TRANSLATE_CONTEXT "DataTranslations"
|
||||
@@ -51,7 +52,7 @@ DataTranslationsWindow::DataTranslationsWindow()
|
||||
B_TITLED_WINDOW, B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE
|
||||
| B_NOT_RESIZABLE | B_AUTO_UPDATE_SIZE_LIMITS)
|
||||
{
|
||||
MoveTo(static_cast<DataTranslationsApplication *>(be_app)->WindowCorner());
|
||||
MoveTo(static_cast<DataTranslationsApplication*>(be_app)->WindowCorner());
|
||||
|
||||
_SetupViews();
|
||||
|
||||
@@ -61,7 +62,7 @@ DataTranslationsWindow::DataTranslationsWindow()
|
||||
if (!screenFrame.Contains(Frame()))
|
||||
CenterOnScreen();
|
||||
|
||||
BTranslatorRoster *roster = BTranslatorRoster::Default();
|
||||
BTranslatorRoster* roster = BTranslatorRoster::Default();
|
||||
roster->StartWatching(this);
|
||||
|
||||
Show();
|
||||
@@ -70,7 +71,7 @@ DataTranslationsWindow::DataTranslationsWindow()
|
||||
|
||||
DataTranslationsWindow::~DataTranslationsWindow()
|
||||
{
|
||||
BTranslatorRoster *roster = BTranslatorRoster::Default();
|
||||
BTranslatorRoster* roster = BTranslatorRoster::Default();
|
||||
roster->StopWatching(this);
|
||||
}
|
||||
|
||||
@@ -79,18 +80,19 @@ DataTranslationsWindow::~DataTranslationsWindow()
|
||||
status_t
|
||||
DataTranslationsWindow::_PopulateListView()
|
||||
{
|
||||
BTranslatorRoster *roster = BTranslatorRoster::Default();
|
||||
BTranslatorRoster* roster = BTranslatorRoster::Default();
|
||||
|
||||
// Get all Translators on the system. Gives us the number of translators
|
||||
// installed in num_translators and a reference to the first one
|
||||
int32 numTranslators;
|
||||
translator_id *translators = NULL;
|
||||
translator_id* translators = NULL;
|
||||
roster->GetAllTranslators(&translators, &numTranslators);
|
||||
|
||||
for (int32 i = 0; i < numTranslators; i++) {
|
||||
// Getting the first three Infos: Name, Info & Version
|
||||
int32 version;
|
||||
const char *name, *info;
|
||||
const char* name;
|
||||
const char* info;
|
||||
roster->GetTranslatorInfo(translators[i], &name, &info, &version);
|
||||
fTranslatorListView->AddItem(new TranslatorItem(translators[i], name));
|
||||
}
|
||||
@@ -109,7 +111,7 @@ DataTranslationsWindow::_GetTranslatorInfo(int32 id, const char*& name,
|
||||
if (id < 0)
|
||||
return B_BAD_VALUE;
|
||||
|
||||
BTranslatorRoster *roster = BTranslatorRoster::Default();
|
||||
BTranslatorRoster* roster = BTranslatorRoster::Default();
|
||||
if (roster->GetTranslatorInfo(id, &name, &info, &version) != B_OK)
|
||||
return B_ERROR;
|
||||
|
||||
@@ -133,7 +135,7 @@ DataTranslationsWindow::_ShowConfigView(int32 id)
|
||||
if (id < 0)
|
||||
return B_BAD_VALUE;
|
||||
|
||||
BTranslatorRoster *roster = BTranslatorRoster::Default();
|
||||
BTranslatorRoster* roster = BTranslatorRoster::Default();
|
||||
|
||||
// fConfigView is NULL the first time this function
|
||||
// is called, prevent a segment fault
|
||||
@@ -168,7 +170,7 @@ DataTranslationsWindow::_SetupViews()
|
||||
fTranslatorListView->SetSelectionMessage(
|
||||
new BMessage(kMsgSelectedTranslator));
|
||||
|
||||
BScrollView *scrollView = new BScrollView("scroll_trans",
|
||||
BScrollView* scrollView = new BScrollView("scroll_trans",
|
||||
fTranslatorListView, B_WILL_DRAW | B_FRAME_EVENTS, false,
|
||||
true, B_FANCY_BORDER);
|
||||
|
||||
@@ -182,7 +184,7 @@ DataTranslationsWindow::_SetupViews()
|
||||
B_FOLLOW_LEFT | B_FOLLOW_BOTTOM, B_WILL_DRAW | B_FRAME_EVENTS);
|
||||
|
||||
// Add the translator info button
|
||||
BButton *button = new BButton("STD", B_TRANSLATE("Info" B_UTF8_ELLIPSIS),
|
||||
BButton* button = new BButton("STD", B_TRANSLATE("Info" B_UTF8_ELLIPSIS),
|
||||
new BMessage(kMsgTranslatorInfo), B_WILL_DRAW | B_FRAME_EVENTS | B_NAVIGABLE);
|
||||
|
||||
// Populate the translators list view
|
||||
@@ -208,7 +210,7 @@ bool
|
||||
DataTranslationsWindow::QuitRequested()
|
||||
{
|
||||
BPoint pt(Frame().LeftTop());
|
||||
dynamic_cast<DataTranslationsApplication *>(be_app)->SetWindowCorner(pt);
|
||||
dynamic_cast<DataTranslationsApplication*>(be_app)->SetWindowCorner(pt);
|
||||
be_app->PostMessage(B_QUIT_REQUESTED);
|
||||
|
||||
return true;
|
||||
@@ -235,7 +237,7 @@ DataTranslationsWindow::_ShowInfoAlert(int32 id)
|
||||
|
||||
BAlert* alert = new BAlert(B_TRANSLATE("Info"), message.String(),
|
||||
B_TRANSLATE("OK"));
|
||||
BTextView *view = alert->TextView();
|
||||
BTextView* view = alert->TextView();
|
||||
BFont font;
|
||||
|
||||
view->SetStylable(true);
|
||||
@@ -255,7 +257,7 @@ DataTranslationsWindow::_ShowInfoAlert(int32 id)
|
||||
|
||||
|
||||
void
|
||||
DataTranslationsWindow::MessageReceived(BMessage *message)
|
||||
DataTranslationsWindow::MessageReceived(BMessage* message)
|
||||
{
|
||||
switch (message->what) {
|
||||
case kMsgTranslatorInfo:
|
||||
|
||||
@@ -11,9 +11,10 @@
|
||||
#define DATA_TRANSLATIONS_WINDOW_H
|
||||
|
||||
|
||||
#include <Window.h>
|
||||
|
||||
#include "IconView.h"
|
||||
|
||||
#include <Window.h>
|
||||
|
||||
class BBox;
|
||||
class BStringView;
|
||||
@@ -24,32 +25,27 @@ class TranslatorListView;
|
||||
|
||||
|
||||
class DataTranslationsWindow : public BWindow {
|
||||
public:
|
||||
DataTranslationsWindow();
|
||||
~DataTranslationsWindow();
|
||||
public:
|
||||
DataTranslationsWindow();
|
||||
~DataTranslationsWindow();
|
||||
|
||||
virtual bool QuitRequested();
|
||||
virtual void MessageReceived(BMessage* message);
|
||||
virtual bool QuitRequested();
|
||||
virtual void MessageReceived(BMessage* message);
|
||||
|
||||
private:
|
||||
status_t _GetTranslatorInfo(int32 id, const char *&name, const char *&info,
|
||||
int32 &version, BPath &path);
|
||||
void _ShowInfoAlert(int32 id);
|
||||
status_t _ShowConfigView(int32 id);
|
||||
status_t _PopulateListView();
|
||||
void _SetupViews();
|
||||
private:
|
||||
status_t _GetTranslatorInfo(int32 id, const char*& name,
|
||||
const char*& info, int32& version, BPath& path);
|
||||
void _ShowInfoAlert(int32 id);
|
||||
status_t _ShowConfigView(int32 id);
|
||||
status_t _PopulateListView();
|
||||
void _SetupViews();
|
||||
|
||||
TranslatorListView *fTranslatorListView;
|
||||
TranslatorListView* fTranslatorListView;
|
||||
|
||||
BBox *fRightBox;
|
||||
// Box hosting fConfigView, fIconView,
|
||||
// fTranNameView and the Info button
|
||||
|
||||
BView *fConfigView;
|
||||
// the translator config view
|
||||
|
||||
IconView *fIconView;
|
||||
BBox* fRightBox;
|
||||
BView* fConfigView;
|
||||
IconView* fIconView;
|
||||
};
|
||||
|
||||
#endif // DATA_TRANSLATIONS_WINDOW_H
|
||||
|
||||
#endif // DATA_TRANSLATIONS_WINDOW_H
|
||||
|
||||
@@ -1,35 +1,25 @@
|
||||
/*****************************************************************************/
|
||||
// IconView
|
||||
// IconView.cpp
|
||||
// Author: Michael Wilber
|
||||
//
|
||||
//
|
||||
// This BView based object displays an icon
|
||||
//
|
||||
//
|
||||
// Copyright (C) Haiku, uses the MIT license
|
||||
/*****************************************************************************/
|
||||
|
||||
|
||||
#include "IconView.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "IconView.h"
|
||||
|
||||
IconView::IconView(const BRect &frame, const char *name,
|
||||
uint32 resize, uint32 flags)
|
||||
: BView(frame, name, resize, flags)
|
||||
#include <Entry.h>
|
||||
#include <Node.h>
|
||||
#include <NodeInfo.h>
|
||||
|
||||
|
||||
IconView::IconView(const BRect& frame, const char* name, uint32 resize,
|
||||
uint32 flags)
|
||||
:
|
||||
BView(frame, name, resize, flags),
|
||||
fIconBitmap(new BBitmap(BRect(B_LARGE_ICON), B_RGBA32)),
|
||||
fDrawIcon(false)
|
||||
{
|
||||
fDrawIcon = false;
|
||||
|
||||
SetDrawingMode(B_OP_OVER);
|
||||
// to preserve transparent areas of the icon
|
||||
|
||||
SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
||||
|
||||
#if __HAIKU__
|
||||
fIconBitmap = new BBitmap(BRect(0, 0, B_LARGE_ICON - 1, B_LARGE_ICON - 1), B_RGBA32);
|
||||
#else
|
||||
fIconBitmap = new BBitmap(BRect(0, 0, B_LARGE_ICON - 1, B_LARGE_ICON - 1), B_CMAP8);
|
||||
#endif
|
||||
}
|
||||
|
||||
IconView::~IconView()
|
||||
@@ -39,7 +29,7 @@ IconView::~IconView()
|
||||
}
|
||||
|
||||
bool
|
||||
IconView::SetIcon(const BPath &path)
|
||||
IconView::SetIcon(const BPath& path)
|
||||
{
|
||||
fDrawIcon = false;
|
||||
|
||||
@@ -69,12 +59,9 @@ IconView::DrawIcon(bool draw)
|
||||
void
|
||||
IconView::Draw(BRect area)
|
||||
{
|
||||
#if __HAIKU__
|
||||
SetDrawingMode(B_OP_ALPHA);
|
||||
SetBlendingMode(B_PIXEL_ALPHA, B_ALPHA_OVERLAY);
|
||||
#else
|
||||
SetDrawingMode(B_OP_OVER);
|
||||
#endif
|
||||
|
||||
if (fDrawIcon)
|
||||
DrawBitmap(fIconBitmap);
|
||||
|
||||
|
||||
@@ -1,40 +1,27 @@
|
||||
/*****************************************************************************/
|
||||
// IconView
|
||||
// IconView.h
|
||||
// Author: Michael Wilber
|
||||
//
|
||||
// This BView based object displays an icon
|
||||
//
|
||||
// Copyright (C) Haiku, uses the MIT license
|
||||
/*****************************************************************************/
|
||||
|
||||
#ifndef ICONVIEW_H
|
||||
#define ICONVIEW_H
|
||||
|
||||
#include <View.h>
|
||||
|
||||
#include <Bitmap.h>
|
||||
#include <Path.h>
|
||||
#include <Entry.h>
|
||||
#include <Node.h>
|
||||
#include <NodeInfo.h>
|
||||
#include <View.h>
|
||||
|
||||
|
||||
class IconView : public BView {
|
||||
public:
|
||||
IconView(const BRect &frame, const char *name, uint32 resize, uint32 flags);
|
||||
// sets up the view
|
||||
~IconView();
|
||||
IconView(const BRect& frame, const char* name,
|
||||
uint32 resize, uint32 flags);
|
||||
~IconView();
|
||||
virtual void Draw(BRect area);
|
||||
|
||||
bool DrawIcon(bool draw);
|
||||
|
||||
bool SetIcon(const BPath &path);
|
||||
bool DrawIcon(bool draw);
|
||||
bool SetIcon(const BPath& path);
|
||||
|
||||
virtual void Draw(BRect area);
|
||||
// draws the icon
|
||||
private:
|
||||
BBitmap *fIconBitmap;
|
||||
// the icon
|
||||
bool fDrawIcon;
|
||||
// whether or not the icon is drawn
|
||||
BBitmap* fIconBitmap;
|
||||
bool fDrawIcon;
|
||||
};
|
||||
|
||||
#endif // #ifndef ICONVIEW_H
|
||||
|
||||
@@ -16,28 +16,30 @@
|
||||
|
||||
|
||||
class TranslatorItem : public BStringItem {
|
||||
public:
|
||||
TranslatorItem(translator_id id, const char* name);
|
||||
virtual ~TranslatorItem();
|
||||
public:
|
||||
TranslatorItem(translator_id id, const char* name);
|
||||
virtual ~TranslatorItem();
|
||||
|
||||
translator_id ID() const { return fID; }
|
||||
translator_id ID() const { return fID; }
|
||||
|
||||
private:
|
||||
translator_id fID;
|
||||
private:
|
||||
translator_id fID;
|
||||
};
|
||||
|
||||
|
||||
class TranslatorListView : public BListView {
|
||||
public:
|
||||
TranslatorListView(const char *name,
|
||||
list_view_type type = B_SINGLE_SELECTION_LIST);
|
||||
virtual ~TranslatorListView();
|
||||
public:
|
||||
TranslatorListView(const char* name,
|
||||
list_view_type type = B_SINGLE_SELECTION_LIST);
|
||||
virtual ~TranslatorListView();
|
||||
|
||||
TranslatorItem* TranslatorAt(int32 index) const;
|
||||
TranslatorItem* TranslatorAt(int32 index) const;
|
||||
|
||||
virtual void MessageReceived(BMessage *message);
|
||||
virtual void MouseMoved(BPoint point, uint32 transit, const BMessage *msg);
|
||||
virtual void MessageReceived(BMessage* message);
|
||||
virtual void MouseMoved(BPoint point, uint32 transit, const BMessage* msg);
|
||||
|
||||
void SortItems();
|
||||
void SortItems();
|
||||
};
|
||||
|
||||
|
||||
#endif // TRANSLATOR_LIST_VIEW_H
|
||||
|
||||
Reference in New Issue
Block a user