Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
M
magicseteditor
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
MyCard
magicseteditor
Commits
eaa6ce05
Commit
eaa6ce05
authored
Dec 10, 2006
by
twanvl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added overdrawDC for drawing selection
parent
54d7eee5
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
76 additions
and
32 deletions
+76
-32
src/gui/control/card_viewer.cpp
src/gui/control/card_viewer.cpp
+41
-3
src/gui/control/card_viewer.hpp
src/gui/control/card_viewer.hpp
+8
-1
src/gui/value/text.cpp
src/gui/value/text.cpp
+21
-22
src/main.cpp
src/main.cpp
+4
-4
src/render/text/viewer.cpp
src/render/text/viewer.cpp
+2
-2
No files found.
src/gui/control/card_viewer.cpp
View file @
eaa6ce05
...
@@ -14,6 +14,7 @@
...
@@ -14,6 +14,7 @@
CardViewer
::
CardViewer
(
Window
*
parent
,
int
id
,
long
style
)
CardViewer
::
CardViewer
(
Window
*
parent
,
int
id
,
long
style
)
:
wxControl
(
parent
,
id
,
wxDefaultPosition
,
wxDefaultSize
,
style
)
:
wxControl
(
parent
,
id
,
wxDefaultPosition
,
wxDefaultSize
,
style
)
,
up_to_date
(
false
)
{}
{}
wxSize
CardViewer
::
DoGetBestSize
()
const
{
wxSize
CardViewer
::
DoGetBestSize
()
const
{
...
@@ -29,17 +30,54 @@ wxSize CardViewer::DoGetBestSize() const {
...
@@ -29,17 +30,54 @@ wxSize CardViewer::DoGetBestSize() const {
void
CardViewer
::
onChange
()
{
void
CardViewer
::
onChange
()
{
Refresh
(
false
);
Refresh
(
false
);
up_to_date
=
false
;
}
}
#ifdef _DEBUG
DECLARE_DYNAMIC_ARG
(
bool
,
inOnPaint
);
IMPLEMENT_DYNAMIC_ARG
(
bool
,
inOnPaint
,
false
);
#endif
void
CardViewer
::
onPaint
(
wxPaintEvent
&
)
{
void
CardViewer
::
onPaint
(
wxPaintEvent
&
)
{
#ifdef _DEBUG
// we don't want recursion
assert
(
!
inOnPaint
());
WITH_DYNAMIC_ARG
(
inOnPaint
,
true
);
#endif
wxSize
cs
=
GetClientSize
();
wxSize
cs
=
GetClientSize
();
if
(
!
buffer
.
Ok
()
||
buffer
.
GetWidth
()
!=
cs
.
GetWidth
()
||
buffer
.
GetHeight
()
!=
cs
.
GetHeight
())
{
if
(
!
buffer
.
Ok
()
||
buffer
.
GetWidth
()
!=
cs
.
GetWidth
()
||
buffer
.
GetHeight
()
!=
cs
.
GetHeight
())
{
buffer
=
Bitmap
(
cs
.
GetWidth
(),
cs
.
GetHeight
());
buffer
=
Bitmap
(
cs
.
GetWidth
(),
cs
.
GetHeight
());
up_to_date
=
false
;
}
}
wxBufferedPaintDC
dc
(
this
,
buffer
);
wxBufferedPaintDC
dc
(
this
,
buffer
);
dc
.
BeginDrawing
();
if
(
!
up_to_date
)
{
draw
(
dc
);
up_to_date
=
true
;
dc
.
EndDrawing
();
dc
.
BeginDrawing
();
draw
(
dc
);
dc
.
EndDrawing
();
}
}
// helper class for overdrawDC()
class
CardViewer
::
OverdrawDC
:
private
wxClientDC
,
public
wxBufferedDC
{
public:
OverdrawDC
(
CardViewer
*
window
)
:
wxClientDC
(
window
)
{
wxBufferedDC
::
Init
((
wxClientDC
*
)
this
,
window
->
buffer
);
wxBufferedDC
::
BeginDrawing
();
}
~
OverdrawDC
()
{
wxBufferedDC
::
EndDrawing
();
}
};
shared_ptr
<
DC
>
CardViewer
::
overdrawDC
()
{
#ifdef _DEBUG
// don't call from onPaint
assert
(
!
inOnPaint
());
#endif
return
shared_ptr
<
DC
>
((
wxBufferedDC
*
)(
new
OverdrawDC
(
this
)));
}
}
// ----------------------------------------------------------------------------- : Event table
// ----------------------------------------------------------------------------- : Event table
...
...
src/gui/control/card_viewer.hpp
View file @
eaa6ce05
...
@@ -19,6 +19,10 @@ class CardViewer : public wxControl, public DataViewer {
...
@@ -19,6 +19,10 @@ class CardViewer : public wxControl, public DataViewer {
public:
public:
CardViewer
(
Window
*
parent
,
int
id
,
long
style
=
0
);
CardViewer
(
Window
*
parent
,
int
id
,
long
style
=
0
);
/// Get a dc to draw on the card outside onPaint
/** May NOT be called while in onPaint/draw */
shared_ptr
<
DC
>
overdrawDC
();
protected:
protected:
/// Return the desired size of control
/// Return the desired size of control
virtual
wxSize
DoGetBestSize
()
const
;
virtual
wxSize
DoGetBestSize
()
const
;
...
@@ -30,7 +34,10 @@ class CardViewer : public wxControl, public DataViewer {
...
@@ -30,7 +34,10 @@ class CardViewer : public wxControl, public DataViewer {
void
onPaint
(
wxPaintEvent
&
);
void
onPaint
(
wxPaintEvent
&
);
Bitmap
buffer
;
/// < Off-screen buffer we draw to
Bitmap
buffer
;
///< Off-screen buffer we draw to
bool
up_to_date
;
///< Is the buffer up to date?
class
OverdrawDC
;
};
};
// ----------------------------------------------------------------------------- : EOF
// ----------------------------------------------------------------------------- : EOF
...
...
src/gui/value/text.cpp
View file @
eaa6ce05
...
@@ -448,31 +448,30 @@ void TextValueEditor::moveSelection(size_t new_end, bool also_move_start, Moveme
...
@@ -448,31 +448,30 @@ void TextValueEditor::moveSelection(size_t new_end, bool also_move_start, Moveme
moveSelectionNoRedraw
(
new_end
,
also_move_start
,
dir
);
moveSelectionNoRedraw
(
new_end
,
also_move_start
,
dir
);
return
;
return
;
}
}
//
First redraw selection
//
Hide caret
wxCaret
*
caret
=
editor
().
GetCaret
();
wxCaret
*
caret
=
editor
().
GetCaret
();
if
(
caret
->
IsVisible
())
caret
->
Hide
();
if
(
caret
->
IsVisible
())
caret
->
Hide
();
{
// Move selection
/* DCP dc = editor.overdrawDC();
shared_ptr
<
DC
>
dc
=
editor
().
overdrawDC
();
RotatedDC rdc(*dc, editor.rotation);
RotatedDC
rdc
(
*
dc
,
viewer
.
getRotation
(),
false
);
if (nativeLook) {
if
(
nativeLook
())
{
// clip the dc to the region of this control
// clip the dc to the region of this control
rdc.SetClippingRegion(style->left, style->top, style->width, style->height);
rdc
.
SetClippingRegion
(
style
().
getRect
());
}
// clear old
v.drawSelection(rdc, style(), selection_start, selection_end);
// move
*/
moveSelectionNoRedraw
(
new_end
,
also_move_start
,
dir
);
// scroll?
// scrollWithCursor = true;
// if (onMove()) {
// // we can't redraw just the selection because we must scroll
// updateScrollbar();
// editor.refreshEditor();
// } else {
// // draw new selection
// v.drawSelection(rdc, style(), selection_start, selection_end);
// }
}
}
// clear old selection by drawing it again
v
.
drawSelection
(
rdc
,
style
(),
selection_start
,
selection_end
);
// move
moveSelectionNoRedraw
(
new_end
,
also_move_start
,
dir
);
// scroll?
// scrollWithCursor = true;
// if (onMove()) {
// // we can't redraw just the selection because we must scroll
// updateScrollbar();
// editor.refreshEditor();
// } else {
// draw new selection
v
.
drawSelection
(
rdc
,
style
(),
selection_start
,
selection_end
);
// }
showCaret
();
showCaret
();
}
}
...
...
src/main.cpp
View file @
eaa6ce05
...
@@ -49,10 +49,10 @@ bool MSE::OnInit() {
...
@@ -49,10 +49,10 @@ bool MSE::OnInit() {
check_updates
();
check_updates
();
//Window* wnd = new SymbolWindow(nullptr);
//Window* wnd = new SymbolWindow(nullptr);
//GameP g = Game::byName(_("magic"))
//GameP g = Game::byName(_("magic"))
//
SetP s = new_shared<Set>();
SetP
s
=
new_shared
<
Set
>
();
//
s->open(_("test.mse-set"));
s
->
open
(
_
(
"test.mse-set"
));
//
Window* wnd = new SetWindow(nullptr, s);
Window
*
wnd
=
new
SetWindow
(
nullptr
,
s
);
Window
*
wnd
=
new
WelcomeWindow
();
//
Window* wnd = new WelcomeWindow();
wnd
->
Show
();
wnd
->
Show
();
return
true
;
return
true
;
...
...
src/render/text/viewer.cpp
View file @
eaa6ce05
...
@@ -95,8 +95,8 @@ void TextViewer::drawSelection(RotatedDC& dc, const TextStyle& style, size_t sel
...
@@ -95,8 +95,8 @@ void TextViewer::drawSelection(RotatedDC& dc, const TextStyle& style, size_t sel
void
TextViewer
::
Line
::
drawSelection
(
RotatedDC
&
dc
,
size_t
sel_start
,
size_t
sel_end
)
{
void
TextViewer
::
Line
::
drawSelection
(
RotatedDC
&
dc
,
size_t
sel_start
,
size_t
sel_end
)
{
if
(
!
visible
(
dc
))
return
;
if
(
!
visible
(
dc
))
return
;
if
(
sel_start
<
end
()
&&
sel_end
>
start
)
{
if
(
sel_start
<
end
()
&&
sel_end
>
start
)
{
double
x1
=
positions
[
sel_start
];
double
x1
=
positions
[
sel_start
-
start
];
double
x2
=
positions
[
min
(
end
(),
sel_end
)];
double
x2
=
positions
[
min
(
end
(),
sel_end
)
-
start
];
dc
.
DrawRectangle
(
RealRect
(
x1
,
top
,
x2
-
x1
,
line_height
));
dc
.
DrawRectangle
(
RealRect
(
x1
,
top
,
x2
-
x1
,
line_height
));
}
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment