-
Notifications
You must be signed in to change notification settings - Fork 2
/
PImageWindow.cxx
111 lines (92 loc) · 2.82 KB
/
PImageWindow.cxx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
//==============================================================================
// File: PImageWindow.cxx
//
// Copyright (c) 2017, Phil Harvey, Queen's University
//==============================================================================
#include <stdio.h>
#include "PImageWindow.h"
#include "PImageCanvas.h"
#include "PResourceManager.h"
#include "PNotifyRaised.h"
char * PImageWindow::sImageWindowClass = "PImageWindow";
PNotifyRaised * PImageWindow::sNotifyRaised = 0;
//------------------------------------------------------------------------------------
// PImageWindow constructor
//
PImageWindow::PImageWindow(ImageData *data)
: PScrollingWindow(data)
{
Initialize();
}
PImageWindow::PImageWindow(ImageData *data, Widget shell, Widget mainPane)
: PScrollingWindow(data)
{
Initialize();
SetShell(shell);
SetMainPane(mainPane);
}
void PImageWindow::Initialize()
{
mImage = NULL;
mPrintable = 1; // by default, image windows are printable
}
PImageWindow::~PImageWindow()
{
if (mImage) {
delete mImage;
}
}
void PImageWindow::SetShell(Widget w)
{
PWindow::SetShell(w);
if (w) {
/* handle circulate events for printing */
// THIS IS WHAT CAUSED THE ENDLESS RESIZE PROBLEM!!!! - PH 01/13/03
// XtAddEventHandler(w, StructureNotifyMask|SubstructureNotifyMask, FALSE, (XtEventHandler)CirculateWindProc, this);
XtAddRawEventHandler(w, StructureNotifyMask|SubstructureNotifyMask, FALSE, (XtEventHandler)CirculateWindProc, this);
}
}
void PImageWindow::Show()
{
SetScrolls(); // make sure our scrollbars are consistent
PWindow::Show(); // let base class show the window
/* define the cursor for our image */
/* (must be done AFTER window is realized) */
mImage->SetCursor(CURSOR_XHAIR);
}
void PImageWindow::UpdateSelf()
{
if (mImage->IsDirty()) {
mImage->Draw();
}
}
void PImageWindow::SetScrolls()
{
if (mImage) mImage->SetScrolls();
}
void PImageWindow::SetToHome(int n)
{
if (mImage) {
mImage->SetToHome(n); // tell the image to move to the home position
SetScrolls(); // make scrollbars consistent with this position
SetDirty(); // inform of change in image data
}
}
void PImageWindow::WasRaised()
{
// send notification to sNotifyRaised that this window was raised
if (sNotifyRaised && mPrintable) {
// inform interested window of the window that was raised
sNotifyRaised->NotifyRaised(this);
// reset the flag
sNotifyRaised = NULL;
}
}
void PImageWindow::CirculateWindProc(Widget w, PImageWindow *aWind, XEvent *event)
{
if (event->type == ConfigureNotify &&
event->xconfigure.window == XtWindow(aWind->GetShell()))
{
aWind->WasRaised();
}
}