exposurses

Check-in [b4468458f4]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Add initial usage of the User Pointer Still need a way to get to the third menu and also need to actually do something with the User Pointer function. Baby steps though.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | origin/master | trunk
Files: files | file ages | folders
SHA3-256: b4468458f408942bfc312f59bb05eedc780591a8584709319f673f9a1b253530
User & Date: atomicules@lavabit.com 2013-07-10 13:14:40
Context
2013-07-11
12:06
Test using the User Pointer to change another menu Requires the Window and Menu variables to be global(?) in scope. I.e. move outside of main routine. Interesting thing about the refreshing of the other menu... check-in: 328662366f user: atomicules@lavabit.com tags: origin/master, trunk
2013-07-10
13:14
Add initial usage of the User Pointer Still need a way to get to the third menu and also need to actually do something with the User Pointer function. Baby steps though. check-in: b4468458f4 user: atomicules@lavabit.com tags: origin/master, trunk
13:13
Identation changes only Was meant to be like this in the first place check-in: b5ca845268 user: atomicules@lavabit.com tags: origin/master, trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to exposurses.c.

36
37
38
39
40
41
42


43
44
45
46
47
48
49
..
69
70
71
72
73
74
75
76
77


78
79
80


81
82
83


84
85
86
87
88
89
90
...
161
162
163
164
165
166
167













168
169
170
171
172
173
174
...
200
201
202
203
204
205
206







	"f/2.8",
	"f/4",
	"f/5.6",
	"f/8",
	"f/11",
	"f/16"
};


void print_in_middle(WINDOW *win, int starty, int startx, int width, char *string, chtype color);

int main(){
	ITEM **iso_items;
	ITEM **shutter_items;
	ITEM **aperture_items;
	int c;
................................................................................
	init_pair(2, COLOR_CYAN, COLOR_BLACK);

	/* Create items */
	n_iso = ARRAY_SIZE(iso);
	n_shutter = ARRAY_SIZE(shutter);
	n_aperture = ARRAY_SIZE(aperture);
	iso_items = (ITEM **)calloc(n_iso, sizeof(ITEM *));
	for(i = 0; i < n_iso; ++i)
		iso_items[i] = new_item(iso[i], iso[i]);


	shutter_items = (ITEM **)calloc(n_shutter, sizeof(ITEM *));
	for(i = 0; i < n_shutter; ++i)
		shutter_items[i] = new_item(shutter[i], shutter[i]);


	aperture_items = (ITEM **)calloc(n_aperture, sizeof(ITEM *));
	for(i = 0; i < n_aperture; ++i)
		aperture_items[i] = new_item(aperture[i], aperture[i]);



	/* Create menu */
	iso_menu = new_menu((ITEM **)iso_items);
	shutter_menu = new_menu((ITEM **)shutter_items);
	aperture_menu = new_menu((ITEM **)aperture_items);

	/* Create the window to be associated with the menu */
................................................................................
			break;
			case KEY_NPAGE:
				menu_driver(*menu, REQ_SCR_DPAGE);
			break;
			case KEY_PPAGE:
				menu_driver(*menu, REQ_SCR_UPAGE);
			break;













		}
		wrefresh(*win);
	}	
	/* Unpost and free all the memory taken up */
	unpost_menu(iso_menu);
	unpost_menu(shutter_menu);
	unpost_menu(aperture_menu);
................................................................................
	temp = (width - length)/ 2;
	x = startx + (int)temp;
	wattron(win, color);
	mvwprintw(win, y, x, "%s", string);
	wattroff(win, color);
	refresh();
}














>
>







 







|

>
>

|

>
>

|

>
>







 







>
>
>
>
>
>
>
>
>
>
>
>
>







 







>
>
>
>
>
>
>
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
..
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
...
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
...
221
222
223
224
225
226
227
228
229
230
231
232
233
234
	"f/2.8",
	"f/4",
	"f/5.6",
	"f/8",
	"f/11",
	"f/16"
};

void selection(char *name);
void print_in_middle(WINDOW *win, int starty, int startx, int width, char *string, chtype color);

int main(){
	ITEM **iso_items;
	ITEM **shutter_items;
	ITEM **aperture_items;
	int c;
................................................................................
	init_pair(2, COLOR_CYAN, COLOR_BLACK);

	/* Create items */
	n_iso = ARRAY_SIZE(iso);
	n_shutter = ARRAY_SIZE(shutter);
	n_aperture = ARRAY_SIZE(aperture);
	iso_items = (ITEM **)calloc(n_iso, sizeof(ITEM *));
	for(i = 0; i < n_iso; ++i) {
		iso_items[i] = new_item(iso[i], iso[i]);
		set_item_userptr(iso_items[i], selection);
	}
	shutter_items = (ITEM **)calloc(n_shutter, sizeof(ITEM *));
	for(i = 0; i < n_shutter; ++i){
		shutter_items[i] = new_item(shutter[i], shutter[i]);
		set_item_userptr(shutter_items[i], selection);
	}
	aperture_items = (ITEM **)calloc(n_aperture, sizeof(ITEM *));
	for(i = 0; i < n_aperture; ++i){
		aperture_items[i] = new_item(aperture[i], aperture[i]);
		set_item_userptr(aperture_items[i], selection);
	}

	/* Create menu */
	iso_menu = new_menu((ITEM **)iso_items);
	shutter_menu = new_menu((ITEM **)shutter_items);
	aperture_menu = new_menu((ITEM **)aperture_items);

	/* Create the window to be associated with the menu */
................................................................................
			break;
			case KEY_NPAGE:
				menu_driver(*menu, REQ_SCR_DPAGE);
			break;
			case KEY_PPAGE:
				menu_driver(*menu, REQ_SCR_UPAGE);
			break;
			case 10: /* ENTER */
			{
				ITEM *cur;
				void (*p)(char *);

				cur = current_item(*menu);
				p = item_userptr(cur);
				p((char *)item_name(cur));
				pos_menu_cursor(*menu);
				break;
			}
			break;
								 
		}
		wrefresh(*win);
	}	
	/* Unpost and free all the memory taken up */
	unpost_menu(iso_menu);
	unpost_menu(shutter_menu);
	unpost_menu(aperture_menu);
................................................................................
	temp = (width - length)/ 2;
	x = startx + (int)temp;
	wattron(win, color);
	mvwprintw(win, y, x, "%s", string);
	wattroff(win, color);
	refresh();
}

void selection(char *name) {
	/* For now let's just print something */
	move(0, 0);
	clrtoeol();
	mvprintw(0, 0, "Item selected is : %s", name);
}