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