13 | .
14 | E-mail: mailto:john.doe@gmail.com
15 | ````````````````````````````````
16 |
17 | With the permissive autolinks enabled, this is sufficient:
18 |
19 | ```````````````````````````````` example
20 | E-mail: john.doe@gmail.com
21 | .
22 | E-mail: john.doe@gmail.com
23 | ````````````````````````````````
24 |
25 | `+` can occur before the `@`, but not after.
26 |
27 | ```````````````````````````````` example
28 | hello@mail+xyz.example isn't valid, but hello+xyz@mail.example is.
29 | .
30 | hello@mail+xyz.example isn't valid, but hello+xyz@mail.example is.
31 | ````````````````````````````````
32 |
33 | `.`, `-`, and `_` can occur on both sides of the `@`, but only `.` may occur at
34 | the end of the email address, in which case it will not be considered part of
35 | the address:
36 |
37 | ```````````````````````````````` example
38 | a.b-c_d@a.b
39 |
40 | a.b-c_d@a.b.
41 |
42 | a.b-c_d@a.b-
43 |
44 | a.b-c_d@a.b_
45 | .
46 | a.b-c_d@a.b
47 | a.b-c_d@a.b.
48 | a.b-c_d@a.b-
49 | a.b-c_d@a.b_
50 | ````````````````````````````````
51 |
--------------------------------------------------------------------------------
/lib/md4c/test/permissive-url-autolinks.txt:
--------------------------------------------------------------------------------
1 |
2 | # Permissive URL Autolinks
3 |
4 | With the flag `MD_FLAG_PERMISSIVEURLAUTOLINKS`, MD4C enables more permissive recognition
5 | of URLs and transform them to autolinks, even if they do not exactly follow the syntax
6 | of autolink as specified in CommonMark specification.
7 |
8 | This is standard CommonMark autolink:
9 |
10 | ```````````````````````````````` example
11 | Homepage:
12 | .
13 | Homepage: https://github.com/mity/md4c
14 | ````````````````````````````````
15 |
16 | With the permissive autolinks enabled, this is sufficient:
17 |
18 | ```````````````````````````````` example
19 | Homepage: https://github.com/mity/md4c
20 | .
21 | Homepage: https://github.com/mity/md4c
22 | ````````````````````````````````
23 |
24 | But this permissive autolink feature can work only for very widely used URL
25 | schemes, in alphabetical order `ftp:`, `http:`, `https:`.
26 |
27 | That's why this is not a permissive autolink:
28 |
29 | ```````````````````````````````` example
30 | ssh://root@example.com
31 | .
32 | ssh://root@example.com
33 | ````````````````````````````````
34 |
35 | The same rules for path validation as for permissivve WWW autolinks apply.
36 | Therefore the final question mark here is not part of the autolink:
37 |
38 | ```````````````````````````````` example
39 | Have you ever visited http://www.zombo.com?
40 | .
41 | Have you ever visited http://www.zombo.com?
42 | ````````````````````````````````
43 |
44 | But in contrast, in this example it is:
45 |
46 | ```````````````````````````````` example
47 | http://www.bing.com/search?q=md4c
48 | .
49 | http://www.bing.com/search?q=md4c
50 | ````````````````````````````````
51 |
52 | And finally one complex example:
53 |
54 | ```````````````````````````````` example
55 | http://commonmark.org
56 |
57 | (Visit https://encrypted.google.com/search?q=Markup+(business))
58 |
59 | Anonymous FTP is available at ftp://foo.bar.baz.
60 | .
61 | http://commonmark.org
62 | (Visit https://encrypted.google.com/search?q=Markup+(business))
63 | Anonymous FTP is available at ftp://foo.bar.baz.
64 | ````````````````````````````````
65 |
66 |
67 | ## GitHub Issues
68 |
69 | ### [Issue 53](https://github.com/mity/md4c/issues/53)
70 |
71 | ```````````````````````````````` example
72 | This is [link](http://github.com/).
73 | .
74 | This is link.
75 | ````````````````````````````````
76 |
77 | ```````````````````````````````` example
78 | This is [link](http://github.com/)X
79 | .
80 | This is linkX
81 | ````````````````````````````````
82 |
83 |
84 | ## [Issue 76](https://github.com/mity/md4c/issues/76)
85 |
86 | ```````````````````````````````` example
87 | *(http://example.com)*
88 | .
89 | (http://example.com)
90 | ````````````````````````````````
91 |
92 |
93 |
--------------------------------------------------------------------------------
/lib/md4c/test/strikethrough.txt:
--------------------------------------------------------------------------------
1 |
2 | # Strike-Through
3 |
4 | With the flag `MD_FLAG_STRIKETHROUGH`, MD4C enables extension for recognition
5 | of strike-through spans.
6 |
7 | Strike-through text is any text wrapped in one or two tildes (`~`).
8 |
9 | ```````````````````````````````` example
10 | ~Hi~ Hello, world!
11 | .
12 | Hi Hello, world!
13 | ````````````````````````````````
14 |
15 | If the length of the opener and closer doesn't match, the strike-through is
16 | not recognized.
17 |
18 | ```````````````````````````````` example
19 | This ~text~~ is curious.
20 | .
21 | This ~text~~ is curious.
22 | ````````````````````````````````
23 |
24 | Too long tilde sequence won't be recognized:
25 |
26 | ```````````````````````````````` example
27 | foo ~~~bar~~~
28 | .
29 | foo ~~~bar~~~
30 | ````````````````````````````````
31 |
32 | Also note the markers cannot open a strike-through span if they are followed
33 | with a whitespace; and similarly, then cannot close the span if they are
34 | preceded with a whitespace:
35 |
36 | ```````````````````````````````` example
37 | ~foo ~bar
38 | .
39 | ~foo ~bar
40 | ````````````````````````````````
41 |
42 |
43 | As with regular emphasis delimiters, a new paragraph will cause the cessation
44 | of parsing a strike-through:
45 |
46 | ```````````````````````````````` example
47 | This ~~has a
48 |
49 | new paragraph~~.
50 | .
51 | This ~~has a
52 | new paragraph~~.
53 | ````````````````````````````````
54 |
55 |
56 | ## GitHub Issues
57 |
58 | ### [Issue 69](https://github.com/mity/md4c/issues/69)
59 | ```````````````````````````````` example
60 | ~`foo`~
61 | .
62 | foo
63 | ````````````````````````````````
64 |
65 | ```````````````````````````````` example
66 | ~*foo*~
67 | .
68 | foo
69 | ````````````````````````````````
70 |
71 | ```````````````````````````````` example
72 | *~foo~*
73 | .
74 | foo
75 | ````````````````````````````````
76 |
--------------------------------------------------------------------------------
/lib/md4c/test/underline.txt:
--------------------------------------------------------------------------------
1 |
2 | # Underline
3 |
4 | With the flag `MD_FLAG_UNDERLINE`, MD4C sees underscore `_` rather as a mark
5 | denoting an underlined span rather then an ordinary emphasis (or a strong
6 | emphasis).
7 |
8 | ```````````````````````````````` example
9 | _foo_
10 | .
11 | foo
12 | ````````````````````````````````
13 |
14 | In sequences of multiple underscores, each single one translates into an
15 | underline span mark.
16 |
17 | ```````````````````````````````` example
18 | ___foo___
19 | .
20 | foo
21 | ````````````````````````````````
22 |
23 | Intra-word underscores are not recognized as underline marks:
24 |
25 | ```````````````````````````````` example
26 | foo_bar_baz
27 | .
28 | foo_bar_baz
29 | ````````````````````````````````
30 |
31 | Also the parser follows the standard understanding when the underscore can
32 | or cannot open or close a span. Therefore there is no underline in the following
33 | example because no underline can be seen as a closing mark.
34 |
35 | ```````````````````````````````` example
36 | _foo _bar
37 | .
38 | _foo _bar
39 | ````````````````````````````````
40 |
--------------------------------------------------------------------------------
/misc/coverity-scan-model.c:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2014 Martin Mitas
3 | *
4 | * Model file to eliminate various false positives, when performing static
5 | * code analyzes of mCtrl source code with Coverity scan.
6 | * (See http://scan.coverity.com)
7 | */
8 |
9 |
10 | /*******************************
11 | *** _malloca() and _freea() ***
12 | *******************************/
13 |
14 | /* Convince Coverity _malloca() is same as malloc()
15 | * (However _malloca() is a macro so we have to redefine inline functions
16 | * it is based on) */
17 | void* _MarkAllocaS(void* ptr, unsigned int marker) { return ptr; }
18 | void* alloca(size_t size) { return __coverity_alloc__(size); }
19 |
20 | /* Convince Coverity _freea() is same as free() */
21 | void _freea(void* ptr) { __coverity_free__(ptr); }
22 |
23 |
24 | /************************
25 | *** Unreachable code ***
26 | ************************/
27 |
28 | /* These are done when an assertion fails (MC_ASSERT). */
29 | void DebugBreak(void) { __coverity_panic__(); }
30 | void exit(int exitcode) { __coverity_panic__(); }
31 |
32 | /* This is gcc way to mark unreachable code path (MC_UNREACHABLE). */
33 | void __builtin_unreachable() { __coverity_panic__(); }
34 |
--------------------------------------------------------------------------------
/scripts/coverity.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # This scripts attempts to build the project via cov-build utility, and prepare
4 | # a package for uploading to the coverity scan service.
5 | #
6 | # (See http://scan.coverity.com for more info.)
7 |
8 | set -e
9 |
10 | # Check presence of coverity static analyzer.
11 | if ! which cov-build; then
12 | echo "Utility cov-build not found in PATH."
13 | exit 1
14 | fi
15 |
16 | # Choose a build system (ninja or GNU make).
17 | if which ninja; then
18 | BUILD_TOOL=ninja
19 | GENERATOR=Ninja
20 | elif which make; then
21 | BUILD_TOOL=make
22 | GENERATOR="MSYS Makefiles"
23 | else
24 | echo "No suitable build system found."
25 | exit 1
26 | fi
27 |
28 | # Choose a zip tool.
29 | if which 7za; then
30 | MKZIP="7za a -r -mx9"
31 | elif which 7z; then
32 | MKZIP="7z a -r -mx9"
33 | elif which zip; then
34 | MKZIP="zip -r"
35 | else
36 | echo "No suitable zip utility found"
37 | exit 1
38 | fi
39 |
40 | # Change dir to project root.
41 | cd `dirname "$0"`/..
42 |
43 | CWD=`pwd`
44 | ROOT_DIR="$CWD"
45 | BUILD_DIR="$CWD/coverity"
46 | OUTPUT="$CWD/cov-int.zip"
47 |
48 | # Sanity checks.
49 | if [ ! -x "$ROOT_DIR/scripts/coverity.sh" ]; then
50 | echo "There is some path mismatch."
51 | exit 1
52 | fi
53 | if [ -e "$BUILD_DIR" ]; then
54 | echo "Path $BUILD_DIR already exists. Delete it and retry."
55 | exit 1
56 | fi
57 | if [ -e "$OUTPUT" ]; then
58 | echo "Path $OUTPUT already exists. Delete it and retry."
59 | exit 1
60 | fi
61 |
62 | # Build the project with the coverity analyzes enabled.
63 | mkdir -p "$BUILD_DIR"
64 | cd "$BUILD_DIR"
65 | cmake -G "$GENERATOR" "$ROOT_DIR"
66 | cov-build --dir cov-int "$BUILD_TOOL"
67 | $MKZIP "$OUTPUT" "cov-int"
68 | cd "$ROOT_DIR"
69 | rm -rf "$BUILD_DIR"
70 |
71 |
--------------------------------------------------------------------------------
/src/anim.c:
--------------------------------------------------------------------------------
1 | /*
2 | * mCtrl: Additional Win32 controls
3 | *
4 | *
5 | *
6 | * Copyright (c) 2015-2020 Martin Mitas
7 | *
8 | * This library is free software; you can redistribute it and/or modify it
9 | * under the terms of the GNU Lesser General Public License as published by
10 | * the Free Software Foundation; either version 2.1 of the License, or
11 | * (at your option) any later version.
12 | *
13 | * This library is distributed in the hope that it will be useful,
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | * GNU Lesser General Public License for more details.
17 | *
18 | * You should have received a copy of the GNU Lesser General Public License
19 | * along with this library; if not, write to the Free Software Foundation,
20 | * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 | */
22 |
23 | #include "anim.h"
24 |
25 |
26 | static inline int
27 | anim_time_cmp(DWORD t1, DWORD t2)
28 | {
29 | return (int32_t) t1 - (int32_t) t2;
30 | }
31 |
32 |
33 | anim_t* anim_start_ex(HWND win, DWORD duration, DWORD freq,
34 | void* extra_bytes, size_t extra_size)
35 | {
36 | anim_t* anim;
37 |
38 | anim = (anim_t*) malloc(sizeof(anim_t) + extra_size);
39 | if(MC_ERR(anim == NULL)) {
40 | MC_TRACE("anim_start_ex: malloc() failed.");
41 | return NULL;
42 | }
43 |
44 | anim->win = win;
45 | if(extra_size > 0)
46 | memcpy(anim+1, extra_bytes, extra_size);
47 |
48 | anim->time_start = GetTickCount();
49 | anim->time_prev_frame = anim->time_start;
50 | anim->time_curr_frame = anim->time_start;
51 | anim->time_end = anim->time_start + duration;
52 |
53 | if(MC_ERR(SetTimer(win, (UINT_PTR) anim, 1000 / freq, NULL) == 0)) {
54 | MC_TRACE_ERR("anim_start_ex: SetTimer() failed.");
55 | free(anim);
56 | return NULL;
57 | }
58 |
59 | return anim;
60 | }
61 |
62 | BOOL
63 | anim_step(anim_t* anim)
64 | {
65 | BOOL check_end = (anim->time_start != anim->time_end);
66 | DWORD now;
67 |
68 | now = GetTickCount();
69 | if(check_end && anim_time_cmp(now, anim->time_end) > 0)
70 | now = anim->time_end;
71 |
72 | anim->time_prev_frame = anim->time_curr_frame;
73 | anim->time_curr_frame = now;
74 |
75 | if(check_end)
76 | return (anim_time_cmp(now, anim->time_end) < 0);
77 | else
78 | return TRUE;
79 | }
80 |
81 | BOOL
82 | anim_is_done(anim_t* anim)
83 | {
84 | return (anim_time_cmp(anim->time_curr_frame, anim->time_end) >= 0);
85 | }
86 |
87 | void
88 | anim_stop(anim_t* anim)
89 | {
90 | KillTimer(anim->win, (UINT_PTR) anim);
91 | free(anim);
92 | }
93 |
--------------------------------------------------------------------------------
/src/button.h:
--------------------------------------------------------------------------------
1 | /*
2 | * mCtrl: Additional Win32 controls
3 | *
4 | *
5 | *
6 | * Copyright (c) 2009-2020 Martin Mitas
7 | *
8 | * This library is free software; you can redistribute it and/or modify it
9 | * under the terms of the GNU Lesser General Public License as published by
10 | * the Free Software Foundation; either version 2.1 of the License, or
11 | * (at your option) any later version.
12 | *
13 | * This library is distributed in the hope that it will be useful,
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | * GNU Lesser General Public License for more details.
17 | *
18 | * You should have received a copy of the GNU Lesser General Public License
19 | * along with this library; if not, write to the Free Software Foundation,
20 | * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 | */
22 |
23 | #ifndef MC_BUTTON_H
24 | #define MC_BUTTON_H
25 |
26 | #include "mCtrl/button.h"
27 | #include "misc.h"
28 |
29 |
30 | #endif /* MC_BUTTON_H */
31 |
--------------------------------------------------------------------------------
/src/chart.h:
--------------------------------------------------------------------------------
1 | /*
2 | * mCtrl: Additional Win32 controls
3 | *
4 | *
5 | *
6 | * Copyright (c) 2020 Martin Mitas
7 | *
8 | * This library is free software; you can redistribute it and/or modify it
9 | * under the terms of the GNU Lesser General Public License as published by
10 | * the Free Software Foundation; either version 2.1 of the License, or
11 | * (at your option) any later version.
12 | *
13 | * This library is distributed in the hope that it will be useful,
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | * GNU Lesser General Public License for more details.
17 | *
18 | * You should have received a copy of the GNU Lesser General Public License
19 | * along with this library; if not, write to the Free Software Foundation,
20 | * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 | */
22 |
23 | #ifndef MC_CHART_H
24 | #define MC_CHART_H
25 |
26 | #include "mCtrl/chart.h"
27 | #include "misc.h"
28 |
29 |
30 | #endif /* MC_CHART_H */
31 |
--------------------------------------------------------------------------------
/src/color.c:
--------------------------------------------------------------------------------
1 | /*
2 | * mCtrl: Additional Win32 controls
3 | *
4 | *
5 | *
6 | * Copyright (c) 2012-2020 Martin Mitas
7 | *
8 | * This library is free software; you can redistribute it and/or modify it
9 | * under the terms of the GNU Lesser General Public License as published by
10 | * the Free Software Foundation; either version 2.1 of the License, or
11 | * (at your option) any later version.
12 | *
13 | * This library is distributed in the hope that it will be useful,
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | * GNU Lesser General Public License for more details.
17 | *
18 | * You should have received a copy of the GNU Lesser General Public License
19 | * along with this library; if not, write to the Free Software Foundation,
20 | * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 | */
22 |
23 | #include "color.h"
24 | #include "hsluv.h"
25 |
26 | #include
27 |
28 |
29 | COLORREF
30 | color_seq(UINT index)
31 | {
32 | double h, s, l;
33 | double r, g, b;
34 |
35 | /* We generate hue by a method of pie cutting. Initially we cut 3 times
36 | * (red, green and blue), and then in N-th round we cut 3*(2^N) times,
37 | * just between each two neighbor cuts from the set of all cuts already
38 | * made in previous rounds.
39 | *
40 | * We also mix up the cuts of each round by cycling between 3 segments
41 | * of the color cycle (0-120, 120-240 and 240-360 degrees).
42 | */
43 | if(index < 3) {
44 | h = 120.0 * index;
45 | } else {
46 | int base, i;
47 |
48 | base = 3 * mc_round_down_to_power_of_two_32((int32_t)(index / 3));
49 | i = index - base;
50 | h = 180.0 / base + (double)(i/3) * (360.0/base) + (double)(i%3) * 120.0;
51 | }
52 |
53 | s = 80.0 + 20.0 * cos(index / 4.2);
54 | l = 50.0 + 30.0 * sin(index / 3.2);
55 |
56 | hsluv2rgb(h, s, l, &r, &g, &b);
57 | return RGB(255.0 * r, 255.0 * g, 255.0 * b);
58 | }
59 |
60 | COLORREF
61 | color_hint(COLORREF color)
62 | {
63 | double r, g, b;
64 | double h, s, l;
65 |
66 | r = GetRValue(color) / 255.0;
67 | g = GetGValue(color) / 255.0;
68 | b = GetBValue(color) / 255.0;
69 |
70 | rgb2hsluv(r, g, b, &h, &s, &l);
71 | l = (l + 100.0) / 2.0;
72 | s = s / 2.0;
73 | hsluv2rgb(h, s, l, &r, &g, &b);
74 | return RGB(255.0 * r, 255.0 * g, 255.0 * b);
75 | }
76 |
--------------------------------------------------------------------------------
/src/color.h:
--------------------------------------------------------------------------------
1 | /*
2 | * mCtrl: Additional Win32 controls
3 | *
4 | *
5 | *
6 | * Copyright (c) 2012-2020 Martin Mitas
7 | *
8 | * This library is free software; you can redistribute it and/or modify it
9 | * under the terms of the GNU Lesser General Public License as published by
10 | * the Free Software Foundation; either version 2.1 of the License, or
11 | * (at your option) any later version.
12 | *
13 | * This library is distributed in the hope that it will be useful,
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | * GNU Lesser General Public License for more details.
17 | *
18 | * You should have received a copy of the GNU Lesser General Public License
19 | * along with this library; if not, write to the Free Software Foundation,
20 | * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 | */
22 |
23 | #ifndef MC_COLOR_H
24 | #define MC_COLOR_H
25 |
26 | #include "misc.h"
27 |
28 |
29 | COLORREF color_seq(UINT index);
30 |
31 | COLORREF color_hint(COLORREF color);
32 |
33 |
34 | #endif /* MC_COLOR_H */
35 |
--------------------------------------------------------------------------------
/src/comua.h:
--------------------------------------------------------------------------------
1 | /*
2 | * mCtrl: Additional Win32 controls
3 | *
4 | *
5 | *
6 | * Copyright (c) 2020 Martin Mitas
7 | *
8 | * This library is free software; you can redistribute it and/or modify it
9 | * under the terms of the GNU Lesser General Public License as published by
10 | * the Free Software Foundation; either version 2.1 of the License, or
11 | * (at your option) any later version.
12 | *
13 | * This library is distributed in the hope that it will be useful,
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | * GNU Lesser General Public License for more details.
17 | *
18 | * You should have received a copy of the GNU Lesser General Public License
19 | * along with this library; if not, write to the Free Software Foundation,
20 | * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 | */
22 |
23 | #ifndef MC_COMUA_H
24 | #define MC_COMUA_H
25 |
26 | #include "misc.h"
27 | #include "c-reusables/data/buffer.h"
28 |
29 |
30 | /* COMUA == Compressed UINTs Array
31 | *
32 | * Sometimes we need to store many UINTs (e.g. some offsets) which generally
33 | * tend to be rather small, but we need to be ready even for the case when they
34 | * are big.
35 | *
36 | * This is a specialized storage for some data.
37 | *
38 | * When building the storage, we use BUFFER. When done, caller may then use
39 | * e.g. buffer_acquire() or copy the data elsewhere, so the reading functions
40 | * take a pointer to the data instead.
41 | */
42 |
43 | /* Use this to mark "main" or "first" mumbers in multi-number records.
44 | * comua_bsearch() considers only these. */
45 | #define COMUA_FLAG_RECORD_LEADER 0x1
46 |
47 | int comua_append(BUFFER* buffer, uint64_t num, DWORD flags);
48 |
49 | /* Read a number at the given offsets. Caller is responsible to make sure
50 | * the data points into the COMUA-compatible buffer, to the first byte of
51 | * an encoded integer. */
52 | uint64_t comua_read(const void* data, size_t size, size_t offset, size_t* p_end_offset);
53 |
54 | /* Binary search in COMUA of the given size. Note the function considers
55 | * only numbers which where marked with COMUA_FLAG_IS_LEADER as potential
56 | * candidates of the search.
57 | *
58 | * Note the function can iterate back byte by byte to find the nearest leader,
59 | * therefore:
60 | * (1) All the "records" should be reasonably short if you want to use this.
61 | * (2) The very 1st number in the COMUA must be leader.
62 | *
63 | * On success, the return value is an offset of the matching record.
64 | * On failure, ((size_t) -1) is returned.
65 | */
66 | size_t comua_bsearch(const void* data, size_t size, const void* key,
67 | int (*cmp_func)(const void* /*key*/, const void* /*data*/,
68 | size_t /*data_len*/, size_t /*offset*/));
69 |
70 |
71 | #endif /* MC_COMUA_H */
72 |
--------------------------------------------------------------------------------
/src/dialog.h:
--------------------------------------------------------------------------------
1 | /*
2 | * mCtrl: Additional Win32 controls
3 | *
4 | *
5 | *
6 | * Copyright (c) 2012-2020 Martin Mitas
7 | *
8 | * This library is free software; you can redistribute it and/or modify it
9 | * under the terms of the GNU Lesser General Public License as published by
10 | * the Free Software Foundation; either version 2.1 of the License, or
11 | * (at your option) any later version.
12 | *
13 | * This library is distributed in the hope that it will be useful,
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | * GNU Lesser General Public License for more details.
17 | *
18 | * You should have received a copy of the GNU Lesser General Public License
19 | * along with this library; if not, write to the Free Software Foundation,
20 | * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 | */
22 |
23 | #ifndef MC_DIALOG_H
24 | #define MC_DIALOG_H
25 |
26 | #include "misc.h"
27 | #include "mCtrl/dialog.h"
28 |
29 |
30 |
31 |
32 |
33 | #endif /* MC_DIALOG_H */
34 |
--------------------------------------------------------------------------------
/src/doublebuffer.c:
--------------------------------------------------------------------------------
1 | /*
2 | * mCtrl: Additional Win32 controls
3 | *
4 | *
5 | *
6 | * Copyright (c) 2015-2020 Martin Mitas
7 | *
8 | * This library is free software; you can redistribute it and/or modify it
9 | * under the terms of the GNU Lesser General Public License as published by
10 | * the Free Software Foundation; either version 2.1 of the License, or
11 | * (at your option) any later version.
12 | *
13 | * This library is distributed in the hope that it will be useful,
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | * GNU Lesser General Public License for more details.
17 | *
18 | * You should have received a copy of the GNU Lesser General Public License
19 | * along with this library; if not, write to the Free Software Foundation,
20 | * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 | */
22 |
23 | #include "doublebuffer.h"
24 |
25 |
26 | void
27 | doublebuffer_init(void)
28 | {
29 | BufferedPaintInit();
30 | }
31 |
32 | void
33 | doublebuffer_fini(void)
34 | {
35 | BufferedPaintUnInit();
36 | }
37 |
38 | void
39 | doublebuffer(void* control, PAINTSTRUCT* ps, doublebuffer_callback_t callback)
40 | {
41 | BP_PAINTPARAMS params = { sizeof(BP_PAINTPARAMS), BPPF_NOCLIP, NULL, NULL };
42 | HPAINTBUFFER paint_buffer;
43 | HDC dc;
44 |
45 | paint_buffer = BeginBufferedPaint(ps->hdc, &ps->rcPaint, BPBF_TOPDOWNDIB, ¶ms, &dc);
46 | if(paint_buffer != NULL) {
47 | callback(control, dc, &ps->rcPaint, TRUE);
48 | EndBufferedPaint(paint_buffer, TRUE);
49 | } else {
50 | MC_TRACE("doublebuffer: BeginBufferedPaint() failed.");
51 | /* We shall painting directly, without the double-buffering. */
52 | callback(control, ps->hdc, &ps->rcPaint, ps->fErase);
53 | }
54 | }
55 |
56 |
--------------------------------------------------------------------------------
/src/doublebuffer.h:
--------------------------------------------------------------------------------
1 | /*
2 | * mCtrl: Additional Win32 controls
3 | *
4 | *
5 | *
6 | * Copyright (c) 2015-2020 Martin Mitas
7 | *
8 | * This library is free software; you can redistribute it and/or modify it
9 | * under the terms of the GNU Lesser General Public License as published by
10 | * the Free Software Foundation; either version 2.1 of the License, or
11 | * (at your option) any later version.
12 | *
13 | * This library is distributed in the hope that it will be useful,
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | * GNU Lesser General Public License for more details.
17 | *
18 | * You should have received a copy of the GNU Lesser General Public License
19 | * along with this library; if not, write to the Free Software Foundation,
20 | * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 | */
22 |
23 | #ifndef MC_DOUBLEBUFFER_H
24 | #define MC_DOUBLEBUFFER_H
25 |
26 | #include "misc.h"
27 |
28 |
29 | typedef struct doublebuffer_tag doublebuffer_t;
30 | struct doublebuffer_tag {
31 | HPAINTBUFFER uxtheme_buf;
32 | };
33 |
34 | /* Every thread using double buffering should call this.
35 | * (Usually we do this by calling doublebuffer_init() from control's
36 | * WM_NCCREATE and doublebuffer_fini() from WM_NCDESTROY). */
37 | void doublebuffer_init(void);
38 | void doublebuffer_fini(void);
39 |
40 | /* Simple wrapper for double-buffering controls */
41 | typedef void (*doublebuffer_callback_t)(void* /*control_data*/, HDC /*dc*/,
42 | RECT* /*dirty_rect*/, BOOL /*erase*/);
43 |
44 | void doublebuffer(void* control, PAINTSTRUCT* ps, doublebuffer_callback_t callback);
45 |
46 |
47 | #endif /* MC_DOUBLEBUFFER_H */
48 |
--------------------------------------------------------------------------------
/src/dsa.h:
--------------------------------------------------------------------------------
1 | /*
2 | * mCtrl: Additional Win32 controls
3 | *
4 | *
5 | *
6 | * Copyright (c) 2011-2020 Martin Mitas
7 | *
8 | * This library is free software; you can redistribute it and/or modify it
9 | * under the terms of the GNU Lesser General Public License as published by
10 | * the Free Software Foundation; either version 2.1 of the License, or
11 | * (at your option) any later version.
12 | *
13 | * This library is distributed in the hope that it will be useful,
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | * GNU Lesser General Public License for more details.
17 | *
18 | * You should have received a copy of the GNU Lesser General Public License
19 | * along with this library; if not, write to the Free Software Foundation,
20 | * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 | */
22 |
23 | #ifndef MC_DSA_H
24 | #define MC_DSA_H
25 |
26 | #include "misc.h"
27 |
28 |
29 | typedef struct dsa_tag dsa_t;
30 | struct dsa_tag {
31 | void* buffer;
32 | WORD item_size;
33 | WORD size;
34 | WORD capacity;
35 | };
36 |
37 | /* destructor */
38 | typedef void (*dsa_dtor_t)(dsa_t*, void*);
39 |
40 |
41 | static inline WORD
42 | dsa_size(dsa_t* dsa)
43 | {
44 | return dsa->size;
45 | }
46 |
47 | static inline WORD
48 | dsa_index(dsa_t* dsa, const void* item)
49 | {
50 | return (int) (((BYTE*)item - (BYTE*)dsa->buffer) / dsa->item_size);
51 | }
52 |
53 | static inline void*
54 | dsa_item(dsa_t* dsa, WORD index)
55 | {
56 | return (void*)&((BYTE*)dsa->buffer)[index * dsa->item_size];
57 | }
58 |
59 | /* This is harder to use, but it should lead to better optimization.
60 | * (Assuming item_size is a constant known at compile time.) */
61 | static inline void*
62 | dsa_item_(dsa_t* dsa, WORD index, WORD item_size)
63 | {
64 | return (void*)&((BYTE*)dsa->buffer)[index * item_size];
65 | }
66 |
67 | #define DSA_ITEM(dsa, index, type) \
68 | ((type*) dsa_item_((dsa), (index), sizeof(type)))
69 |
70 |
71 | void dsa_init(dsa_t* dsa, WORD item_size);
72 | void dsa_fini(dsa_t* dsa, dsa_dtor_t dtor_func);
73 |
74 | int dsa_reserve(dsa_t* dsa, WORD size);
75 |
76 | void* dsa_insert_raw(dsa_t* dsa, WORD index);
77 | int dsa_insert(dsa_t* dsa, WORD index, void* item);
78 | void dsa_remove(dsa_t* dsa, WORD index, dsa_dtor_t dtor_func);
79 | void dsa_clear(dsa_t* dsa, dsa_dtor_t dtor_func);
80 |
81 | /* Move an item to the new position. */
82 | void dsa_move(dsa_t* dsa, WORD old_index, WORD new_index);
83 |
84 |
85 | #endif /* MC_DSA_H */
86 |
--------------------------------------------------------------------------------
/src/entity.h:
--------------------------------------------------------------------------------
1 | /*
2 | * mCtrl: Additional Win32 controls
3 | *
4 | *
5 | *
6 | * Copyright (c) 2020 Martin Mitas
7 | *
8 | * This library is free software; you can redistribute it and/or modify it
9 | * under the terms of the GNU Lesser General Public License as published by
10 | * the Free Software Foundation; either version 2.1 of the License, or
11 | * (at your option) any later version.
12 | *
13 | * This library is distributed in the hope that it will be useful,
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | * GNU Lesser General Public License for more details.
17 | *
18 | * You should have received a copy of the GNU Lesser General Public License
19 | * along with this library; if not, write to the Free Software Foundation,
20 | * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 | */
22 |
23 | #ifndef MC_ENTITY_H
24 | #define MC_ENTITY_H
25 |
26 | #include "misc.h"
27 |
28 |
29 | typedef struct entity_tag entity_t;
30 | struct entity_tag {
31 | WCHAR buffer[8];
32 | size_t len;
33 | };
34 |
35 |
36 | /* Note: the name should point to the 1st letter after '&'. The string does not
37 | * need to be zero-terminated but its last character has to be semicolon. */
38 | int entity_decode(const TCHAR* name, entity_t* ent);
39 |
40 |
41 | #endif /* MC_ENTITY_H */
42 |
--------------------------------------------------------------------------------
/src/expand.h:
--------------------------------------------------------------------------------
1 | /*
2 | * mCtrl: Additional Win32 controls
3 | *
4 | *
5 | *
6 | * Copyright (c) 2012-2020 Martin Mitas
7 | *
8 | * This library is free software; you can redistribute it and/or modify it
9 | * under the terms of the GNU Lesser General Public License as published by
10 | * the Free Software Foundation; either version 2.1 of the License, or
11 | * (at your option) any later version.
12 | *
13 | * This library is distributed in the hope that it will be useful,
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | * GNU Lesser General Public License for more details.
17 | *
18 | * You should have received a copy of the GNU Lesser General Public License
19 | * along with this library; if not, write to the Free Software Foundation,
20 | * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 | */
22 |
23 | #ifndef MC_EXPAND_H
24 | #define MC_EXPAND_H
25 |
26 | #include "mCtrl/expand.h"
27 | #include "misc.h"
28 |
29 |
30 | #endif /* MC_EXPAND_H */
31 |
--------------------------------------------------------------------------------
/src/generic.h:
--------------------------------------------------------------------------------
1 | /*
2 | * mCtrl: Additional Win32 controls
3 | *
4 | *
5 | *
6 | * Copyright (c) 2014-2020 Martin Mitas
7 | *
8 | * This library is free software; you can redistribute it and/or modify it
9 | * under the terms of the GNU Lesser General Public License as published by
10 | * the Free Software Foundation; either version 2.1 of the License, or
11 | * (at your option) any later version.
12 | *
13 | * This library is distributed in the hope that it will be useful,
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | * GNU Lesser General Public License for more details.
17 | *
18 | * You should have received a copy of the GNU Lesser General Public License
19 | * along with this library; if not, write to the Free Software Foundation,
20 | * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 | */
22 |
23 | #ifndef MC_GENERIC_H
24 | #define MC_GENERIC_H
25 |
26 | #include "misc.h"
27 | #include "doublebuffer.h"
28 |
29 |
30 | /* "Generic" implementations of some standard control messages. */
31 |
32 | static inline LRESULT
33 | generic_paint(HWND win, BOOL no_redraw, BOOL do_doublebuffer,
34 | void (*func_paint)(void*, HDC, RECT*, BOOL),
35 | void* ctrl)
36 | {
37 | PAINTSTRUCT ps;
38 |
39 | BeginPaint(win, &ps);
40 | if(!no_redraw) {
41 | if(do_doublebuffer)
42 | doublebuffer(ctrl, &ps, func_paint);
43 | else
44 | func_paint(ctrl, ps.hdc, &ps.rcPaint, ps.fErase);
45 | }
46 | EndPaint(win, &ps);
47 | return 0;
48 | }
49 |
50 | static inline LRESULT
51 | generic_printclient(HWND win, HDC dc,
52 | void (*func_paint)(void*, HDC, RECT*, BOOL), void* ctrl)
53 | {
54 | RECT rect;
55 |
56 | GetClientRect(win, &rect);
57 | func_paint(ctrl, dc, &rect, TRUE);
58 | return 0;
59 | }
60 |
61 | LRESULT generic_ncpaint(HWND win, HTHEME theme, HRGN orig_clip);
62 | LRESULT generic_erasebkgnd(HWND win, HTHEME theme, HDC dc);
63 |
64 | LRESULT generic_settooltips(HWND win, HWND* tooltip_storage, HWND tooltip_win, BOOL tracking);
65 |
66 |
67 | #endif /* MC_GENERIC_H */
68 |
--------------------------------------------------------------------------------
/src/grid.h:
--------------------------------------------------------------------------------
1 | /*
2 | * mCtrl: Additional Win32 controls
3 | *
4 | *
5 | *
6 | * Copyright (c) 2010-2020 Martin Mitas
7 | *
8 | * This library is free software; you can redistribute it and/or modify it
9 | * under the terms of the GNU Lesser General Public License as published by
10 | * the Free Software Foundation; either version 2.1 of the License, or
11 | * (at your option) any later version.
12 | *
13 | * This library is distributed in the hope that it will be useful,
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | * GNU Lesser General Public License for more details.
17 | *
18 | * You should have received a copy of the GNU Lesser General Public License
19 | * along with this library; if not, write to the Free Software Foundation,
20 | * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 | */
22 |
23 | #ifndef MC_GRID_H
24 | #define MC_GRID_H
25 |
26 | #include "mCtrl/grid.h"
27 | #include "misc.h"
28 |
29 |
30 | #endif /* MC_GRID_H */
31 |
--------------------------------------------------------------------------------
/src/html.h:
--------------------------------------------------------------------------------
1 | /*
2 | * mCtrl: Additional Win32 controls
3 | *
4 | *
5 | *
6 | * Copyright (c) 2008-2020 Martin Mitas
7 | *
8 | * This library is free software; you can redistribute it and/or modify it
9 | * under the terms of the GNU Lesser General Public License as published by
10 | * the Free Software Foundation; either version 2.1 of the License, or
11 | * (at your option) any later version.
12 | *
13 | * This library is distributed in the hope that it will be useful,
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | * GNU Lesser General Public License for more details.
17 | *
18 | * You should have received a copy of the GNU Lesser General Public License
19 | * along with this library; if not, write to the Free Software Foundation,
20 | * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 | */
22 |
23 | #ifndef MC_HTML_H
24 | #define MC_HTML_H
25 |
26 | #include "mCtrl/html.h"
27 | #include "misc.h"
28 |
29 |
30 | #endif /* MC_HTML_H */
31 |
--------------------------------------------------------------------------------
/src/imgview.h:
--------------------------------------------------------------------------------
1 | /*
2 | * mCtrl: Additional Win32 controls
3 | *
4 | *
5 | *
6 | * Copyright (c) 2013-2020 Martin Mitas
7 | *
8 | * This library is free software; you can redistribute it and/or modify it
9 | * under the terms of the GNU Lesser General Public License as published by
10 | * the Free Software Foundation; either version 2.1 of the License, or
11 | * (at your option) any later version.
12 | *
13 | * This library is distributed in the hope that it will be useful,
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | * GNU Lesser General Public License for more details.
17 | *
18 | * You should have received a copy of the GNU Lesser General Public License
19 | * along with this library; if not, write to the Free Software Foundation,
20 | * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 | */
22 |
23 | #ifndef MC_IMGVIEW_H
24 | #define MC_IMGVIEW_H
25 |
26 | #include "mCtrl/imgview.h"
27 | #include "misc.h"
28 |
29 |
30 | #endif /* MC_IMGVIEW_H */
31 |
--------------------------------------------------------------------------------
/src/labeledit.h:
--------------------------------------------------------------------------------
1 | /*
2 | * mCtrl: Additional Win32 controls
3 | *
4 | *
5 | *
6 | * Copyright (c) 2015-2020 Martin Mitas
7 | *
8 | * This library is free software; you can redistribute it and/or modify it
9 | * under the terms of the GNU Lesser General Public License as published by
10 | * the Free Software Foundation; either version 2.1 of the License, or
11 | * (at your option) any later version.
12 | *
13 | * This library is distributed in the hope that it will be useful,
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | * GNU Lesser General Public License for more details.
17 | *
18 | * You should have received a copy of the GNU Lesser General Public License
19 | * along with this library; if not, write to the Free Software Foundation,
20 | * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 | */
22 |
23 | #ifndef MC_LABELEDIT_H
24 | #define MC_LABELEDIT_H
25 |
26 | #include "misc.h"
27 |
28 |
29 | typedef void (*labeledit_callback_t)(void* /*data*/, const TCHAR* /*text*/, BOOL /*save*/);
30 |
31 |
32 | HWND labeledit_start(HWND parent_win, const TCHAR* text, labeledit_callback_t callback, void* callback_data);
33 | void labeledit_end(HWND parent_win, BOOL save);
34 |
35 | HWND labeledit_win(HWND parent_win);
36 |
37 |
38 | #endif /* MC_LABELEDIT_H */
39 |
--------------------------------------------------------------------------------
/src/mCtrl.def:
--------------------------------------------------------------------------------
1 | EXPORTS
2 | DllGetVersion
3 | mcButton_Initialize
4 | mcButton_Terminate
5 | mcChart_Initialize
6 | mcChart_Terminate
7 | mcCreateDialogIndirectParamA
8 | mcCreateDialogIndirectParamW
9 | mcCreateDialogParamA
10 | mcCreateDialogParamW
11 | mcDialogBoxIndirectParamA
12 | mcDialogBoxIndirectParamW
13 | mcDialogBoxParamA
14 | mcDialogBoxParamW
15 | mcExpand_Initialize
16 | mcExpand_Terminate
17 | mcGrid_Initialize
18 | mcGrid_Terminate
19 | mcHtml_Initialize
20 | mcHtml_Terminate
21 | mcImgView_Initialize
22 | mcImgView_Terminate
23 | mcIsMenubarMessage
24 | mcMditab_DefWindowProc
25 | mcMditab_Initialize
26 | mcMditab_Terminate
27 | mcMdView_Initialize
28 | mcMdView_Terminate
29 | mcMenubar_HandleRebarChevronPushed
30 | mcMenubar_Initialize
31 | mcMenubar_Terminate
32 | mcTable_AddRef
33 | mcTable_Clear
34 | mcTable_ColumnCount
35 | mcTable_Create
36 | mcTable_GetCellA
37 | mcTable_GetCellW
38 | mcTable_Release
39 | mcTable_Resize
40 | mcTable_RowCount
41 | mcTable_SetCellA
42 | mcTable_SetCellW
43 | mcTreeList_Initialize
44 | mcTreeList_Terminate
45 | mcVersion
46 |
--------------------------------------------------------------------------------
/src/mditab.h:
--------------------------------------------------------------------------------
1 | /*
2 | * mCtrl: Additional Win32 controls
3 | *
4 | *
5 | *
6 | * Copyright (c) 2008-2020 Martin Mitas
7 | *
8 | * This library is free software; you can redistribute it and/or modify it
9 | * under the terms of the GNU Lesser General Public License as published by
10 | * the Free Software Foundation; either version 2.1 of the License, or
11 | * (at your option) any later version.
12 | *
13 | * This library is distributed in the hope that it will be useful,
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | * GNU Lesser General Public License for more details.
17 | *
18 | * You should have received a copy of the GNU Lesser General Public License
19 | * along with this library; if not, write to the Free Software Foundation,
20 | * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 | */
22 |
23 | #ifndef MC_MDITAB_H
24 | #define MC_MDITAB_H
25 |
26 | #include "mCtrl/mditab.h"
27 | #include "misc.h"
28 |
29 |
30 | #endif /* MC_MDITAB_H */
31 |
--------------------------------------------------------------------------------
/src/mdtext.h:
--------------------------------------------------------------------------------
1 | /*
2 | * mCtrl: Additional Win32 controls
3 | *
4 | *
5 | *
6 | * Copyright (c) 2019-2020 Martin Mitas
7 | *
8 | * This library is free software; you can redistribute it and/or modify it
9 | * under the terms of the GNU Lesser General Public License as published by
10 | * the Free Software Foundation; either version 2.1 of the License, or
11 | * (at your option) any later version.
12 | *
13 | * This library is distributed in the hope that it will be useful,
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | * GNU Lesser General Public License for more details.
17 | *
18 | * You should have received a copy of the GNU Lesser General Public License
19 | * along with this library; if not, write to the Free Software Foundation,
20 | * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 | */
22 |
23 | #ifndef MC_MDTEXT_H
24 | #define MC_MDTEXT_H
25 |
26 | #include "misc.h"
27 | #include "xd2d.h"
28 | #include "xdwrite.h"
29 |
30 |
31 | typedef struct mdtext_tag mdtext_t;
32 |
33 |
34 | #define MDTEXT_FLAG_NOJUSTIFY 0x0001
35 |
36 | mdtext_t* mdtext_create(c_IDWriteTextFormat* text_fmt, const TCHAR* text, UINT text_len, UINT width, DWORD flags);
37 | void mdtext_destroy(mdtext_t* mdtext);
38 |
39 | void mdtext_set_width(mdtext_t* mdtext, UINT width);
40 |
41 | UINT mdtext_min_width(mdtext_t* mdtext);
42 | void mdtext_size(mdtext_t* mdtext, SIZE* size);
43 |
44 | void mdtext_paint(mdtext_t* mdtext, c_ID2D1RenderTarget* rt,
45 | int x_offset, int y_offset,
46 | int portview_y0, int portview_y1);
47 |
48 |
49 | typedef struct mdtext_hittest_info_tag mdtext_hittest_info_t;
50 | struct mdtext_hittest_info_tag {
51 | BOOL in_text;
52 |
53 | BOOL in_link;
54 | const TCHAR* link_href;
55 | const TCHAR* link_title;
56 | };
57 |
58 |
59 | void mdtext_hit_test(mdtext_t* mdtext, int x, int y, mdtext_hittest_info_t* info);
60 |
61 |
62 | #endif /* MC_MDTEXT_H */
63 |
--------------------------------------------------------------------------------
/src/mdview.h:
--------------------------------------------------------------------------------
1 | /*
2 | * mCtrl: Additional Win32 controls
3 | *
4 | *
5 | *
6 | * Copyright (c) 2019-2020 Martin Mitas
7 | *
8 | * This library is free software; you can redistribute it and/or modify it
9 | * under the terms of the GNU Lesser General Public License as published by
10 | * the Free Software Foundation; either version 2.1 of the License, or
11 | * (at your option) any later version.
12 | *
13 | * This library is distributed in the hope that it will be useful,
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | * GNU Lesser General Public License for more details.
17 | *
18 | * You should have received a copy of the GNU Lesser General Public License
19 | * along with this library; if not, write to the Free Software Foundation,
20 | * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 | */
22 |
23 | #ifndef MC_MDVIEW_H
24 | #define MC_MDVIEW_H
25 |
26 | #include "mCtrl/mdview.h"
27 | #include "misc.h"
28 |
29 |
30 | #endif /* MC_MDVIEW_H */
31 |
--------------------------------------------------------------------------------
/src/menubar.h:
--------------------------------------------------------------------------------
1 | /*
2 | * mCtrl: Additional Win32 controls
3 | *
4 | *
5 | *
6 | * Copyright (c) 2012-2020 Martin Mitas
7 | *
8 | * This library is free software; you can redistribute it and/or modify it
9 | * under the terms of the GNU Lesser General Public License as published by
10 | * the Free Software Foundation; either version 2.1 of the License, or
11 | * (at your option) any later version.
12 | *
13 | * This library is distributed in the hope that it will be useful,
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | * GNU Lesser General Public License for more details.
17 | *
18 | * You should have received a copy of the GNU Lesser General Public License
19 | * along with this library; if not, write to the Free Software Foundation,
20 | * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 | */
22 |
23 | #ifndef MC_MENUBAR_H
24 | #define MC_MENUBAR_H
25 |
26 | #include "mCtrl/menubar.h"
27 | #include "misc.h"
28 |
29 |
30 | #endif /* MC_MENUBAR_H */
31 |
--------------------------------------------------------------------------------
/src/module.h:
--------------------------------------------------------------------------------
1 | /*
2 | * mCtrl: Additional Win32 controls
3 | *
4 | *
5 | *
6 | * Copyright (c) 2009-2020 Martin Mitas
7 | *
8 | * This library is free software; you can redistribute it and/or modify it
9 | * under the terms of the GNU Lesser General Public License as published by
10 | * the Free Software Foundation; either version 2.1 of the License, or
11 | * (at your option) any later version.
12 | *
13 | * This library is distributed in the hope that it will be useful,
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | * GNU Lesser General Public License for more details.
17 | *
18 | * You should have received a copy of the GNU Lesser General Public License
19 | * along with this library; if not, write to the Free Software Foundation,
20 | * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 | */
22 |
23 | #ifndef MC_MODULE_H
24 | #define MC_MODULE_H
25 |
26 | #include "misc.h"
27 |
28 |
29 |
30 | #endif /* MC_MODULE_H */
31 |
--------------------------------------------------------------------------------
/src/mousewheel.h:
--------------------------------------------------------------------------------
1 | /*
2 | * mCtrl: Additional Win32 controls
3 | *
4 | *
5 | *
6 | * Copyright (c) 2015-2020 Martin Mitas
7 | *
8 | * This library is free software; you can redistribute it and/or modify it
9 | * under the terms of the GNU Lesser General Public License as published by
10 | * the Free Software Foundation; either version 2.1 of the License, or
11 | * (at your option) any later version.
12 | *
13 | * This library is distributed in the hope that it will be useful,
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | * GNU Lesser General Public License for more details.
17 | *
18 | * You should have received a copy of the GNU Lesser General Public License
19 | * along with this library; if not, write to the Free Software Foundation,
20 | * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 | */
22 |
23 | #ifndef MC_MOUSEWHEEL_H
24 | #define MC_MOUSEWHEEL_H
25 |
26 | #include "misc.h"
27 |
28 |
29 | int mousewheel_scroll(HWND win, int delta, int page, BOOL is_vertical);
30 |
31 |
32 | #endif /* MC_MOUSEWHEEL_H */
33 |
--------------------------------------------------------------------------------
/src/res/divider-h.cur:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mity/mctrl/db87aecc14ab912f681ef7c5b22f939e53957b6a/src/res/divider-h.cur
--------------------------------------------------------------------------------
/src/res/divider-v.cur:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mity/mctrl/db87aecc14ab912f681ef7c5b22f939e53957b6a/src/res/divider-v.cur
--------------------------------------------------------------------------------
/src/res/divopen-h.cur:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mity/mctrl/db87aecc14ab912f681ef7c5b22f939e53957b6a/src/res/divopen-h.cur
--------------------------------------------------------------------------------
/src/res/divopen-v.cur:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mity/mctrl/db87aecc14ab912f681ef7c5b22f939e53957b6a/src/res/divopen-v.cur
--------------------------------------------------------------------------------
/src/res/expand-19x19.bmp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mity/mctrl/db87aecc14ab912f681ef7c5b22f939e53957b6a/src/res/expand-19x19.bmp
--------------------------------------------------------------------------------
/src/res/expand-24x24.bmp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mity/mctrl/db87aecc14ab912f681ef7c5b22f939e53957b6a/src/res/expand-24x24.bmp
--------------------------------------------------------------------------------
/src/res/expand-29x29.bmp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mity/mctrl/db87aecc14ab912f681ef7c5b22f939e53957b6a/src/res/expand-29x29.bmp
--------------------------------------------------------------------------------
/src/res/lang-cs.rc:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2012 Martin Mitas
3 | *
4 | * This library is free software; you can redistribute it and/or modify it
5 | * under the terms of the GNU Lesser General Public License as published by
6 | * the Free Software Foundation; either version 2.1 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This library is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public License
15 | * along with this library; if not, write to the Free Software Foundation,
16 | * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 | */
18 |
19 | LANGUAGE LANG_CZECH, SUBLANG_NEUTRAL
20 | #pragma code_page(65001) /* UTF-8 */
21 |
22 | STRINGTABLE
23 | BEGIN
24 | IDS_EXPAND_MOREDETAILS "Další podrobnosti\0"
25 | IDS_EXPAND_FEWERDETAILS "Méně podrobností\0"
26 | END
27 |
--------------------------------------------------------------------------------
/src/res/lang-en.rc:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2012 Martin Mitas
3 | *
4 | * This library is free software; you can redistribute it and/or modify it
5 | * under the terms of the GNU Lesser General Public License as published by
6 | * the Free Software Foundation; either version 2.1 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This library is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public License
15 | * along with this library; if not, write to the Free Software Foundation,
16 | * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 | */
18 |
19 | LANGUAGE LANG_ENGLISH, SUBLANG_NEUTRAL
20 | #pragma code_page(65001) /* UTF-8 */
21 |
22 | STRINGTABLE
23 | BEGIN
24 | IDS_EXPAND_MOREDETAILS "More details\0"
25 | IDS_EXPAND_FEWERDETAILS "Less details\0"
26 | END
27 |
--------------------------------------------------------------------------------
/src/res/lang-fr.rc:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2012 Martin Mitas
3 | *
4 | * This library is free software; you can redistribute it and/or modify it
5 | * under the terms of the GNU Lesser General Public License as published by
6 | * the Free Software Foundation; either version 2.1 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This library is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public License
15 | * along with this library; if not, write to the Free Software Foundation,
16 | * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 | */
18 |
19 | LANGUAGE LANG_FRENCH, SUBLANG_NEUTRAL
20 | #pragma code_page(65001) /* UTF-8 */
21 |
22 | STRINGTABLE
23 | BEGIN
24 | IDS_EXPAND_MOREDETAILS "Afficher les détails\0"
25 | IDS_EXPAND_FEWERDETAILS "Masquer les détails\0"
26 | END
27 |
--------------------------------------------------------------------------------
/src/res/lang-it.rc:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2012 Martin Mitas
3 | * Copyright (c) 2016 Carlo Bramini
4 | *
5 | * This library is free software; you can redistribute it and/or modify it
6 | * under the terms of the GNU Lesser General Public License as published by
7 | * the Free Software Foundation; either version 2.1 of the License, or
8 | * (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public License
16 | * along with this library; if not, write to the Free Software Foundation,
17 | * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 | */
19 |
20 | LANGUAGE LANG_ITALIAN, SUBLANG_NEUTRAL
21 | #pragma code_page(65001) /* UTF-8 */
22 |
23 | STRINGTABLE
24 | BEGIN
25 | IDS_EXPAND_MOREDETAILS "Mostra i dettagli\0"
26 | IDS_EXPAND_FEWERDETAILS "Nascondi i dettagli\0"
27 | END
28 |
--------------------------------------------------------------------------------
/src/resource.h:
--------------------------------------------------------------------------------
1 | /* This file is generated automatically from 'resource.h.in' by script 'mkres.sh'.
2 | * Do not edit this file manually.
3 | */
4 |
5 | /*
6 | * mCtrl: Additional Win32 controls
7 | *
8 | *
9 | *
10 | * Copyright (c) 2008-2020 Martin Mitas
11 | *
12 | * This library is free software; you can redistribute it and/or modify it
13 | * under the terms of the GNU Lesser General Public License as published by
14 | * the Free Software Foundation; either version 2.1 of the License, or
15 | * (at your option) any later version.
16 | *
17 | * This library is distributed in the hope that it will be useful,
18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 | * GNU Lesser General Public License for more details.
21 | *
22 | * You should have received a copy of the GNU Lesser General Public License
23 | * along with this library; if not, write to the Free Software Foundation,
24 | * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
25 | */
26 |
27 | #ifndef MC_RESOURCE_H
28 | #define MC_RESOURCE_H
29 |
30 |
31 | /********************
32 | *** Resource IDs ***
33 | *********************/
34 |
35 | #define IDR_EXPAND_GLYPHS_19 100
36 | #define IDR_EXPAND_GLYPHS_24 101
37 | #define IDR_EXPAND_GLYPHS_29 102
38 |
39 | #define IDR_CURSOR_DIVIDER_H 103
40 | #define IDR_CURSOR_DIVIDER_V 104
41 | #define IDR_CURSOR_DIVOPEN_H 105
42 | #define IDR_CURSOR_DIVOPEN_V 106
43 |
44 |
45 | /******************
46 | *** String IDs ***
47 | ******************/
48 |
49 | #define IDS_EXPAND_MOREDETAILS 0
50 | #define IDS_EXPAND_FEWERDETAILS 1
51 |
52 |
53 | #endif /* MC_RESOURCE_H */
54 |
--------------------------------------------------------------------------------
/src/resource.h.in:
--------------------------------------------------------------------------------
1 | /*
2 | * mCtrl: Additional Win32 controls
3 | *
4 | *
5 | *
6 | * Copyright (c) 2008-2020 Martin Mitas
7 | *
8 | * This library is free software; you can redistribute it and/or modify it
9 | * under the terms of the GNU Lesser General Public License as published by
10 | * the Free Software Foundation; either version 2.1 of the License, or
11 | * (at your option) any later version.
12 | *
13 | * This library is distributed in the hope that it will be useful,
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | * GNU Lesser General Public License for more details.
17 | *
18 | * You should have received a copy of the GNU Lesser General Public License
19 | * along with this library; if not, write to the Free Software Foundation,
20 | * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 | */
22 |
23 | #ifndef MC_RESOURCE_H
24 | #define MC_RESOURCE_H
25 |
26 |
27 | /********************
28 | *** Resource IDs ***
29 | *********************/
30 |
31 | #define IDR_EXPAND_GLYPHS_19 @RESOURCE_ID@
32 | #define IDR_EXPAND_GLYPHS_24 @RESOURCE_ID@
33 | #define IDR_EXPAND_GLYPHS_29 @RESOURCE_ID@
34 |
35 | #define IDR_CURSOR_DIVIDER_H @RESOURCE_ID@
36 | #define IDR_CURSOR_DIVIDER_V @RESOURCE_ID@
37 | #define IDR_CURSOR_DIVOPEN_H @RESOURCE_ID@
38 | #define IDR_CURSOR_DIVOPEN_V @RESOURCE_ID@
39 |
40 |
41 | /******************
42 | *** String IDs ***
43 | ******************/
44 |
45 | #define IDS_EXPAND_MOREDETAILS @STRING_ID@
46 | #define IDS_EXPAND_FEWERDETAILS @STRING_ID@
47 |
48 |
49 | #endif /* MC_RESOURCE_H */
50 |
--------------------------------------------------------------------------------
/src/resource.rc:
--------------------------------------------------------------------------------
1 | /*
2 | * mCtrl: Additional Win32 controls
3 | *
4 | *
5 | *
6 | * Copyright (c) 2008-2020 Martin Mitas
7 | *
8 | * This library is free software; you can redistribute it and/or modify it
9 | * under the terms of the GNU Lesser General Public License as published by
10 | * the Free Software Foundation; either version 2.1 of the License, or
11 | * (at your option) any later version.
12 | *
13 | * This library is distributed in the hope that it will be useful,
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | * GNU Lesser General Public License for more details.
17 | *
18 | * You should have received a copy of the GNU Lesser General Public License
19 | * along with this library; if not, write to the Free Software Foundation,
20 | * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 | */
22 |
23 | #include
24 | #include "version.h"
25 | #include "resource.h"
26 |
27 |
28 | LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
29 | #pragma code_page(65001) /* UTF-8 */
30 |
31 |
32 |
33 | /**********************************
34 | *** Language neutral resources ***
35 | **********************************/
36 |
37 | IDR_EXPAND_GLYPHS_19 BITMAP "res/expand-19x19.bmp"
38 | IDR_EXPAND_GLYPHS_24 BITMAP "res/expand-24x24.bmp"
39 | IDR_EXPAND_GLYPHS_29 BITMAP "res/expand-29x29.bmp"
40 |
41 | IDR_CURSOR_DIVIDER_H CURSOR "res/divider-h.cur"
42 | IDR_CURSOR_DIVIDER_V CURSOR "res/divider-v.cur"
43 | IDR_CURSOR_DIVOPEN_H CURSOR "res/divopen-h.cur"
44 | IDR_CURSOR_DIVOPEN_V CURSOR "res/divopen-v.cur"
45 |
46 |
47 | /********************
48 | *** Version info ***
49 | ********************/
50 |
51 | VS_VERSION_INFO VERSIONINFO
52 | FILEVERSION MC_VERSION_MAJOR, MC_VERSION_MINOR, MC_VERSION_RELEASE, 0
53 | PRODUCTVERSION MC_VERSION_MAJOR, MC_VERSION_MINOR, MC_VERSION_RELEASE, 0
54 | FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
55 | #ifndef DEBUG
56 | FILEFLAGS 0
57 | #else
58 | FILEFLAGS VS_FF_DEBUG
59 | #endif
60 | FILEOS VOS_NT_WINDOWS32
61 | FILETYPE VFT_DLL
62 | FILESUBTYPE 0
63 | BEGIN
64 | BLOCK "StringFileInfo"
65 | BEGIN
66 | BLOCK "000004b0" /* language: 0 (neutral); charset: 0x04b0 == 1200 (unicode) */
67 | BEGIN
68 | VALUE "ProductName", "mCtrl Library"
69 | VALUE "FileDescription", "Additional User Experience Controls Library"
70 | VALUE "OriginalFilename", "mCtrl.dll"
71 | VALUE "InternalName", "mCtrl"
72 | VALUE "CompanyName", "morous.org"
73 | VALUE "FileVersion", MC_VERSION_STR
74 | VALUE "ProductVersion", MC_VERSION_STR
75 | VALUE "LegalCopyright", "© 2008-2019 Martin Mitáš"
76 | VALUE "WWW", "http://mctrl.org"
77 | END
78 | END
79 | BLOCK "VarFileInfo"
80 | BEGIN
81 | VALUE "Translation", 0, 1200
82 | END
83 | END
84 |
85 |
86 | /******************************
87 | *** Per-language resources ***
88 | ******************************/
89 |
90 | #include "res/lang-cs.rc" /* Czech */
91 | #include "res/lang-en.rc" /* English */
92 | #include "res/lang-fr.rc" /* French */
93 | #include "res/lang-it.rc" /* Italian */
94 |
95 |
--------------------------------------------------------------------------------
/src/tooltip.h:
--------------------------------------------------------------------------------
1 | /*
2 | * mCtrl: Additional Win32 controls
3 | *
4 | *
5 | *
6 | * Copyright (c) 2015-2020 Martin Mitas
7 | *
8 | * This library is free software; you can redistribute it and/or modify it
9 | * under the terms of the GNU Lesser General Public License as published by
10 | * the Free Software Foundation; either version 2.1 of the License, or
11 | * (at your option) any later version.
12 | *
13 | * This library is distributed in the hope that it will be useful,
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | * GNU Lesser General Public License for more details.
17 | *
18 | * You should have received a copy of the GNU Lesser General Public License
19 | * along with this library; if not, write to the Free Software Foundation,
20 | * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 | */
22 |
23 | #ifndef MC_TOOLTIP_H
24 | #define MC_TOOLTIP_H
25 |
26 | #include "misc.h"
27 |
28 |
29 | /* Notes:
30 | * - tooltip_create() calls tooltip_install() automatically.
31 | * - notify_win (if not NULL), it gets NM_TOOLTIPSCREATED) but all
32 | * notifications from the tooltip itself are sent to the control_win.
33 | */
34 | HWND tooltip_create(HWND control_win, HWND notify_win, BOOL tracking);
35 | void tooltip_destroy(HWND tooltip_win);
36 |
37 | /* Add/remove a tooltip tool for complete control_win. */
38 | void tooltip_install(HWND tooltip_win, HWND control_win, BOOL tracking);
39 | void tooltip_uninstall(HWND tooltip_win, HWND control_win);
40 |
41 | /* Functions to be used only for tracking tooltip. */
42 | void tooltip_show_tracking(HWND tooltip_win, HWND control_win, BOOL show);
43 | void tooltip_move_tracking(HWND tooltip_win, HWND control_win, int x, int y);
44 |
45 | /* str may be LPSTR_TEXTCALLBACK if control_win handles TTN_GETDISPINFO. */
46 | void tooltip_update_text(HWND tooltip_win, HWND control_win, const TCHAR* str);
47 |
48 | /* Get current tooltip window size. */
49 | void tooltip_size(HWND tooltip_win, SIZE* size);
50 |
51 |
52 | #endif /* MC_TOOLTIP_H */
53 |
--------------------------------------------------------------------------------
/src/treelist.h:
--------------------------------------------------------------------------------
1 | /*
2 | * mCtrl: Additional Win32 controls
3 | *
4 | *
5 | *
6 | * Copyright (c) 2020 Martin Mitas
7 | *
8 | * This library is free software; you can redistribute it and/or modify it
9 | * under the terms of the GNU Lesser General Public License as published by
10 | * the Free Software Foundation; either version 2.1 of the License, or
11 | * (at your option) any later version.
12 | *
13 | * This library is distributed in the hope that it will be useful,
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | * GNU Lesser General Public License for more details.
17 | *
18 | * You should have received a copy of the GNU Lesser General Public License
19 | * along with this library; if not, write to the Free Software Foundation,
20 | * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 | */
22 |
23 | #ifndef MC_TREELIST_H
24 | #define MC_TREELIST_H
25 |
26 | #include "mCtrl/treelist.h"
27 | #include "misc.h"
28 |
29 |
30 | #endif /* MC_TREELIST_H */
31 |
--------------------------------------------------------------------------------
/src/url.c:
--------------------------------------------------------------------------------
1 | /*
2 | * mCtrl: Additional Win32 controls
3 | *
4 | *
5 | *
6 | * Copyright (c) 2019-2020 Martin Mitas
7 | *
8 | * This library is free software; you can redistribute it and/or modify it
9 | * under the terms of the GNU Lesser General Public License as published by
10 | * the Free Software Foundation; either version 2.1 of the License, or
11 | * (at your option) any later version.
12 | *
13 | * This library is distributed in the hope that it will be useful,
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | * GNU Lesser General Public License for more details.
17 | *
18 | * You should have received a copy of the GNU Lesser General Public License
19 | * along with this library; if not, write to the Free Software Foundation,
20 | * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 | */
22 |
23 | #include "url.h"
24 |
25 |
26 | #define DECODE_IS_XDIGIT(ch) ((_T('0') <= (ch) && (ch) <= _T('9')) || \
27 | (_T('a') <= (ch) && (ch) <= _T('f')) || \
28 | (_T('A') <= (ch) && (ch) <= _T('F')))
29 |
30 | #define DECODE_XDIGIT_VAL(ch) \
31 | ((_T('0') <= (ch) && (ch) <= _T('9')) ? (ch) - _T('0') : \
32 | (_T('a') <= (ch) && (ch) <= _T('f')) ? 10 + (ch) - _T('a') : \
33 | 10 + (ch) - _T('A'))
34 |
35 | void
36 | url_decode(TCHAR* str)
37 | {
38 | TCHAR* in = str;
39 | TCHAR* out;
40 |
41 | /* Fast path for any prefix without any percents. */
42 | while(*in != _T('\0') && *in != _T('%'))
43 | in++;
44 | out = in;
45 |
46 | /* Slow path if we encounter any percent(s). */
47 | while(*in != _T('\0')) {
48 | if(*in == _T('%') && DECODE_IS_XDIGIT(*(in+1)) && DECODE_IS_XDIGIT(*(in+2))) {
49 | *out = (DECODE_XDIGIT_VAL(*(in+1)) << 4) | DECODE_XDIGIT_VAL(*(in+2));
50 | in += 3;
51 | out++;
52 | } else {
53 | *in = *out;
54 | in++;
55 | out++;
56 | }
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/src/url.h:
--------------------------------------------------------------------------------
1 | /*
2 | * mCtrl: Additional Win32 controls
3 | *
4 | *
5 | *
6 | * Copyright (c) 2019-2020 Martin Mitas
7 | *
8 | * This library is free software; you can redistribute it and/or modify it
9 | * under the terms of the GNU Lesser General Public License as published by
10 | * the Free Software Foundation; either version 2.1 of the License, or
11 | * (at your option) any later version.
12 | *
13 | * This library is distributed in the hope that it will be useful,
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | * GNU Lesser General Public License for more details.
17 | *
18 | * You should have received a copy of the GNU Lesser General Public License
19 | * along with this library; if not, write to the Free Software Foundation,
20 | * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 | */
22 |
23 | #ifndef MC_URL_H
24 | #define MC_URL_H
25 |
26 | #include "misc.h"
27 |
28 |
29 | /* Decode (in-place) URL percent notation. */
30 | void url_decode(TCHAR* str);
31 |
32 |
33 | #endif /* MC_URL_H */
34 |
--------------------------------------------------------------------------------
/src/version.c:
--------------------------------------------------------------------------------
1 | /*
2 | * mCtrl: Additional Win32 controls
3 | *
4 | *
5 | *
6 | * Copyright (c) 2008-2020 Martin Mitas
7 | *
8 | * This library is free software; you can redistribute it and/or modify it
9 | * under the terms of the GNU Lesser General Public License as published by
10 | * the Free Software Foundation; either version 2.1 of the License, or
11 | * (at your option) any later version.
12 | *
13 | * This library is distributed in the hope that it will be useful,
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | * GNU Lesser General Public License for more details.
17 | *
18 | * You should have received a copy of the GNU Lesser General Public License
19 | * along with this library; if not, write to the Free Software Foundation,
20 | * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 | */
22 |
23 | #include "version.h"
24 | #include "mCtrl/version.h"
25 | #include "misc.h"
26 |
27 |
28 | void MCTRL_API
29 | mcVersion(MC_VERSION* version)
30 | {
31 | version->dwMajor = MC_VERSION_MAJOR;
32 | version->dwMinor = MC_VERSION_MINOR;
33 | version->dwRelease = MC_VERSION_RELEASE;
34 | }
35 |
36 |
37 | /* DllGetVersion accepts pointer to structure determined in runtime
38 | * by first DWORD (cbSize). */
39 | typedef union dllgetversioninfo_tag dllgetversioninfo_t;
40 | union dllgetversioninfo_tag {
41 | DWORD cbSize;
42 | DLLVERSIONINFO info1;
43 | DLLVERSIONINFO2 info2;
44 | };
45 |
46 | HRESULT MCTRL_API
47 | DllGetVersion(dllgetversioninfo_t* dvi)
48 | {
49 | switch(dvi->cbSize) {
50 | case sizeof(DLLVERSIONINFO2):
51 | dvi->info2.dwFlags = 0;
52 | dvi->info2.ullVersion = MAKEDLLVERULL(MC_VERSION_MAJOR,
53 | MC_VERSION_MINOR, MC_VERSION_RELEASE, 0);
54 | /* no break, fall through */
55 |
56 | case sizeof(DLLVERSIONINFO):
57 | dvi->info1.dwMajorVersion = MC_VERSION_MAJOR;
58 | dvi->info1.dwMinorVersion = MC_VERSION_MINOR;
59 | dvi->info1.dwBuildNumber = MC_VERSION_RELEASE;
60 | dvi->info1.dwPlatformID = DLLVER_PLATFORM_NT;
61 | return S_OK;
62 |
63 | default:
64 | MC_TRACE("DllGetVersion: unsupported cbSize");
65 | return E_INVALIDARG;
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/src/version.h.in:
--------------------------------------------------------------------------------
1 | /*
2 | * mCtrl: Additional Win32 controls
3 | *
4 | *
5 | *
6 | * Copyright (c) 2008-2020 Martin Mitas
7 | *
8 | * This library is free software; you can redistribute it and/or modify it
9 | * under the terms of the GNU Lesser General Public License as published by
10 | * the Free Software Foundation; either version 2.1 of the License, or
11 | * (at your option) any later version.
12 | *
13 | * This library is distributed in the hope that it will be useful,
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | * GNU Lesser General Public License for more details.
17 | *
18 | * You should have received a copy of the GNU Lesser General Public License
19 | * along with this library; if not, write to the Free Software Foundation,
20 | * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 | */
22 |
23 | #ifndef MC_VERSION_H
24 | #define MC_VERSION_H
25 |
26 |
27 | #define MC_VERSION_MAJOR @MCTRL_MAJOR_VERSION@
28 | #define MC_VERSION_MINOR @MCTRL_MINOR_VERSION@
29 | #define MC_VERSION_RELEASE @MCTRL_PATCH_VERSION@
30 |
31 |
32 | /* Stringize given expression */
33 | #define MC_STRINGIZE_HELPER(a) #a
34 | #define MC_STRINGIZE(a) MC_STRINGIZE_HELPER(a)
35 |
36 |
37 | #ifdef DEBUG
38 | #define MC_VERSION_STR \
39 | MC_STRINGIZE(MC_VERSION_MAJOR.MC_VERSION_MINOR.MC_VERSION_RELEASE-dbg(DEBUG))
40 | #else
41 | #define MC_VERSION_STR \
42 | MC_STRINGIZE(MC_VERSION_MAJOR.MC_VERSION_MINOR.MC_VERSION_RELEASE)
43 | #endif
44 |
45 |
46 | #endif /* MC_VERSION_H */
47 |
--------------------------------------------------------------------------------
/src/viewlist.c:
--------------------------------------------------------------------------------
1 | /*
2 | * mCtrl: Additional Win32 controls
3 | *
4 | *
5 | *
6 | * Copyright (c) 2010-2020 Martin Mitas
7 | *
8 | * This library is free software; you can redistribute it and/or modify it
9 | * under the terms of the GNU Lesser General Public License as published by
10 | * the Free Software Foundation; either version 2.1 of the License, or
11 | * (at your option) any later version.
12 | *
13 | * This library is distributed in the hope that it will be useful,
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | * GNU Lesser General Public License for more details.
17 | *
18 | * You should have received a copy of the GNU Lesser General Public License
19 | * along with this library; if not, write to the Free Software Foundation,
20 | * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 | */
22 |
23 | #include "viewlist.h"
24 |
25 |
26 | int
27 | view_list_install_view(view_list_t* vlist, void* view, view_refresh_t refresh)
28 | {
29 | view_node_t* node;
30 |
31 | node = dsa_insert_raw(&vlist->dsa, dsa_size(&vlist->dsa));
32 | if(MC_ERR(node == NULL)) {
33 | MC_TRACE("view_install: dsa_insert_raw() failed.");
34 | return -1;
35 | }
36 |
37 | node->view = view;
38 | node->refresh = refresh;
39 | return 0;
40 | }
41 |
42 | void
43 | view_list_uninstall_view(view_list_t* vlist, void* view)
44 | {
45 | int i, n;
46 |
47 | n = dsa_size(&vlist->dsa);
48 | for(i = 0; i < n; i++) {
49 | view_node_t* node = DSA_ITEM(&vlist->dsa, i, view_node_t);
50 | if(view == node->view) {
51 | dsa_remove(&vlist->dsa, i, NULL);
52 | return;
53 | }
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/src/viewlist.h:
--------------------------------------------------------------------------------
1 | /*
2 | * mCtrl: Additional Win32 controls
3 | *
4 | *
5 | *
6 | * Copyright (c) 2010-2020 Martin Mitas
7 | *
8 | * This library is free software; you can redistribute it and/or modify it
9 | * under the terms of the GNU Lesser General Public License as published by
10 | * the Free Software Foundation; either version 2.1 of the License, or
11 | * (at your option) any later version.
12 | *
13 | * This library is distributed in the hope that it will be useful,
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | * GNU Lesser General Public License for more details.
17 | *
18 | * You should have received a copy of the GNU Lesser General Public License
19 | * along with this library; if not, write to the Free Software Foundation,
20 | * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 | */
22 |
23 | #ifndef MC_VIEWLIST_H
24 | #define MC_VIEWLIST_H
25 |
26 | #include "misc.h"
27 | #include "dsa.h"
28 |
29 |
30 | /* The models (as in model-view-controller paradigm) must be aware of their
31 | * views so the views are notified to be refreshed whenever the model state
32 | * changes.
33 | *
34 | * The view list is just such a container for the views reused in the various
35 | * models.
36 | */
37 |
38 |
39 | typedef void (*view_refresh_t)(void* /*view*/, void* /*detail*/);
40 |
41 |
42 | typedef struct view_node_tag view_node_t;
43 | struct view_node_tag {
44 | void* view;
45 | view_refresh_t refresh;
46 | };
47 |
48 | typedef struct view_list_tag view_list_t;
49 | struct view_list_tag {
50 | dsa_t dsa;
51 | };
52 |
53 |
54 | static inline void
55 | view_list_init(view_list_t* vlist)
56 | {
57 | dsa_init(&vlist->dsa, sizeof(view_node_t));
58 | }
59 |
60 | static inline void
61 | view_list_fini(view_list_t* vlist)
62 | {
63 | MC_ASSERT(dsa_size(&vlist->dsa) == 0);
64 | dsa_fini(&vlist->dsa, NULL);
65 | }
66 |
67 | int view_list_install_view(view_list_t* vlist, void* view, view_refresh_t refresh);
68 | void view_list_uninstall_view(view_list_t* vlist, void* view);
69 |
70 | static inline void
71 | view_list_refresh(view_list_t* vlist, void* detail)
72 | {
73 | int i, n;
74 | n = dsa_size(&vlist->dsa);
75 | for(i = 0; i < n; i++) {
76 | view_node_t* node = DSA_ITEM(&vlist->dsa, i, view_node_t);
77 | node->refresh(node->view, detail);
78 | }
79 | }
80 |
81 |
82 | #endif /* MC_VIEWLIST_H */
83 |
--------------------------------------------------------------------------------
/src/xcom.h:
--------------------------------------------------------------------------------
1 | /*
2 | * mCtrl: Additional Win32 controls
3 | *
4 | *
5 | *
6 | * Copyright (c) 2015-2020 Martin Mitas
7 | *
8 | * This library is free software; you can redistribute it and/or modify it
9 | * under the terms of the GNU Lesser General Public License as published by
10 | * the Free Software Foundation; either version 2.1 of the License, or
11 | * (at your option) any later version.
12 | *
13 | * This library is distributed in the hope that it will be useful,
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | * GNU Lesser General Public License for more details.
17 | *
18 | * You should have received a copy of the GNU Lesser General Public License
19 | * along with this library; if not, write to the Free Software Foundation,
20 | * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 | */
22 |
23 | #ifndef MC_XCOM_H
24 | #define MC_XCOM_H
25 |
26 | #include "misc.h"
27 |
28 |
29 | /* The purpose of this is to not force COM-unaware applications to initialize
30 | * COM just for MCTRL.DLL, yet to not stand in a way if the application does so.
31 | * (See http://blogs.msdn.com/b/larryosterman/archive/2004/05/12/130541.aspx)
32 | *
33 | * The function ensures COM is initialized (if not it calls CoInitialize()
34 | * or some of its friends), and then it just calls CoCreateInstance().
35 | */
36 | void* xcom_init_create(const CLSID* clsid, DWORD context, const IID* iid);
37 |
38 | /* Calls CoUninitialize() if it was initialized in previous xcom_create_init().
39 | * Otherwise noop. */
40 | void xcom_uninit(void);
41 |
42 |
43 | #endif /* MC_XCOM_H */
44 |
--------------------------------------------------------------------------------
/src/xdwm.h:
--------------------------------------------------------------------------------
1 | /*
2 | * mCtrl: Additional Win32 controls
3 | *
4 | *
5 | *
6 | * Copyright (c) 2015-2020 Martin Mitas
7 | *
8 | * This library is free software; you can redistribute it and/or modify it
9 | * under the terms of the GNU Lesser General Public License as published by
10 | * the Free Software Foundation; either version 2.1 of the License, or
11 | * (at your option) any later version.
12 | *
13 | * This library is distributed in the hope that it will be useful,
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | * GNU Lesser General Public License for more details.
17 | *
18 | * You should have received a copy of the GNU Lesser General Public License
19 | * along with this library; if not, write to the Free Software Foundation,
20 | * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 | */
22 |
23 | #ifndef MC_XDWM_H
24 | #define MC_XDWM_H
25 |
26 | #include "misc.h"
27 |
28 |
29 | BOOL xdwm_is_composition_enabled(void);
30 |
31 | void xdwm_extend_frame(HWND win, int margin_left, int margin_top,
32 | int margin_right, int margin_bottom);
33 |
34 | BOOL xdwm_def_window_proc(HWND win, UINT msg, WPARAM wp, LPARAM lp, LRESULT* res);
35 |
36 |
37 | #endif /* MC_XDWM_H */
38 |
--------------------------------------------------------------------------------
/src/xwic.h:
--------------------------------------------------------------------------------
1 | /*
2 | * mCtrl: Additional Win32 controls
3 | *
4 | *
5 | *
6 | * Copyright (c) 2019-2020 Martin Mitas
7 | *
8 | * Permission is hereby granted, free of charge, to any person obtaining a
9 | * copy of this software and associated documentation files (the "Software"),
10 | * to deal in the Software without restriction, including without limitation
11 | * the rights to use, copy, modify, merge, publish, distribute, sublicense,
12 | * and/or sell copies of the Software, and to permit persons to whom the
13 | * Software is furnished to do so, subject to the following conditions:
14 | *
15 | * The above copyright notice and this permission notice shall be included in
16 | * all copies or substantial portions of the Software.
17 | *
18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
24 | * IN THE SOFTWARE.
25 | */
26 |
27 | #ifndef MC_XWIC_H
28 | #define MC_XWIC_H
29 |
30 | #include "misc.h"
31 | #include
32 |
33 |
34 | IWICBitmapSource* xwic_from_HICON(HICON icon);
35 | IWICBitmapSource* xwic_from_HBITMAP(HBITMAP bmp, WICBitmapAlphaChannelOption alpha_mode);
36 | IWICBitmapSource* xwic_from_file(const TCHAR* path);
37 | IWICBitmapSource* xwic_from_resource(HINSTANCE instance, const TCHAR* res_type, const TCHAR* res_name);
38 |
39 |
40 | #endif /* MC_XWIC_H */
41 |
--------------------------------------------------------------------------------
/tests/CMakeLists.txt:
--------------------------------------------------------------------------------
1 |
2 |
3 | if(CMAKE_COMPILER_IS_GNUCC)
4 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall")
5 | set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libgcc")
6 | elseif(MSVC)
7 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /MT")
8 | set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /MANIFEST:NO")
9 | add_definitions(/D_CRT_SECURE_NO_WARNINGS)
10 | endif()
11 |
12 |
13 | add_executable(test-build test-build.c)
14 | # (test-build.exe uses LoadLibrary. Do not link with the mCtrl lib.)
15 |
16 | add_executable(test-grid test-grid.c)
17 | target_link_libraries(test-grid mCtrl)
18 |
19 | add_executable(test-table test-table.c)
20 | target_link_libraries(test-table mCtrl)
21 |
--------------------------------------------------------------------------------
/tests/test-grid.c:
--------------------------------------------------------------------------------
1 | /*
2 | * Unit tests verifying grid control
3 | * Copyright (c) 2016 Martin Mitas
4 | */
5 |
6 | #include "acutest.h"
7 | #include
8 | #include
9 |
10 |
11 | static void
12 | init_test(void)
13 | {
14 | TEST_CHECK(mcGrid_Initialize());
15 | mcGrid_Terminate();
16 | }
17 |
18 |
19 | /*****************
20 | *** Test List ***
21 | *****************/
22 |
23 | TEST_LIST = {
24 | { "initialization", init_test },
25 | { 0 }
26 | };
27 |
--------------------------------------------------------------------------------