File: lexalignpop.c

package info (click to toggle)
pup 1.1-5
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 684 kB
  • ctags: 458
  • sloc: ansic: 12,994; makefile: 67
file content (205 lines) | stat: -rw-r--r-- 8,405 bytes parent folder | download | duplicates (2)
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
/* *************************************************************************
  Module:        lexalignpop.c   
  Author:        Matt Simpson
                 Arlington, TX
                 matthewsimpson@home.com
  Date:          August, 2000
  Description:
                 Routines for 'Align Cartridges' popup window.
  Changes:

****************************************************************************
                 COPYRIGHT (C) 1999, 2000 Matt Simpson
                 GNU General Public License
                 See lexgui.c for full notice.
**************************************************************************** */
#include <stdio.h>
#include <gtk/gtk.h>
#include "lexgui.h"

/* Values of scale widget defaults */
int scale_value[4] = {15, 7, 15, 15};
/* -------------------------------------------------------------------------
        scale_CB()
   ------------------------------------------------------------------------- */
void scale_CB(GtkAdjustment *adj, gint *indx)
{
  scale_value[*indx] = (int)adj->value;
}
/* -------------------------------------------------------------------------
        align_CB()
   ------------------------------------------------------------------------- */
void align_CB(GtkWidget *w, msgbox_struct *m)
{
  char message[50];

  clear_msgbox(m); /* clear immediately */
  if(!opendev(m, 2))
  {
    sprintf(message, "%s", "Printing an alignment page...");
    put_msg(m, message, GREEN, 0);
    print_alignment(m);
    clear_message(m); /* clear with timer */
  }
  closedev();
}
/* -------------------------------------------------------------------------
        sendalign_CB()
   ------------------------------------------------------------------------- */
void sendalign_CB(GtkWidget *w, msgbox_struct *m)
{
  char message[50];

  clear_msgbox(m); /* clear immediately */
  if(!opendev(m, 2))
  {
    sprintf(message, "%s", "Sent the alignment info.");
    put_msg(m, message, GREEN, 0);
    send_alignment(scale_value, m);
    clear_message(m); /* clear with timer */
  }
  closedev();
} 
/* -------------------------------------------------------------------------
        make_scale()
   ------------------------------------------------------------------------- */
void make_scale(GtkWidget *hbox, int init_setting, int min, int max, int *indx)
{
  GtkObject *adjustment;
  GtkWidget *scale;

  adjustment = gtk_adjustment_new(init_setting, min, max, 1, 1, 0);
  gtk_signal_connect (GTK_OBJECT (adjustment), "value_changed",
                      GTK_SIGNAL_FUNC (scale_CB), (gpointer)indx);
  scale = gtk_hscale_new(GTK_ADJUSTMENT(adjustment));
  gtk_scale_set_digits(GTK_SCALE(scale), 0);
  gtk_box_pack_start(GTK_BOX(hbox), scale, FALSE, FALSE, 0);
  gtk_widget_show(scale);
}
/* -------------------------------------------------------------------------
        make_button() Returns button with left justified label. Pass 
                      in the box to put it in and the string to use
                      for the label. Does not do an event handler
                      (gtk_signal_connect).
   ------------------------------------------------------------------------- */
GtkWidget *make_button(GtkWidget *box, char *label_str)
{
  GtkWidget *button, *hbox, *blabel;

  /* button is as long as longest sentence below */
  button = gtk_button_new();
  gtk_box_pack_start(GTK_BOX(box), button, FALSE, FALSE, 0);
  gtk_widget_show(button);

  hbox = gtk_hbox_new(FALSE, 0);
  gtk_container_add(GTK_CONTAINER(button), hbox);
  gtk_widget_show(hbox);

  /* added above hbox to allow left-justification of the following label */
  blabel = gtk_label_new(label_str);
  gtk_label_set_justify(GTK_LABEL(blabel), GTK_JUSTIFY_LEFT);
  gtk_box_pack_start(GTK_BOX(hbox), blabel, FALSE, FALSE, 0);
  gtk_widget_show(blabel);

  return(button);
}
/* -------------------------------------------------------------------------
        align_window()
   ------------------------------------------------------------------------- */
