summaryrefslogtreecommitdiffstats
path: root/src/client/gui/OO_FLTK.cpp
diff options
context:
space:
mode:
authorJoursoir <chat@joursoir.net>2020-12-09 16:12:53 +0000
committerJoursoir <chat@joursoir.net>2020-12-09 16:12:53 +0000
commit1baf22ad58cc1a9aa9089ca9a09fc80a453cb3c9 (patch)
tree16bc9aa1391fb76a9f7d540485dc9b949799dbc9 /src/client/gui/OO_FLTK.cpp
parent27cd9aded215835ffde615153600476bf9be2473 (diff)
downloadwant-chat-1baf22ad58cc1a9aa9089ca9a09fc80a453cb3c9.tar.gz
want-chat-1baf22ad58cc1a9aa9089ca9a09fc80a453cb3c9.tar.bz2
want-chat-1baf22ad58cc1a9aa9089ca9a09fc80a453cb3c9.zip
gui: receive msg from server to chat and move it
Diffstat (limited to 'src/client/gui/OO_FLTK.cpp')
-rw-r--r--src/client/gui/OO_FLTK.cpp26
1 files changed, 17 insertions, 9 deletions
diff --git a/src/client/gui/OO_FLTK.cpp b/src/client/gui/OO_FLTK.cpp
index 9dc088d..a86ecd6 100644
--- a/src/client/gui/OO_FLTK.cpp
+++ b/src/client/gui/OO_FLTK.cpp
@@ -1,24 +1,27 @@
#include "OO_FLTK.hpp"
#include "../../const_vars.hpp"
+#include "Client.hpp"
-BoxOutline::BoxOutline(int x, int y, int w, int h, const char *lb)
+BoxBackground::BoxBackground(int x, int y, int w, int h,
+ const char *lb, Fl_Color clr)
: Fl_Box(x, y, w, h, lb)
{
box(FL_FLAT_BOX);
- color(FL_WHITE);
+ color(clr);
}
-ChatInput::ChatInput(int x, int y, int w, int h, const char *lb)
+ChatInput::ChatInput(int x, int y, int w, int h,
+ const char *lb, Client *user)
: Fl_Input(x, y, w, h, lb)
{
- callback(CallbackFunction, 0);
+ callback(CallbackFunction, (void *)user);
when(FL_WHEN_ENTER_KEY | FL_WHEN_NOT_CHANGED);
box(FL_FLAT_BOX);
color(FL_BLACK);
cursor_color(FL_WHITE);
- textfont(FL_COURIER);
+ textfont(STD_FONT);
textsize(20);
textcolor(FL_WHITE);
@@ -30,19 +33,24 @@ void ChatInput::SendMessage(void *user)
if(strlen(value()) < 1)
return;
- printf("SendMessage\n");
- // send message to server
+ Client *cl = (Client *)user;
+ if(cl != 0) { // send message to server
+ const char *message = value();
+ printf("U sent: %s\n", message);
+ cl->SendMessage(message);
+ }
+
value("");
take_focus();
}
ChatBaseOutput::ChatBaseOutput(int x, int y, int w, int h, const char *lb)
- : Fl_Multiline_Output(x, y, w, h, lb)
+ : Fl_Output(x, y, w, h, lb)
{
box(FL_FLAT_BOX);
color(FL_BLACK);
- textfont(FL_COURIER);
+ textfont(STD_FONT);
textsize(20);
textcolor(FL_WHITE);
} \ No newline at end of file