74b437b1ea5c2fdc2df51cb4563b0f5cf38ae4c6
[tpg/acess2.git] / Usermode / Applications / axwin3_src / libaxwin3.so_src / r_richtext.c
1 /*
2  * AxWin3 Interface Library
3  * - By John Hodge (thePowersGang)
4  *
5  * r_richtext.c
6  * - Formatted Text window type
7  */
8 #include <axwin3/axwin.h>
9 #include <axwin3/richtext.h>
10 #include "include/internal.h"
11 #include <richtext_messages.h>
12
13 // === TYPES ===
14 typedef struct sRichText_Window
15 {
16         tAxWin3_RichText_KeyHandler     KeyCallback;
17         tAxWin3_RichText_MouseHandler   MouseCallback;
18         tAxWin3_RichText_LineHandler    LineHandler;
19 } tRichText_Window;
20
21 // === CODE ===
22 int AxWin3_RichText_MessageHandler(tHWND Window, int MessageID, int Size, void *Data)
23 {
24         return 0;
25 }
26
27 static void _SendAttrib(tHWND Window, int Attr, uint32_t Value)
28 {
29         struct sRichTextMsg_SetAttr     msg;
30         msg.Attr = Attr;
31         msg.Value = Value;
32         AxWin3_SendMessage(Window, Window, MSG_RICHTEXT_SETATTR, sizeof(msg), &msg);
33 }
34
35 tHWND AxWin3_RichText_CreateWindow(tHWND Parent, int Flags)
36 {
37         tHWND ret = AxWin3_CreateWindow(Parent, "RichText", Flags, sizeof(tRichText_Window), AxWin3_RichText_MessageHandler);
38 //      tRichText_Window *info = AxWin3_int_GetDataPtr(ret);
39         return ret;
40 }
41
42 void AxWin3_RichText_SetKeyHandler(tHWND Window, tAxWin3_RichText_KeyHandler Handler)
43 {
44         tRichText_Window        *info = AxWin3_int_GetDataPtr(Window);
45         info->KeyCallback = Handler;
46 }
47
48 void AxWin3_RichText_SetMouseHandler(tHWND Window, tAxWin3_RichText_MouseHandler Handler)
49 {
50         tRichText_Window        *info = AxWin3_int_GetDataPtr(Window);
51         info->MouseCallback = Handler;
52 }
53
54 void AxWin3_RichText_EnableScroll(tHWND Window, int bEnable)
55 {
56         _SendAttrib(Window, _ATTR_SCROLL, bEnable);
57 }
58 void AxWin3_RichText_SetLineCount(tHWND Window, int Lines)
59 {
60         _SendAttrib(Window, _ATTR_LINECOUNT, Lines);
61 }
62 void AxWin3_RichText_SetColCount(tHWND Window, int Cols)
63 {
64         _SendAttrib(Window, _ATTR_COLCOUNT, Cols);
65 }
66 void AxWin3_RichText_SetBackground(tHWND Window, uint32_t ARGB_Colour)
67 {
68         _SendAttrib(Window, _ATTR_DEFBG, ARGB_Colour);
69 }
70 void AxWin3_RichText_SetDefaultColour(tHWND Window, uint32_t ARGB_Colour)
71 {
72         _SendAttrib(Window, _ATTR_DEFFG, ARGB_Colour);
73 }
74 void AxWin3_RichText_SetFont(tHWND Window, const char *FontName, int PointSize)
75 {
76         // TODO: Send message
77 }
78 void AxWin3_RichText_SetCursorType(tHWND Window, int Type)
79 {
80         _SendAttrib(Window, _ATTR_CURSOR, Type);
81 }
82 void AxWin3_RichText_SetCursorBlink(tHWND Window, int bBlink)
83 {
84         _SendAttrib(Window, _ATTR_CURSORBLINK, bBlink);
85 }
86 void AxWin3_RichText_SetCursorPos(tHWND Window, int Row, int Column)
87 {
88         if(Row < 0 || Row > 0xFFFFF || Column > 0xFFF || Column < 0)
89                 return ;
90         _SendAttrib(Window, _ATTR_CURSORPOS, ((Row & 0xFFFFF) << 12) | (Column & 0xFFF));
91 }

UCC git Repository :: git.ucc.asn.au