2 * Copyright (C) 2009 Stephan Aßmus <superstippi@gmx.de>
3 * All rights reserved. Distributed under the terms of the MIT license.
6 #include "DrawingModeToString.h"
11 struct DrawingModeString
{
17 static const DrawingModeString kDrawingModes
[] = {
18 { "B_OP_COPY", B_OP_COPY
},
19 { "B_OP_OVER", B_OP_OVER
},
20 { "B_OP_ERASE", B_OP_ERASE
},
21 { "B_OP_INVERT", B_OP_INVERT
},
22 { "B_OP_ADD", B_OP_ADD
},
23 { "B_OP_SUBTRACT", B_OP_SUBTRACT
},
24 { "B_OP_BLEND", B_OP_BLEND
},
25 { "B_OP_MIN", B_OP_MIN
},
26 { "B_OP_MAX", B_OP_MAX
},
27 { "B_OP_SELECT", B_OP_SELECT
},
28 { "B_OP_ALPHA", B_OP_ALPHA
}
32 bool ToDrawingMode(const char* string
, drawing_mode
& mode
)
34 int entries
= sizeof(kDrawingModes
) / sizeof(DrawingModeString
);
35 for (int32 i
= 0; i
< entries
; i
++) {
36 if (strcmp(kDrawingModes
[i
].string
, string
) == 0) {
37 mode
= kDrawingModes
[i
].mode
;
45 bool ToString(drawing_mode mode
, const char*& string
)
47 int entries
= sizeof(kDrawingModes
) / sizeof(DrawingModeString
);
48 for (int32 i
= 0; i
< entries
; i
++) {
49 if (kDrawingModes
[i
].mode
== mode
) {
50 string
= kDrawingModes
[i
].string
;