38
ApvlvCore::ApvlvCore ()
49
mVbox = gtk_vbox_new (FALSE, 0);
52
mScrollwin = gtk_scrolled_window_new (NULL, NULL);
53
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (mScrollwin), GTK_POLICY_AUTOMATIC,
54
GTK_POLICY_AUTOMATIC);
56
mVaj = gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (mScrollwin));
57
mHaj = gtk_scrolled_window_get_hadjustment (GTK_SCROLLED_WINDOW (mScrollwin));
40
extern ApvlvView *gView;
42
ApvlvCore::ApvlvCore ()
53
mVbox = gtk_vbox_new (FALSE, 0);
56
mScrollwin = gtk_scrolled_window_new (NULL, NULL);
57
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (mScrollwin),
59
GTK_POLICY_AUTOMATIC);
62
gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (mScrollwin));
64
gtk_scrolled_window_get_hadjustment (GTK_SCROLLED_WINDOW (mScrollwin));
60
67
ApvlvCore::~ApvlvCore ()
62
g_object_unref (mVbox);
66
ApvlvCore::inuse (bool use)
84
ApvlvCore::process (int ct, guint key)
90
ApvlvCore::setsize (int w, int h)
92
gtk_widget_set_usize (widget (), w, h);
93
gtk_widget_set_usize (mScrollwin, w, h - 20);
94
mStatus->setsize (w, 20);
106
ApvlvCore::filename ()
108
return mReady && mFilestr.length () > 0? mFilestr.c_str (): NULL;
119
ApvlvCore::zoomout ()
121
if (mZoomrate >= 0.5)
129
ApvlvCore::setzoom (const char *z)
131
if (strcasecmp (z, "normal") == 0)
135
if (strcasecmp (z, "fitwidth") == 0)
137
mZoommode = FITWIDTH;
139
if (strcasecmp (z, "fitheight") == 0)
141
mZoommode = FITHEIGHT;
157
ApvlvCore::setzoom (double d)
165
ApvlvCore::pagenumber ()
171
ApvlvCore::getrotate ()
177
ApvlvCore::pagesum ()
183
ApvlvCore::zoomvalue ()
189
ApvlvCore::loadfile (const char *file, bool check)
201
ApvlvCore::showpage (gint p, gdouble s)
206
ApvlvCore::refresh ()
211
ApvlvCore::scrollrate ()
213
double maxv = mVaj->upper - mVaj->lower - mVaj->page_size;
214
double val = mVaj->value / maxv;
230
ApvlvCore::scrollto (double s)
235
if (mVaj->upper != mVaj->lower)
237
double maxv = mVaj->upper - mVaj->lower - mVaj->page_size;
238
double val = maxv * s;
239
gtk_adjustment_set_value (mVaj, val);
245
debug ("fatal a timer error, try again!");
251
ApvlvCore::scrollup (int times)
256
gdouble val = gtk_adjustment_get_value (mVaj);
257
gdouble sub = mVaj->upper - mVaj->lower;
258
mVrate = sub / mLines;
260
if (val - mVrate * times > mVaj->lower)
262
gtk_adjustment_set_value (mVaj, val - mVrate * times);
264
else if (val > mVaj->lower)
266
gtk_adjustment_set_value (mVaj, mVaj->lower);
270
if (gParams->valueb ("continuous"))
272
showpage (mPagenum - 1, mVaj->upper / (2 * sub - mVaj->page_size));
276
showpage (mPagenum - 1, 1.0);
284
ApvlvCore::scrolldown (int times)
289
gdouble val = gtk_adjustment_get_value (mVaj);
290
gdouble sub = mVaj->upper - mVaj->lower;
291
mVrate = sub / mLines;
293
if (val + mVrate * times + mVaj->page_size < mVaj->upper)
295
gtk_adjustment_set_value (mVaj, val + mVrate * times);
297
else if (val + mVaj->page_size < mVaj->upper)
299
gtk_adjustment_set_value (mVaj, mVaj->upper - mVaj->page_size);
303
if (gParams->valueb ("continuous"))
305
showpage (mPagenum + 1, (sub - mVaj->page_size) / 2 / sub);
309
showpage (mPagenum + 1, 0.0);
317
ApvlvCore::scrollleft (int times)
322
mHrate = (mHaj->upper - mHaj->lower) / mChars;
323
gdouble val = mHaj->value - mHrate * times;
324
if (val > mVaj->lower)
326
gtk_adjustment_set_value (mHaj, val);
330
gtk_adjustment_set_value (mHaj, mHaj->lower);
335
ApvlvCore::scrollright (int times)
340
mHrate = (mHaj->upper - mHaj->lower) / mChars;
341
gdouble val = mHaj->value + mHrate * times;
342
if (val + mHaj->page_size < mHaj->upper)
344
gtk_adjustment_set_value (mHaj, val);
348
gtk_adjustment_set_value (mHaj, mHaj->upper - mHaj->page_size);
353
ApvlvCore::setactive (bool act)
69
g_object_unref (mVbox);
72
void ApvlvCore::inuse (bool use)
76
if (mInuse == false && gView->hasloaded (filename (), type ()) == false)
78
debug ("core :%p is not needed, delete it\n", this);
83
bool ApvlvCore::inuse ()
88
int ApvlvCore::type ()
93
returnType ApvlvCore::process (int ct, guint key)
98
void ApvlvCore::setsize (int w, int h)
100
gtk_widget_set_usize (widget (), w, h);
101
gtk_widget_set_usize (mScrollwin, w, h - 20);
102
mStatus->setsize (w, 20);
107
ApvlvCore *ApvlvCore::copy ()
112
const char *ApvlvCore::filename ()
114
return mReady && mFilestr.length () > 0 ? mFilestr.c_str () : NULL;
117
void ApvlvCore::zoomin ()
123
void ApvlvCore::zoomout ()
125
if (mZoomrate >= 0.5)
132
void ApvlvCore::setzoom (const char *z)
134
if (strcasecmp (z, "normal") == 0)
138
if (strcasecmp (z, "fitwidth") == 0)
140
mZoommode = FITWIDTH;
142
if (strcasecmp (z, "fitheight") == 0)
144
mZoommode = FITHEIGHT;
159
void ApvlvCore::setzoom (double d)
166
gint ApvlvCore::pagenumber ()
171
gint ApvlvCore::getrotate ()
176
gint ApvlvCore::pagesum ()
181
gdouble ApvlvCore::zoomvalue ()
186
bool ApvlvCore::loadfile (const char *file, bool check)
191
GtkWidget *ApvlvCore::widget ()
196
void ApvlvCore::showpage (gint p, gdouble s)
200
void ApvlvCore::refresh ()
204
double ApvlvCore::scrollrate ()
206
double maxv = mVaj->upper - mVaj->lower - mVaj->page_size;
207
double val = mVaj->value / maxv;
222
gboolean ApvlvCore::scrollto (double s)
227
if (mVaj->upper != mVaj->lower)
229
double maxv = mVaj->upper - mVaj->lower - mVaj->page_size;
230
double val = maxv * s;
231
gtk_adjustment_set_value (mVaj, val);
237
debug ("fatal a timer error, try again!");
242
void ApvlvCore::scrollup (int times)
247
gdouble val = gtk_adjustment_get_value (mVaj);
248
gdouble sub = mVaj->upper - mVaj->lower;
249
mVrate = sub / mLines;
251
if (val - mVrate * times > mVaj->lower)
253
gtk_adjustment_set_value (mVaj, val - mVrate * times);
255
else if (val > mVaj->lower)
257
gtk_adjustment_set_value (mVaj, mVaj->lower);
261
if (gParams->valueb ("autoscrollpage"))
263
if (gParams->valueb ("continuous"))
265
showpage (mPagenum - 1,
266
mVaj->upper / (2 * sub - mVaj->page_size));
270
showpage (mPagenum - 1, 1.0);
278
void ApvlvCore::scrolldown (int times)
283
gdouble val = gtk_adjustment_get_value (mVaj);
284
gdouble sub = mVaj->upper - mVaj->lower;
285
mVrate = sub / mLines;
287
if (val + mVrate * times + mVaj->page_size < mVaj->upper)
289
gtk_adjustment_set_value (mVaj, val + mVrate * times);
291
else if (val + mVaj->page_size < mVaj->upper)
293
gtk_adjustment_set_value (mVaj, mVaj->upper - mVaj->page_size);
297
if (gParams->valueb ("autoscrollpage"))
299
if (gParams->valueb ("continuous"))
301
showpage (mPagenum + 1, (sub - mVaj->page_size) / 2 / sub);
305
showpage (mPagenum + 1, 0.0);
313
void ApvlvCore::scrollleft (int times)
318
mHrate = (mHaj->upper - mHaj->lower) / mChars;
319
gdouble val = mHaj->value - mHrate * times;
320
if (val > mVaj->lower)
322
gtk_adjustment_set_value (mHaj, val);
326
gtk_adjustment_set_value (mHaj, mHaj->lower);
330
void ApvlvCore::scrollright (int times)
335
mHrate = (mHaj->upper - mHaj->lower) / mChars;
336
gdouble val = mHaj->value + mHrate * times;
337
if (val + mHaj->page_size < mHaj->upper)
339
gtk_adjustment_set_value (mHaj, val);
343
gtk_adjustment_set_value (mHaj, mHaj->upper - mHaj->page_size);
347
void ApvlvCore::setactive (bool act)
351
if (mActive && filename () && gView)
353
gchar *base = g_path_get_basename (filename ());
354
gView->settitle (base);
358
359
ApvlvCoreStatus::ApvlvCoreStatus ()
360
mHbox = gtk_hbox_new (FALSE, 0);
361
mHbox = gtk_hbox_new (FALSE, 0);
363
364
ApvlvCoreStatus::~ApvlvCoreStatus ()
368
ApvlvCoreStatus::widget ()
374
ApvlvCoreStatus::active (bool act)
379
ApvlvCoreStatus::setsize (int w, int h)
384
ApvlvCoreStatus::show ()
368
GtkWidget *ApvlvCoreStatus::widget ()
373
void ApvlvCoreStatus::active (bool act)
377
void ApvlvCoreStatus::setsize (int w, int h)
381
void ApvlvCoreStatus::show ()