Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed issues, improved the app in general #53

Closed
wants to merge 16 commits into from
Closed
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions source/AlarmView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,14 @@
*/

#include "AlarmView.h"
#include <Catalog.h>
#include <TranslationUtils.h>

#undef B_TRANSLATION_CONTEXT
#define B_TRANSLATION_CONTEXT "AlarmView"

// Constructor
AlarmView::AlarmView(BRect rect, char *name)
AlarmView::AlarmView(BRect rect, const char *name)
: BView(rect, name, B_FOLLOW_ALL, B_WILL_DRAW) {

}
Expand All @@ -27,7 +32,7 @@ void AlarmView :: AttachedToWindow() {
// Drawing the window
void AlarmView :: Draw (BRect updateRect) {
MovePenTo(BPoint(20.0, 20.0));
DrawString ("Insert time and date to set an alarm");
DrawString (B_TRANSLATE("Insert time and date to set an alarm"));
}


2 changes: 1 addition & 1 deletion source/AlarmView.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class AlarmView : public BView {

public:

AlarmView (BRect frame, char *name);
AlarmView (BRect frame, const char *name);
virtual void AttachedToWindow ();
virtual void Draw(BRect updateRect);
};
Expand Down
24 changes: 16 additions & 8 deletions source/AlarmWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@
#include <stdlib.h>
#include <stdio.h>

//translation
#include <Catalog.h>
#include <TranslationUtils.h>

#undef B_TRANSLATION_CONTEXT
#define B_TRANSLATION_CONTEXT "AlarmWindow"


// Messages
#define BUTTON_ALARM_OK 'alok'
#define BUTTON_ALARM_UNDO 'alun'
Expand All @@ -33,7 +41,7 @@
* It is created with the dimensions of BRect
*/
AlarmWindow :: AlarmWindow (BRect frame, BHandler *handler)
: BWindow (frame, "Set alarm for this note", B_TITLED_WINDOW,B_NOT_RESIZABLE) {
: BWindow (frame, B_TRANSLATE("Set alarm for this note"), B_TITLED_WINDOW,B_NOT_RESIZABLE) {
thaflo marked this conversation as resolved.
Show resolved Hide resolved

// Variables
fMessenger = new BMessenger(handler);
Expand All @@ -58,11 +66,11 @@ AlarmWindow :: AlarmWindow (BRect frame, BHandler *handler)
AddChild(fAlarmView);

// Text fields for the data
hour = new BTextControl(BRect(20,40,100,35), "hour", "hour:", hourDefaultField , NULL);
minute = new BTextControl(BRect(120,40,200,35), "minute", "min:", minuteDefaultField, NULL);
day = new BTextControl(BRect(20,100,100,35), "day", "day:", dayDefaultField, NULL);
month = new BTextControl(BRect(120,100,200,35), "month", "month:", monthDefaultField, NULL);
year = new BTextControl(BRect(220,100,300,35), "year", "year:", yearDefaultField, NULL);
hour = new BTextControl(BRect(20,40,100,35), B_TRANSLATE("hour"), B_TRANSLATE("hour:"), hourDefaultField , NULL);
minute = new BTextControl(BRect(120,40,200,35), B_TRANSLATE("minute"), B_TRANSLATE("min:"), minuteDefaultField, NULL);
day = new BTextControl(BRect(20,100,100,35), B_TRANSLATE("day"), B_TRANSLATE("day:"), dayDefaultField, NULL);
month = new BTextControl(BRect(120,100,200,35), B_TRANSLATE("month"), B_TRANSLATE("month:"), monthDefaultField, NULL);
year = new BTextControl(BRect(220,100,300,35), B_TRANSLATE("year"), B_TRANSLATE("year:"), yearDefaultField, NULL);

// Text field label: visible
hour -> SetDivider(hour->StringWidth("hour:") + 5);
Expand All @@ -72,8 +80,8 @@ AlarmWindow :: AlarmWindow (BRect frame, BHandler *handler)
year -> SetDivider(year->StringWidth("year:") + 5);

// Allocate the OK button
fButtonOk = new BButton (BRect(400,230,450,240),"ok", "Done", new BMessage(BUTTON_ALARM_OK));
fButtonUndo = new BButton (BRect(340,230,390,240),"undo","Undo",new BMessage(BUTTON_ALARM_UNDO));
fButtonOk = new BButton (BRect(400,230,450,240),"ok", B_TRANSLATE("Done"), new BMessage(BUTTON_ALARM_OK));
thaflo marked this conversation as resolved.
Show resolved Hide resolved
fButtonUndo = new BButton (BRect(340,230,390,240),"undo",B_TRANSLATE("Undo"),new BMessage(BUTTON_ALARM_UNDO));

// Making all the objects part of the view
fAlarmView->AddChild(hour);
Expand Down
9 changes: 8 additions & 1 deletion source/ChoiceView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@
#define BUTTON_OK 'btok'
#define BUTTON_UNDO 'btun'

//translation
#include <Catalog.h>
#include <TranslationUtils.h>

#undef B_TRANSLATION_CONTEXT
#define B_TRANSLATION_CONTEXT "ChoiceView"

// Constructor
ChoiceView :: ChoiceView(BRect rect, char *vname,BHandler *handler)
: BView(rect, vname, B_FOLLOW_ALL, B_WILL_DRAW | B_FRAME_EVENTS | B_FULL_UPDATE_ON_RESIZE){
Expand Down Expand Up @@ -100,7 +107,7 @@ ChoiceView :: ChoiceView(BRect rect, char *vname,BHandler *handler)
frame.top = frame.bottom - 40;
frame.right-= 90;
frame.bottom -= 10;
fUndoButton = new BButton(frame,"undo","Undo",new BMessage(BUTTON_UNDO));
fUndoButton = new BButton(frame,"undo",B_TRANSLATE("Undo"),new BMessage(BUTTON_UNDO));

frame = Bounds();
frame.left += 430;
Expand Down
10 changes: 8 additions & 2 deletions source/ColorView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,17 @@
#include "ColorView.h"
#include "StringView.h"

//translation
#include <Catalog.h>
#include <TranslationUtils.h>

#undef B_TRANSLATION_CONTEXT
#define B_TRANSLATION_CONTEXT "ColorWindow"
// Messages
#define COLOR_CHANGED 'ccrq'

// Constructor
ColorView :: ColorView(BRect rect, char *name,BHandler *handler)
ColorView :: ColorView(BRect rect, const char *name,BHandler *handler)
: BView(rect, name, B_FOLLOW_ALL, B_WILL_DRAW){
}

Expand All @@ -35,7 +41,7 @@ void ColorView :: Draw (BRect updateRect) {
// Variables
BStringView *instructions;
BRect frame(10,20,600,35);
const char *text = "Press the button to change the color";
const char *text = B_TRANSLATE("Change the color. It will be applied immediatly.");
thaflo marked this conversation as resolved.
Show resolved Hide resolved

instructions = new BStringView (frame, "instructions", text);
AddChild(instructions);
Expand Down
2 changes: 1 addition & 1 deletion source/ColorView.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class ColorView : public BView {

public:

ColorView (BRect frame, char *name, BHandler *handler);
ColorView (BRect frame, const char *name, BHandler *handler);
virtual void AttachedToWindow ();
virtual void Draw(BRect updateRect);
virtual void MouseDown(BPoint point);
Expand Down
58 changes: 33 additions & 25 deletions source/ColorWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,56 +8,67 @@
* Eleonora Ciceri
*
* Last revision: Eleonora Ciceri, 23th June 2009
*
* December 2020: thaflo: Change color directly (that's the Be way)
* Description: Window that is opened to change the background color
*/

#include "ColorWindow.h"
#include "NoteText.h"
#include <ColorControl.h>
#include <stdio.h>

// Libraries
#include <Alert.h>
#include <Button.h>

// Messages
#define COLOR_CHANGED 'ccrq'
#define BUTTON_OK 'btok'
#define BUTTON_UNDO 'btun'
#define BUTTON_DEFAULT 'btdf'
#define COLOR_CLOSE '_clc'
#define COLOR_CHOSEN '_cch'
#define COLOR 'colo'
#define SAVE 'save'

//translation
#include <Catalog.h>
#include <TranslationUtils.h>

#undef B_TRANSLATION_CONTEXT
#define B_TRANSLATION_CONTEXT "ColorWindow"

/*
* Constructor
* It is created with the dimensions of BRect
*/
ColorWindow :: ColorWindow (BRect frame, BHandler *handler)
: BWindow (frame, "Change the background color", B_TITLED_WINDOW,B_NOT_RESIZABLE) {
ColorWindow :: ColorWindow (BRect frame, BHandler *handler, rgb_color color)
: BWindow (frame, B_TRANSLATE("Change the background color"), B_TITLED_WINDOW, B_NOT_RESIZABLE) {

// Variables
BPoint leftTop(20.0, 50.0);
BPoint leftTop(10.0, 50.0);
color_control_layout matrix;
long cellSide;

BButton *okButton;
BButton *undoButton;

// Create the view and set the background color, then add child to window
thaflo marked this conversation as resolved.
Show resolved Hide resolved
frame.OffsetTo(B_ORIGIN);
fColorView = new ColorView (frame, "ColorView",handler);
fColorView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
fColorView->ResizeToPreferred();
AddChild(fColorView);

// Drawing...
fMessenger = new BMessenger(handler);

matrix = B_CELLS_16x16;
cellSide = 16;
matrix = B_CELLS_32x8;
cellSide = 9.0;

fColorControl = new BColorControl (leftTop, matrix, cellSide, "ColorControl");
fColorControl = new BColorControl (leftTop, matrix, cellSide, "ColorControl", new BMessage(COLOR_CHANGED));
fColorControl->SetValue(color);
fColorView -> AddChild(fColorControl);

okButton = new BButton (BRect(280, 320, 350, 350), "ok", "Change", new BMessage(BUTTON_OK));
fColorView -> AddChild(okButton);

undoButton = new BButton (BRect(200, 320, 270, 350), "undo", "Undo", new BMessage(BUTTON_UNDO));
undoButton = new BButton (BRect(10, 150, 170, 175), "default", B_TRANSLATE("Default"), new BMessage(BUTTON_DEFAULT));
undoButton->ResizeToPreferred();
fColorView -> AddChild(undoButton);

Show();
Expand All @@ -73,10 +84,7 @@ void ColorWindow :: MessageReceived (BMessage* message) {
message->PrintToStream();

switch (message -> what) {

// It answer to an OK request
case BUTTON_OK: {

case COLOR_CHANGED: {
// I catch the color that was chosen by the user
userColorChoice = fColorControl -> ValueAsColor();

Expand All @@ -86,19 +94,18 @@ void ColorWindow :: MessageReceived (BMessage* message) {
msg -> AddInt8 ("green", (int8)userColorChoice.green);
msg -> AddInt8 ("blue", (int8)userColorChoice.blue);
fMessenger->SendMessage(msg);
Quit();
}
break;
}
break;

// It answer to an UNDO request
case BUTTON_UNDO: {
case BUTTON_DEFAULT: {

alert = new BAlert("", "Latest changes will be discarded", "Yes", "No", NULL, B_WIDTH_AS_USUAL, B_WARNING_ALERT);
alert = new BAlert("", B_TRANSLATE("Set default values ?"), B_TRANSLATE("Yes"), B_TRANSLATE("No"), NULL, B_WIDTH_AS_USUAL, B_WARNING_ALERT);
thaflo marked this conversation as resolved.
Show resolved Hide resolved
alert->SetShortcut(0, B_ESCAPE);

if (alert->Go() == 0) {
// Discard all the changes
Quit();
fColorControl->SetValue(gBgColor);
this->PostMessage(COLOR_CHANGED);
}
}
break;
Expand All @@ -116,6 +123,7 @@ void ColorWindow :: Quit(){
BMessage *message;

// Inform NoteWindow that this window is going to be closed
fMessenger->SendMessage(message);
message = new BMessage (COLOR_CLOSE);
fMessenger->SendMessage(message);

Expand Down
4 changes: 3 additions & 1 deletion source/ColorWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,12 @@ class ColorWindow : public BWindow {

public:

ColorWindow(BRect frame, BHandler *handler);
ColorWindow(BRect frame, BHandler *handler, rgb_color);
virtual bool QuitRequested();
virtual void MessageReceived(BMessage*);
virtual void Quit();
const rgb_color gBgColor = {255,240,113};


private:

Expand Down
38 changes: 27 additions & 11 deletions source/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ TYPE= APP

# if you plan to use localization features
# specify the application MIME siganture
APP_MIME_SIG=
APP_MIME_SIG= application/x-vnd.TakeNotes

# add support for new Pe and Eddie features
# to fill in generic makefile
Expand All @@ -34,25 +34,41 @@ APP_MIME_SIG=
# if two source files with the same name (source.c or source.cpp)
# are included from different directories. Also note that spaces
# in folder names do not work well with this makefile.
SRCS= AlarmView.cpp AlarmWindow.cpp \
AppHashTable.cpp \
ChoiceView.cpp ChoiceWindow.cpp \
ColorMenuItem.cpp ColorView.cpp ColorWindow.cpp \
NoteApplication.cpp NoteRefFilter.cpp NoteText.cpp NoteView.cpp NoteWindow.cpp \
TagsWindow.cpp
SRCS = \
AlarmView.cpp \
AlarmWindow.cpp \
AppHashTable.cpp \
ChoiceView.cpp \
ChoiceWindow.cpp \
ColorMenuItem.cpp \
ColorView.cpp \
ColorWindow.cpp \
NoteApplication.cpp \
NoteRefFilter.cpp \
NoteText.cpp \
NoteView.cpp \
NoteWindow.cpp \
SettingsWindow.cpp \
TagsWindow.cpp \


# specify the resource definition files to use
# full path or a relative path to the resource file can be used.
RDEFS= TakeNotes.rdef
RDEFS = \
TakeNotes.rdef \
thaflo marked this conversation as resolved.
Show resolved Hide resolved


# specify the resource files to use.
# full path or a relative path to the resource file can be used.
# both RDEFS and RSRCS can be defined in the same makefile.
RSRCS=
RSRCS = \
thaflo marked this conversation as resolved.
Show resolved Hide resolved


# @<-src@
#%}

#%}

# end support for Pe and Eddie

# specify additional libraries to link against
Expand All @@ -71,7 +87,7 @@ RSRCS=
# naming scheme you need to specify the path to the library
# and it's name
# library: my_lib.a entry: my_lib.a or path/my_lib.a
LIBS= be tracker $(STDCPPLIBS)
LIBS= be localestub shared translation tracker $(STDCPPLIBS)

# specify additional paths to directories following the standard
# libXXX.so or libXXX.a naming scheme. You can specify full paths
Expand Down Expand Up @@ -101,7 +117,7 @@ OPTIMIZE=
# locales/en.catkeys file. Use it as template for creating other
# languages catkeys. All localization files must be placed
# in "locales" sub-directory.
LOCALES=
LOCALES= en de

# specify any preprocessor symbols to be defined. The symbols will not
# have their values set automatically; you must supply the value (if any)
Expand Down
Loading