Compiler warning and code style fixes. No functional changes.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37278 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Wim van der Meer
2010-06-27 10:38:05 +00:00
parent ca29fe0117
commit 3d00bd66b8
2 changed files with 58 additions and 47 deletions
+14 -10
View File
@@ -1,23 +1,29 @@
#include "SnowView.h"
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <math.h> #include <math.h>
#include <Alert.h> #include <Alert.h>
#include <Debug.h> #include <Debug.h>
#include <Message.h> #include <Message.h>
#include <MessageRunner.h> #include <MessageRunner.h>
#include <OS.h>
#include <Screen.h>
#include "SnowView.h"
#include "Flakes.h"
#include <Region.h>
#include <MessageFilter.h> #include <MessageFilter.h>
#include <OS.h>
#include <Region.h>
#include <Screen.h>
#include "Flakes.h"
#define FORWARD_TO_PARENT #define FORWARD_TO_PARENT
SnowView::SnowView() SnowView::SnowView()
: BView(BRect(SNOW_VIEW_RECT), "BSnow", B_FOLLOW_NONE, B_WILL_DRAW|B_PULSE_NEEDED) :
BView(BRect(SNOW_VIEW_RECT), "BSnow", B_FOLLOW_NONE,
B_WILL_DRAW | B_PULSE_NEEDED)
{ {
fAttached = false; fAttached = false;
fMsgRunner = NULL; fMsgRunner = NULL;
@@ -79,7 +85,7 @@ SnowView::SnowView(BMessage *archive)
SetFlags(Flags() & ~B_PULSE_NEEDED); /* it's only used when in the app */ SetFlags(Flags() & ~B_PULSE_NEEDED); /* it's only used when in the app */
get_system_info(&si); get_system_info(&si);
fNumFlakes = ((int32)(si.cpu_clock_speed/1000000)) * si.cpu_count / 3; //; fNumFlakes = ((int32)(si.cpu_clock_speed/1000000)) * si.cpu_count / 3; //;
printf("BSnow: using %d flakes\n", fNumFlakes); printf("BSnow: using %ld flakes\n", fNumFlakes);
for (int i = 0; i < WORKSPACES_COUNT; i++) { for (int i = 0; i < WORKSPACES_COUNT; i++) {
fFlakes[i] = new flake[fNumFlakes]; fFlakes[i] = new flake[fNumFlakes];
memset(fFlakes[i], 0, fNumFlakes * sizeof(flake)); memset(fFlakes[i], 0, fNumFlakes * sizeof(flake));
@@ -545,8 +551,6 @@ void SnowView::KeyUp(const char *bytes, int32 numBytes)
int32 SnowView::SnowMakerThread(void *p_this) int32 SnowView::SnowMakerThread(void *p_this)
{ {
SnowView *_this = (SnowView *)p_this; SnowView *_this = (SnowView *)p_this;
bigtime_t nextDraw = 0LL;
int current=0;
BView *p = _this->Parent(); BView *p = _this->Parent();
BRect portion(0,0,(_this->fCachedWsWidth/PORTION_GRAN)-1, (_this->fCachedWsHeight/PORTION_GRAN)-1); BRect portion(0,0,(_this->fCachedWsWidth/PORTION_GRAN)-1, (_this->fCachedWsHeight/PORTION_GRAN)-1);
int nf = _this->fNumFlakes; int nf = _this->fNumFlakes;
+44 -37
View File
@@ -1,13 +1,17 @@
#ifndef _SNOW_VIEW_H #ifndef _SNOW_VIEW_H
#define _SNOW_VIEW_H #define _SNOW_VIEW_H
#include <Bitmap.h> #include <Bitmap.h>
#include <Dragger.h> #include <Dragger.h>
#include <List.h> #include <List.h>
#include <OS.h> #include <OS.h>
#include <View.h> #include <View.h>
#include <MessageRunner.h> #include <MessageRunner.h>
#include "Flakes.h" #include "Flakes.h"
#define APP_SIG "application/x-vnd.mmu_man.BSnow" #define APP_SIG "application/x-vnd.mmu_man.BSnow"
#define SNOW_VIEW_RECT 0,0,200,40 #define SNOW_VIEW_RECT 0,0,200,40
#define NUM_FLAKES 200 #define NUM_FLAKES 200
@@ -22,58 +26,61 @@
#define FALLEN_HEIGHT 30 #define FALLEN_HEIGHT 30
#define INVALIDATOR_THREAD_NAME "You're Neo? I'm the Snow Maker!" #define INVALIDATOR_THREAD_NAME "You're Neo? I'm the Snow Maker!"
#define MSG_DRAG_ME "Drag me on your desktop..." #define MSG_DRAG_ME "Drag me on your desktop..."
#define MSG_CLICK_ME "Click me to remove BSnow..." #define MSG_CLICK_ME "Click me to remove BSnow..."
typedef struct flake { typedef struct flake {
BPoint pos; BPoint pos;
BPoint opos; BPoint opos;
float weight; float weight;
} flake; } flake;
class SnowView : public BView class SnowView : public BView
{ {
public: public:
SnowView(); SnowView();
SnowView(BMessage *archive); SnowView(BMessage *archive);
~SnowView(); ~SnowView();
static BArchivable *Instantiate(BMessage *data); static BArchivable *Instantiate(BMessage *data);
virtual status_t Archive(BMessage *data, bool deep = true) const; virtual status_t Archive(BMessage *data, bool deep = true) const;
void AttachedToWindow(); void AttachedToWindow();
void DetachedFromWindow(); void DetachedFromWindow();
void MessageReceived(BMessage *msg); void MessageReceived(BMessage *msg);
void Draw(BRect ur); void Draw(BRect ur);
void Pulse(); void Pulse();
virtual void MouseDown(BPoint where); virtual void MouseDown(BPoint where);
virtual void MouseUp(BPoint where); virtual void MouseUp(BPoint where);
virtual void MouseMoved(BPoint where, uint32 code, const BMessage *a_message); virtual void MouseMoved(BPoint where, uint32 code,
virtual void KeyDown(const char *bytes, int32 numBytes); const BMessage *a_message);
virtual void KeyUp(const char *bytes, int32 numBytes); virtual void KeyDown(const char *bytes, int32 numBytes);
virtual void KeyUp(const char *bytes, int32 numBytes);
static int32 SnowMakerThread(void *p_this);
void Calc();
void InvalFlakes();
static int32 SnowMakerThread(void *p_this);
void Calc();
void InvalFlakes();
private: private:
BMessageRunner *fMsgRunner; BMessageRunner *fMsgRunner;
BDragger *fDragger; BDragger *fDragger;
long fNumFlakes; long fNumFlakes;
flake *fFlakes[WORKSPACES_COUNT]; flake *fFlakes[WORKSPACES_COUNT];
BList *fFallenFlakes[WORKSPACES_COUNT]; BList *fFallenFlakes[WORKSPACES_COUNT];
uint32 fCurrentWorkspace; uint32 fCurrentWorkspace;
uint32 fCachedWsWidth; uint32 fCachedWsWidth;
uint32 fCachedWsHeight; uint32 fCachedWsHeight;
float fWind; float fWind;
bigtime_t fWindDuration; bigtime_t fWindDuration;
bool fAttached; bool fAttached;
BBitmap *fFlakeBitmaps[NUM_PATTERNS]; BBitmap *fFlakeBitmaps[NUM_PATTERNS];
thread_id fInvalidator; thread_id fInvalidator;
BView *fCachedParent; BView *fCachedParent;
BBitmap *fFallenBmp; BBitmap *fFallenBmp;
BView *fFallenView; BView *fFallenView;
BRegion *fFallenReg; BRegion *fFallenReg;
bool fShowClickMe; bool fShowClickMe;
}; };
#endif #endif