void align_window(int alreadyopen, topwin_struct *top)
{
  static task_struct alignw;
  GtkWidget *hbox, *button, *label;
  char label_str[64];
  GtkWidget *draftbox, *pixmapwidget;
  extern int devtype;
  static gint index[4] = {0, 1, 2, 3};

  init_task(top, &alignw);
  popup_window(&alignw, "Align Cartridges");

  /* For the drafting pixmap at the top, added at the end of this function */
  draftbox = gtk_hbox_new(FALSE, 0);
  gtk_box_pack_start(GTK_BOX(alignw.vbox_top), draftbox, FALSE, FALSE, 0);
  gtk_widget_show(draftbox);
  make_separator(alignw.vbox_top);

  /*---------------------- Step 1 ----------------------------*/ 
  sprintf(label_str, "%s", "Step 1: Press to print alignment page.");
  button = make_button(alignw.vbox_top, label_str);
  gtk_signal_connect(GTK_OBJECT (button), "clicked",
                     GTK_SIGNAL_FUNC (align_CB), (gpointer)&(alignw.msgbox));
  make_separator(alignw.vbox_top);
  /*---------------------- Step 2 ----------------------------*/ 
  hbox = gtk_hbox_new(FALSE, 0);
  gtk_box_pack_start(GTK_BOX(alignw.vbox_top), hbox, TRUE, FALSE, 0);
  gtk_widget_show(hbox);

  /* added above hbox to allow left-justification of the following label */
  label = gtk_label_new("Step 2: Examine the printed results.");
  gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT);
  gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
  gtk_widget_show(label);

  make_separator(alignw.vbox_top);
  /*---------------------- Step 3 ----------------------------*/ 
  /* long label, so hbox and left-justify not needed. */
  label = gtk_label_new("Step 3: Select the best alignment number for A:");
  gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT);
  gtk_box_pack_start (GTK_BOX (alignw.vbox_top), label, FALSE, FALSE, 0);
  gtk_widget_show(label); 

  make_scale(alignw.vbox_top, scale_value[0], 0, 30, &(index[0]));
  make_separator(alignw.vbox_top);
  /*---------------------- Step 4 ----------------------------*/ 
  /* long label, so hbox and left-justify not needed. */
  label = gtk_label_new("Step 4: Select the best alignment number for B:");
  gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT);
  gtk_box_pack_start (GTK_BOX (alignw.vbox_top), label, FALSE, FALSE, 0);
  gtk_widget_show(label);

  make_scale(alignw.vbox_top, scale_value[1], 0, 15, &(index[1]));
  make_separator(alignw.vbox_top);
  /*---------------------- Step 5 ----------------------------*/ 
  /* long label, so hbox and left-justify not needed. */
  label = gtk_label_new("Step 5: Select the best alignment number for C:");
  gtk_box_pack_start (GTK_BOX (alignw.vbox_top), label, FALSE, FALSE, 0);
  gtk_widget_show(label);

  label = gtk_label_new("(Not used for photo cartridges.)");
  gtk_box_pack_start (GTK_BOX (alignw.vbox_top), label, FALSE, FALSE, 0);
  gtk_widget_show(label);

  make_scale(alignw.vbox_top, scale_value[2], 0, 30, &(index[2]));
  make_separator(alignw.vbox_top);
  /*---------------------- Step 6 ----------------------------*/ 
   /* long label, so hbox and left-justify not needed. */
  label = gtk_label_new("Step 6: Select the best alignment number for D:");
  gtk_box_pack_start (GTK_BOX (alignw.vbox_top), label, FALSE, FALSE, 0);
  gtk_widget_show(label);

  label = gtk_label_new("(Not used for photo cartridges.)");
  gtk_box_pack_start (GTK_BOX (alignw.vbox_top), label, FALSE, FALSE, 0);
  gtk_widget_show(label);

  make_scale(alignw.vbox_top, scale_value[3], 0, 30, &(index[3]));
  make_separator(alignw.vbox_top);
  /*---------------------- Step 7 ----------------------------*/ 
  sprintf(label_str, "%s", "Step 7: Press to send alignment values.");
  button = make_button(alignw.vbox_top, label_str);
  gtk_signal_connect(GTK_OBJECT (button), "clicked",
                     GTK_SIGNAL_FUNC (sendalign_CB),(gpointer)&(alignw.msgbox));
  make_separator(alignw.vbox_top);
  /*----------------------------------------------------------*/ 
  make_messageBox(&(alignw.vbox_top), &(alignw.msgbox));
  /* For the X delete */
  gtk_signal_connect(GTK_OBJECT(alignw.tasktop), "delete_event",
                     GTK_SIGNAL_FUNC(deleteTWX), (gpointer)&alignw);
  gtk_widget_show(alignw.tasktop);
  /* Add the drafting pixmap to this window */
  pixmapwidget = create_nbpix(&(alignw.tasktop), 2);
  gtk_box_pack_start(GTK_BOX(draftbox), pixmapwidget, TRUE, FALSE, 0);

  if(!devtype && alreadyopen)
    pop_set_note(&alignw, NULL);
}