summaryrefslogtreecommitdiff
path: root/pico/osdep/mswin_tw.h
blob: 9ddfb5be00d5801fadfeafed024bf752076c267d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/*
 * ========================================================================
 * Copyright 2006-2007 University of Washington
 * Copyright 2013-2014 Eduardo Chappa
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * ========================================================================
 */
typedef struct MSWIN_TEXTWINDOW MSWIN_TEXTWINDOW;
typedef void (MSWIN_TW_CALLBACK)(MSWIN_TEXTWINDOW *mswin_tw);

typedef struct MSWIN_TEXTWINDOW
{
    // User should set these fields before calling mswin_tw_create()
    UINT            id;             // Caller can use to determine which
                                    // textwindow this is (Ie: IDM_OPT_NEWMAILWIN)
    HANDLE          hInstance;
    RECT            rcSize;         // Window position

    MSWIN_TW_CALLBACK *print_callback; // Print menu selected callback routine.
    MSWIN_TW_CALLBACK *close_callback; // Callback for when window is closed.
    MSWIN_TW_CALLBACK *clear_callback; // Callback after text is cleared.

    LPCTSTR         out_file;       // Save edit contents on close to this file.
    BOOL            out_file_ret;   // TRUE - out_file written, FALSE - nope.

    // internal fields
    HWND            hwnd;           // hwnd for this mswin textwindow.
    HWND            hwnd_edit;
} MSWIN_TEXTWINDOW;

int mswin_tw_create(MSWIN_TEXTWINDOW *mswin_tw, LPCTSTR title);
void mswin_tw_close(MSWIN_TEXTWINDOW *mswin_tw);

void mswin_tw_showwindow(MSWIN_TEXTWINDOW *mswin_tw, int nCmdShow);

BOOL mswin_tw_fill_from_file(MSWIN_TEXTWINDOW *mswin_tw, LPCTSTR file);
BOOL mswin_tw_write_to_file(MSWIN_TEXTWINDOW *mswin_tw, LPCTSTR file);

void mswin_tw_setfont(MSWIN_TEXTWINDOW *mswin_tw, HFONT hfont);
void mswin_tw_setcolor(MSWIN_TEXTWINDOW *mswin_tw,
    COLORREF TextColor, COLORREF BackColor);

int mswin_tw_puts_lptstr(MSWIN_TEXTWINDOW *mswin_tw, LPTSTR msg);
int mswin_tw_printf(MSWIN_TEXTWINDOW *mswin_tw, LPCTSTR fmt, ...);

UINT mswin_tw_gettext(MSWIN_TEXTWINDOW *mswin_tw, LPTSTR lptstr_ret, int lptstr_len);
UINT mswin_tw_gettextlength(MSWIN_TEXTWINDOW *mswin_tw);

void mswin_tw_setsel(MSWIN_TEXTWINDOW *mswin_tw, LONG min, LONG max);
void mswin_tw_clear(MSWIN_TEXTWINDOW *mswin_tw);

void mswin_set_readonly(MSWIN_TEXTWINDOW *mswin_tw, BOOL read_only);